blob: f10806dc4e19d44a3826ad97fc466e8e8d6056fa [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))) \
Yifan Honge51dff22020-06-23 17:26:57 -0700386 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700387 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Yifan Hong3d5e2c22020-07-15 17:01:14 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700389 $(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 $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700479 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS))),$(sort $(SOONG_CONV.$(s).MAKEFILES)),$(sort $(SOONG_CONV.$(s).INSTALLED))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -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
Joe Onorato02fb89a2020-06-27 00:10:23 -0700488MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
489MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
490$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
491$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
492 @rm -f $@
493 $(hide) $(MK2BP_CATALOG_SCRIPT) \
494 --device=$(TARGET_DEVICE) \
495 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
496 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
497 --out_dir="$(OUT_DIR)" \
498 > $@
499$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
500
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700501# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800502# Modules use -Wno-error, or added default -Wall -Werror
503WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
504$(WALL_WERROR):
505 @rm -f $@
506 echo "# Modules using -Wno-error" >> $@
507 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 -0800508 echo "# Modules added default -Wall" >> $@
509 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
510
511$(call dist-for-goals,droidcore,$(WALL_WERROR))
512
513# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700514# C/C++ flag information for modules
515$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
516
517# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800518# Modules missing profile files
519PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
520$(PGO_PROFILE_MISSING):
521 @rm -f $@
522 echo "# Modules missing PGO profile files" >> $@
523 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
524
525$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
526
527# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700528# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700529# for future OTA packages installed by this system. Actual product
530# deliverables will be re-signed by hand. We expect this file to
531# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700532DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700533
534
Jeff Browne33ba4c2011-07-11 22:11:46 -0700535# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800536# if they don't do anything.
537.PHONY: systemimage
538systemimage:
539
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800540# -----------------------------------------------------------------
541
542.PHONY: event-log-tags
543
Joe Onoratob7510532010-07-14 10:22:54 -0700544# Produce an event logs tag file for everything we know about, in order
545# to properly allocate numbers. Then produce a file that's filtered
546# for what's going to be installed.
547
548all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
549
Colin Crossdc8f8e42012-04-12 13:25:54 -0700550event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
551
Joe Onoratob7510532010-07-14 10:22:54 -0700552# Include tags from all packages that we know about
553all_event_log_tags_src := \
554 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
555
Dan Willemsena3f66322020-05-28 15:46:33 -0700556$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
557$(all_event_log_tags_file): $(all_event_log_tags_src) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700558 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900559 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700560
Doug Zongkera34fa952011-02-23 12:17:29 -0800561# Include tags from all packages included in this product, plus all
562# tags that are part of the system (ie, not in a vendor/ or device/
563# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800564event_log_tags_src := \
565 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800566 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800568 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
569 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800570
Dan Willemsena3f66322020-05-28 15:46:33 -0700571$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700572$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700573$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800574 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900575 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800576
577event-log-tags: $(event_log_tags_file)
578
579ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
580
Joe Onoratob7510532010-07-14 10:22:54 -0700581
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582# #################################################################
583# Targets for boot/OS images
584# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800585ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
586 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000587 ifdef BOARD_PREBUILT_BOOTLOADER
588 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
589 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
590 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800591 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
592 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
593 else
594 INSTALLED_2NDBOOTLOADER_TARGET :=
595 endif
596else
597 INSTALLED_BOOTLOADER_MODULE :=
598 INSTALLED_2NDBOOTLOADER_TARGET :=
599endif # TARGET_NO_BOOTLOADER
600ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700601 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
602 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
603 $(PRODUCT_OUT)/$(k))
604 else
605 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
606 endif
Ying Wangc6349742014-01-13 16:14:20 -0800607else
608 INSTALLED_KERNEL_TARGET :=
609endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610
611# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700612# the root dir
613INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800614 $(ALL_GENERATED_SOURCES) \
615 $(ALL_DEFAULT_INSTALLED_MODULES))
616
Luis Hector Chavezff489932018-07-03 15:41:40 -0700617INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
618INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
619$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700620$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700621 @echo Installed file list: $@
622 @mkdir -p $(dir $@)
623 @rm -f $@
624 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700625 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700626
627$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
628
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800629#------------------------------------------------------------------
630# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700631ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800632INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700633ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800634$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800635 cat $^ > $@
636endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700637endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800638
Tom Cherryd14b8952018-08-09 14:26:00 -0700639# -----------------------------------------------------------------
640# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800641ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700642INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
643 $(ALL_GENERATED_SOURCES) \
644 $(ALL_DEFAULT_INSTALLED_MODULES))
645
646INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
647INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
648$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700649$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700650 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800651 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700652 @mkdir -p $(dir $@)
653 @rm -f $@
654 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700655 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700656
657$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700658BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
659
J. Avila3f6560e2020-05-11 20:20:03 +0000660ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
661# -l enables the legacy format used by the Linux kernel
662COMPRESSION_COMMAND_DEPS := $(LZ4)
663COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
664RAMDISK_EXT := .lz4
665else
666COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
667COMPRESSION_COMMAND := $(MINIGZIP)
668RAMDISK_EXT := .gz
669endif
670
Joe Onorato64d85d02009-04-09 19:31:12 -0700671# We just build this directly to the install location.
672INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000673$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800674 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000675 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800676
Ying Wangad7fd292013-08-08 16:34:29 -0700677.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000678ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700679 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000680 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800681
Dan Willemsen67495202019-01-16 12:42:05 -0800682endif # BUILDING_RAMDISK_IMAGE
683
The Android Open Source Project88b60792009-03-03 19:28:42 -0800684# -----------------------------------------------------------------
685# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700686
687# This is defined here since we may be building recovery as boot
688# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700689ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
690 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
691else
692 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
693endif
694
Steve Muckle04b6f052020-08-09 14:36:56 -0700695# $1: boot image target
696# returns the kernel used to make the bootimage
697define bootimage-to-kernel
698 $(if $(BOARD_KERNEL_BINARIES),\
699 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
700 $(INSTALLED_KERNEL_TARGET))
701endef
702
Steve Muckle903a1ca2020-05-07 17:32:10 -0700703ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
704 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
705endif
706
707# $1: boot image file name
708# $2: boot image variant (boot, boot-debug)
709define get-bootimage-partition-size
710 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
711endef
Chris Grossa784ef12019-04-22 11:09:57 -0700712
713ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700715 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700716
717ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
718INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
719endif
720
Steve Mucklee1b10862019-07-10 10:49:37 -0700721ifndef BUILDING_VENDOR_BOOT_IMAGE
722ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
723 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
724endif
725endif
726
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
728
Anton Hansson8dab0a62019-03-28 15:45:40 +0000729ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700730ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000731VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700732 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
733endif
734endif
735
Anton Hansson72e36f02019-02-26 17:36:30 +0000736INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700737
738ifndef BUILDING_VENDOR_BOOT_IMAGE
739ifdef BOARD_KERNEL_BASE
740 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
741endif
742ifdef BOARD_KERNEL_PAGESIZE
743 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
744endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700745ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700746 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
747endif
748else
749# building vendor boot image, dtb/base/pagesize go there
750ifdef GENERIC_KERNEL_CMDLINE
751 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
752endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700753endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700754
Sami Tolvanen3303d902016-03-15 16:49:30 +0000755INTERNAL_MKBOOTIMG_VERSION_ARGS := \
756 --os_version $(PLATFORM_VERSION) \
757 --os_patch_level $(PLATFORM_SECURITY_PATCH)
758
Chris Grossa784ef12019-04-22 11:09:57 -0700759# Define these only if we are building boot
760ifdef BUILDING_BOOT_IMAGE
761INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
762
The Android Open Source Project88b60792009-03-03 19:28:42 -0800763ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800764$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400765
766else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
767
Steve Muckle04b6f052020-08-09 14:36:56 -0700768# $1: boot image target
769define build_boot_board_avb_enabled
770 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
771 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
772 $(AVBTOOL) add_hash_footer \
773 --image $(1) \
774 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
775 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
776 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
777endef
778
779$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(call bootimage-to-kernel,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400780 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700781 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400782
783.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800784bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400785 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700786 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400787
Anton Hansson8dab0a62019-03-28 15:45:40 +0000788else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700789
Steve Muckle04b6f052020-08-09 14:36:56 -0700790# $1: boot image target
791define build_boot_supports_boot_signer
792 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
793 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
794 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
795endef
796
797$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER) $(call bootimage-to-kernel,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700798 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700799 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700800
801.PHONY: bootimage-nodeps
802bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
803 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700804 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700805
Anton Hansson8dab0a62019-03-28 15:45:40 +0000806else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800807
Steve Muckle04b6f052020-08-09 14:36:56 -0700808# $1: boot image target
809define build_boot_supports_vboot
810 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
811 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
812 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
813endef
814
815$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY) $(call bootimage-to-kernel,$@)
David Riley17be3d32015-03-03 08:54:11 -0800816 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700817 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800818
819.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800820bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800821 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700822 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800823
824else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800825
Steve Muckle04b6f052020-08-09 14:36:56 -0700826# $1: boot image target
827define build_boot_novboot
828 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
829 $(call assert-max-image-size,$1,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
830endef
831
832$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(call bootimage-to-kernel,$@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800833 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700834 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700835
836.PHONY: bootimage-nodeps
837bootimage-nodeps: $(MKBOOTIMG)
838 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700839 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700840
The Android Open Source Project88b60792009-03-03 19:28:42 -0800841endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -0700842endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843
Tao Baob1a2e352018-08-14 16:17:12 -0700844else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700845ifdef BOARD_PREBUILT_BOOTIMAGE
846ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
847# Remove when b/63676296 is resolved.
848$(error Prebuilt bootimage is only supported for AB targets)
849endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900850INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700851$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700852else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700853INSTALLED_BOOTIMAGE_TARGET :=
854endif # BOARD_PREBUILT_BOOTIMAGE
855endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800856
857# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700858# vendor boot image
859ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
860
861ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
862 $(error vboot 1.0 does not support vendor_boot partition)
863endif
864
865INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
866 $(ALL_GENERATED_SOURCES) \
867 $(ALL_DEFAULT_INSTALLED_MODULES))
868
Steve Muckle414dbe12020-06-18 21:38:35 -0700869INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000870$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
871 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700872
873ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
874 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
875endif
876ifdef BOARD_KERNEL_BASE
877 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
878endif
879ifdef BOARD_KERNEL_PAGESIZE
880 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
881endif
882ifdef INTERNAL_KERNEL_CMDLINE
883 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
884endif
885
886INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
887$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
888ifeq ($(BOARD_AVB_ENABLE),true)
889$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
890 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800891 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700892 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
893 $(AVBTOOL) add_hash_footer \
894 --image $@ \
895 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
896 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
897 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
898else
899$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
900 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800901 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700902 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
903endif
904endif # BUILDING_VENDOR_BOOT_IMAGE
905
906# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907# NOTICE files
908#
Steve Blockd14d3b42012-03-01 11:34:41 +0000909# We are required to publish the licenses for all code under BSD, GPL and
910# Apache licenses (and possibly other more exotic ones as well). We err on the
911# side of caution, so the licenses for other third-party code are included here
912# too.
913#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914# This needs to be before the systemimage rules, because it adds to
915# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
916# go into the systemimage.
917
Steve Block495e5852012-02-29 19:18:08 +0000918.PHONY: notice_files
919
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900920# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700921# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
922# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
923# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
924# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900925# $(2) - Plain text output file
926# $(3) - HTML/XML output file
927# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700928# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900930# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800931# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932#
933# The algorithm here is that we go collect a hash for each of the notice
934# files and write the names of the files that match that hash. Then
935# to generate the real files, we go print out all of the files and their
936# hashes.
937#
938# These rules are fairly complex, so they depend on this makefile so if
939# it changes, they'll run again.
940#
941# TODO: We could clean this up so that we just record the locations of the
942# original notice files instead of making rules to copy them somwehere.
943# Then we could traverse that without quite as much bash drama.
944define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700945$(2): PRIVATE_MESSAGE := $(4)
946$(2): PRIVATE_DIR := $(5)
947$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
948$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800949 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -0700950 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
951 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000952 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900953 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700954 $(if $(filter $(1),xml_system),-i system --xml-output, \
955 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700956 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -0700957 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
958 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -0700959 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900960notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800961endef
962
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000963# Notice file logic isn't relevant for TARGET_BUILD_APPS
964ifndef TARGET_BUILD_APPS
965
The Android Open Source Project88b60792009-03-03 19:28:42 -0800966# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
967# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
968# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000969target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000970tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000972kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
973winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974
Bob Badour4b25c902020-01-28 13:23:39 -0800975# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
976# reasons--not to be flashed onto any device. Targets under these directories
977# need no associated notice file on the device UI.
978exclude_target_dirs := apex
979
Steven Morelandae69e572017-12-15 14:49:55 -0800980# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000981ifneq ($(PRODUCT_NOTICE_SPLIT),true)
982target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
983target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
984installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
985$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000986 $(target_notice_file_txt), \
987 $(target_notice_file_html), \
988 "Notices for files contained in the filesystem images in this directory:", \
989 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -0700990 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -0800991 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000992$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
993 $(hide) $(MINIGZIP) -9 < $< > $@
994$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
995 $(copy-file-to-target)
996else
997target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
998target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900999installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1000
1001target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1002target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1003target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1004installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001005
1006target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1007target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1008target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1009installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001010
Justin Yun6151e3f2019-06-25 15:58:13 +09001011target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1012target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1013target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1014installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001015
Chris Gross15d96552019-07-16 14:38:43 -07001016target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1017target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1018target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1019installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1020
Yifan Hong3d3f0302020-05-11 18:35:11 -07001021target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1022target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1023target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1024installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1025
Yifan Hongc83f9e92020-07-15 16:57:47 -07001026target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1027target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1028target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1029installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1030
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001031# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1032# being built. A notice xml file must depend on all modules that could potentially
1033# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001034license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001035# Only files copied to a system image need system image notices.
1036license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001037# Phonys/fakes don't have notice files (though their deps might)
1038license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001039# testcases are not relevant to the system image.
1040license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001041# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001042license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001043license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1044license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001045license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001046license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001047license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001048license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001049license_modules_agg := $(license_modules_system) \
1050 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001051 $(license_modules_product) \
1052 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001053 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001054 $(license_modules_vendor_dlkm) \
1055 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001056# targets used for debug symbols only and do not get copied to the device
1057license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1058
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001059license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001060license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1061
1062# Identify the other targets we expect to have notices for:
1063# targets copied to the device but are not readable by the UI (e.g. must boot
1064# into a different partition to read or don't have an associated /etc
1065# directory) must have their notices built somewhere readable.
1066license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1067license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1068license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1069license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1070license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1071license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1072license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1073license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1074license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1075license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1076license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1077license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1078license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1079
1080# after removing targets in system images, targets reported in system images, and
1081# targets used for debug symbols that do not need notices, nothing must remain.
1082license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1083$(call maybe-print-list-and-error, $(license_modules_rest), \
1084 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001085
Chris Grossaad39b32019-06-13 09:43:26 -07001086# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1087# update its notice file, so include those notices in the system partition instead
1088ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001089license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001090system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1091system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001092else
Bob Badour4b25c902020-01-28 13:23:39 -08001093license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001094system_xml_directories := xml_system
1095system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001096endif
1097
1098$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001099 $(target_notice_file_txt), \
1100 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001101 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001102 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001103 $(license_modules_system), \
1104 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001105$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001106 $(target_vendor_notice_file_txt), \
1107 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001108 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001109 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001110 $(license_modules_vendor), \
1111 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001112$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001113 $(target_product_notice_file_txt), \
1114 $(target_product_notice_file_xml), \
1115 "Notices for files contained in the product filesystem image in this directory:", \
1116 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001117 $(license_modules_product), \
1118 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001119$(eval $(call combine-notice-files, xml_system_ext, \
1120 $(target_system_ext_notice_file_txt), \
1121 $(target_system_ext_notice_file_xml), \
1122 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001123 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001124 $(license_modules_system_ext), \
1125 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001126$(eval $(call combine-notice-files, xml_odm, \
1127 $(target_odm_notice_file_txt), \
1128 $(target_odm_notice_file_xml), \
1129 "Notices for files contained in the odm filesystem image in this directory:", \
1130 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001131 $(license_modules_odm), \
1132 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001133$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1134 $(target_vendor_dlkm_notice_file_txt), \
1135 $(target_vendor_dlkm_notice_file_xml), \
1136 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1137 $(TARGET_OUT_NOTICE_FILES), \
1138 $(license_modules_vendor_dlkm), \
1139 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001140$(eval $(call combine-notice-files, xml_odm_dlkm, \
1141 $(target_odm_dlkm_notice_file_txt), \
1142 $(target_odm_dlkm_notice_file_xml), \
1143 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1144 $(TARGET_OUT_NOTICE_FILES), \
1145 $(license_modules_odm_dlkm), \
1146 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001147
1148$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1149 $(hide) $(MINIGZIP) -9 < $< > $@
1150$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1151 $(hide) $(MINIGZIP) -9 < $< > $@
1152$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1153 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001154$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001155 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001156$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1157 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001158$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1159 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001160$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1161 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001162$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1163 $(copy-file-to-target)
1164$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1165 $(copy-file-to-target)
1166$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1167 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001168$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001169 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001170$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1171 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001172$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1173 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001174$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1175 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001176
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001177ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1178ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1179ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1180ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1181ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001182ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001183ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001184endif # PRODUCT_NOTICE_SPLIT
1185
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001186ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001187
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001188$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001189 $(tools_notice_file_txt), \
1190 $(tools_notice_file_html), \
1191 "Notices for files contained in the tools directory:", \
1192 $(HOST_OUT_NOTICE_FILES), \
1193 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001194 $(winpthreads_notice_file), \
1195 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001196
Ying Wang62c81f82013-08-22 20:02:03 -07001197endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001198
1199# The kernel isn't really a module, so to get its module file in there, we
1200# make the target NOTICE files depend on this particular file too, which will
1201# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001202$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001203
Dan Willemsen288bedf2019-05-28 15:36:47 -07001204$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001205
Doug Zongker8678df42009-06-15 14:30:14 -07001206
The Android Open Source Project88b60792009-03-03 19:28:42 -08001207# #################################################################
1208# Targets for user images
1209# #################################################################
1210
Ying Wang933abf12010-06-16 14:31:34 -07001211INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001213INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1214else
1215ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001216INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1217else
1218ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001219INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1220endif
1221endif
1222endif
1223
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001224# These options tell the recovery updater/installer how to mount the partitions writebale.
1225# <fstype>=<fstype_opts>[|<fstype_opts>]...
1226# fstype_opts := <opt>[,<opt>]...
1227# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001228# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1229DEFAULT_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 -07001230
Ying Wang542903a2010-11-17 15:40:38 -08001231ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1232 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1233endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001234ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1235 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1236endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001237ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1238 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1239endif
Tao Baodba635a2019-06-24 10:39:54 -07001240
1241INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001242 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001243 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001244 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001245
1246ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1247INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001248endif
1249
Yifan Hongcfb917a2020-05-07 14:58:20 -07001250ifneq ($(filter \
1251 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1252 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1253 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1254 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1255 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1256 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001257 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001258 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001259INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1260endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001261
Anton Hansson8dab0a62019-03-28 15:45:40 +00001262ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001263INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001264ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001265INTERNAL_USERIMAGES_DEPS += $(FEC)
1266endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001267endif
1268
Tao Baodba635a2019-06-24 10:39:54 -07001269ifeq ($(BOARD_AVB_ENABLE),true)
1270INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1271endif
1272
1273# Get a colon-separated list of search paths.
1274INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1275
Alex Klyubin092c9022017-03-13 13:28:34 -07001276SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001277INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1278
Yifan Hongc5c01242018-11-09 10:27:23 -08001279ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001280
Anton Hansson8dab0a62019-03-28 15:45:40 +00001281ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001282 $(error vboot 1.0 doesn't support logical partition)
1283endif
1284
Yifan Hongc5c01242018-11-09 10:27:23 -08001285endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001286
Ying Wangbd93d422011-10-28 17:02:30 -07001287# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001288# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001289# $(3): additional "key=value" pairs to append to the dictionary file.
1290define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001291$(if $(filter $(2),system),\
1292 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001293 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001294 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1295 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1296 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1297 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1298 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1299 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1300 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1301 $(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 +00001302 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1303 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001304 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001305 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001306 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1307)
1308$(if $(filter $(2),system_other),\
1309 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001310)
Yifan Hong760d3c02018-05-30 11:16:46 -07001311$(if $(filter $(2),userdata),\
1312 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1313 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001314 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1315 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001316 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001317 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001318)
Yifan Hong760d3c02018-05-30 11:16:46 -07001319$(if $(filter $(2),cache),\
1320 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1321 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001322 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001323 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001324)
1325$(if $(filter $(2),vendor),\
1326 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1327 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1328 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1329 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1330 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1331 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1332 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1333 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1334 $(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 +00001335 $(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 -07001336 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001337 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001338 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001339)
1340$(if $(filter $(2),product),\
1341 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1342 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1343 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1344 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1345 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1346 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1347 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1348 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1349 $(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 +00001350 $(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 -07001351 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001352 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001353 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001354)
Justin Yun6151e3f2019-06-25 15:58:13 +09001355$(if $(filter $(2),system_ext),\
1356 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1357 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1358 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1359 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1360 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1361 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1362 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1363 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1364 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1365 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1366 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001367 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001368)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001369$(if $(filter $(2),odm),\
1370 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1371 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1372 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1373 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1374 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1375 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1376 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1377 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1378 $(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 +00001379 $(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 +08001380 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001381 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001382 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001383)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001384$(if $(filter $(2),vendor_dlkm),\
1385 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1386 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1387 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1388 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1389 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1390 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1391 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1392 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1393 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1394 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1395 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1396 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1397)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001398$(if $(filter $(2),odm_dlkm),\
1399 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1400 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1401 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1402 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1403 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1404 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1405 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1406 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1407 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1408 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1409 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1410 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1411)
Yifan Hong760d3c02018-05-30 11:16:46 -07001412$(if $(filter $(2),oem),\
1413 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1414 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1415 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1416 $(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 -07001417 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001418)
Tao Bao3602eca2018-07-10 10:53:55 -07001419$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001420
Tao Bao3602eca2018-07-10 10:53:55 -07001421$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001422$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001423$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001424$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001425$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1426$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1427$(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 +00001428$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1429$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1430$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1431$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1432$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001433$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001434$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1435$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1436$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001437$(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 -07001438$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001439$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001440$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1441$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1442$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1443$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1444$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001445$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001446$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1447$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1448$(if $(BOARD_AVB_ENABLE),\
1449 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1450 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1451 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1452 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001453$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1454$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1455$(if $(BOARD_AVB_ENABLE),\
1456 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1457 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001458 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001459$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1460$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1461$(if $(BOARD_AVB_ENABLE),\
1462 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1463 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1464 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1465 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001466$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1467$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1468$(if $(BOARD_AVB_ENABLE),\
1469 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1470 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1471 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1472 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001473$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001474$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001475 $(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 +01001476$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001477 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1478 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1479 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1480 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001481$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1482$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1483$(if $(BOARD_AVB_ENABLE),\
1484 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1485 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1486 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1487 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001488$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1489$(if $(BOARD_AVB_ENABLE),\
1490 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1491$(if $(BOARD_AVB_ENABLE),\
1492 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1493 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1494 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1495 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001496$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1497$(if $(BOARD_AVB_ENABLE),\
1498 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1499$(if $(BOARD_AVB_ENABLE),\
1500 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1501 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1502 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1503 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001504$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1505 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001506$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001507 $(hide) echo "system_root_image=true" >> $(1))
1508$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001509$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1510 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001511$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1512endef
1513
1514# $(1): the path of the output dictionary file
1515# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001516PROP_DICTIONARY_IMAGES := oem
1517ifdef BUILDING_CACHE_IMAGE
1518 PROP_DICTIONARY_IMAGES += cache
1519endif
1520ifdef BUILDING_SYSTEM_IMAGE
1521 PROP_DICTIONARY_IMAGES += system
1522endif
Chris Gross203191b2020-05-30 02:39:12 +00001523ifdef BUILDING_SYSTEM_OTHER_IMAGE
1524 PROP_DICTIONARY_IMAGES += system_other
1525endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001526ifdef BUILDING_USERDATA_IMAGE
1527 PROP_DICTIONARY_IMAGES += userdata
1528endif
1529ifdef BUILDING_VENDOR_IMAGE
1530 PROP_DICTIONARY_IMAGES += vendor
1531endif
1532ifdef BUILDING_PRODUCT_IMAGE
1533 PROP_DICTIONARY_IMAGES += product
1534endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001535ifdef BUILDING_SYSTEM_EXT_IMAGE
1536 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001537endif
1538ifdef BUILDING_ODM_IMAGE
1539 PROP_DICTIONARY_IMAGES += odm
1540endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001541ifdef BUILDING_VENDOR_DLKM_IMAGE
1542 PROP_DICTIONARY_IMAGES += vendor_dlkm
1543endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001544ifdef BUILDING_ODM_DLKM_IMAGE
1545 PROP_DICTIONARY_IMAGES += odm_dlkm
1546endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001547define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001548 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001549endef
1550
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001551# $(1): the path of the input dictionary file, where each line has the format key=value
1552# $(2): the key to look up
1553define read-image-prop-dictionary
1554$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1555endef
1556
The Android Open Source Project88b60792009-03-03 19:28:42 -08001557# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001558# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001559
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001560# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001561ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001562
Ying Wang37526142015-03-10 12:02:57 -07001563INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1564 $(ALL_DEFAULT_INSTALLED_MODULES))
1565
Tao Bao10fc9492018-08-14 12:17:48 -07001566INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1567INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1568
1569# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1570# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1571# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1572# the call to FILELIST.
1573ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001574INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001575$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1576else
1577$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1578endif
1579
1580$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001581$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001582 @echo Installed file list: $@
1583 @mkdir -p $(dir $@)
1584 @rm -f $@
1585 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001586 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001587
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001588recovery_sepolicy := \
1589 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001590 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001591 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001592 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1593 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1594 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001595 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001596 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001597 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1598 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1599 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001600
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001601# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1602# SELinux files
1603IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1604
Steve Muckle04b6f052020-08-09 14:36:56 -07001605# if building multiple boot images from multiple kernels, use the first kernel listed
1606# for the recovery image
1607recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001608recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001609recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001610
Anton Hansson45a40da2019-01-18 14:06:34 +00001611# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1612# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1613# which get remapped to a bucket.
1614recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001615ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1616recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001617# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001618# ------160------240------320----------480------------640------
1619# mdpi hdpi xhdpi xxhdpi xxxhdpi
1620recovery_density := $(strip \
1621 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1622 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1623 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1624 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001625endif
1626
1627ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1628recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1629else
Doug Zongker25d55f82014-04-04 13:51:15 -07001630recovery_resources_common := $(recovery_resources_common)-xhdpi
1631endif
1632
Tao Baoe1e829e2018-08-29 20:36:00 -07001633# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1634# Note that the font selected here can be overridden for a particular device by putting a font.png
1635# in its private recovery resources.
1636ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001637recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001638else
Dan Willemsen97672232020-05-27 00:09:16 -07001639recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001640endif
1641
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001642
1643# We will only generate the recovery background text images if the variable
1644# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1645# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1646# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1647# BoardConfig in order to use this feature.
1648ifeq ($(recovery_density),xxxhdpi)
1649TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1650else ifeq ($(recovery_density),xxhdpi)
1651TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1652endif
1653
1654ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1655# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1656ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1657 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1658else
1659 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1660endif
1661
1662
Dan Willemsen97672232020-05-27 00:09:16 -07001663RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001664RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1665RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1666RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1667RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1668
xunchangcc57d312018-12-07 12:12:17 -08001669RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1670RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1671RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1672RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1673RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1674
1675generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001676 $(RECOVERY_INSTALLING_TEXT_FILE) \
1677 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1678 $(RECOVERY_ERASING_TEXT_FILE) \
1679 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001680 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1681 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1682 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1683 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1684 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1685 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001686
Dan Willemsen97672232020-05-27 00:09:16 -07001687resource_dir := bootable/recovery/tools/recovery_l10n/res/
1688resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001689image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001690zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001691$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001692$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001693$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1694$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001695$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001696$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001697$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001698 recovery_installing \
1699 recovery_installing_security \
1700 recovery_erasing \
1701 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001702 recovery_no_command
1703$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001704 recovery_cancel_wipe_data \
1705 recovery_factory_data_reset \
1706 recovery_try_again \
1707 recovery_wipe_data_menu_header \
1708 recovery_wipe_data_confirmation
1709$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001710$(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 -08001711 # Prepares the font directory.
1712 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1713 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001714 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001715 @rm -rf $(dir $@)
1716 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001717 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001718 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001719 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001720 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1721 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1722 --text_name $(text_name) \
1723 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1724 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001725 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001726 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001727else
1728RECOVERY_INSTALLING_TEXT_FILE :=
1729RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1730RECOVERY_ERASING_TEXT_FILE :=
1731RECOVERY_ERROR_TEXT_FILE :=
1732RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001733RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1734RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1735RECOVERY_TRY_AGAIN_TEXT_FILE :=
1736RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1737RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001738endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1739
Ying Wang9a175682015-08-06 11:47:47 -07001740ifndef TARGET_PRIVATE_RES_DIRS
1741TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1742endif
Doug Zongker4647f122009-07-02 09:00:54 -07001743recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001744 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001745recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001746
1747
Andrew Boiefa61ff02012-09-28 09:33:45 -07001748ifdef TARGET_RECOVERY_FSTAB
1749recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1750else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001751recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001752endif
Tao Baoc3c17532016-06-10 10:11:54 -07001753ifdef TARGET_RECOVERY_WIPE
1754recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001755else
Tao Baoc3c17532016-06-10 10:11:54 -07001756recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001757endif
Tao Bao8beab692015-07-22 12:33:18 -07001758
Tao Bao6d5d6232018-03-09 17:04:42 -08001759# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001760# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001761# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1762# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001763#
1764# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001765# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001766# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001767# b) We build a single image that contains boot and recovery both - no recovery image to install
1768# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001769# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001770# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001771# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1772# do bsdiff because boot and recovery will contain different number of entries
1773# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001774# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1775# do bsdiff because boot and recovery will contain different number of entries
1776# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001777
Tom Cherry2929cad2018-09-20 11:04:37 -07001778ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001779 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001780# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001781RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1782ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001783else
Tao Bao8beab692015-07-22 12:33:18 -07001784RECOVERY_RESOURCE_ZIP :=
1785endif
Doug Zongker4647f122009-07-02 09:00:54 -07001786
Tao Bao139c7272018-07-31 13:26:54 -07001787INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1788
1789$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001790 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1791 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1792 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1793 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1794 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1795 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1796 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1797 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1798
1799# Parses the given list of build variables and writes their values as build properties if defined.
1800# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1801# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1802# $(1): Map from the build variable names to property names
1803# $(2): Output file
1804define append-recovery-ui-properties
1805echo "#" >> $(2)
1806echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1807echo "#" >> $(2)
1808$(foreach prop,$(1), \
1809 $(eval _varname := $(call word-colon,1,$(prop))) \
1810 $(eval _propname := $(call word-colon,2,$(prop))) \
1811 $(eval _value := $($(_varname))) \
1812 $(if $(_value), \
1813 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1814endef
1815
1816$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001817 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001818 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1819 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1820 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001821 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001822 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001823 $(hide) mkdir -p $(dir $@)
1824 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001825 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001826 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001827 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001828 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001829 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001830 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1831
Steve Mucklef84668e2020-03-16 19:13:46 -07001832ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001833 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001834ifdef GENERIC_KERNEL_CMDLINE
1835 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1836endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001837else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001838 INTERNAL_RECOVERYIMAGE_ARGS := \
1839 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001840 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001841# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001842ifdef INTERNAL_KERNEL_CMDLINE
1843 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001844endif
1845ifdef BOARD_KERNEL_BASE
1846 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1847endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001848ifdef BOARD_KERNEL_PAGESIZE
1849 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1850endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001851ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001852ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1853 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1854else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001855 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1856endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001857endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001858ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1859 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1860endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001861ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1862 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1863endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001864endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001865ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1866 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1867endif
Doug Zongker4647f122009-07-02 09:00:54 -07001868
J. Avila3f6560e2020-05-11 20:20:03 +00001869$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001870 $(INTERNAL_ROOT_FILES) \
1871 $(INSTALLED_RAMDISK_TARGET) \
1872 $(INTERNAL_RECOVERYIMAGE_FILES) \
1873 $(recovery_sepolicy) \
1874 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1875 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1876 $(recovery_resource_deps) \
1877 $(recovery_fstab)
1878 # Making recovery image
1879 mkdir -p $(TARGET_RECOVERY_OUT)
1880 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1881 # Copying baseline ramdisk...
1882 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1883 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1884 # Modifying ramdisk contents...
1885 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1886 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1887 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1888 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1889 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1890 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1891 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1892 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1893 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1894 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1895 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1896 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1897 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1898 $(foreach item,$(recovery_fstab), \
1899 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1900 $(if $(strip $(recovery_wipe)), \
1901 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1902 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1903 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001904 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001905
Ying Wang747b9f12015-01-30 14:05:22 -08001906# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001907# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001908define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001909 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001910 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001911 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001912 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001913 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001914 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001915 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001916 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001917 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001918 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1919 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001920 )\
1921 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001922 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1923 $(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 +08001924 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001925 $(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 -07001926 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001927 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1928 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001929 $(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 -07001930 $(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 -08001931endef
1932
Dan Willemsend120ac62020-06-12 02:39:34 +00001933recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001934ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001935 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001936endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001937ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001938 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001939endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001940ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001941 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001942endif
Tao Baof4866c72018-08-22 14:35:09 -07001943ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001944 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1945 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1946 else
1947 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1948 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001949endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001950ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001951 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001952endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001953ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001954 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001955endif
Tao Baof4866c72018-08-22 14:35:09 -07001956
Dan Willemsend120ac62020-06-12 02:39:34 +00001957ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1958$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001959 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001960 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001961endif # BOARD_USES_RECOVERY_AS_BOOT
1962
Dan Willemsend120ac62020-06-12 02:39:34 +00001963$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001964 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001965
Tao Bao4594d0e2015-12-22 09:47:46 -08001966ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001967$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001968 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001969 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1970 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001971endif
Doug Zongker56588872012-08-20 15:38:58 -07001972
Ying Wang747b9f12015-01-30 14:05:22 -08001973.PHONY: recoveryimage-nodeps
1974recoveryimage-nodeps:
1975 @echo "make $@: ignoring dependencies"
Steve Mucklea21b44a2020-08-09 14:54:42 -07001976 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), $(recovery_kernel))
Ying Wang747b9f12015-01-30 14:05:22 -08001977
Chris Grossa784ef12019-04-22 11:09:57 -07001978else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001979RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001980endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001981
1982.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001983recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001984
Jiyong Park03eb0612017-10-04 21:22:41 +09001985ifneq ($(BOARD_NAND_PAGE_SIZE),)
1986$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001987endif
1988
Jiyong Park03eb0612017-10-04 21:22:41 +09001989ifneq ($(BOARD_NAND_SPARE_SIZE),)
1990$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001991endif
1992
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001993ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07001994# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08001995# the debug ramdisk, which is the original ramdisk plus additional
1996# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
1997# When /force_debuggable is present, /init will load userdebug sepolicy
1998# and property files to allow adb root, if the device is unlocked.
1999
2000ifdef BUILDING_RAMDISK_IMAGE
2001BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2002INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2003
2004INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2005 $(ALL_GENERATED_SOURCES) \
2006 $(ALL_DEFAULT_INSTALLED_MODULES))
2007
2008# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2009# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2010# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2011my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2012
2013INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2014INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2015$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2016$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2017
2018# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2019# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2020# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2021$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002022$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002023 echo Installed file list: $@
2024 mkdir -p $(dir $@)
2025 rm -f $@
2026 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002027 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002028
2029# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2030# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2031ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2032my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2033else
2034my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2035endif # BOARD_USES_RECOVERY_AS_BOOT
2036
2037$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2038$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002039
2040ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2041# 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 +08002042$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002043else
2044# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2045$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2046endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002047$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002048 $(call pretty,"Target debug ram disk: $@")
2049 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2050 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002051 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002052 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002053
2054.PHONY: ramdisk_debug-nodeps
2055ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2056ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002057ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002058 echo "make $@: ignoring dependencies"
2059 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2060 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002061 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002062 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002063
2064my_debug_ramdisk_sync_dir :=
2065my_debug_ramdisk_root_dir :=
2066
2067endif # BUILDING_RAMDISK_IMAGE
2068
2069# -----------------------------------------------------------------
2070# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2071#
2072# Note: it's intentional to skip signing for boot-debug.img, because it
2073# can only be used if the device is unlocked with verification error.
2074ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002075ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2076 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2077 $(PRODUCT_OUT)/$(k).img)
2078else
2079 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2080endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002081
2082# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2083ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2084INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2085else
2086INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2087endif
2088
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002089# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2090# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2091# Using a test key to sign boot-debug.img to continue booting with the mismatched
2092# public key, if the device is unlocked.
2093ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002094$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002095endif
2096
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002097BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2098INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2099# $(1): the bootimage to sign
2100define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002101$(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 +08002102$(AVBTOOL) add_hash_footer \
2103 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002104 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002105 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2106 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002107$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002108endef
2109
Steve Muckleb3dda772020-03-11 16:03:07 -07002110# $(1): output file
2111define build-debug-bootimage-target
2112 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2113 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2114 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2115endef
2116
Bowgo Tsai0013f552019-03-20 17:59:52 +08002117# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2118$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2119 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002120 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002121
2122.PHONY: bootimage_debug-nodeps
2123bootimage_debug-nodeps: $(MKBOOTIMG)
2124 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002125 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002126
2127endif # TARGET_NO_KERNEL
2128
Bowgo Tsai6a683672020-02-14 19:00:15 +08002129ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2130ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2131# -----------------------------------------------------------------
2132# vendor debug ramdisk
2133# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002134INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002135$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2136$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2137
2138INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2139 $(ALL_GENERATED_SOURCES) \
2140 $(ALL_DEFAULT_INSTALLED_MODULES))
2141
2142# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2143# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2144# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2145# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2146$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2147$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002148$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002149 $(call pretty,"Target vendor debug ram disk: $@")
2150 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2151 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2152 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2153 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2154 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002155 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002156
2157INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2158INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2159$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2160$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2161
2162# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2163# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2164$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2165$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2166 echo Installed file list: $@
2167 mkdir -p $(dir $@)
2168 rm -f $@
2169 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2170 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2171
2172# -----------------------------------------------------------------
2173# vendor_boot-debug.img.
2174INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2175
2176# The util to sign vendor_boot-debug.img with a test key.
2177BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2178INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2179# $(1): the vendor bootimage to sign
2180define test-key-sign-vendor-bootimage
2181$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2182$(AVBTOOL) add_hash_footer \
2183 --image $(1) \
2184 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2185 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2186 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2187$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2188endef
2189
2190ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2191$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2192endif
2193
2194# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2195$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2196 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002197 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002198 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2199 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2200
2201endif # BUILDING_RAMDISK_IMAGE
2202endif # BUILDING_VENDOR_BOOT_IMAGE
2203
Bowgo Tsai0013f552019-03-20 17:59:52 +08002204# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002205# The test harness ramdisk, which is based off debug_ramdisk, plus a
2206# few additional test-harness-specific properties in adb_debug.prop.
2207
2208ifdef BUILDING_RAMDISK_IMAGE
2209BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2210INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2211
2212# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2213# appends a few test harness specific properties into the adb_debug.prop.
2214TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2215TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2216
2217# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2218# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2219TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2220ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2221ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2222
2223# $(1): a list of key=value pairs for additional property assignments
2224# $(2): the target .prop file to append the properties from $(1)
2225define append-test-harness-props
2226 echo "#" >> $(2); \
2227 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2228 echo "#" >> $(2);
2229 $(foreach line,$(1), echo "$(line)" >> $(2);)
2230endef
2231
2232$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002233$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002234 $(call pretty,"Target test harness ram disk: $@")
2235 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2236 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002237 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002238
2239.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002240ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002241 echo "make $@: ignoring dependencies"
2242 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2243 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002244 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002245
2246endif # BUILDING_RAMDISK_IMAGE
2247
2248# -----------------------------------------------------------------
2249# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2250#
2251# Note: it's intentional to skip signing for boot-test-harness.img, because it
2252# can only be used if the device is unlocked with verification error.
2253ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2254
Steve Muckle4866bd62020-04-02 11:31:08 -07002255ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2256 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2257 $(PRODUCT_OUT)/$(k).img)
2258else
2259 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2260endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002261
2262# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2263INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2264
2265# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2266# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2267# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2268# public key, if the device is unlocked.
2269ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2270$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2271endif
2272
Steve Muckle4866bd62020-04-02 11:31:08 -07002273# $(1): output file
2274define build-boot-test-harness-target
2275 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2276 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2277 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2278endef
2279
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002280# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2281$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2282 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002283 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002284
2285.PHONY: bootimage_test_harness-nodeps
2286bootimage_test_harness-nodeps: $(MKBOOTIMG)
2287 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002288 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002289
2290endif # TARGET_NO_KERNEL
2291endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2292
2293# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002294# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002295
Dan Willemsen37a19862018-10-31 16:31:46 -07002296INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002297 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002298 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002299
Ying Wang82cceba2012-08-13 15:03:00 -07002300FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002301
2302# ASAN libraries in the system image - add dependency.
2303ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002304ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002305 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2306 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2307 endif
2308endif
2309
Tom Cherryd14b8952018-08-09 14:26:00 -07002310FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002311
Ying Wange5e8c5f2011-09-09 16:35:53 -07002312# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002313ifdef BUILDING_SYSTEM_IMAGE
2314
Ying Wange5e8c5f2011-09-09 16:35:53 -07002315# installed file list
2316# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2317# We put installed-files.txt ahead of image itself in the dependency graph
2318# so that we can get the size stat even if the build fails due to too large
2319# system image.
2320INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002321INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2322$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002323$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002324 @echo Installed file list: $@
2325 @mkdir -p $(dir $@)
2326 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002327 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002328 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002329
2330.PHONY: installed-file-list
2331installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002332
2333$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002334
2335systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002336 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002337BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2338
Ying Wang23898df2014-06-18 20:26:24 -07002339# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002340ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002341define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002342$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2343 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2344 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2345 exit 1; \
2346fi
Ying Wang23898df2014-06-18 20:26:24 -07002347$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2348endef
2349else
2350define create-system-vendor-symlink
2351endef
2352endif
2353
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002354# Create symlink /system/product to /product if necessary.
2355ifdef BOARD_USES_PRODUCTIMAGE
2356define create-system-product-symlink
2357$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2358 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2359 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2360 exit 1; \
2361fi
2362$(hide) ln -sf /product $(TARGET_OUT)/product
2363endef
2364else
2365define create-system-product-symlink
2366endef
2367endif
2368
Justin Yun6151e3f2019-06-25 15:58:13 +09002369# Create symlink /system/system_ext to /system_ext if necessary.
2370ifdef BOARD_USES_SYSTEM_EXTIMAGE
2371define create-system-system_ext-symlink
2372$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2373 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2374 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 +01002375 exit 1; \
2376fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002377$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002378endef
2379else
Justin Yun6151e3f2019-06-25 15:58:13 +09002380define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002381endef
2382endif
2383
The Android Open Source Project88b60792009-03-03 19:28:42 -08002384# $(1): output file
2385define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002386 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002387 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002388 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002389 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002390 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002391 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002392 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002393 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002394 $(BUILD_IMAGE) \
2395 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2396 || ( mkdir -p $${DIST_DIR}; \
2397 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2398 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002399endef
2400
Dan Willemsen6b72c732019-06-12 21:33:38 +00002401ifeq ($(BOARD_AVB_ENABLE),true)
2402$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2403endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002404$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002405 $(call build-systemimage-target,$@)
2406
Tao Baoe9d61b02018-08-20 21:09:07 -07002407INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002408SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002409
Tao Baoe9d61b02018-08-20 21:09:07 -07002410# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2411# compatibility, in case device-specific Makefiles still refer to the old name.
2412INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2413
Doug Zongker73ef8252009-07-23 15:12:53 -07002414# The system partition needs room for the recovery image as well. We
2415# now store the recovery image as a binary patch using the boot image
2416# as the source (since they are very similar). Generate the patch so
2417# we can see how big it's going to be, and include that in the system
2418# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002419ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002420ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002421ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002422ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002423diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2424else
2425diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2426endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002427intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2428RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002429$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2430$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002431 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002432 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002433 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002434 @echo "Construct recovery from boot"
2435 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002436 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002437else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2438RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002439endif # BOARD_USES_FULL_RECOVERY_IMAGE
2440endif # INSTALLED_RECOVERYIMAGE_TARGET
2441endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002442
Yifan Hong9a3cad92020-04-27 19:06:59 -07002443$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002444 @echo "Install system fs image: $@"
2445 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002446 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002447
Tao Baoe9d61b02018-08-20 21:09:07 -07002448systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002449
2450.PHONY: systemimage-nodeps snod
2451systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002452 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002453 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002454 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002455 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002456ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002457 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002458endif
2459
Dan Willemsen67495202019-01-16 12:42:05 -08002460endif # BUILDING_SYSTEM_IMAGE
2461
Anton Hansson30e061b2018-11-12 13:36:46 +00002462.PHONY: sync syncsys
2463sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002464
Ying Wang3a61eeb2016-03-11 10:32:01 -08002465# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002466# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002467.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002468platform:
2469 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002470
2471.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002472platform-java:
2473 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002474
Ying Wang3a61eeb2016-03-11 10:32:01 -08002475# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002476# data partition image
2477INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002478 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002479
Dan Willemsen67495202019-01-16 12:42:05 -08002480ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002481userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002482 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002483BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2484
Ying Wangbd93d422011-10-28 17:02:30 -07002485define build-userdataimage-target
2486 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2487 @mkdir -p $(TARGET_OUT_DATA)
2488 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002489 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002490 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002491 $(BUILD_IMAGE) \
2492 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2493 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2494 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002495endef
2496
Joe Onorato64d85d02009-04-09 19:31:12 -07002497# We just build this directly to the install location.
2498INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002499INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2500 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002501 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002502$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002503 $(build-userdataimage-target)
2504
2505.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002506userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002507 $(build-userdataimage-target)
2508
Dan Willemsen67495202019-01-16 12:42:05 -08002509endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002510
Andreas Gampe039b5c72017-03-24 16:06:31 -07002511# ASAN libraries in the system image - build rule.
2512ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2513 $(TARGET_OUT_SHARED_LIBRARIES) \
2514 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2515 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2516 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002517# Extra options: Enforce the system user for the files to avoid having to change ownership.
2518ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002519# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2520# enough space.
2521$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002522 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 -07002523
The Android Open Source Project88b60792009-03-03 19:28:42 -08002524# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002525# partition table image
2526ifdef BOARD_BPT_INPUT_FILES
2527
2528BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002529BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002530
2531INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2532 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002533 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002534 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2535
2536ifdef BOARD_BPT_DISK_SIZE
2537INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2538endif
2539
2540define build-bptimage-target
2541 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2542 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2543endef
2544
2545INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002546$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2547 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2548
David Zeuthen25328622016-04-08 15:08:03 -04002549$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2550 $(build-bptimage-target)
2551
2552.PHONY: bptimage-nodeps
2553bptimage-nodeps:
2554 $(build-bptimage-target)
2555
2556endif # BOARD_BPT_INPUT_FILES
2557
2558# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002559# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002560ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002561INTERNAL_CACHEIMAGE_FILES := \
2562 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2563
2564cacheimage_intermediates := \
2565 $(call intermediates-dir-for,PACKAGING,cache)
2566BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2567
2568define build-cacheimage-target
2569 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2570 @mkdir -p $(TARGET_OUT_CACHE)
2571 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002572 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002573 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002574 $(BUILD_IMAGE) \
2575 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2576 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2577 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002578endef
2579
2580# We just build this directly to the install location.
2581INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002582$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002583 $(build-cacheimage-target)
2584
2585.PHONY: cacheimage-nodeps
2586cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2587 $(build-cacheimage-target)
2588
Dan Willemsen67495202019-01-16 12:42:05 -08002589else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002590# we need to ignore the broken cache link when doing the rsync
2591IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002592endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002593
David Zeuthen0eb10972016-09-28 17:55:27 -04002594# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002595# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002596ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002597ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002598# Marker file to identify that odex files are installed
2599INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2600ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2601$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2602 $(hide) touch $@
2603endif
2604
Alex Light4e358ab2016-06-16 14:47:10 -07002605INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2606 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002607 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002608
Colin Cross6db5b0e2018-11-16 21:26:33 -08002609# system_other dex files are installed as a side-effect of installing system image files
2610INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2611
Alex Light4e358ab2016-06-16 14:47:10 -07002612INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002613INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2614$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002615$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002616 @echo Installed file list: $@
2617 @mkdir -p $(dir $@)
2618 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002619 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002620 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002621
Bowgo Tsai867ab662019-01-29 13:30:18 +08002622# Determines partition size for system_other.img.
2623ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2624ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2625INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2626endif
2627endif
2628
2629ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2630INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2631endif
2632
Alex Light4e358ab2016-06-16 14:47:10 -07002633systemotherimage_intermediates := \
2634 $(call intermediates-dir-for,PACKAGING,system_other)
2635BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2636
2637# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2638define build-systemotherimage-target
2639 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2640 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2641 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002642 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002643 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002644 $(BUILD_IMAGE) \
2645 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2646 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2647 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002648endef
2649
2650# We just build this directly to the install location.
2651INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002652ifneq (true,$(SANITIZE_LITE))
2653# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002654$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2655 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002656endif
Alex Light4e358ab2016-06-16 14:47:10 -07002657
2658.PHONY: systemotherimage-nodeps
2659systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2660 $(build-systemotherimage-target)
2661
Dan Willemsen67495202019-01-16 12:42:05 -08002662endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002663
2664
2665# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002666# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002667ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002668INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002669 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002670 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002671
Ying Wang8da19e32015-09-15 14:22:12 -07002672INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002673INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2674$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002675$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07002676 @echo Installed file list: $@
2677 @mkdir -p $(dir $@)
2678 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002679 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002680 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002681
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002682# Create symlink /vendor/odm to /odm if necessary.
2683ifdef BOARD_USES_ODMIMAGE
2684define create-vendor-odm-symlink
2685$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
2686 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
2687 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
2688 exit 1; \
2689fi
2690$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
2691endef
2692else
2693define create-vendor-odm-symlink
2694endef
2695endif
2696
Yifan Honge51dff22020-06-23 17:26:57 -07002697# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2698# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2699#
2700# On devices with a vendor_dlkm partition,
2701# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2702# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2703# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2704# are hidden.
2705# On devices without a vendor_dlkm partition,
2706# - /vendor/lib/modules stores vendor DLKMs directly.
2707# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2708# See system/core/rootdir/Android.mk for a list of created symlinks.
2709# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2710# are not guaranteed to exist on all devices.
2711ifdef BOARD_USES_VENDOR_DLKMIMAGE
2712define create-vendor-vendor_dlkm-symlink
Yifan Hong1e6d2172020-07-15 17:27:28 -07002713$(hide) mkdir -p $(TARGET_OUT_VENDOR)/lib
Yifan Honge51dff22020-06-23 17:26:57 -07002714$(hide) if [ -d $(TARGET_OUT_VENDOR)/lib/modules ] && [ ! -h $(TARGET_OUT_VENDOR)/lib/modules ]; then \
2715 echo 'Non-symlink $(TARGET_OUT_VENDOR)/lib/modules detected!' 1>&2; \
2716 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/lib/modules while building a separate vendor_dlkm.img!' 1>&2; \
2717 exit 1; \
2718fi
2719$(hide) ln -sf /vendor_dlkm/lib/modules $(TARGET_OUT_VENDOR)/lib/modules
2720endef
2721else
2722define create-vendor-vendor_dlkm-symlink
2723endef
2724endif
2725
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002726# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2727# /odm/lib/modules -> /odm_dlkm/lib/modules
2728#
2729# On devices with a odm_dlkm partition,
2730# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2731# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2732# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2733# are hidden.
2734# On devices without a odm_dlkm partition,
2735# - /odm/lib/modules stores odm DLKMs directly.
2736# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2737# See system/core/rootdir/Android.mk for a list of created symlinks.
2738# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2739# are not guaranteed to exist on all devices.
2740ifdef BOARD_USES_ODM_DLKMIMAGE
2741define create-odm-odm_dlkm-symlink
Yifan Hong1e6d2172020-07-15 17:27:28 -07002742$(hide) mkdir -p $(TARGET_OUT_ODM)/lib
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002743$(hide) if [ -d $(TARGET_OUT_ODM)/lib/modules ] && [ ! -h $(TARGET_OUT_ODM)/lib/modules ]; then \
2744 echo 'Non-symlink $(TARGET_OUT_ODM)/lib/modules detected!' 1>&2; \
2745 echo 'You cannot install files to $(TARGET_OUT_ODM)/lib/modules while building a separate odm_dlkm.img!' 1>&2; \
2746 exit 1; \
2747fi
2748$(hide) ln -sf /odm_dlkm/lib/modules $(TARGET_OUT_ODM)/lib/modules
2749endef
2750else
2751define create-odm-odm_dlkm-symlink
2752endef
2753endif
2754
Ying Wanga0febe52013-03-20 11:02:05 -07002755vendorimage_intermediates := \
2756 $(call intermediates-dir-for,PACKAGING,vendor)
2757BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002758define build-vendorimage-target
2759 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2760 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002761 $(call create-vendor-odm-symlink)
Yifan Honge51dff22020-06-23 17:26:57 -07002762 $(call create-vendor-vendor_dlkm-symlink)
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002763 $(call create-odm-odm_dlkm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002764 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002765 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002766 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002767 $(BUILD_IMAGE) \
2768 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2769 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002770 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002771endef
2772
2773# We just build this directly to the install location.
2774INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002775$(INSTALLED_VENDORIMAGE_TARGET): \
2776 $(INTERNAL_USERIMAGES_DEPS) \
2777 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002778 $(INSTALLED_FILES_FILE_VENDOR) \
2779 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002780 $(build-vendorimage-target)
2781
Steven Morelanda2e734d2017-03-07 12:10:09 -08002782.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002783vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002784 $(build-vendorimage-target)
2785
Colin Cross91a52272017-06-20 16:57:52 -07002786sync: $(INTERNAL_VENDORIMAGE_FILES)
2787
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002788else ifdef BOARD_PREBUILT_VENDORIMAGE
2789INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2790$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2791endif
Ying Wanga0febe52013-03-20 11:02:05 -07002792
Ying Wang9f8e8db2011-11-04 11:37:01 -07002793# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002794# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002795ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002796INTERNAL_PRODUCTIMAGE_FILES := \
2797 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002798 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002799
2800INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002801INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2802$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002803$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002804 @echo Installed file list: $@
2805 @mkdir -p $(dir $@)
2806 @rm -f $@
2807 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002808 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002809
2810productimage_intermediates := \
2811 $(call intermediates-dir-for,PACKAGING,product)
2812BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2813define build-productimage-target
2814 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2815 @mkdir -p $(TARGET_OUT_PRODUCT)
2816 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002817 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002818 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002819 $(BUILD_IMAGE) \
2820 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2821 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2822 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002823endef
2824
2825# We just build this directly to the install location.
2826INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002827$(INSTALLED_PRODUCTIMAGE_TARGET): \
2828 $(INTERNAL_USERIMAGES_DEPS) \
2829 $(INTERNAL_PRODUCTIMAGE_FILES) \
2830 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002831 $(build-productimage-target)
2832
2833.PHONY: productimage-nodeps pnod
2834productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2835 $(build-productimage-target)
2836
2837sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2838
2839else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2840INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2841$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2842endif
2843
2844# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002845# system_ext partition image
2846ifdef BUILDING_SYSTEM_EXT_IMAGE
2847INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2848 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002849 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002850
Justin Yun6151e3f2019-06-25 15:58:13 +09002851INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2852INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2853$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2854$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002855 @echo Installed file list: $@
2856 @mkdir -p $(dir $@)
2857 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002858 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002859 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002860
Justin Yun6151e3f2019-06-25 15:58:13 +09002861system_extimage_intermediates := \
2862 $(call intermediates-dir-for,PACKAGING,system_ext)
2863BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2864define build-system_extimage-target
2865 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2866 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2867 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2868 $(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 -07002869 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002870 $(BUILD_IMAGE) \
2871 $(TARGET_OUT_SYSTEM_EXT) \
2872 $(system_extimage_intermediates)/system_ext_image_info.txt \
2873 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2874 $(TARGET_OUT)
2875 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002876endef
2877
2878# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002879INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002880$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2881 $(INTERNAL_USERIMAGES_DEPS) \
2882 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2883 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002884 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002885
Justin Yun6151e3f2019-06-25 15:58:13 +09002886.PHONY: systemextimage-nodeps senod
2887systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2888 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002889
Justin Yun6151e3f2019-06-25 15:58:13 +09002890sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002891
Justin Yun6151e3f2019-06-25 15:58:13 +09002892else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2893INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2894$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002895endif
2896
2897# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002898# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002899ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002900INTERNAL_ODMIMAGE_FILES := \
2901 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002902 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002903
2904INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2905INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2906$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002907$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002908 @echo Installed file list: $@
2909 @mkdir -p $(dir $@)
2910 @rm -f $@
2911 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002912 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002913
2914odmimage_intermediates := \
2915 $(call intermediates-dir-for,PACKAGING,odm)
2916BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2917define build-odmimage-target
2918 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2919 @mkdir -p $(TARGET_OUT_ODM)
2920 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2921 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002922 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002923 $(BUILD_IMAGE) \
2924 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2925 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2926 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002927endef
2928
2929# We just build this directly to the install location.
2930INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002931$(INSTALLED_ODMIMAGE_TARGET): \
2932 $(INTERNAL_USERIMAGES_DEPS) \
2933 $(INTERNAL_ODMIMAGE_FILES) \
2934 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002935 $(build-odmimage-target)
2936
2937.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002938odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002939 $(build-odmimage-target)
2940
2941sync: $(INTERNAL_ODMIMAGE_FILES)
2942
2943else ifdef BOARD_PREBUILT_ODMIMAGE
2944INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2945$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2946endif
2947
2948# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002949# vendor_dlkm partition image
2950ifdef BUILDING_VENDOR_DLKM_IMAGE
2951INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2952 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002953 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002954
2955INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2956INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2957$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2958$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2959 @echo Installed file list: $@
2960 @mkdir -p $(dir $@)
2961 @rm -f $@
2962 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2963 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2964
2965vendor_dlkmimage_intermediates := \
2966 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2967BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2968define build-vendor_dlkmimage-target
2969 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2970 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2971 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2972 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2973 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2974 $(BUILD_IMAGE) \
2975 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2976 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2977 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2978endef
2979
2980# We just build this directly to the install location.
2981INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2982$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2983 $(INTERNAL_USERIMAGES_DEPS) \
2984 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2985 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2986 $(build-vendor_dlkmimage-target)
2987
2988.PHONY: vendor_dlkmimage-nodeps vdnod
2989vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2990 $(build-vendor_dlkmimage-target)
2991
2992sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2993
2994else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2995INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2996$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2997endif
2998
2999# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003000# odm_dlkm partition image
3001ifdef BUILDING_ODM_DLKM_IMAGE
3002INTERNAL_ODM_DLKMIMAGE_FILES := \
3003 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003004 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003005
3006INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3007INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3008$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3009$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3010 @echo Installed file list: $@
3011 @mkdir -p $(dir $@)
3012 @rm -f $@
3013 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3014 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3015
3016odm_dlkmimage_intermediates := \
3017 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3018BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3019define build-odm_dlkmimage-target
3020 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3021 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3022 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3023 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3024 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3025 $(BUILD_IMAGE) \
3026 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3027 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3028 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3029endef
3030
3031# We just build this directly to the install location.
3032INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3033$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3034 $(INTERNAL_USERIMAGES_DEPS) \
3035 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3036 $(INSTALLED_FILES_FILE_ODM_DLKM)
3037 $(build-odm_dlkmimage-target)
3038
3039.PHONY: odm_dlkmimage-nodeps odnod
3040odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3041 $(build-odm_dlkmimage-target)
3042
3043sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3044
3045else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3046INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3047$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3048endif
3049
3050
3051# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003052# dtbo image
3053ifdef BOARD_PREBUILT_DTBOIMAGE
3054INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3055
3056ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003057$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003058 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3059 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003060 --image $@ \
3061 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3062 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3063 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003064else
3065$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3066 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3067endif
3068
Tao Bao0da43472018-08-22 22:53:41 -07003069endif # BOARD_PREBUILT_DTBOIMAGE
3070
3071# Returns a list of image targets corresponding to the given list of partitions. For example, it
3072# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3073# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003074# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003075define images-for-partitions
3076$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3077endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003078
3079# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003080# custom images
3081INSTALLED_CUSTOMIMAGES_TARGET :=
3082
3083ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3084INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3085
3086# Sign custom image.
3087# $(1): the prebuilt custom image.
3088# $(2): the mount point of the prebuilt custom image.
3089# $(3): the signed custom image target.
3090define sign_custom_image
3091$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3092 @echo Target custom image: $(3)
3093 mkdir -p $(dir $(3))
3094 cp $(1) $(3)
3095ifeq ($(BOARD_AVB_ENABLE),true)
3096 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3097 $(AVBTOOL) add_hashtree_footer \
3098 --image $(3) \
3099 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3100 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3101 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3102 --partition_name $(2) \
3103 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3104 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3105endif
3106INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3107endef
3108
3109$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3110 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3111 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3112endif
3113
3114# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003115# vbmeta image
3116ifeq ($(BOARD_AVB_ENABLE),true)
3117
3118BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003119AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003120
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003121ifdef BOARD_AVB_KEY_PATH
3122$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3123else
3124# If key path isn't specified, use the 4096-bit test key.
3125BOARD_AVB_ALGORITHM := SHA256_RSA4096
3126BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3127endif
3128
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003129# AVB signing for system_other.img.
3130ifdef BUILDING_SYSTEM_OTHER_IMAGE
3131ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3132$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3133else
3134# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3135BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3136BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3137endif
3138
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003139$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3140 @echo Extracting system_other avb key: $@
3141 @rm -f $@
3142 @mkdir -p $(dir $@)
3143 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003144
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003145ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3146BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3147endif
3148
3149BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3150endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3151
Tao Bao744c4c72018-08-20 21:09:07 -07003152INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003153 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003154 $(BOARD_AVB_VBMETA_VENDOR)
3155
3156# Not allowing the same partition to appear in multiple groups.
3157ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003158 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003159endif
3160
cfig1aeef722019-09-20 22:45:06 +08003161# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3162# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3163# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003164ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003165ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3166$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003167 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003168 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3169endif
3170endif
3171
Bowgo Tsai9b548012019-05-14 16:57:03 +08003172# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003173
3174BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003175 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003176 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003177 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3178
3179BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003180 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003181 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003182 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3183
Justin Yun6151e3f2019-06-25 15:58:13 +09003184BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003185 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003186 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3187 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003188
Bowgo Tsai9b548012019-05-14 16:57:03 +08003189BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003190 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003191 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3192
Tao Bao19b02fe2019-10-09 00:04:28 -07003193BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3194 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3195
3196BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3197 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3198
Bowgo Tsai9b548012019-05-14 16:57:03 +08003199BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003200 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003201 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3202
3203BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003204 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003205 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3206
Yifan Hongcfb917a2020-05-07 14:58:20 -07003207BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3208 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3209 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3210
Yifan Hongf496f1b2020-07-15 16:52:59 -07003211BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3212 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3213 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3214
Tao Bao19b02fe2019-10-09 00:04:28 -07003215BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3216 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3217
Bowgo Tsai9b548012019-05-14 16:57:03 +08003218# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003219ifdef BOOT_SECURITY_PATCH
3220BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3221 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3222endif
3223
3224ifdef VENDOR_SECURITY_PATCH
3225BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3226 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3227endif
3228
3229ifdef ODM_SECURITY_PATCH
3230BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3231 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3232endif
3233
Yifan Hongcfb917a2020-05-07 14:58:20 -07003234ifdef VENDOR_DLKM_SECURITY_PATCH
3235BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3236 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3237endif
3238
Yifan Hongf496f1b2020-07-15 16:52:59 -07003239ifdef ODM_DLKM_SECURITY_PATCH
3240BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3241 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3242endif
3243
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003244BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003245VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003246DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3247SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3248VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003249RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003250PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003251SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003252ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003253VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003254ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003255
Tao Bao0da43472018-08-22 22:53:41 -07003256# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003257# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003258define _check-and-set-avb-chain-args
3259$(eval part := $(1))
3260$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003261
3262$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3263$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3264$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3265$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3266$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3267$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3268$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3269$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3270
3271# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3272$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3273$(eval $(_signing_args) := \
3274 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3275
cfig1aeef722019-09-20 22:45:06 +08003276# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3277# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003278$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003279 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3280 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003281
Tao Bao744c4c72018-08-20 21:09:07 -07003282# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003283# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003284$(if $(filter $(part),$(part:vbmeta_%=%)),\
3285 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3286 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003287endef
3288
Tao Bao0da43472018-08-22 22:53:41 -07003289# Checks and sets the required build variables for an AVB partition. The partition will be
3290# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003291# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3292# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003293# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3294# but vbmeta would capture the image descriptor of only the first boot
3295# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003296# $(1): Partition name, e.g. boot or system.
3297define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003298$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003299$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003300 $(if $(_in_chained_vbmeta),\
3301 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003302 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003303 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003304 $(if $(filter boot,$(1)),\
3305 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3306 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3307 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3308 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003309endef
3310
Hongguang Chenf23364d2020-04-27 18:36:36 -07003311# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3312# $(1): the custom partition to enable AVB chain.
3313define check-and-set-custom-avb-chain-args
3314$(eval part := $(1))
3315$(eval PART=$(call to-upper,$(part)))
3316$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3317$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3318
3319INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3320 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3321endef
3322
Tao Baob1a2e352018-08-14 16:17:12 -07003323ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003324$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003325endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003326
Steve Mucklee1b10862019-07-10 10:49:37 -07003327ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3328$(eval $(call check-and-set-avb-args,vendor_boot))
3329endif
3330
Tao Bao0da43472018-08-22 22:53:41 -07003331$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003332
3333ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003334$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003335endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003336
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003337ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003338$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003339endif
3340
Justin Yun6151e3f2019-06-25 15:58:13 +09003341ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3342$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003343endif
3344
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003345ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003346$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003347endif
3348
Yifan Hongcfb917a2020-05-07 14:58:20 -07003349ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3350$(eval $(call check-and-set-avb-args,vendor_dlkm))
3351endif
3352
Yifan Hongf496f1b2020-07-15 16:52:59 -07003353ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3354$(eval $(call check-and-set-avb-args,odm_dlkm))
3355endif
3356
Yueyao Zhu211c9012017-04-27 00:34:50 -07003357ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003358$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003359endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003360
David Zeuthen8fecb282017-12-01 16:24:01 -05003361ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003362$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003363endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003364
David Anderson7709ab22018-10-15 14:41:34 -07003365# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3366ifdef BOARD_AVB_VBMETA_SYSTEM
3367$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003368endif
3369
3370ifdef BOARD_AVB_VBMETA_VENDOR
3371$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3372endif
3373
Hongguang Chenf23364d2020-04-27 18:36:36 -07003374ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3375$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3376 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3377endif
3378
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003379# Add kernel cmdline descriptor for kernel to mount system.img as root with
3380# dm-verity. This works when system.img is either chained or not-chained:
3381# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3382# cmdline descriptor to system.img
3383# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3384# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003385ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003386ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003387BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003388endif
David Anderson8916a2a2018-09-18 15:46:59 -07003389endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003390
Tao Bao0da43472018-08-22 22:53:41 -07003391BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003392BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003393BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3394
3395ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003396# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003397BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003398endif
Tao Bao0da43472018-08-22 22:53:41 -07003399
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003400ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003401BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003402endif
3403
David Anderson7709ab22018-10-15 14:41:34 -07003404ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3405BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3406 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003407endif
3408
3409ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3410BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3411 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003412endif
3413
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003414# $(1): the directory to extract public keys to
3415define extract-avb-chain-public-keys
3416 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3417 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3418 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003419 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3420 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3421 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003422 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3423 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3424 --output $(1)/system.avbpubkey)
3425 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3426 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3427 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003428 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3429 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3430 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003431 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3432 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3433 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003434 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3435 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3436 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003437 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3438 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3439 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003440 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3441 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3442 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003443 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3444 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3445 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003446 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3447 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3448 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003449 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3450 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3451 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003452 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3453 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3454 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003455 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3456 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3457 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3458 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003459endef
3460
Tao Bao744c4c72018-08-20 21:09:07 -07003461# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3462# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003463# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003464# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3465# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003466# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003467# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003468# $(2): Output filename.
3469define build-chained-vbmeta-image
3470 $(call pretty,"Target chained vbmeta image: $@")
3471 $(hide) $(AVBTOOL) make_vbmeta_image \
3472 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3473 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3474 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3475 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3476 --output $@
3477endef
3478
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003479ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003480ifdef BOARD_AVB_VBMETA_SYSTEM
3481INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3482$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003483 $(AVBTOOL) \
3484 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3485 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003486 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003487endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003488endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003489
3490ifdef BOARD_AVB_VBMETA_VENDOR
3491INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3492$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003493 $(AVBTOOL) \
3494 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3495 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003496 $(call build-chained-vbmeta-image,vbmeta_vendor)
3497endif
3498
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003499define build-vbmetaimage-target
3500 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003501 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3502 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003503 $(hide) $(AVBTOOL) make_vbmeta_image \
3504 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003505 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003506 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3507 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003508 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003509endef
3510
Paul Trautrim4e143232019-08-13 16:30:57 +09003511ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003512INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003513$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3514 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3515
David Zeuthen8fecb282017-12-01 16:24:01 -05003516$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003517 $(AVBTOOL) \
3518 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003519 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003520 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3521 $(INSTALLED_VENDORIMAGE_TARGET) \
3522 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003523 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003524 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003525 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003526 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003527 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003528 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003529 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3530 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3531 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3532 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3533 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3534 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003535 $(build-vbmetaimage-target)
3536
3537.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003538vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3539 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003540vbmetaimage-nodeps:
3541 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003542endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003543
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003544endif # BOARD_AVB_ENABLE
3545
3546# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003547# Check VINTF of build
3548
Yifan Hongf496f1b2020-07-15 16:52:59 -07003549# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003550ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003551
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003552intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3553check_vintf_all_deps :=
3554
Yifan Hongaf9b0702020-01-21 12:46:57 -08003555# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3556# because they are only used for prebuilt images.
3557check_vintf_common_srcs_patterns := \
3558 $(TARGET_OUT)/etc/vintf/% \
3559 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3560 $(TARGET_OUT_ODM)/etc/vintf/% \
3561 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3562 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3563
3564check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3565 $(INTERNAL_SYSTEMIMAGE_FILES) \
3566 $(INTERNAL_VENDORIMAGE_FILES) \
3567 $(INTERNAL_ODMIMAGE_FILES) \
3568 $(INTERNAL_PRODUCTIMAGE_FILES) \
3569 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3570))
3571check_vintf_common_srcs_patterns :=
3572
3573check_vintf_has_system :=
3574check_vintf_has_vendor :=
3575
Yifan Hong28ffd732020-03-13 13:11:10 -07003576ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3577$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3578endif
3579ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3580$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3581endif
3582
Yifan Hong605ea042020-01-14 21:36:00 +00003583# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003584check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3585ifneq ($(check_vintf_system_deps),)
3586check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003587check_vintf_system_log := $(intermediates)/check_vintf_system_log
3588check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003589$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003590 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3591check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003592endif # check_vintf_system_deps
3593check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003594
3595# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003596check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3597ifneq ($(check_vintf_vendor_deps),)
3598check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003599check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3600check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003601# Check vendor SKU=(empty) case when:
3602# - DEVICE_MANIFEST_FILE is not empty; OR
3603# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003604$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003605 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3606 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003607 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003608$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003609 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3610 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3611 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3612 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003613check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003614endif # check_vintf_vendor_deps
3615check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003616
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003617# -- Check VINTF compatibility of build.
3618# Skip partial builds; only check full builds. Only check if:
3619# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003620# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003621# - Building product / system_ext / odm images if board has product / system_ext / odm images
3622ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003623ifeq ($(check_vintf_has_system),true)
3624ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003625ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3626ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3627ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3628
3629check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3630check_vintf_all_deps += $(check_vintf_compatible_log)
3631
3632check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003633check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003634
3635# -- Kernel version and configurations.
3636ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3637
Yifan Hong605ea042020-01-14 21:36:00 +00003638BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3639BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3640
3641my_board_extracted_kernel :=
3642
3643# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3644# from INSTALLED_KERNEL_TARGET.
3645ifdef BOARD_KERNEL_CONFIG_FILE
3646ifdef BOARD_KERNEL_VERSION
3647$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3648 cp $< $@
3649$(BUILT_KERNEL_VERSION_FILE):
3650 echo $(BOARD_KERNEL_VERSION) > $@
3651
3652my_board_extracted_kernel := true
3653endif # BOARD_KERNEL_VERSION
3654endif # BOARD_KERNEL_CONFIG_FILE
3655
3656ifneq ($(my_board_extracted_kernel),true)
3657ifndef INSTALLED_KERNEL_TARGET
3658$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3659 is true. Information about the updated kernel cannot be built into OTA update package. \
3660 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3661 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3662 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3663 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3664 manually.)
3665else
3666
3667# Tools for decompression that is not in PATH.
3668# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3669# Algorithms that are in the script but not in this list will be found in PATH.
3670my_decompress_tools := \
3671 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3672
3673$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3674$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3675$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003676$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3677 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003678 --output-configs $@ \
3679 --output-version $(BUILT_KERNEL_VERSION_FILE)
3680
3681my_decompress_tools :=
3682
3683endif # my_board_extracted_kernel
3684my_board_extracted_kernel :=
3685
3686endif # INSTALLED_KERNEL_TARGET
3687
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003688check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3689check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3690
3691endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3692
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003693check_vintf_compatible_args += \
3694 --dirmap /system:$(TARGET_OUT) \
3695 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3696 --dirmap /odm:$(TARGET_OUT_ODM) \
3697 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3698 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3699
3700ifdef PRODUCT_SHIPPING_API_LEVEL
3701check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3702endif # PRODUCT_SHIPPING_API_LEVEL
3703
3704$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3705$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003706# Check ODM SKU=(empty) case when:
3707# - ODM_MANIFEST_FILES is not empty; OR
3708# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003709$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003710 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3711 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003712 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003713# Check vendor SKU=(empty) case when:
3714# - DEVICE_MANIFEST_FILE is not empty; OR
3715# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003716$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003717 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3718 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003719 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003720$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3721 @echo -n -e 'Deps: \n ' > $@
3722 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3723 @echo -n -e 'Args: \n ' >> $@
3724 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003725 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3726 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003727 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003728 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3729 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3730 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003731
3732check_vintf_compatible_log :=
3733check_vintf_compatible_args :=
3734check_vintf_compatible_deps :=
3735
3736endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3737endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3738endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003739endif # check_vintf_has_vendor
3740endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003741endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3742
3743# Add all logs of VINTF checks to dist builds
3744droid_targets: $(check_vintf_all_deps)
3745$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3746
3747# Helper alias to check all VINTF of current build.
3748.PHONY: check-vintf-all
3749check-vintf-all: $(check_vintf_all_deps)
3750 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3751
Yifan Hongaf9b0702020-01-21 12:46:57 -08003752check_vintf_has_vendor :=
3753check_vintf_has_system :=
3754check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003755check_vintf_all_deps :=
3756intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003757endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003758
3759# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003760# Check image sizes <= size of super partition
3761
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003762ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003763
3764ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003765
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003766# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003767# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003768define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003769 mkdir -p $(dir $(1))
3770 rm -f $(1)
3771 $(call dump-super-image-info, $(1))
3772 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3773 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003774 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003775endef
3776
Yifan Hong30910932019-10-25 20:36:55 -07003777check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3778droid_targets: $(check_all_partition_sizes_log)
3779$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003780
Yifan Hong30910932019-10-25 20:36:55 -07003781$(check_all_partition_sizes_log): \
3782 $(CHECK_PARTITION_SIZES) \
3783 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3784 $(call check-all-partition-sizes-target, \
3785 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3786 $@)
3787
3788.PHONY: check-all-partition-sizes
3789check-all-partition-sizes: $(check_all_partition_sizes_log)
3790
3791.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003792check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003793 $(call check-all-partition-sizes-target, \
3794 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003795
Yifan Hong2dae5722018-07-31 12:47:27 -07003796endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003797
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003798endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003799
3800# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003801# bring in the installer image generation defines if necessary
3802ifeq ($(TARGET_USE_DISKINSTALLER),true)
3803include bootable/diskinstaller/config.mk
3804endif
3805
3806# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003807# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003808
Ying Wangbd2d0242015-09-22 11:17:52 -07003809ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003810 build_ota_package := false
3811 build_otatools_package := false
3812else
Tao Bao9be20c72019-04-08 21:11:59 -07003813 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003814 build_ota_package := true
3815 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3816 build_ota_package := false
3817 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003818 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003819 build_ota_package := false
3820 endif
3821 ifeq ($(TARGET_PRODUCT),sdk)
3822 build_ota_package := false
3823 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003824 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3825 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3826 build_ota_package := false
3827 endif
3828 ifeq ($(TARGET_NO_KERNEL),true)
3829 build_ota_package := false
3830 endif
3831 ifeq ($(recovery_fstab),)
3832 build_ota_package := false
3833 endif
3834 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003835
Tao Bao9be20c72019-04-08 21:11:59 -07003836 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003837 build_otatools_package := true
3838 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3839 build_otatools_package := false
3840 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003841endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003842
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003843ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003844
3845INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003846 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003847 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003848 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003849 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003850 append2simg \
3851 avbtool \
3852 blk_alloc_to_base_fs \
3853 boot_signer \
3854 brillo_update_payload \
3855 brotli \
3856 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003857 build_image \
3858 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003859 build_verity_metadata \
3860 build_verity_tree \
3861 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003862 check_ota_package_signature \
3863 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003864 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003865 checkvintf \
3866 delta_generator \
3867 e2fsck \
3868 e2fsdroid \
3869 fc_sort \
3870 fec \
3871 fs_config \
3872 generate_verity_key \
3873 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003874 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003875 imgdiff \
3876 libconscrypt_openjdk_jni \
3877 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003878 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003879 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003880 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003881 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003882 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003883 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003884 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003885 mkbootfs \
3886 mkbootimg \
3887 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003888 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003889 mkf2fsuserimg.sh \
3890 mksquashfs \
3891 mksquashfsimage.sh \
3892 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003893 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003894 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003895 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003896 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003897 sign_apex \
3898 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003899 signapk \
3900 simg2img \
3901 sload_f2fs \
3902 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003903 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003904 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003905 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003906 verity_signer \
3907 verity_verifier \
3908 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003909
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003910# Additional tools to unpack and repack the apex file.
3911INTERNAL_OTATOOLS_MODULES += \
3912 apexer \
3913 deapexer \
3914 debugfs_static \
3915 merge_zips \
3916 resize2fs \
3917 soong_zip \
3918
Anton Hansson8dab0a62019-03-28 15:45:40 +00003919ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003920INTERNAL_OTATOOLS_MODULES += \
3921 futility \
3922 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003923endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003924
Tao Bao96daeeb2019-05-01 21:17:13 -07003925INTERNAL_OTATOOLS_FILES := \
3926 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003927
Ying Wang06898662010-06-17 17:52:18 -07003928.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003929otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003930
Tao Bao96daeeb2019-05-01 21:17:13 -07003931# For each module, recursively resolve its host shared library dependencies. Then we have a full
3932# list of modules whose installed files need to be packed.
3933INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3934 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3935 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003936
Tao Bao96daeeb2019-05-01 21:17:13 -07003937INTERNAL_OTATOOLS_PACKAGE_FILES := \
3938 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3939
3940INTERNAL_OTATOOLS_PACKAGE_FILES += \
3941 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3942 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003943
3944ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003945INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003946 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003947 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003948endif
3949ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003950INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003951 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3952 -name "atx_metadata.bin"))
3953endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003954ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003955INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003956 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003957endif
3958
Tao Bao96daeeb2019-05-01 21:17:13 -07003959INTERNAL_OTATOOLS_RELEASETOOLS := \
3960 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3961 \( -type f -o -type l \) -print))
3962
3963BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3964$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3965$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3966$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3967$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003968$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003969 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003970 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3971 mkdir -p $(dir $@)
3972 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3973 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003974 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003975 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003976
3977.PHONY: otatools-package
3978otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3979
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003980endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003981
The Android Open Source Project88b60792009-03-03 19:28:42 -08003982# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003983# misc_info.txt
3984
3985INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3986
3987ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3988# default to common dir for device vendor
3989tool_extensions := $(TARGET_DEVICE_DIR)/../common
3990else
3991tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3992endif
3993.KATI_READONLY := tool_extensions
3994
Steve Muckle903a1ca2020-05-07 17:32:10 -07003995# $1: boot image file name
3996define misc_boot_size
3997$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3998endef
3999
Daniel Normane1e48082019-06-27 13:55:23 -07004000$(INSTALLED_MISC_INFO_TARGET):
4001 rm -f $@
4002 $(call pretty,"Target misc_info.txt: $@")
4003 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4004 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4005ifdef BOARD_FLASH_BLOCK_SIZE
4006 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4007endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004008ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4009 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4010 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004011endif
4012ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4013 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004014else
4015 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004016endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004017ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4018 echo "lz4_ramdisks=true" >> $@
4019endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004020ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4021 echo "vendor_boot=true" >> $@
4022 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4023endif
Daniel Normane1e48082019-06-27 13:55:23 -07004024ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4025 $(hide) echo "no_recovery=true" >> $@
4026endif
4027ifdef BOARD_INCLUDE_RECOVERY_DTBO
4028 $(hide) echo "include_recovery_dtbo=true" >> $@
4029endif
4030ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4031 $(hide) echo "include_recovery_acpio=true" >> $@
4032endif
4033ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4034 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4035endif
4036ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4037 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4038 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4039else
4040 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4041endif
4042 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4043 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4044ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4045 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4046endif
4047 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004048 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004049 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4050 $(hide) echo "multistage_support=1" >> $@
4051 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4052ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4053 $(hide) echo "build_generic_ota_package=true" >> $@
4054endif
4055ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4056 # OTA scripts are only interested in fingerprint related properties
4057 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4058endif
4059ifneq (,$(filter address, $(SANITIZE_TARGET)))
4060 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4061 $(hide) echo "userdata_img_with_data=true" >> $@
4062endif
4063ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4064 $(hide) echo "full_recovery_image=true" >> $@
4065endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004066ifdef BOARD_USES_VENDORIMAGE
4067 $(hide) echo "board_uses_vendorimage=true" >> $@
4068endif
Daniel Normane1e48082019-06-27 13:55:23 -07004069ifeq ($(BOARD_AVB_ENABLE),true)
4070 $(hide) echo "avb_enable=true" >> $@
4071 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4072 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4073 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4074 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4075ifdef BOARD_AVB_BOOT_KEY_PATH
4076 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4077 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4078 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4079endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004080 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4081ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4082 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4083 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4084 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4085endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004086 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4087ifdef BOARD_AVB_RECOVERY_KEY_PATH
4088 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4089 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4090 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4091endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004092ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4093 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4094 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4095 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4096 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4097 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4098 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4099 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4100 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4101endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004102ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4103 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4104 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4105 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4106 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4107 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4108endif # BOARD_AVB_VBMETA_SYSTEM
4109ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4110 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4111 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4112 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4113 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4114 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4115endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4116endif # BOARD_AVB_ENABLE
4117ifdef BOARD_BPT_INPUT_FILES
4118 $(hide) echo "board_bpt_enable=true" >> $@
4119 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4120 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4121endif
4122ifdef BOARD_BPT_DISK_SIZE
4123 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4124endif
4125 $(call generate-userimage-prop-dictionary, $@)
4126ifeq ($(AB_OTA_UPDATER),true)
4127 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4128 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4129 $(hide) echo "ab_update=true" >> $@
4130endif
Yifan Hong65afc072020-04-17 10:08:10 -07004131ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4132 $(hide) echo "allow_non_ab=true" >> $@
4133endif
Daniel Normane1e48082019-06-27 13:55:23 -07004134ifdef BOARD_PREBUILT_DTBOIMAGE
4135 $(hide) echo "has_dtbo=true" >> $@
4136ifeq ($(BOARD_AVB_ENABLE),true)
4137 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4138 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4139ifdef BOARD_AVB_DTBO_KEY_PATH
4140 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4141 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4142 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4143endif # BOARD_AVB_DTBO_KEY_PATH
4144endif # BOARD_AVB_ENABLE
4145endif # BOARD_PREBUILT_DTBOIMAGE
4146 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004147 @# VINTF checks
4148ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4149 $(hide) echo "vintf_enforce=true" >> $@
4150endif
4151ifdef ODM_MANIFEST_SKUS
4152 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4153endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004154ifdef ODM_MANIFEST_FILES
4155 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4156endif
4157ifdef DEVICE_MANIFEST_SKUS
4158 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4159endif
4160ifdef DEVICE_MANIFEST_FILE
4161 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4162endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004163ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4164 $(hide) echo "bootloader_in_update_package=true" >> $@
4165endif
Daniel Normane1e48082019-06-27 13:55:23 -07004166
4167.PHONY: misc_info
4168misc_info: $(INSTALLED_MISC_INFO_TARGET)
4169
4170droidcore: $(INSTALLED_MISC_INFO_TARGET)
4171
4172# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004173# A zip of the directories that map to the target filesystem.
4174# This zip can be used to create an OTA package or filesystem image
4175# as a post-build step.
4176#
4177name := $(TARGET_PRODUCT)
4178ifeq ($(TARGET_BUILD_TYPE),debug)
4179 name := $(name)_debug
4180endif
4181name := $(name)-target_files-$(FILE_NAME_TAG)
4182
4183intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4184BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4185$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4186$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004187 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004188
4189# $(1): Directory to copy
4190# $(2): Location to copy it to
4191# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4192define package_files-copy-root
4193 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4194 mkdir -p $(2) && \
4195 $(ACP) -rd $(strip $(1))/* $(2); \
4196 fi
4197endef
4198
Tao Baoa04fca32015-11-30 12:22:24 -08004199built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004200
4201# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004202ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004203built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004204 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004205endif
4206
The Android Open Source Project88b60792009-03-03 19:28:42 -08004207$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4208
Dan Willemsen653bea92017-03-21 15:47:37 -07004209tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004210$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004211
Sen Jiang4438fd92016-03-07 16:51:01 -08004212ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004213updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004214endif
4215
4216# Build OTA tools if non-A/B is allowed
4217ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004218updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004219endif
Yifan Hong65afc072020-04-17 10:08:10 -07004220
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004221$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004222
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004223# If we are using recovery as boot, output recovery files to BOOT/.
4224ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4225$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4226else
4227$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4228endif
4229
Dan Willemsen653bea92017-03-21 15:47:37 -07004230ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004231 ifdef OSRELEASED_DIRECTORY
4232 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4233 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4234 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4235 endif
Tao Baoa835f382019-07-18 15:55:30 -07004236
4237 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4238 # additionally include radio or bootloader partitions).
4239 ifeq ($(AB_OTA_PARTITIONS),)
4240 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4241 endif
4242endif
4243
4244ifneq ($(AB_OTA_PARTITIONS),)
4245 ifneq ($(AB_OTA_UPDATER),true)
4246 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4247 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004248endif
4249
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004250# Run fs_config while creating the target files package
4251# $1: root directory
4252# $2: add prefix
4253define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004254(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 -08004255endef
4256
Yifan Hong60bfcc42019-11-01 11:39:45 -07004257# Filter out vendor from the list for AOSP targets.
4258# $(1): list
4259define filter-out-missing-vendor
4260$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4261endef
4262
4263# Information related to dynamic partitions and virtual A/B. This information
4264# is needed for building the super image (see dump-super-image-info) and
4265# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004266# $(1): file
4267define dump-dynamic-partitions-info
4268 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4269 echo "use_dynamic_partitions=true" >> $(1))
4270 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4271 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004272 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4273 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4274 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004275 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4276 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004277 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4278 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4279 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4280 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4281 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4282 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004283 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004284 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4285 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4286 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4287 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4288 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004289 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 -07004290 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4291 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004292 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4293 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004294 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4295 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004296 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4297 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4298 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4299 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4300 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4301 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4302 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4303 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004304 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4305 echo "virtual_ab=true" >> $(1))
4306 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4307 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004308endef
4309
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004310# By conditionally including the dependency of the target files package on the
4311# full system image deps, we speed up builds that do not build the system
4312# image.
4313ifdef BUILDING_SYSTEM_IMAGE
4314$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4315endif
4316
Isaac Chen9e09d472019-07-05 17:30:41 +08004317ifeq ($(BUILD_QEMU_IMAGES),true)
4318MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4319$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4320endif
4321
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004322ifdef BOARD_PREBUILT_BOOTLOADER
4323$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004324droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004325endif
4326
The Android Open Source Project88b60792009-03-03 19:28:42 -08004327# Depending on the various images guarantees that the underlying
4328# directories are up-to-date.
4329$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004330 $(INSTALLED_RAMDISK_TARGET) \
4331 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004332 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004333 $(INSTALLED_RADIOIMAGE_TARGET) \
4334 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004335 $(INSTALLED_USERDATAIMAGE_TARGET) \
4336 $(INSTALLED_CACHEIMAGE_TARGET) \
4337 $(INSTALLED_VENDORIMAGE_TARGET) \
4338 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004339 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004340 $(INSTALLED_VBMETAIMAGE_TARGET) \
4341 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004342 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004343 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004344 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004345 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004346 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4347 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4348 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004349 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004350 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4351 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004352 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004353 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004354 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4355 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4356 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004357 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004358 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004359 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004360 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004361 $(LPMAKE) \
4362 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004363 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004364 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004365 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004366 $(SOONG_ZIP) \
4367 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004368 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004369 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004370 $(BUILT_KERNEL_CONFIGS_FILE) \
4371 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004372 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004373 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004374 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004375 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004376 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004377 $(call create-vendor-odm-symlink)
Yifan Honge51dff22020-06-23 17:26:57 -07004378 $(call create-vendor-vendor_dlkm-symlink)
Yifan Hong3d5e2c22020-07-15 17:01:14 -07004379 $(call create-odm-odm_dlkm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004380 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004381 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004382ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004383 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004384 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004385 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004386 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004387ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004388ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004389 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Steve Muckle04b6f052020-08-09 14:36:56 -07004390else # BOARD_USES_RECOVERY_AS_BOOT not true
4391 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4392endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004393endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004394ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004395 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004396else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004397ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004398 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004399endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004400ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004401ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004402 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004403else
Steve Mucklee1b10862019-07-10 10:49:37 -07004404 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004405endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004406endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004407ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004408 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004409endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004410ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004411 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004412endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004413ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004414 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004415endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004416ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004417 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004418endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004419ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004420 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004421endif
Colin Crossa6de2ad2020-08-26 18:40:19 -07004422endif # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004423endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004424 @# Components of the boot image
4425 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004426 $(hide) mkdir -p $(zip_root)/ROOT
4427 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004428 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004429 @# If we are using recovery as boot, this is already done when processing recovery.
4430ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004431ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004432 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004433 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004434endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004435ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004436 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004437endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004438ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004439ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004440 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004441endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004442ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004443 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004444endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004445 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004446ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004447 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004448endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004449ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004450 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004451endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004452else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4453 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4454endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4455endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004456 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4457 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004458 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004459ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4460 mkdir -p $(zip_root)/VENDOR_BOOT
4461 $(call package_files-copy-root, \
4462 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4463ifdef INSTALLED_DTBIMAGE_TARGET
4464 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4465endif
4466ifdef BOARD_KERNEL_BASE
4467 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4468endif
4469ifdef BOARD_KERNEL_PAGESIZE
4470 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4471endif
4472 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4473endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004474ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004475 @# Contents of the system image
4476 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004477 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004478endif
4479ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004480 @# Contents of the data image
4481 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004482 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004483endif
4484ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004485 @# Contents of the vendor image
4486 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004487 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004488endif
Dan Willemsen67495202019-01-16 12:42:05 -08004489ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004490 @# Contents of the product image
4491 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004492 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004493endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004494ifdef BUILDING_SYSTEM_EXT_IMAGE
4495 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004496 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004497 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004498endif
Dan Willemsen67495202019-01-16 12:42:05 -08004499ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004500 @# Contents of the odm image
4501 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004502 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004503endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004504ifdef BUILDING_VENDOR_DLKM_IMAGE
4505 @# Contents of the vendor_dlkm image
4506 $(hide) $(call package_files-copy-root, \
4507 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4508endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004509ifdef BUILDING_ODM_DLKM_IMAGE
4510 @# Contents of the odm_dlkm image
4511 $(hide) $(call package_files-copy-root, \
4512 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4513endif
Dan Willemsen67495202019-01-16 12:42:05 -08004514ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004515 @# Contents of the system_other image
4516 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004517 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004518endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004519 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004520 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004521 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004522ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004523ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004524 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004525 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004526endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004527endif
Doug Zongker8678df42009-06-15 14:30:14 -07004528 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004529 @# build them.
4530 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004531 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004532 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004533ifneq ($(tool_extension),)
4534 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4535endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004536 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004537 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004538 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004539ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4540 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4541 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004542endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004543ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4544 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4545 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004546endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004547ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4548 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4549 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004550endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004551ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4552 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4553 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004554endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004555ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4556 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4557 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004558endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004559ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4560 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4561 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4562endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004563ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4564 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4565 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4566endif
Yifan Hong65afc072020-04-17 10:08:10 -07004567ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004568ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004569 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004570 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004571endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004572endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004573ifeq ($(AB_OTA_UPDATER),true)
4574 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004575 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004576 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004577 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4578 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004579 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4580 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4581 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004582ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004583 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4584 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4585 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004586endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004587endif
Steve Fungdfbab492015-09-24 18:12:33 -07004588ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004589 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004590 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004591endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004592ifdef BOARD_PREBUILT_VENDORIMAGE
4593 $(hide) mkdir -p $(zip_root)/IMAGES
4594 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4595endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004596ifdef BOARD_PREBUILT_PRODUCTIMAGE
4597 $(hide) mkdir -p $(zip_root)/IMAGES
4598 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4599endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004600ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004601 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004602 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004603endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004604ifdef BOARD_PREBUILT_BOOTIMAGE
4605 $(hide) mkdir -p $(zip_root)/IMAGES
4606 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4607endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004608ifdef BOARD_PREBUILT_ODMIMAGE
4609 $(hide) mkdir -p $(zip_root)/IMAGES
4610 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4611endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004612ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004613 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004614 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4615endif
4616ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4617 $(hide) mkdir -p $(zip_root)/IMAGES
4618 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004619endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004620ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004621 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4622 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004623endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004624ifdef BOARD_PREBUILT_BOOTLOADER
4625 $(hide) mkdir -p $(zip_root)/IMAGES
4626 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4627endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004628ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4629 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4630 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4631 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4632endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004633 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4634 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4635 @# INSTALLED_RADIOIMAGE_TARGET.
4636 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4637 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004638 @# Run fs_config on all the system, vendor, boot ramdisk,
4639 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004640ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004641 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004642endif
4643ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004644 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4645endif
Dan Willemsen67495202019-01-16 12:42:05 -08004646ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004647 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4648endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004649ifdef BUILDING_SYSTEM_EXT_IMAGE
4650 $(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 +01004651endif
Dan Willemsen67495202019-01-16 12:42:05 -08004652ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004653 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4654endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004655ifdef BUILDING_VENDOR_DLKM_IMAGE
4656 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4657endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004658ifdef BUILDING_ODM_DLKM_IMAGE
4659 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4660endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004661 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004662 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004663ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004664 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004665 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004666endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004667ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4668 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4669endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004670ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4671 @# 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 -08004672 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4673endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004674ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4675 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4676endif
Dan Willemsen67495202019-01-16 12:42:05 -08004677ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004678 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4679endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004680 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004681ifdef BUILT_KERNEL_CONFIGS_FILE
4682 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4683endif
4684ifdef BUILT_KERNEL_VERSION_FILE
4685 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4686endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004687 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4688ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4689 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4690endif
Tao Baocbd6d492019-10-07 22:46:02 -07004691 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4692 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004693ifeq ($(BUILD_QEMU_IMAGES),true)
4694 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4695 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4696endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004697 @# Zip everything up, preserving symlinks and placing META/ files first to
4698 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004699 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004700 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004701 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004702
Ying Wanga0febe52013-03-20 11:02:05 -07004703.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004704target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4705
Ying Wang4709d7c2014-04-14 17:25:43 -07004706ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4707$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4708endif
Doug Zongker367910f2009-06-15 18:56:51 -07004709
Dan Albert4d323332016-10-14 13:23:06 -07004710# -----------------------------------------------------------------
4711# NDK Sysroot Package
4712NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004713$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004714 @echo Package NDK sysroot...
4715 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4716
4717$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4718
Ying Wang09c4b682015-08-11 11:24:19 -07004719ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004720# -----------------------------------------------------------------
4721# OTA update package
4722
Yifan Hong50e79542018-11-08 17:44:12 -08004723# $(1): output file
4724# $(2): additional args
4725define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004726PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004727 $(OTA_FROM_TARGET_FILES) \
4728 --verbose \
4729 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4730 --path $(HOST_OUT) \
4731 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4732 $(2) \
4733 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004734endef
4735
Doug Zongker8678df42009-06-15 14:30:14 -07004736name := $(TARGET_PRODUCT)
4737ifeq ($(TARGET_BUILD_TYPE),debug)
4738 name := $(name)_debug
4739endif
4740name := $(name)-ota-$(FILE_NAME_TAG)
4741
4742INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004743INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4744
Doug Zongker8678df42009-06-15 14:30:14 -07004745$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004746$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004747$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004748 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004749 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004750
4751.PHONY: otapackage
4752otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4753
Tao Bao519d1822018-12-27 12:47:23 -08004754ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004755name := $(TARGET_PRODUCT)
4756ifeq ($(TARGET_BUILD_TYPE),debug)
4757 name := $(name)_debug
4758endif
4759name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4760
4761INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004762$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004763$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4764 $(BUILT_TARGET_FILES_PACKAGE) \
4765 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004766 @echo "Package OTA (retrofit dynamic partitions): $@"
4767 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4768
4769.PHONY: otardppackage
4770
4771otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4772
Tao Bao519d1822018-12-27 12:47:23 -08004773endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004774
Ying Wang09c4b682015-08-11 11:24:19 -07004775endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004776
Ying Wang09a00a62010-10-20 14:01:09 -07004777# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004778# A zip of the appcompat directory containing logs
4779APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4780# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004781ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004782$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004783 $(INSTALLED_RAMDISK_TARGET) \
4784 $(INSTALLED_BOOTIMAGE_TARGET) \
4785 $(INSTALLED_USERDATAIMAGE_TARGET) \
4786 $(INSTALLED_VENDORIMAGE_TARGET) \
4787 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004788 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004789endif
4790$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4791$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4792 @echo "appcompat logs: $@"
4793 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4794 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4795 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4796 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4797
Dario Frenid1011272018-07-23 20:20:15 +01004798# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004799# A zip of the symbols directory. Keep the full paths to make it
4800# more obvious where these files came from.
4801#
4802name := $(TARGET_PRODUCT)
4803ifeq ($(TARGET_BUILD_TYPE),debug)
4804 name := $(name)_debug
4805endif
4806name := $(name)-symbols-$(FILE_NAME_TAG)
4807
4808SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004809# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004810ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004811$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004812 $(INSTALLED_RAMDISK_TARGET) \
4813 $(INSTALLED_BOOTIMAGE_TARGET) \
4814 $(INSTALLED_USERDATAIMAGE_TARGET) \
4815 $(INSTALLED_VENDORIMAGE_TARGET) \
4816 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004817 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004818 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004819 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004820 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004821 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004822endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004823$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4824$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004825 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004826 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4827 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004828 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004829 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004830# -----------------------------------------------------------------
4831# A zip of the coverage directory.
4832#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004833name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004834ifeq ($(TARGET_BUILD_TYPE),debug)
4835name := $(name)_debug
4836endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004837COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004838ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004839$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004840 $(INSTALLED_RAMDISK_TARGET) \
4841 $(INSTALLED_BOOTIMAGE_TARGET) \
4842 $(INSTALLED_USERDATAIMAGE_TARGET) \
4843 $(INSTALLED_VENDORIMAGE_TARGET) \
4844 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004845 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004846 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004847 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4848 $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004849endif
4850$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4851$(COVERAGE_ZIP): $(SOONG_ZIP)
4852 @echo "Package coverage: $@"
4853 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4854 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4855 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4856 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004857
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004858#------------------------------------------------------------------
4859# Export the LLVM profile data tool and dependencies for Clang coverage processing
4860#
4861ifeq (true,$(CLANG_COVERAGE))
4862 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4863 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4864 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4865 $(PROFDATA_ZIP): $(SOONG_ZIP)
4866 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4867
4868 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4869endif
4870
The Android Open Source Project88b60792009-03-03 19:28:42 -08004871# -----------------------------------------------------------------
4872# A zip of the Android Apps. Not keeping full path so that we don't
4873# include product names when distributing
4874#
4875name := $(TARGET_PRODUCT)
4876ifeq ($(TARGET_BUILD_TYPE),debug)
4877 name := $(name)_debug
4878endif
4879name := $(name)-apps-$(FILE_NAME_TAG)
4880
4881APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004882$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004883 @echo "Package apps: $@"
4884 $(hide) rm -rf $@
4885 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004886 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4887 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004888 echo "No apps to zip up. Generating empty apps archive." ; \
4889 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004890 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004891 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004892 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004893
Ying Wangbc415dd2012-08-15 12:22:44 -07004894ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004895#------------------------------------------------------------------
4896# An archive of classes for use in generating code-coverage reports
4897# These are the uninstrumented versions of any classes that were
4898# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004899# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004900
Colin Crossa6bc3a82017-09-27 14:28:41 -07004901JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004902$(JACOCO_REPORT_CLASSES_ALL) :
4903 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004904 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4905 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004906
Ying Wangbc415dd2012-08-15 12:22:44 -07004907endif # EMMA_INSTRUMENT=true
4908
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004909
Ying Wangae9115a2013-08-22 20:52:47 -07004910#------------------------------------------------------------------
4911# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004912#
Ying Wangc62c92c2013-08-28 18:38:25 -07004913PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004914# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004915ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004916$(PROGUARD_DICT_ZIP): \
4917 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4918 $(INSTALLED_RAMDISK_TARGET) \
4919 $(INSTALLED_BOOTIMAGE_TARGET) \
4920 $(INSTALLED_USERDATAIMAGE_TARGET) \
4921 $(INSTALLED_VENDORIMAGE_TARGET) \
4922 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4923 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4924 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004925 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004926 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Colin Cross114e8df2019-09-05 17:19:35 -07004927 $(updater_dep)
4928endif
4929$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4930$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004931 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004932 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4933 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4934 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4935 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004936
Colin Crossa9b9e6e2020-08-14 17:43:35 -07004937#------------------------------------------------------------------
4938# A zip of Proguard usage files.
4939#
4940PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
4941# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4942ifeq (,$(TARGET_BUILD_UNBUNDLED))
4943$(PROGUARD_USAGE_ZIP): \
4944 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4945 $(INSTALLED_RAMDISK_TARGET) \
4946 $(INSTALLED_BOOTIMAGE_TARGET) \
4947 $(INSTALLED_USERDATAIMAGE_TARGET) \
4948 $(INSTALLED_VENDORIMAGE_TARGET) \
4949 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4950 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4951 $(INSTALLED_ODMIMAGE_TARGET) \
4952 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4953 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
4954 $(updater_dep)
4955endif
4956$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
4957$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
4958 @echo "Packaging Proguard usage files."
4959 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4960 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
4961 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07004962
4963ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4964
4965# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4966# $(1): output file
4967define dump-super-image-info
4968 $(call dump-dynamic-partitions-info,$(1))
4969 $(if $(filter true,$(AB_OTA_UPDATER)), \
4970 echo "ab_update=true" >> $(1))
4971endef
4972
4973endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4974
The Android Open Source Project88b60792009-03-03 19:28:42 -08004975# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004976# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004977
4978ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4979
4980# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4981ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4982
4983ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004984
4985# For real devices and for dist builds, build super image from target files to an intermediate directory.
4986INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4987$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4988$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4989 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004990 PATH=$(dir $(LPMAKE)):$$PATH \
4991 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004992
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004993# Skip packing it in dist package because it is in update package.
4994ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004995$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004996endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004997
4998.PHONY: superimage_dist
4999superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005000
5001endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005002endif # BOARD_SUPER_PARTITION_SIZE != ""
5003endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005004
Yifan Hongacd862a2019-04-16 15:44:30 -07005005# -----------------------------------------------------------------
5006# super partition image for development
5007
5008ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5009ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5010ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5011
5012# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5013# $(1): built image path
5014# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5015define build-superimage-target
5016 mkdir -p $(dir $(2))
5017 rm -rf $(2)
5018 $(call dump-super-image-info,$(2))
5019 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5020 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005021 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5022 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005023 mkdir -p $(dir $(1))
5024 PATH=$(dir $(LPMAKE)):$$PATH \
5025 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5026endef
5027
5028INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5029INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5030 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5031
changho.shina8f9f112019-10-15 13:26:19 +09005032ifdef BUILDING_SYSTEM_OTHER_IMAGE
5033ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5034INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5035endif
5036endif
5037
Yifan Hongacd862a2019-04-16 15:44:30 -07005038# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5039# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5040# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5041# virtual devices.
5042ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5043$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5044 $(call pretty,"Target super fs image for debug: $@")
5045 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005046 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005047
5048droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5049
5050# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5051.PHONY: superimage
5052superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005053
5054$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005055endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5056
5057# Build $(PRODUCT_OUT)/super.img without dependencies.
5058.PHONY: superimage-nodeps supernod
5059superimage-nodeps supernod: intermediates :=
5060superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5061 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5062 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5063 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5064
5065endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5066endif # BOARD_SUPER_PARTITION_SIZE != ""
5067endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5068
5069# -----------------------------------------------------------------
5070# super empty image
5071
Tao Bao48a2feb2019-06-28 11:00:05 -07005072ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005073ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005074
Yifan Hong8b79d162018-11-29 12:32:00 -08005075INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5076$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5077$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5078 $(call pretty,"Target empty super fs image: $@")
5079 mkdir -p $(intermediates)
5080 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005081 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005082 PATH=$(dir $(LPMAKE)):$$PATH \
5083 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005084
5085$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5086
Yifan Hong2b891ac2018-11-29 12:06:31 -08005087endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005088endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005089
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005090
5091# -----------------------------------------------------------------
5092# The update package
5093
5094name := $(TARGET_PRODUCT)
5095ifeq ($(TARGET_BUILD_TYPE),debug)
5096 name := $(name)_debug
5097endif
5098name := $(name)-img-$(FILE_NAME_TAG)
5099
5100INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5101
Tao Bao57f8ed62019-08-14 23:08:18 -07005102$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5103 $(call pretty,"Package: $@")
5104 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5105 $(IMG_FROM_TARGET_FILES) \
5106 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5107 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005108
5109.PHONY: updatepackage
5110updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005111$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005112
5113
Yifan Hong2b891ac2018-11-29 12:06:31 -08005114# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005115# dalvik something
5116.PHONY: dalvikfiles
5117dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5118
Bo Huf0d50bb2017-08-01 19:02:09 +00005119ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005120MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005121MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005122SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005123
5124ifdef INSTALLED_SYSTEMIMAGE_TARGET
5125INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005126INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5127$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5128 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5129 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005130$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005131 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5132 @echo Create system-qemu.img now
5133 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005134 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005135
5136systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5137droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005138endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005139ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005140INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005141$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005142 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005143 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005144
5145vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5146droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5147endif
bohu8fd437c2020-03-30 20:16:13 -07005148
5149ifdef INSTALLED_RAMDISK_TARGET
5150ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5151ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5152INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5153$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5154 @echo Create ramdisk-qemu.img
5155 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5156
5157droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5158endif
5159endif
5160endif
5161
Anton Hansson32c76fe2018-12-13 14:34:18 +00005162ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005163INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005164$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005165 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005166 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005167
5168productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5169droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5170endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005171ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5172INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5173$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5174 @echo Create system_ext-qemu.img
5175 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005176
Justin Yun6151e3f2019-06-25 15:58:13 +09005177systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5178droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005179endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005180ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005181INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5182$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5183 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005184 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005185
5186odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5187droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5188endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005189
Yifan Hongcfb917a2020-05-07 14:58:20 -07005190ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5191INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5192$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5193 @echo Create vendor_dlkm-qemu.img
5194 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5195
5196vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5197droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5198endif
5199
Yifan Hongf496f1b2020-07-15 16:52:59 -07005200ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5201INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5202$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5203 @echo Create odm_dlkm-qemu.img
5204 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5205
5206odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5207droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5208endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005209
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005210QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005211$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5212 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005213 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005214 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5215 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005216
5217systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5218droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005219
Bo Huf0d50bb2017-08-01 19:02:09 +00005220endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005221# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005222# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005223ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005224INTERNAL_EMULATOR_PACKAGE_FILES += \
5225 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005226 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005227 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005228 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5229 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005230
5231name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5232
5233INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5234
Ying Wang5d887702015-11-04 10:06:25 -08005235$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005236 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005237 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005238
Ying Wang7d8c5352012-07-26 10:15:21 -07005239endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005240
The Android Open Source Project88b60792009-03-03 19:28:42 -08005241
5242# -----------------------------------------------------------------
5243# The SDK
5244
The Android Open Source Project88b60792009-03-03 19:28:42 -08005245# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005246sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005247
5248# Build a name that looks like:
5249#
5250# linux-x86 --> android-sdk_12345_linux-x86
5251# darwin-x86 --> android-sdk_12345_mac-x86
5252# windows-x86 --> android-sdk_12345_windows
5253#
5254sdk_name := android-sdk_$(FILE_NAME_TAG)
5255ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005256 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005257else
Joe Onorato03fbe402009-04-13 08:31:16 -07005258 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005259endif
5260ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005261 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005262endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005263sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005264
5265sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5266
5267ATREE_FILES :=
5268-include $(sdk_dep_file)
5269
5270# if we don't have a real list, then use "everything"
5271ifeq ($(strip $(ATREE_FILES)),)
5272ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005273 $(ALL_DEFAULT_INSTALLED_MODULES) \
5274 $(INSTALLED_RAMDISK_TARGET) \
5275 $(ALL_DOCS) \
5276 $(ALL_SDK_FILES)
5277endif
5278
5279atree_dir := development/build
5280
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005281
The Android Open Source Project88b60792009-03-03 19:28:42 -08005282sdk_atree_files := \
5283 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005284 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005285
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005286# development/build/sdk-android-<abi>.atree is used to differentiate
5287# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5288# files like the kernel image. We use TARGET_CPU_ABI because we don't
5289# have a better way to distinguish between CPU models.
5290ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5291 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5292endif
5293
Anton Hansson8dab0a62019-03-28 15:45:40 +00005294ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5295sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005296else
5297sdk_atree_files += $(atree_dir)/sdk.atree
5298endif
5299
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005300include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005301
The Android Open Source Project88b60792009-03-03 19:28:42 -08005302deps := \
5303 $(target_notice_file_txt) \
5304 $(tools_notice_file_txt) \
5305 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005306 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005307 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005308 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005309 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005310 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005311 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005312 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005313 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005314 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005315 $(INSTALLED_USERDATAIMAGE_TARGET) \
5316 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005317 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005318 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005319 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005320 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005321 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005322 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005323 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005324
5325INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5326$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5327$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5328$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5329$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5330
5331# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5332#
5333#SDK_GNU_ERROR := true
5334
Ying Wang5d887702015-11-04 10:06:25 -08005335$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005336 @echo "Package SDK: $@"
5337 $(hide) rm -rf $(PRIVATE_DIR) $@
5338 $(hide) for f in $(target_gnu_MODULES); do \
5339 if [ -f $$f ]; then \
5340 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5341 including GNU target $$f >&2; \
5342 FAIL=$(SDK_GNU_ERROR); \
5343 fi; \
5344 done; \
5345 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005346 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005347 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005348 ATREE_STRIP="$(HOST_STRIP) -x" \
5349 $(HOST_OUT_EXECUTABLES)/atree \
5350 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5351 -m $(PRIVATE_DEP_FILE) \
5352 -I . \
5353 -I $(PRODUCT_OUT) \
5354 -I $(HOST_OUT) \
5355 -I $(TARGET_COMMON_OUT_ROOT) \
5356 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5357 -v "OUT_DIR=$(OUT_DIR)" \
5358 -v "HOST_OUT=$(HOST_OUT)" \
5359 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5360 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5361 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5362 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5363 -o $(PRIVATE_DIR) && \
5364 cp -f $(target_notice_file_txt) \
5365 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5366 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5367 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5368 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5369 chmod -R ug+rwX $(PRIVATE_DIR) && \
5370 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005371 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5372
Raphael3d224a02010-04-16 17:50:09 -07005373
5374# Is a Windows SDK requested? If so, we need some definitions from here
5375# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005376MAIN_SDK_NAME := $(sdk_name)
5377MAIN_SDK_DIR := $(sdk_dir)
5378MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005379ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005380include $(TOPDIR)development/build/tools/windows_sdk.mk
5381endif
5382
The Android Open Source Project88b60792009-03-03 19:28:42 -08005383# -----------------------------------------------------------------
5384# Findbugs
5385INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5386INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5387$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5388 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005389 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005390 > $@
5391$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5392 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005393 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005394 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005395
5396# -----------------------------------------------------------------
5397# Findbugs
5398
5399# -----------------------------------------------------------------
5400# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005401ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005402include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005403-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005404-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005405-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005406# Also the project-specific tasks
5407-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5408-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005409-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005410# Also add test specifc tasks
5411include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005412include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005413endif
Raphaelc4d47312011-02-15 16:09:36 -08005414
Ying Wang67132ba2015-10-28 16:42:39 -07005415include $(BUILD_SYSTEM)/product-graph.mk
5416
Raphaelc4d47312011-02-15 16:09:36 -08005417# -----------------------------------------------------------------
5418# Create SDK repository packages. Must be done after tasks/* since
5419# we need the addon rules defined.
5420ifneq ($(sdk_repo_goal),)
5421include $(TOPDIR)development/build/tools/sdk_repo.mk
5422endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005423
5424# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005425# Soong generates the list of all shared libraries that are depended on by fuzz
5426# targets. It saves this list as a source:destination pair to
5427# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5428# build of the unstripped shared library, and the destination is the
5429# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5430# where fuzz target shared libraries are to be "reinstalled". The
5431# copy-many-files below generates the rules to copy the unstripped shared
5432# libraries to the device or host "reinstallation" directory. These rules are
5433# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5434# a dependency on each shared library that it needs to be "reinstalled".
5435FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5436
5437# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005438# The rule to build all fuzz targets, and package them.
5439# Note: The packages are created in Soong, and in a perfect world,
5440# we'd be able to create the phony rule there. But, if we want to
5441# have dist goals for the fuzz target, we need to have the PHONY
5442# target defined in make. MakeVarsContext.DistForGoal doesn't take
5443# into account that a PHONY rule create by Soong won't be available
5444# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005445# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005446# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005447.PHONY: haiku
5448haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5449$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005450
5451# -----------------------------------------------------------------
5452# The makefile for haiku line coverage.
5453include $(BUILD_SYSTEM)/line_coverage.mk