blob: 48ba059e759da332e7dc63ffe14cbd03e5255c2a [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)" \
Joe Onorato31986072020-08-10 09:58:49 -0700498 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700499 > $@
500$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
501
Joe Onorato31986072020-08-10 09:58:49 -0700502MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
503$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
504 @rm -f $@
505 $(hide) $(MK2BP_CATALOG_SCRIPT) \
506 --device=$(TARGET_DEVICE) \
507 --out_dir="$(OUT_DIR)" \
508 --mode=csv \
509 > $@
510$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_CSV))
511
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700512# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800513# Modules use -Wno-error, or added default -Wall -Werror
514WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
515$(WALL_WERROR):
516 @rm -f $@
517 echo "# Modules using -Wno-error" >> $@
518 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 -0800519 echo "# Modules added default -Wall" >> $@
520 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
521
522$(call dist-for-goals,droidcore,$(WALL_WERROR))
523
524# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700525# C/C++ flag information for modules
526$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
527
528# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800529# Modules missing profile files
530PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
531$(PGO_PROFILE_MISSING):
532 @rm -f $@
533 echo "# Modules missing PGO profile files" >> $@
534 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
535
536$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
537
538# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700539# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700540# for future OTA packages installed by this system. Actual product
541# deliverables will be re-signed by hand. We expect this file to
542# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700543DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700544
545
Jeff Browne33ba4c2011-07-11 22:11:46 -0700546# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547# if they don't do anything.
548.PHONY: systemimage
549systemimage:
550
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800551# -----------------------------------------------------------------
552
553.PHONY: event-log-tags
554
Joe Onoratob7510532010-07-14 10:22:54 -0700555# Produce an event logs tag file for everything we know about, in order
556# to properly allocate numbers. Then produce a file that's filtered
557# for what's going to be installed.
558
559all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
560
Colin Crossdc8f8e42012-04-12 13:25:54 -0700561event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
562
Joe Onoratob7510532010-07-14 10:22:54 -0700563# Include tags from all packages that we know about
564all_event_log_tags_src := \
565 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
566
Dan Willemsena3f66322020-05-28 15:46:33 -0700567$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
568$(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 -0700569 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900570 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700571
Doug Zongkera34fa952011-02-23 12:17:29 -0800572# Include tags from all packages included in this product, plus all
573# tags that are part of the system (ie, not in a vendor/ or device/
574# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800575event_log_tags_src := \
576 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800577 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800578 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800579 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
580 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800581
Dan Willemsena3f66322020-05-28 15:46:33 -0700582$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700583$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700584$(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 -0800585 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900586 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800587
588event-log-tags: $(event_log_tags_file)
589
590ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
591
Joe Onoratob7510532010-07-14 10:22:54 -0700592
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593# #################################################################
594# Targets for boot/OS images
595# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800596ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
597 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000598 ifdef BOARD_PREBUILT_BOOTLOADER
599 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
600 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
601 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800602 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
603 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
604 else
605 INSTALLED_2NDBOOTLOADER_TARGET :=
606 endif
607else
608 INSTALLED_BOOTLOADER_MODULE :=
609 INSTALLED_2NDBOOTLOADER_TARGET :=
610endif # TARGET_NO_BOOTLOADER
611ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700612 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
613 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
614 $(PRODUCT_OUT)/$(k))
615 else
616 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
617 endif
Ying Wangc6349742014-01-13 16:14:20 -0800618else
619 INSTALLED_KERNEL_TARGET :=
620endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800621
622# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700623# the root dir
624INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800625 $(ALL_GENERATED_SOURCES) \
626 $(ALL_DEFAULT_INSTALLED_MODULES))
627
Luis Hector Chavezff489932018-07-03 15:41:40 -0700628INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
629INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
630$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700631$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700632 @echo Installed file list: $@
633 @mkdir -p $(dir $@)
634 @rm -f $@
635 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700636 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700637
638$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
639
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800640#------------------------------------------------------------------
641# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700642ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800643INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700644ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800645$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800646 cat $^ > $@
647endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700648endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800649
Tom Cherryd14b8952018-08-09 14:26:00 -0700650# -----------------------------------------------------------------
651# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800652ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700653INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
654 $(ALL_GENERATED_SOURCES) \
655 $(ALL_DEFAULT_INSTALLED_MODULES))
656
657INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
658INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
659$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700660$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700661 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800662 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700663 @mkdir -p $(dir $@)
664 @rm -f $@
665 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700666 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700667
668$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700669BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
670
J. Avila3f6560e2020-05-11 20:20:03 +0000671ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
672# -l enables the legacy format used by the Linux kernel
673COMPRESSION_COMMAND_DEPS := $(LZ4)
674COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
675RAMDISK_EXT := .lz4
676else
677COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
678COMPRESSION_COMMAND := $(MINIGZIP)
679RAMDISK_EXT := .gz
680endif
681
Joe Onorato64d85d02009-04-09 19:31:12 -0700682# We just build this directly to the install location.
683INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000684$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800685 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000686 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800687
Ying Wangad7fd292013-08-08 16:34:29 -0700688.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000689ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700690 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000691 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800692
Dan Willemsen67495202019-01-16 12:42:05 -0800693endif # BUILDING_RAMDISK_IMAGE
694
The Android Open Source Project88b60792009-03-03 19:28:42 -0800695# -----------------------------------------------------------------
696# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700697
698# This is defined here since we may be building recovery as boot
699# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700700ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
701 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
702else
703 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
704endif
705
Steve Muckle04b6f052020-08-09 14:36:56 -0700706# $1: boot image target
707# returns the kernel used to make the bootimage
708define bootimage-to-kernel
709 $(if $(BOARD_KERNEL_BINARIES),\
710 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
711 $(INSTALLED_KERNEL_TARGET))
712endef
713
Steve Muckle903a1ca2020-05-07 17:32:10 -0700714ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
715 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
716endif
717
718# $1: boot image file name
719# $2: boot image variant (boot, boot-debug)
720define get-bootimage-partition-size
721 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
722endef
Chris Grossa784ef12019-04-22 11:09:57 -0700723
724ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800725INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700726 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700727
728ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
729INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
730endif
731
Steve Mucklee1b10862019-07-10 10:49:37 -0700732ifndef BUILDING_VENDOR_BOOT_IMAGE
733ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
734 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
735endif
736endif
737
The Android Open Source Project88b60792009-03-03 19:28:42 -0800738INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
739
Anton Hansson8dab0a62019-03-28 15:45:40 +0000740ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700741ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000742VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700743 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
744endif
745endif
746
Anton Hansson72e36f02019-02-26 17:36:30 +0000747INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700748
749ifndef BUILDING_VENDOR_BOOT_IMAGE
750ifdef BOARD_KERNEL_BASE
751 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
752endif
753ifdef BOARD_KERNEL_PAGESIZE
754 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
755endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700756ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700757 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
758endif
759else
760# building vendor boot image, dtb/base/pagesize go there
761ifdef GENERIC_KERNEL_CMDLINE
762 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
763endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700764endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700765
Sami Tolvanen3303d902016-03-15 16:49:30 +0000766INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700767 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000768 --os_patch_level $(PLATFORM_SECURITY_PATCH)
769
Chris Grossa784ef12019-04-22 11:09:57 -0700770# Define these only if we are building boot
771ifdef BUILDING_BOOT_IMAGE
772INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
773
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800775$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700776endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400777
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700778$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
779
780ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400781
Steve Muckle04b6f052020-08-09 14:36:56 -0700782# $1: boot image target
783define build_boot_board_avb_enabled
784 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
785 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
786 $(AVBTOOL) add_hash_footer \
787 --image $(1) \
788 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
789 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
790 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
791endef
792
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700793$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400794 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700795 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400796
797.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800798bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400799 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700800 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400801
Anton Hansson8dab0a62019-03-28 15:45:40 +0000802else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700803
Steve Muckle04b6f052020-08-09 14:36:56 -0700804# $1: boot image target
805define build_boot_supports_boot_signer
806 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
807 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
808 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
809endef
810
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700811$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -0700812 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700813 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700814
815.PHONY: bootimage-nodeps
816bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
817 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700818 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700819
Anton Hansson8dab0a62019-03-28 15:45:40 +0000820else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800821
Steve Muckle04b6f052020-08-09 14:36:56 -0700822# $1: boot image target
823define build_boot_supports_vboot
824 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
825 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
826 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
827endef
828
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700829$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800830 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700831 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800832
833.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800834bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800835 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700836 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800837
838else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800839
Steve Muckle04b6f052020-08-09 14:36:56 -0700840# $1: boot image target
841define build_boot_novboot
842 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
843 $(call assert-max-image-size,$1,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
844endef
845
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700846$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800847 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700848 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700849
850.PHONY: bootimage-nodeps
851bootimage-nodeps: $(MKBOOTIMG)
852 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700853 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700854
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700855endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -0700856endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800857
Tao Baob1a2e352018-08-14 16:17:12 -0700858else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700859ifdef BOARD_PREBUILT_BOOTIMAGE
860ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
861# Remove when b/63676296 is resolved.
862$(error Prebuilt bootimage is only supported for AB targets)
863endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900864INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700865$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700866else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700867INSTALLED_BOOTIMAGE_TARGET :=
868endif # BOARD_PREBUILT_BOOTIMAGE
869endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800870
871# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700872# vendor boot image
873ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
874
875ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
876 $(error vboot 1.0 does not support vendor_boot partition)
877endif
878
879INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
880 $(ALL_GENERATED_SOURCES) \
881 $(ALL_DEFAULT_INSTALLED_MODULES))
882
Steve Muckle414dbe12020-06-18 21:38:35 -0700883INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000884$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
885 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700886
887ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
888 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
889endif
890ifdef BOARD_KERNEL_BASE
891 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
892endif
893ifdef BOARD_KERNEL_PAGESIZE
894 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
895endif
896ifdef INTERNAL_KERNEL_CMDLINE
897 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
898endif
899
900INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
901$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
902ifeq ($(BOARD_AVB_ENABLE),true)
903$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
904 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800905 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700906 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
907 $(AVBTOOL) add_hash_footer \
908 --image $@ \
909 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
910 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
911 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
912else
913$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
914 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800915 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700916 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
917endif
918endif # BUILDING_VENDOR_BOOT_IMAGE
919
920# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921# NOTICE files
922#
Steve Blockd14d3b42012-03-01 11:34:41 +0000923# We are required to publish the licenses for all code under BSD, GPL and
924# Apache licenses (and possibly other more exotic ones as well). We err on the
925# side of caution, so the licenses for other third-party code are included here
926# too.
927#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928# This needs to be before the systemimage rules, because it adds to
929# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
930# go into the systemimage.
931
Steve Block495e5852012-02-29 19:18:08 +0000932.PHONY: notice_files
933
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900934# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700935# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
936# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
937# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
938# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900939# $(2) - Plain text output file
940# $(3) - HTML/XML output file
941# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700942# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800943# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900944# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800945# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800946#
947# The algorithm here is that we go collect a hash for each of the notice
948# files and write the names of the files that match that hash. Then
949# to generate the real files, we go print out all of the files and their
950# hashes.
951#
952# These rules are fairly complex, so they depend on this makefile so if
953# it changes, they'll run again.
954#
955# TODO: We could clean this up so that we just record the locations of the
956# original notice files instead of making rules to copy them somwehere.
957# Then we could traverse that without quite as much bash drama.
958define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700959$(2): PRIVATE_MESSAGE := $(4)
960$(2): PRIVATE_DIR := $(5)
961$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
962$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800963 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -0700964 $(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, \
965 $(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 +0000966 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900967 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700968 $(if $(filter $(1),xml_system),-i system --xml-output, \
969 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700970 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -0700971 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
972 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -0700973 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900974notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800975endef
976
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000977# Notice file logic isn't relevant for TARGET_BUILD_APPS
978ifndef TARGET_BUILD_APPS
979
The Android Open Source Project88b60792009-03-03 19:28:42 -0800980# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
981# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
982# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000983target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000984tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800985tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000986kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
987winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800988
Bob Badour4b25c902020-01-28 13:23:39 -0800989# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
990# reasons--not to be flashed onto any device. Targets under these directories
991# need no associated notice file on the device UI.
992exclude_target_dirs := apex
993
Steven Morelandae69e572017-12-15 14:49:55 -0800994# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000995ifneq ($(PRODUCT_NOTICE_SPLIT),true)
996target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
997target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
998installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
999$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001000 $(target_notice_file_txt), \
1001 $(target_notice_file_html), \
1002 "Notices for files contained in the filesystem images in this directory:", \
1003 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -07001004 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -08001005 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001006$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1007 $(hide) $(MINIGZIP) -9 < $< > $@
1008$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1009 $(copy-file-to-target)
1010else
1011target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1012target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001013installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1014
1015target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1016target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1017target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1018installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001019
1020target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1021target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1022target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1023installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001024
Justin Yun6151e3f2019-06-25 15:58:13 +09001025target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1026target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1027target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1028installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001029
Chris Gross15d96552019-07-16 14:38:43 -07001030target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1031target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1032target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1033installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1034
Yifan Hong3d3f0302020-05-11 18:35:11 -07001035target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1036target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1037target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1038installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1039
Yifan Hongc83f9e92020-07-15 16:57:47 -07001040target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1041target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1042target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1043installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1044
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001045# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1046# being built. A notice xml file must depend on all modules that could potentially
1047# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001048license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001049# Only files copied to a system image need system image notices.
1050license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001051# Phonys/fakes don't have notice files (though their deps might)
1052license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001053# testcases are not relevant to the system image.
1054license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001055# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001056license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001057# system_other is relevant to system partition.
1058license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001059license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1060license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001061license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001062license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001063license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001064license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001065license_modules_agg := $(license_modules_system) \
1066 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001067 $(license_modules_product) \
1068 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001069 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001070 $(license_modules_vendor_dlkm) \
1071 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001072# targets used for debug symbols only and do not get copied to the device
1073license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1074
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001075license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001076license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1077
1078# Identify the other targets we expect to have notices for:
1079# targets copied to the device but are not readable by the UI (e.g. must boot
1080# into a different partition to read or don't have an associated /etc
1081# directory) must have their notices built somewhere readable.
1082license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1083license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1084license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1085license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1086license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1087license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1088license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1089license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1090license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1091license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1092license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1093license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1094license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1095
1096# after removing targets in system images, targets reported in system images, and
1097# targets used for debug symbols that do not need notices, nothing must remain.
1098license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1099$(call maybe-print-list-and-error, $(license_modules_rest), \
1100 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001101
Chris Grossaad39b32019-06-13 09:43:26 -07001102# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1103# update its notice file, so include those notices in the system partition instead
1104ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001105license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001106system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1107system_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 -07001108else
Bob Badour4b25c902020-01-28 13:23:39 -08001109license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001110system_xml_directories := xml_system
1111system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001112endif
1113
1114$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001115 $(target_notice_file_txt), \
1116 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001117 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001118 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001119 $(license_modules_system), \
1120 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001121$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001122 $(target_vendor_notice_file_txt), \
1123 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001124 "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 +00001125 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001126 $(license_modules_vendor), \
1127 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001128$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001129 $(target_product_notice_file_txt), \
1130 $(target_product_notice_file_xml), \
1131 "Notices for files contained in the product filesystem image in this directory:", \
1132 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001133 $(license_modules_product), \
1134 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001135$(eval $(call combine-notice-files, xml_system_ext, \
1136 $(target_system_ext_notice_file_txt), \
1137 $(target_system_ext_notice_file_xml), \
1138 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001139 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001140 $(license_modules_system_ext), \
1141 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001142$(eval $(call combine-notice-files, xml_odm, \
1143 $(target_odm_notice_file_txt), \
1144 $(target_odm_notice_file_xml), \
1145 "Notices for files contained in the odm filesystem image in this directory:", \
1146 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001147 $(license_modules_odm), \
1148 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001149$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1150 $(target_vendor_dlkm_notice_file_txt), \
1151 $(target_vendor_dlkm_notice_file_xml), \
1152 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1153 $(TARGET_OUT_NOTICE_FILES), \
1154 $(license_modules_vendor_dlkm), \
1155 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001156$(eval $(call combine-notice-files, xml_odm_dlkm, \
1157 $(target_odm_dlkm_notice_file_txt), \
1158 $(target_odm_dlkm_notice_file_xml), \
1159 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1160 $(TARGET_OUT_NOTICE_FILES), \
1161 $(license_modules_odm_dlkm), \
1162 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001163
1164$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1165 $(hide) $(MINIGZIP) -9 < $< > $@
1166$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1167 $(hide) $(MINIGZIP) -9 < $< > $@
1168$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1169 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001170$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001171 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001172$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1173 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001174$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1175 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001176$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1177 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001178$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1179 $(copy-file-to-target)
1180$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1181 $(copy-file-to-target)
1182$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1183 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001184$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001185 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001186$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1187 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001188$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1189 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001190$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1191 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001192
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001193ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1194ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1195ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1196ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1197ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001198ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001199ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001200endif # PRODUCT_NOTICE_SPLIT
1201
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001202ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001203
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001204$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001205 $(tools_notice_file_txt), \
1206 $(tools_notice_file_html), \
1207 "Notices for files contained in the tools directory:", \
1208 $(HOST_OUT_NOTICE_FILES), \
1209 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001210 $(winpthreads_notice_file), \
1211 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212
Ying Wang62c81f82013-08-22 20:02:03 -07001213endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001214
1215# The kernel isn't really a module, so to get its module file in there, we
1216# make the target NOTICE files depend on this particular file too, which will
1217# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001218$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001219
Dan Willemsen288bedf2019-05-28 15:36:47 -07001220$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001221
Doug Zongker8678df42009-06-15 14:30:14 -07001222
The Android Open Source Project88b60792009-03-03 19:28:42 -08001223# #################################################################
1224# Targets for user images
1225# #################################################################
1226
Ying Wang933abf12010-06-16 14:31:34 -07001227INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001228ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001229INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1230else
1231ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001232INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1233else
1234ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001235INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1236endif
1237endif
1238endif
1239
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001240# These options tell the recovery updater/installer how to mount the partitions writebale.
1241# <fstype>=<fstype_opts>[|<fstype_opts>]...
1242# fstype_opts := <opt>[,<opt>]...
1243# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001244# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1245DEFAULT_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 -07001246
Ying Wang542903a2010-11-17 15:40:38 -08001247ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1248 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1249endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001250ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1251 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1252endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001253ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1254 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1255endif
Tao Baodba635a2019-06-24 10:39:54 -07001256
1257INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001258 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001259 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001260 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001261
1262ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1263INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001264endif
1265
Yifan Hongcfb917a2020-05-07 14:58:20 -07001266ifneq ($(filter \
1267 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1268 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1269 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1270 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1271 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1272 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001273 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001274 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001275INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1276endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001277
Anton Hansson8dab0a62019-03-28 15:45:40 +00001278ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001279INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001280ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001281INTERNAL_USERIMAGES_DEPS += $(FEC)
1282endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001283endif
1284
Tao Baodba635a2019-06-24 10:39:54 -07001285ifeq ($(BOARD_AVB_ENABLE),true)
1286INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1287endif
1288
1289# Get a colon-separated list of search paths.
1290INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1291
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001292# Collects file_contexts files from modules to be installed
1293$(call merge-fc-files, \
1294 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1295 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1296
Alex Klyubin092c9022017-03-13 13:28:34 -07001297SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001298
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001299INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1300
Yifan Hongc5c01242018-11-09 10:27:23 -08001301ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001302
Anton Hansson8dab0a62019-03-28 15:45:40 +00001303ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001304 $(error vboot 1.0 doesn't support logical partition)
1305endif
1306
Yifan Hongc5c01242018-11-09 10:27:23 -08001307endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001308
Ying Wangbd93d422011-10-28 17:02:30 -07001309# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001310# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001311# $(3): additional "key=value" pairs to append to the dictionary file.
1312define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001313$(if $(filter $(2),system),\
1314 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001315 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001316 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1317 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1318 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1319 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1320 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1321 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1322 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1323 $(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 +00001324 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1325 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001326 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001327 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001328 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1329)
1330$(if $(filter $(2),system_other),\
1331 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001332)
Yifan Hong760d3c02018-05-30 11:16:46 -07001333$(if $(filter $(2),userdata),\
1334 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1335 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001336 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1337 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001338 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001339 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001340)
Yifan Hong760d3c02018-05-30 11:16:46 -07001341$(if $(filter $(2),cache),\
1342 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1343 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001344 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001345 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001346)
1347$(if $(filter $(2),vendor),\
1348 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1349 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1350 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1351 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1352 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1353 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1354 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1355 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1356 $(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 +00001357 $(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 -07001358 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001359 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001360 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001361)
1362$(if $(filter $(2),product),\
1363 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1364 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1365 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1366 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1367 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1368 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1369 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1370 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1371 $(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 +00001372 $(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 -07001373 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001374 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001375 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001376)
Justin Yun6151e3f2019-06-25 15:58:13 +09001377$(if $(filter $(2),system_ext),\
1378 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1379 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1380 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1381 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1382 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1383 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1384 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1385 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1386 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1387 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1388 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001389 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001390)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001391$(if $(filter $(2),odm),\
1392 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1393 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1394 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1395 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1396 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1397 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1398 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1399 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1400 $(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 +00001401 $(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 +08001402 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001403 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001404 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001405)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001406$(if $(filter $(2),vendor_dlkm),\
1407 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1408 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1409 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1410 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1411 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1412 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1413 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1414 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1415 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1416 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1417 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1418 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1419)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001420$(if $(filter $(2),odm_dlkm),\
1421 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1422 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1423 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1424 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1425 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1426 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1427 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1428 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1429 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1430 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1431 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1432 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1433)
Yifan Hong760d3c02018-05-30 11:16:46 -07001434$(if $(filter $(2),oem),\
1435 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1436 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1437 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1438 $(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 -07001439 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001440)
Tao Bao3602eca2018-07-10 10:53:55 -07001441$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001442
Tao Bao3602eca2018-07-10 10:53:55 -07001443$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001444$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001445$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001446$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001447$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1448$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1449$(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 +00001450$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1451$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1452$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1453$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1454$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001455$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001456$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1457$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1458$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001459$(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 -07001460$(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 -07001461$(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 +00001462$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1463$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1464$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1465$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1466$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001467$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001468$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1469$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1470$(if $(BOARD_AVB_ENABLE),\
1471 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1472 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1473 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1474 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001475$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1476$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1477$(if $(BOARD_AVB_ENABLE),\
1478 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1479 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001480 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001481$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1482$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1483$(if $(BOARD_AVB_ENABLE),\
1484 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1485 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1486 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1487 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001488$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1489$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1490$(if $(BOARD_AVB_ENABLE),\
1491 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1492 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1493 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1494 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001495$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001496$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001497 $(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 +01001498$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001499 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1500 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1501 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1502 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001503$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1504$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1505$(if $(BOARD_AVB_ENABLE),\
1506 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1507 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1508 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1509 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001510$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1511$(if $(BOARD_AVB_ENABLE),\
1512 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1513$(if $(BOARD_AVB_ENABLE),\
1514 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1515 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1516 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1517 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001518$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1519$(if $(BOARD_AVB_ENABLE),\
1520 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1521$(if $(BOARD_AVB_ENABLE),\
1522 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1523 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1524 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1525 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001526$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1527 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001528$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001529 $(hide) echo "system_root_image=true" >> $(1))
1530$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001531$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1532 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001533$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1534endef
1535
1536# $(1): the path of the output dictionary file
1537# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001538PROP_DICTIONARY_IMAGES := oem
1539ifdef BUILDING_CACHE_IMAGE
1540 PROP_DICTIONARY_IMAGES += cache
1541endif
1542ifdef BUILDING_SYSTEM_IMAGE
1543 PROP_DICTIONARY_IMAGES += system
1544endif
Chris Gross203191b2020-05-30 02:39:12 +00001545ifdef BUILDING_SYSTEM_OTHER_IMAGE
1546 PROP_DICTIONARY_IMAGES += system_other
1547endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001548ifdef BUILDING_USERDATA_IMAGE
1549 PROP_DICTIONARY_IMAGES += userdata
1550endif
1551ifdef BUILDING_VENDOR_IMAGE
1552 PROP_DICTIONARY_IMAGES += vendor
1553endif
1554ifdef BUILDING_PRODUCT_IMAGE
1555 PROP_DICTIONARY_IMAGES += product
1556endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001557ifdef BUILDING_SYSTEM_EXT_IMAGE
1558 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001559endif
1560ifdef BUILDING_ODM_IMAGE
1561 PROP_DICTIONARY_IMAGES += odm
1562endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001563ifdef BUILDING_VENDOR_DLKM_IMAGE
1564 PROP_DICTIONARY_IMAGES += vendor_dlkm
1565endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001566ifdef BUILDING_ODM_DLKM_IMAGE
1567 PROP_DICTIONARY_IMAGES += odm_dlkm
1568endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001569define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001570 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001571endef
1572
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001573# $(1): the path of the input dictionary file, where each line has the format key=value
1574# $(2): the key to look up
1575define read-image-prop-dictionary
1576$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1577endef
1578
The Android Open Source Project88b60792009-03-03 19:28:42 -08001579# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001580# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001581
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001582# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001583ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001584
Ying Wang37526142015-03-10 12:02:57 -07001585INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1586 $(ALL_DEFAULT_INSTALLED_MODULES))
1587
Tao Bao10fc9492018-08-14 12:17:48 -07001588INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1589INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1590
1591# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1592# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1593# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1594# the call to FILELIST.
1595ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001596INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001597$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1598else
1599$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1600endif
1601
1602$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001603$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001604 @echo Installed file list: $@
1605 @mkdir -p $(dir $@)
1606 @rm -f $@
1607 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001608 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001609
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001610recovery_sepolicy := \
1611 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001612 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001613 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001614 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1615 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1616 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001617 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001618 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001619 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1620 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1621 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001622
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001623# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1624# SELinux files
1625IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1626
Steve Muckle04b6f052020-08-09 14:36:56 -07001627# if building multiple boot images from multiple kernels, use the first kernel listed
1628# for the recovery image
1629recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001630recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001631recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001632
Anton Hansson45a40da2019-01-18 14:06:34 +00001633# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1634# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1635# which get remapped to a bucket.
1636recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001637ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1638recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001639# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001640# ------160------240------320----------480------------640------
1641# mdpi hdpi xhdpi xxhdpi xxxhdpi
1642recovery_density := $(strip \
1643 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1644 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1645 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1646 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001647endif
1648
1649ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1650recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1651else
Doug Zongker25d55f82014-04-04 13:51:15 -07001652recovery_resources_common := $(recovery_resources_common)-xhdpi
1653endif
1654
Tao Baoe1e829e2018-08-29 20:36:00 -07001655# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1656# Note that the font selected here can be overridden for a particular device by putting a font.png
1657# in its private recovery resources.
1658ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001659recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001660else
Dan Willemsen97672232020-05-27 00:09:16 -07001661recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001662endif
1663
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001664
1665# We will only generate the recovery background text images if the variable
1666# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1667# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1668# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1669# BoardConfig in order to use this feature.
1670ifeq ($(recovery_density),xxxhdpi)
1671TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1672else ifeq ($(recovery_density),xxhdpi)
1673TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1674endif
1675
1676ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1677# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1678ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1679 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1680else
1681 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1682endif
1683
1684
Dan Willemsen97672232020-05-27 00:09:16 -07001685RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001686RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1687RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1688RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1689RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1690
xunchangcc57d312018-12-07 12:12:17 -08001691RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1692RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1693RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1694RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1695RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1696
1697generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001698 $(RECOVERY_INSTALLING_TEXT_FILE) \
1699 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1700 $(RECOVERY_ERASING_TEXT_FILE) \
1701 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001702 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1703 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1704 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1705 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1706 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1707 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001708
Dan Willemsen97672232020-05-27 00:09:16 -07001709resource_dir := bootable/recovery/tools/recovery_l10n/res/
1710resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001711image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001712zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001713$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001714$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001715$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1716$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001717$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001718$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001719$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001720 recovery_installing \
1721 recovery_installing_security \
1722 recovery_erasing \
1723 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001724 recovery_no_command
1725$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001726 recovery_cancel_wipe_data \
1727 recovery_factory_data_reset \
1728 recovery_try_again \
1729 recovery_wipe_data_menu_header \
1730 recovery_wipe_data_confirmation
1731$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001732$(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 -08001733 # Prepares the font directory.
1734 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1735 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001736 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001737 @rm -rf $(dir $@)
1738 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001739 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001740 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001741 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001742 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1743 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1744 --text_name $(text_name) \
1745 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1746 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001747 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001748 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001749else
1750RECOVERY_INSTALLING_TEXT_FILE :=
1751RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1752RECOVERY_ERASING_TEXT_FILE :=
1753RECOVERY_ERROR_TEXT_FILE :=
1754RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001755RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1756RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1757RECOVERY_TRY_AGAIN_TEXT_FILE :=
1758RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1759RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001760endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1761
Ying Wang9a175682015-08-06 11:47:47 -07001762ifndef TARGET_PRIVATE_RES_DIRS
1763TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1764endif
Doug Zongker4647f122009-07-02 09:00:54 -07001765recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001766 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001767recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001768
1769
Andrew Boiefa61ff02012-09-28 09:33:45 -07001770ifdef TARGET_RECOVERY_FSTAB
1771recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1772else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001773recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001774endif
Tao Baoc3c17532016-06-10 10:11:54 -07001775ifdef TARGET_RECOVERY_WIPE
1776recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001777else
Tao Baoc3c17532016-06-10 10:11:54 -07001778recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001779endif
Tao Bao8beab692015-07-22 12:33:18 -07001780
Tao Bao6d5d6232018-03-09 17:04:42 -08001781# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001782# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001783# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1784# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001785#
1786# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001787# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001788# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001789# b) We build a single image that contains boot and recovery both - no recovery image to install
1790# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001791# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001792# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001793# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1794# do bsdiff because boot and recovery will contain different number of entries
1795# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001796# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1797# do bsdiff because boot and recovery will contain different number of entries
1798# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001799
Tom Cherry2929cad2018-09-20 11:04:37 -07001800ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001801 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001802# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001803RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1804ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001805else
Tao Bao8beab692015-07-22 12:33:18 -07001806RECOVERY_RESOURCE_ZIP :=
1807endif
Doug Zongker4647f122009-07-02 09:00:54 -07001808
Tao Bao139c7272018-07-31 13:26:54 -07001809INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1810
1811$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001812 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1813 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1814 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1815 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1816 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1817 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1818 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1819 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1820
1821# Parses the given list of build variables and writes their values as build properties if defined.
1822# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1823# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1824# $(1): Map from the build variable names to property names
1825# $(2): Output file
1826define append-recovery-ui-properties
1827echo "#" >> $(2)
1828echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1829echo "#" >> $(2)
1830$(foreach prop,$(1), \
1831 $(eval _varname := $(call word-colon,1,$(prop))) \
1832 $(eval _propname := $(call word-colon,2,$(prop))) \
1833 $(eval _value := $($(_varname))) \
1834 $(if $(_value), \
1835 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1836endef
1837
1838$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001839 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001840 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1841 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1842 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001843 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001844 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001845 $(hide) mkdir -p $(dir $@)
1846 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001847 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001848 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001849 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001850 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001851 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001852 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1853
Steve Mucklef84668e2020-03-16 19:13:46 -07001854ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001855 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001856ifdef GENERIC_KERNEL_CMDLINE
1857 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1858endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001859else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001860 INTERNAL_RECOVERYIMAGE_ARGS := \
1861 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001862 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001863# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001864ifdef INTERNAL_KERNEL_CMDLINE
1865 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001866endif
1867ifdef BOARD_KERNEL_BASE
1868 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1869endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001870ifdef BOARD_KERNEL_PAGESIZE
1871 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1872endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001873ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001874ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1875 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1876else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001877 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1878endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001879endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001880ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1881 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1882endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001883ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1884 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1885endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001886endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001887ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1888 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1889endif
Doug Zongker4647f122009-07-02 09:00:54 -07001890
J. Avila3f6560e2020-05-11 20:20:03 +00001891$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001892 $(INTERNAL_ROOT_FILES) \
1893 $(INSTALLED_RAMDISK_TARGET) \
1894 $(INTERNAL_RECOVERYIMAGE_FILES) \
1895 $(recovery_sepolicy) \
1896 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1897 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1898 $(recovery_resource_deps) \
1899 $(recovery_fstab)
1900 # Making recovery image
1901 mkdir -p $(TARGET_RECOVERY_OUT)
1902 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1903 # Copying baseline ramdisk...
1904 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1905 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1906 # Modifying ramdisk contents...
1907 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1908 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1909 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1910 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1911 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1912 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1913 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1914 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1915 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1916 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1917 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1918 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1919 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1920 $(foreach item,$(recovery_fstab), \
1921 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1922 $(if $(strip $(recovery_wipe)), \
1923 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1924 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1925 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001926 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001927
Ying Wang747b9f12015-01-30 14:05:22 -08001928# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001929# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001930define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001931 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001932 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001933 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001934 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001935 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001936 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001937 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001938 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001939 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001940 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1941 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001942 )\
1943 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001944 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1945 $(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 +08001946 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001947 $(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 -07001948 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001949 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1950 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001951 $(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 -07001952 $(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 -08001953endef
1954
Dan Willemsend120ac62020-06-12 02:39:34 +00001955recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001956ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001957 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001958endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001959ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001960 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001961endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001962ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001963 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001964endif
Tao Baof4866c72018-08-22 14:35:09 -07001965ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001966 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1967 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1968 else
1969 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1970 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001971endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001972ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001973 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001974endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001975ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001976 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001977endif
Tao Baof4866c72018-08-22 14:35:09 -07001978
Dan Willemsend120ac62020-06-12 02:39:34 +00001979ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001980$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00001981$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001982 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001983 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001984endif # BOARD_USES_RECOVERY_AS_BOOT
1985
Dan Willemsend120ac62020-06-12 02:39:34 +00001986$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001987 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001988
Tao Bao4594d0e2015-12-22 09:47:46 -08001989ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001990$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001991 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001992 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1993 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001994endif
Doug Zongker56588872012-08-20 15:38:58 -07001995
Ying Wang747b9f12015-01-30 14:05:22 -08001996.PHONY: recoveryimage-nodeps
1997recoveryimage-nodeps:
1998 @echo "make $@: ignoring dependencies"
Steve Mucklea21b44a2020-08-09 14:54:42 -07001999 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), $(recovery_kernel))
Ying Wang747b9f12015-01-30 14:05:22 -08002000
Chris Grossa784ef12019-04-22 11:09:57 -07002001else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002002RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002003endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002004
2005.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002006recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002007
Jiyong Park03eb0612017-10-04 21:22:41 +09002008ifneq ($(BOARD_NAND_PAGE_SIZE),)
2009$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002010endif
2011
Jiyong Park03eb0612017-10-04 21:22:41 +09002012ifneq ($(BOARD_NAND_SPARE_SIZE),)
2013$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002014endif
2015
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002016ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002017# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002018# the debug ramdisk, which is the original ramdisk plus additional
2019# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2020# When /force_debuggable is present, /init will load userdebug sepolicy
2021# and property files to allow adb root, if the device is unlocked.
2022
2023ifdef BUILDING_RAMDISK_IMAGE
2024BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2025INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2026
2027INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2028 $(ALL_GENERATED_SOURCES) \
2029 $(ALL_DEFAULT_INSTALLED_MODULES))
2030
2031# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2032# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2033# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2034my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2035
2036INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2037INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2038$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2039$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2040
2041# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2042# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2043# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2044$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002045$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002046 echo Installed file list: $@
2047 mkdir -p $(dir $@)
2048 rm -f $@
2049 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002050 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002051
2052# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2053# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2054ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2055my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2056else
2057my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2058endif # BOARD_USES_RECOVERY_AS_BOOT
2059
2060$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2061$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002062
2063ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2064# 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 +08002065$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002066else
2067# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2068$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2069endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002070$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002071 $(call pretty,"Target debug ram disk: $@")
2072 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2073 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002074 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002075 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002076
2077.PHONY: ramdisk_debug-nodeps
2078ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2079ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002080ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002081 echo "make $@: ignoring dependencies"
2082 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2083 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002084 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002085 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002086
2087my_debug_ramdisk_sync_dir :=
2088my_debug_ramdisk_root_dir :=
2089
2090endif # BUILDING_RAMDISK_IMAGE
2091
2092# -----------------------------------------------------------------
2093# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2094#
2095# Note: it's intentional to skip signing for boot-debug.img, because it
2096# can only be used if the device is unlocked with verification error.
Daniel Norman42879ff2020-10-06 11:09:56 -07002097ifdef BUILDING_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002098ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002099ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2100 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2101 $(PRODUCT_OUT)/$(k).img)
2102else
2103 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2104endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002105
2106# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2107ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2108INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2109else
2110INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2111endif
2112
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002113# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2114# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2115# Using a test key to sign boot-debug.img to continue booting with the mismatched
2116# public key, if the device is unlocked.
2117ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002118$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002119endif
2120
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002121BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2122INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2123# $(1): the bootimage to sign
2124define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002125$(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 +08002126$(AVBTOOL) add_hash_footer \
2127 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002128 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002129 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2130 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002131$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002132endef
2133
Steve Muckleb3dda772020-03-11 16:03:07 -07002134# $(1): output file
2135define build-debug-bootimage-target
2136 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2137 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2138 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2139endef
2140
Bowgo Tsai0013f552019-03-20 17:59:52 +08002141# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2142$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2143 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002144 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002145
2146.PHONY: bootimage_debug-nodeps
2147bootimage_debug-nodeps: $(MKBOOTIMG)
2148 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002149 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002150
2151endif # TARGET_NO_KERNEL
Daniel Norman42879ff2020-10-06 11:09:56 -07002152endif # BUILDING_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002153
Bowgo Tsai6a683672020-02-14 19:00:15 +08002154ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2155ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2156# -----------------------------------------------------------------
2157# vendor debug ramdisk
2158# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002159INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002160$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2161$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2162
2163INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2164 $(ALL_GENERATED_SOURCES) \
2165 $(ALL_DEFAULT_INSTALLED_MODULES))
2166
2167# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2168# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2169# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2170# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2171$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2172$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002173$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002174 $(call pretty,"Target vendor debug ram disk: $@")
2175 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2176 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2177 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2178 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2179 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002180 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002181
2182INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2183INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2184$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2185$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2186
2187# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2188# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2189$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2190$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2191 echo Installed file list: $@
2192 mkdir -p $(dir $@)
2193 rm -f $@
2194 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2195 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2196
2197# -----------------------------------------------------------------
2198# vendor_boot-debug.img.
2199INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2200
2201# The util to sign vendor_boot-debug.img with a test key.
2202BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2203INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2204# $(1): the vendor bootimage to sign
2205define test-key-sign-vendor-bootimage
2206$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2207$(AVBTOOL) add_hash_footer \
2208 --image $(1) \
2209 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2210 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2211 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2212$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2213endef
2214
2215ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2216$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2217endif
2218
2219# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2220$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2221 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002222 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002223 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2224 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2225
2226endif # BUILDING_RAMDISK_IMAGE
2227endif # BUILDING_VENDOR_BOOT_IMAGE
2228
Bowgo Tsai0013f552019-03-20 17:59:52 +08002229# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002230# The test harness ramdisk, which is based off debug_ramdisk, plus a
2231# few additional test-harness-specific properties in adb_debug.prop.
2232
2233ifdef BUILDING_RAMDISK_IMAGE
2234BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2235INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2236
2237# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2238# appends a few test harness specific properties into the adb_debug.prop.
2239TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2240TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2241
2242# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2243# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2244TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2245ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2246ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2247
2248# $(1): a list of key=value pairs for additional property assignments
2249# $(2): the target .prop file to append the properties from $(1)
2250define append-test-harness-props
2251 echo "#" >> $(2); \
2252 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2253 echo "#" >> $(2);
2254 $(foreach line,$(1), echo "$(line)" >> $(2);)
2255endef
2256
2257$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002258$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002259 $(call pretty,"Target test harness ram disk: $@")
2260 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2261 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002262 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002263
2264.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002265ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002266 echo "make $@: ignoring dependencies"
2267 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2268 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002269 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002270
2271endif # BUILDING_RAMDISK_IMAGE
2272
2273# -----------------------------------------------------------------
2274# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2275#
2276# Note: it's intentional to skip signing for boot-test-harness.img, because it
2277# can only be used if the device is unlocked with verification error.
2278ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2279
Steve Muckle4866bd62020-04-02 11:31:08 -07002280ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2281 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2282 $(PRODUCT_OUT)/$(k).img)
2283else
2284 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2285endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002286
2287# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2288INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2289
2290# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2291# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2292# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2293# public key, if the device is unlocked.
2294ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2295$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2296endif
2297
Steve Muckle4866bd62020-04-02 11:31:08 -07002298# $(1): output file
2299define build-boot-test-harness-target
2300 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2301 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2302 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2303endef
2304
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002305# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2306$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2307 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002308 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002309
2310.PHONY: bootimage_test_harness-nodeps
2311bootimage_test_harness-nodeps: $(MKBOOTIMG)
2312 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002313 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002314
2315endif # TARGET_NO_KERNEL
2316endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2317
Colin Crossbd382142020-08-26 15:08:57 -07002318# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2319# $1: from location (e.g $(TARGET_OUT)/vendor)
2320# $2: destination location (e.g. /vendor)
2321# $3: partition image name (e.g. vendor.img)
2322define create-partition-compat-symlink
2323$(eval \
2324$1:
2325 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2326 mkdir -p $(dir $1)
2327 if [ -d $1 ] && [ ! -h $1 ]; then \
2328 echo 'Non-symlink $1 detected!' 1>&2; \
2329 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2330 exit 1; \
2331 fi
2332 ln -sfn $2 $1
2333)
2334$1
2335endef
2336
2337
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002338# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002339# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002340
Dan Willemsen37a19862018-10-31 16:31:46 -07002341INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002342 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002343 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002344
Colin Crossbd382142020-08-26 15:08:57 -07002345# Create symlink /system/vendor to /vendor if necessary.
2346ifdef BOARD_USES_VENDORIMAGE
2347 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2348endif
2349
2350# Create symlink /system/product to /product if necessary.
2351ifdef BOARD_USES_PRODUCTIMAGE
2352 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2353endif
2354
2355# Create symlink /system/system_ext to /system_ext if necessary.
2356ifdef BOARD_USES_SYSTEM_EXTIMAGE
2357 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2358endif
2359
Ying Wang82cceba2012-08-13 15:03:00 -07002360FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002361
2362# ASAN libraries in the system image - add dependency.
2363ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002364ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002365 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2366 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2367 endif
2368endif
2369
Tom Cherryd14b8952018-08-09 14:26:00 -07002370FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002371
Ying Wange5e8c5f2011-09-09 16:35:53 -07002372# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002373ifdef BUILDING_SYSTEM_IMAGE
2374
Ying Wange5e8c5f2011-09-09 16:35:53 -07002375# installed file list
2376# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2377# We put installed-files.txt ahead of image itself in the dependency graph
2378# so that we can get the size stat even if the build fails due to too large
2379# system image.
2380INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002381INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2382$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002383$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002384 @echo Installed file list: $@
2385 @mkdir -p $(dir $@)
2386 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002387 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002388 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002389
2390.PHONY: installed-file-list
2391installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002392
2393$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002394
2395systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002396 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002397BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2398
The Android Open Source Project88b60792009-03-03 19:28:42 -08002399# $(1): output file
2400define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002401 @echo "Target system fs image: $(1)"
2402 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002403 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002404 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002405 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002406 $(BUILD_IMAGE) \
2407 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2408 || ( mkdir -p $${DIST_DIR}; \
2409 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2410 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002411endef
2412
Dan Willemsen6b72c732019-06-12 21:33:38 +00002413ifeq ($(BOARD_AVB_ENABLE),true)
2414$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2415endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002416$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002417 $(call build-systemimage-target,$@)
2418
Tao Baoe9d61b02018-08-20 21:09:07 -07002419INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002420SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002421
Tao Baoe9d61b02018-08-20 21:09:07 -07002422# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2423# compatibility, in case device-specific Makefiles still refer to the old name.
2424INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2425
Doug Zongker73ef8252009-07-23 15:12:53 -07002426# The system partition needs room for the recovery image as well. We
2427# now store the recovery image as a binary patch using the boot image
2428# as the source (since they are very similar). Generate the patch so
2429# we can see how big it's going to be, and include that in the system
2430# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002431ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002432ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002433ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002434ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002435diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2436else
2437diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2438endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002439intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2440RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002441$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2442$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002443 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002444 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002445 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002446 @echo "Construct recovery from boot"
2447 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002448 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002449else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2450RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002451endif # BOARD_USES_FULL_RECOVERY_IMAGE
2452endif # INSTALLED_RECOVERYIMAGE_TARGET
2453endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002454
Yifan Hong9a3cad92020-04-27 19:06:59 -07002455$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002456 @echo "Install system fs image: $@"
2457 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002458 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002459
Tao Baoe9d61b02018-08-20 21:09:07 -07002460systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002461
2462.PHONY: systemimage-nodeps snod
2463systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002464 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002465 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002466 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002467 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002468ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002469 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002470endif
2471
Dan Willemsen67495202019-01-16 12:42:05 -08002472endif # BUILDING_SYSTEM_IMAGE
2473
Anton Hansson30e061b2018-11-12 13:36:46 +00002474.PHONY: sync syncsys
2475sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002476
Ying Wang3a61eeb2016-03-11 10:32:01 -08002477# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002478# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002479.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002480platform:
2481 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002482
2483.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002484platform-java:
2485 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002486
Ying Wang3a61eeb2016-03-11 10:32:01 -08002487# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002488# data partition image
2489INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002490 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002491
Dan Willemsen67495202019-01-16 12:42:05 -08002492ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002493userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002494 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002495BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2496
Ying Wangbd93d422011-10-28 17:02:30 -07002497define build-userdataimage-target
2498 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2499 @mkdir -p $(TARGET_OUT_DATA)
2500 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002501 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002502 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002503 $(BUILD_IMAGE) \
2504 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2505 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2506 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002507endef
2508
Joe Onorato64d85d02009-04-09 19:31:12 -07002509# We just build this directly to the install location.
2510INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002511INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2512 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002513 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002514$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002515 $(build-userdataimage-target)
2516
2517.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002518userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002519 $(build-userdataimage-target)
2520
Dan Willemsen67495202019-01-16 12:42:05 -08002521endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002522
Andreas Gampe039b5c72017-03-24 16:06:31 -07002523# ASAN libraries in the system image - build rule.
2524ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2525 $(TARGET_OUT_SHARED_LIBRARIES) \
2526 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2527 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2528 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002529# Extra options: Enforce the system user for the files to avoid having to change ownership.
2530ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002531# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2532# enough space.
2533$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002534 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 -07002535
The Android Open Source Project88b60792009-03-03 19:28:42 -08002536# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002537# partition table image
2538ifdef BOARD_BPT_INPUT_FILES
2539
2540BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002541BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002542
2543INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2544 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002545 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002546 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2547
2548ifdef BOARD_BPT_DISK_SIZE
2549INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2550endif
2551
2552define build-bptimage-target
2553 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2554 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2555endef
2556
2557INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002558$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2559 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2560
David Zeuthen25328622016-04-08 15:08:03 -04002561$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2562 $(build-bptimage-target)
2563
2564.PHONY: bptimage-nodeps
2565bptimage-nodeps:
2566 $(build-bptimage-target)
2567
2568endif # BOARD_BPT_INPUT_FILES
2569
2570# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002571# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002572ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002573INTERNAL_CACHEIMAGE_FILES := \
2574 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2575
2576cacheimage_intermediates := \
2577 $(call intermediates-dir-for,PACKAGING,cache)
2578BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2579
2580define build-cacheimage-target
2581 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2582 @mkdir -p $(TARGET_OUT_CACHE)
2583 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002584 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002585 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002586 $(BUILD_IMAGE) \
2587 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2588 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2589 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002590endef
2591
2592# We just build this directly to the install location.
2593INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002594$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002595 $(build-cacheimage-target)
2596
2597.PHONY: cacheimage-nodeps
2598cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2599 $(build-cacheimage-target)
2600
Dan Willemsen67495202019-01-16 12:42:05 -08002601else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002602# we need to ignore the broken cache link when doing the rsync
2603IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002604endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002605
David Zeuthen0eb10972016-09-28 17:55:27 -04002606# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002607# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002608ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002609ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002610# Marker file to identify that odex files are installed
2611INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2612ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2613$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2614 $(hide) touch $@
2615endif
2616
Alex Light4e358ab2016-06-16 14:47:10 -07002617INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2618 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002619 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002620
Colin Cross6db5b0e2018-11-16 21:26:33 -08002621# system_other dex files are installed as a side-effect of installing system image files
2622INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2623
Alex Light4e358ab2016-06-16 14:47:10 -07002624INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002625INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2626$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002627$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002628 @echo Installed file list: $@
2629 @mkdir -p $(dir $@)
2630 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002631 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002632 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002633
Bowgo Tsai867ab662019-01-29 13:30:18 +08002634# Determines partition size for system_other.img.
2635ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2636ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2637INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2638endif
2639endif
2640
2641ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2642INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2643endif
2644
Alex Light4e358ab2016-06-16 14:47:10 -07002645systemotherimage_intermediates := \
2646 $(call intermediates-dir-for,PACKAGING,system_other)
2647BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2648
2649# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2650define build-systemotherimage-target
2651 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2652 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2653 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002654 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002655 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002656 $(BUILD_IMAGE) \
2657 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2658 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2659 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002660endef
2661
2662# We just build this directly to the install location.
2663INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002664ifneq (true,$(SANITIZE_LITE))
2665# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002666$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2667 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002668endif
Alex Light4e358ab2016-06-16 14:47:10 -07002669
2670.PHONY: systemotherimage-nodeps
2671systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2672 $(build-systemotherimage-target)
2673
Dan Willemsen67495202019-01-16 12:42:05 -08002674endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002675
2676
2677# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002678# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002679ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002680INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002681 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002682 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002683
Ying Wang8da19e32015-09-15 14:22:12 -07002684
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002685# Create symlink /vendor/odm to /odm if necessary.
2686ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002687 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002688endif
2689
Yifan Honge51dff22020-06-23 17:26:57 -07002690# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2691# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2692#
2693# On devices with a vendor_dlkm partition,
2694# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2695# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2696# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2697# are hidden.
2698# On devices without a vendor_dlkm partition,
2699# - /vendor/lib/modules stores vendor DLKMs directly.
2700# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2701# See system/core/rootdir/Android.mk for a list of created symlinks.
2702# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2703# are not guaranteed to exist on all devices.
2704ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002705 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/lib/modules,/vendor_dlkm/lib/modules,vendor_dlkm.img)
Yifan Honge51dff22020-06-23 17:26:57 -07002706endif
2707
Colin Crossbd382142020-08-26 15:08:57 -07002708INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2709INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2710$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2711$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2712 @echo Installed file list: $@
2713 @mkdir -p $(dir $@)
2714 @rm -f $@
2715 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2716 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002717
Ying Wanga0febe52013-03-20 11:02:05 -07002718vendorimage_intermediates := \
2719 $(call intermediates-dir-for,PACKAGING,vendor)
2720BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002721define build-vendorimage-target
2722 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2723 @mkdir -p $(TARGET_OUT_VENDOR)
2724 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002725 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002726 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002727 $(BUILD_IMAGE) \
2728 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2729 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002730 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002731endef
2732
2733# We just build this directly to the install location.
2734INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002735$(INSTALLED_VENDORIMAGE_TARGET): \
2736 $(INTERNAL_USERIMAGES_DEPS) \
2737 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002738 $(INSTALLED_FILES_FILE_VENDOR) \
2739 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002740 $(build-vendorimage-target)
2741
Steven Morelanda2e734d2017-03-07 12:10:09 -08002742.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002743vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002744 $(build-vendorimage-target)
2745
Colin Cross91a52272017-06-20 16:57:52 -07002746sync: $(INTERNAL_VENDORIMAGE_FILES)
2747
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002748else ifdef BOARD_PREBUILT_VENDORIMAGE
2749INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2750$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2751endif
Ying Wanga0febe52013-03-20 11:02:05 -07002752
Ying Wang9f8e8db2011-11-04 11:37:01 -07002753# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002754# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002755ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002756INTERNAL_PRODUCTIMAGE_FILES := \
2757 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002758 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002759
2760INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002761INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2762$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002763$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002764 @echo Installed file list: $@
2765 @mkdir -p $(dir $@)
2766 @rm -f $@
2767 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002768 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002769
2770productimage_intermediates := \
2771 $(call intermediates-dir-for,PACKAGING,product)
2772BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2773define build-productimage-target
2774 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2775 @mkdir -p $(TARGET_OUT_PRODUCT)
2776 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002777 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002778 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002779 $(BUILD_IMAGE) \
2780 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2781 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2782 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002783endef
2784
2785# We just build this directly to the install location.
2786INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002787$(INSTALLED_PRODUCTIMAGE_TARGET): \
2788 $(INTERNAL_USERIMAGES_DEPS) \
2789 $(INTERNAL_PRODUCTIMAGE_FILES) \
2790 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002791 $(build-productimage-target)
2792
2793.PHONY: productimage-nodeps pnod
2794productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2795 $(build-productimage-target)
2796
2797sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2798
2799else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2800INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2801$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2802endif
2803
2804# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002805# system_ext partition image
2806ifdef BUILDING_SYSTEM_EXT_IMAGE
2807INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2808 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002809 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002810
Justin Yun6151e3f2019-06-25 15:58:13 +09002811INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2812INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2813$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2814$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002815 @echo Installed file list: $@
2816 @mkdir -p $(dir $@)
2817 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002818 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002819 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002820
Justin Yun6151e3f2019-06-25 15:58:13 +09002821system_extimage_intermediates := \
2822 $(call intermediates-dir-for,PACKAGING,system_ext)
2823BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2824define build-system_extimage-target
2825 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2826 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2827 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2828 $(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 -07002829 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002830 $(BUILD_IMAGE) \
2831 $(TARGET_OUT_SYSTEM_EXT) \
2832 $(system_extimage_intermediates)/system_ext_image_info.txt \
2833 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2834 $(TARGET_OUT)
2835 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002836endef
2837
2838# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002839INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002840$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2841 $(INTERNAL_USERIMAGES_DEPS) \
2842 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2843 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002844 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002845
Justin Yun6151e3f2019-06-25 15:58:13 +09002846.PHONY: systemextimage-nodeps senod
2847systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2848 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002849
Justin Yun6151e3f2019-06-25 15:58:13 +09002850sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002851
Justin Yun6151e3f2019-06-25 15:58:13 +09002852else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2853INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2854$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002855endif
2856
2857# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002858# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002859ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002860INTERNAL_ODMIMAGE_FILES := \
2861 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002862 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002863
Colin Crossbd382142020-08-26 15:08:57 -07002864# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2865# /odm/lib/modules -> /odm_dlkm/lib/modules
2866#
2867# On devices with a odm_dlkm partition,
2868# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2869# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2870# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2871# are hidden.
2872# On devices without a odm_dlkm partition,
2873# - /odm/lib/modules stores odm DLKMs directly.
2874# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2875# See system/core/rootdir/Android.mk for a list of created symlinks.
2876# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2877# are not guaranteed to exist on all devices.
2878ifdef BOARD_USES_ODM_DLKMIMAGE
2879 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
2880endif
2881
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002882INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2883INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2884$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002885$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002886 @echo Installed file list: $@
2887 @mkdir -p $(dir $@)
2888 @rm -f $@
2889 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002890 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002891
2892odmimage_intermediates := \
2893 $(call intermediates-dir-for,PACKAGING,odm)
2894BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2895define build-odmimage-target
2896 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2897 @mkdir -p $(TARGET_OUT_ODM)
2898 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2899 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002900 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002901 $(BUILD_IMAGE) \
2902 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2903 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2904 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002905endef
2906
2907# We just build this directly to the install location.
2908INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002909$(INSTALLED_ODMIMAGE_TARGET): \
2910 $(INTERNAL_USERIMAGES_DEPS) \
2911 $(INTERNAL_ODMIMAGE_FILES) \
2912 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002913 $(build-odmimage-target)
2914
2915.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002916odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002917 $(build-odmimage-target)
2918
2919sync: $(INTERNAL_ODMIMAGE_FILES)
2920
2921else ifdef BOARD_PREBUILT_ODMIMAGE
2922INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2923$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2924endif
2925
2926# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002927# vendor_dlkm partition image
2928ifdef BUILDING_VENDOR_DLKM_IMAGE
2929INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2930 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002931 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002932
2933INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2934INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2935$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2936$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2937 @echo Installed file list: $@
2938 @mkdir -p $(dir $@)
2939 @rm -f $@
2940 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2941 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2942
2943vendor_dlkmimage_intermediates := \
2944 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2945BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2946define build-vendor_dlkmimage-target
2947 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2948 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2949 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2950 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2951 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2952 $(BUILD_IMAGE) \
2953 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2954 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2955 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2956endef
2957
2958# We just build this directly to the install location.
2959INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2960$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2961 $(INTERNAL_USERIMAGES_DEPS) \
2962 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2963 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2964 $(build-vendor_dlkmimage-target)
2965
2966.PHONY: vendor_dlkmimage-nodeps vdnod
2967vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2968 $(build-vendor_dlkmimage-target)
2969
2970sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2971
2972else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2973INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2974$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2975endif
2976
2977# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07002978# odm_dlkm partition image
2979ifdef BUILDING_ODM_DLKM_IMAGE
2980INTERNAL_ODM_DLKMIMAGE_FILES := \
2981 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002982 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002983
2984INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
2985INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
2986$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
2987$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2988 @echo Installed file list: $@
2989 @mkdir -p $(dir $@)
2990 @rm -f $@
2991 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
2992 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2993
2994odm_dlkmimage_intermediates := \
2995 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
2996BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
2997define build-odm_dlkmimage-target
2998 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
2999 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3000 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3001 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3002 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3003 $(BUILD_IMAGE) \
3004 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3005 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3006 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3007endef
3008
3009# We just build this directly to the install location.
3010INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3011$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3012 $(INTERNAL_USERIMAGES_DEPS) \
3013 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3014 $(INSTALLED_FILES_FILE_ODM_DLKM)
3015 $(build-odm_dlkmimage-target)
3016
3017.PHONY: odm_dlkmimage-nodeps odnod
3018odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3019 $(build-odm_dlkmimage-target)
3020
3021sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3022
3023else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3024INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3025$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3026endif
3027
3028
3029# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003030# dtbo image
3031ifdef BOARD_PREBUILT_DTBOIMAGE
3032INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3033
3034ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003035$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003036 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3037 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003038 --image $@ \
3039 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3040 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3041 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003042else
3043$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3044 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3045endif
3046
Tao Bao0da43472018-08-22 22:53:41 -07003047endif # BOARD_PREBUILT_DTBOIMAGE
3048
3049# Returns a list of image targets corresponding to the given list of partitions. For example, it
3050# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3051# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003052# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003053define images-for-partitions
3054$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3055endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003056
3057# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003058# custom images
3059INSTALLED_CUSTOMIMAGES_TARGET :=
3060
3061ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3062INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3063
3064# Sign custom image.
3065# $(1): the prebuilt custom image.
3066# $(2): the mount point of the prebuilt custom image.
3067# $(3): the signed custom image target.
3068define sign_custom_image
3069$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3070 @echo Target custom image: $(3)
3071 mkdir -p $(dir $(3))
3072 cp $(1) $(3)
3073ifeq ($(BOARD_AVB_ENABLE),true)
3074 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3075 $(AVBTOOL) add_hashtree_footer \
3076 --image $(3) \
3077 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3078 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3079 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3080 --partition_name $(2) \
3081 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3082 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3083endif
3084INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3085endef
3086
3087$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3088 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3089 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3090endif
3091
3092# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003093# vbmeta image
3094ifeq ($(BOARD_AVB_ENABLE),true)
3095
3096BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003097AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003098
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003099ifdef BOARD_AVB_KEY_PATH
3100$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3101else
3102# If key path isn't specified, use the 4096-bit test key.
3103BOARD_AVB_ALGORITHM := SHA256_RSA4096
3104BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3105endif
3106
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003107# AVB signing for system_other.img.
3108ifdef BUILDING_SYSTEM_OTHER_IMAGE
3109ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3110$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3111else
3112# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3113BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3114BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3115endif
3116
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003117$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3118 @echo Extracting system_other avb key: $@
3119 @rm -f $@
3120 @mkdir -p $(dir $@)
3121 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003122
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003123ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3124BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3125endif
3126
3127BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3128endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3129
Tao Bao744c4c72018-08-20 21:09:07 -07003130INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003131 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003132 $(BOARD_AVB_VBMETA_VENDOR)
3133
3134# Not allowing the same partition to appear in multiple groups.
3135ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003136 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003137endif
3138
cfig1aeef722019-09-20 22:45:06 +08003139# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3140# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3141# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003142ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003143ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3144$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003145 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003146 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3147endif
3148endif
3149
Bowgo Tsai9b548012019-05-14 16:57:03 +08003150# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003151
3152BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003153 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003154 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003155 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3156
3157BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003158 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003159 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003160 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3161
Justin Yun6151e3f2019-06-25 15:58:13 +09003162BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003163 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003164 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003165 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003166
Bowgo Tsai9b548012019-05-14 16:57:03 +08003167BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003168 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003169 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003170
Tao Bao19b02fe2019-10-09 00:04:28 -07003171BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3172 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3173
3174BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3175 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3176
Bowgo Tsai9b548012019-05-14 16:57:03 +08003177BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003178 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003179 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003180
3181BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003182 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003183 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003184
Yifan Hongcfb917a2020-05-07 14:58:20 -07003185BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3186 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3187 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3188
Yifan Hongf496f1b2020-07-15 16:52:59 -07003189BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3190 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3191 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3192
Tao Bao19b02fe2019-10-09 00:04:28 -07003193BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3194 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3195
Bowgo Tsai9b548012019-05-14 16:57:03 +08003196# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003197ifdef BOOT_SECURITY_PATCH
3198BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3199 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3200endif
3201
3202ifdef VENDOR_SECURITY_PATCH
3203BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3204 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3205endif
3206
3207ifdef ODM_SECURITY_PATCH
3208BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3209 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3210endif
3211
Yifan Hongcfb917a2020-05-07 14:58:20 -07003212ifdef VENDOR_DLKM_SECURITY_PATCH
3213BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3214 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3215endif
3216
Yifan Hongf496f1b2020-07-15 16:52:59 -07003217ifdef ODM_DLKM_SECURITY_PATCH
3218BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3219 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3220endif
3221
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003222BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003223VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003224DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3225SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3226VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003227RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003228PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003229SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003230ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003231VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003232ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003233
Tao Bao0da43472018-08-22 22:53:41 -07003234# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003235# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003236define _check-and-set-avb-chain-args
3237$(eval part := $(1))
3238$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003239
3240$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3241$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3242$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3243$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3244$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3245$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3246$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3247$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3248
3249# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3250$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3251$(eval $(_signing_args) := \
3252 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3253
cfig1aeef722019-09-20 22:45:06 +08003254# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3255# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003256$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003257 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3258 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003259
Tao Bao744c4c72018-08-20 21:09:07 -07003260# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003261# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003262$(if $(filter $(part),$(part:vbmeta_%=%)),\
3263 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3264 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003265endef
3266
Tao Bao0da43472018-08-22 22:53:41 -07003267# Checks and sets the required build variables for an AVB partition. The partition will be
3268# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003269# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3270# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003271# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3272# but vbmeta would capture the image descriptor of only the first boot
3273# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003274# $(1): Partition name, e.g. boot or system.
3275define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003276$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003277$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003278 $(if $(_in_chained_vbmeta),\
3279 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003280 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003281 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003282 $(if $(filter boot,$(1)),\
3283 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3284 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3285 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3286 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003287endef
3288
Hongguang Chenf23364d2020-04-27 18:36:36 -07003289# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3290# $(1): the custom partition to enable AVB chain.
3291define check-and-set-custom-avb-chain-args
3292$(eval part := $(1))
3293$(eval PART=$(call to-upper,$(part)))
3294$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3295$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3296
3297INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3298 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3299endef
3300
Tao Baob1a2e352018-08-14 16:17:12 -07003301ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003302$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003303endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003304
Steve Mucklee1b10862019-07-10 10:49:37 -07003305ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3306$(eval $(call check-and-set-avb-args,vendor_boot))
3307endif
3308
Tao Bao0da43472018-08-22 22:53:41 -07003309$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003310
3311ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003312$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003313endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003314
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003315ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003316$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003317endif
3318
Justin Yun6151e3f2019-06-25 15:58:13 +09003319ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3320$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003321endif
3322
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003323ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003324$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003325endif
3326
Yifan Hongcfb917a2020-05-07 14:58:20 -07003327ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3328$(eval $(call check-and-set-avb-args,vendor_dlkm))
3329endif
3330
Yifan Hongf496f1b2020-07-15 16:52:59 -07003331ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3332$(eval $(call check-and-set-avb-args,odm_dlkm))
3333endif
3334
Yueyao Zhu211c9012017-04-27 00:34:50 -07003335ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003336$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003337endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003338
David Zeuthen8fecb282017-12-01 16:24:01 -05003339ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003340$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003341endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003342
David Anderson7709ab22018-10-15 14:41:34 -07003343# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3344ifdef BOARD_AVB_VBMETA_SYSTEM
3345$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003346endif
3347
3348ifdef BOARD_AVB_VBMETA_VENDOR
3349$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3350endif
3351
Hongguang Chenf23364d2020-04-27 18:36:36 -07003352ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3353$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3354 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3355endif
3356
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003357# Add kernel cmdline descriptor for kernel to mount system.img as root with
3358# dm-verity. This works when system.img is either chained or not-chained:
3359# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3360# cmdline descriptor to system.img
3361# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3362# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003363ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003364ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003365BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003366endif
David Anderson8916a2a2018-09-18 15:46:59 -07003367endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003368
Tao Bao0da43472018-08-22 22:53:41 -07003369BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003370BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003371BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3372
3373ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003374# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003375BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003376endif
Tao Bao0da43472018-08-22 22:53:41 -07003377
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003378ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003379BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003380endif
3381
David Anderson7709ab22018-10-15 14:41:34 -07003382ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3383BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3384 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003385endif
3386
3387ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3388BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3389 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003390endif
3391
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003392# $(1): the directory to extract public keys to
3393define extract-avb-chain-public-keys
3394 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3395 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3396 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003397 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3398 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3399 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003400 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3401 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3402 --output $(1)/system.avbpubkey)
3403 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3404 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3405 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003406 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3407 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3408 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003409 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3410 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3411 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003412 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3413 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3414 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003415 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3416 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3417 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003418 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3419 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3420 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003421 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3422 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3423 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003424 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3425 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3426 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003427 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3428 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3429 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003430 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3431 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3432 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003433 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3434 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3435 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3436 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003437endef
3438
Tao Bao744c4c72018-08-20 21:09:07 -07003439# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3440# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003441# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003442# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3443# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003444# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003445# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003446# $(2): Output filename.
3447define build-chained-vbmeta-image
3448 $(call pretty,"Target chained vbmeta image: $@")
3449 $(hide) $(AVBTOOL) make_vbmeta_image \
3450 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3451 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3452 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3453 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3454 --output $@
3455endef
3456
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003457ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003458ifdef BOARD_AVB_VBMETA_SYSTEM
3459INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3460$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003461 $(AVBTOOL) \
3462 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3463 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003464 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003465endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003466endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003467
3468ifdef BOARD_AVB_VBMETA_VENDOR
3469INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3470$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003471 $(AVBTOOL) \
3472 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3473 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003474 $(call build-chained-vbmeta-image,vbmeta_vendor)
3475endif
3476
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003477define build-vbmetaimage-target
3478 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003479 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3480 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003481 $(hide) $(AVBTOOL) make_vbmeta_image \
3482 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003483 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003484 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3485 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003486 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003487endef
3488
Paul Trautrim4e143232019-08-13 16:30:57 +09003489ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003490INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003491$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3492 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3493
David Zeuthen8fecb282017-12-01 16:24:01 -05003494$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003495 $(AVBTOOL) \
3496 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003497 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003498 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3499 $(INSTALLED_VENDORIMAGE_TARGET) \
3500 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003501 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003502 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003503 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003504 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003505 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003506 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003507 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3508 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3509 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3510 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3511 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3512 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003513 $(build-vbmetaimage-target)
3514
3515.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003516vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3517 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003518vbmetaimage-nodeps:
3519 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003520endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003521
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003522endif # BOARD_AVB_ENABLE
3523
3524# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003525# Check VINTF of build
3526
Yifan Hongc08cbf02020-09-15 19:07:39 +00003527# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003528ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003529
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003530intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3531check_vintf_all_deps :=
3532
Yifan Hongaf9b0702020-01-21 12:46:57 -08003533# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3534# because they are only used for prebuilt images.
3535check_vintf_common_srcs_patterns := \
3536 $(TARGET_OUT)/etc/vintf/% \
3537 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3538 $(TARGET_OUT_ODM)/etc/vintf/% \
3539 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3540 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3541
3542check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3543 $(INTERNAL_SYSTEMIMAGE_FILES) \
3544 $(INTERNAL_VENDORIMAGE_FILES) \
3545 $(INTERNAL_ODMIMAGE_FILES) \
3546 $(INTERNAL_PRODUCTIMAGE_FILES) \
3547 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3548))
3549check_vintf_common_srcs_patterns :=
3550
3551check_vintf_has_system :=
3552check_vintf_has_vendor :=
3553
Yifan Hong28ffd732020-03-13 13:11:10 -07003554ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3555$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3556endif
3557ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3558$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3559endif
3560
Yifan Hong605ea042020-01-14 21:36:00 +00003561# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003562check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3563ifneq ($(check_vintf_system_deps),)
3564check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003565check_vintf_system_log := $(intermediates)/check_vintf_system_log
3566check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003567$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003568 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3569check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003570endif # check_vintf_system_deps
3571check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003572
3573# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003574check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3575ifneq ($(check_vintf_vendor_deps),)
3576check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003577check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3578check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003579# Check vendor SKU=(empty) case when:
3580# - DEVICE_MANIFEST_FILE is not empty; OR
3581# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003582$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003583 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3584 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003585 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003586$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003587 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3588 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3589 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3590 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003591check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003592endif # check_vintf_vendor_deps
3593check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003594
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003595# -- Check VINTF compatibility of build.
3596# Skip partial builds; only check full builds. Only check if:
3597# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003598# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003599# - Building product / system_ext / odm images if board has product / system_ext / odm images
3600ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003601ifeq ($(check_vintf_has_system),true)
3602ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003603ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3604ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3605ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3606
3607check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3608check_vintf_all_deps += $(check_vintf_compatible_log)
3609
3610check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003611check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003612
3613# -- Kernel version and configurations.
3614ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3615
Yifan Hong605ea042020-01-14 21:36:00 +00003616BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3617BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3618
3619my_board_extracted_kernel :=
3620
3621# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3622# from INSTALLED_KERNEL_TARGET.
3623ifdef BOARD_KERNEL_CONFIG_FILE
3624ifdef BOARD_KERNEL_VERSION
3625$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3626 cp $< $@
3627$(BUILT_KERNEL_VERSION_FILE):
3628 echo $(BOARD_KERNEL_VERSION) > $@
3629
3630my_board_extracted_kernel := true
3631endif # BOARD_KERNEL_VERSION
3632endif # BOARD_KERNEL_CONFIG_FILE
3633
3634ifneq ($(my_board_extracted_kernel),true)
3635ifndef INSTALLED_KERNEL_TARGET
3636$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3637 is true. Information about the updated kernel cannot be built into OTA update package. \
3638 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3639 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3640 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3641 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3642 manually.)
3643else
3644
3645# Tools for decompression that is not in PATH.
3646# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3647# Algorithms that are in the script but not in this list will be found in PATH.
3648my_decompress_tools := \
3649 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3650
3651$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3652$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3653$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003654$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3655 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003656 --output-configs $@ \
3657 --output-version $(BUILT_KERNEL_VERSION_FILE)
3658
3659my_decompress_tools :=
3660
3661endif # my_board_extracted_kernel
3662my_board_extracted_kernel :=
3663
3664endif # INSTALLED_KERNEL_TARGET
3665
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003666check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3667check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3668
3669endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3670
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003671check_vintf_compatible_args += \
3672 --dirmap /system:$(TARGET_OUT) \
3673 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3674 --dirmap /odm:$(TARGET_OUT_ODM) \
3675 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3676 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3677
3678ifdef PRODUCT_SHIPPING_API_LEVEL
3679check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3680endif # PRODUCT_SHIPPING_API_LEVEL
3681
3682$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3683$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003684# Check ODM SKU=(empty) case when:
3685# - ODM_MANIFEST_FILES is not empty; OR
3686# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003687$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003688 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3689 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003690 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003691# Check vendor SKU=(empty) case when:
3692# - DEVICE_MANIFEST_FILE is not empty; OR
3693# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003694$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003695 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3696 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003697 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003698$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3699 @echo -n -e 'Deps: \n ' > $@
3700 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3701 @echo -n -e 'Args: \n ' >> $@
3702 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003703 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3704 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003705 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003706 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3707 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3708 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003709
3710check_vintf_compatible_log :=
3711check_vintf_compatible_args :=
3712check_vintf_compatible_deps :=
3713
3714endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3715endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3716endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003717endif # check_vintf_has_vendor
3718endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003719endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3720
3721# Add all logs of VINTF checks to dist builds
3722droid_targets: $(check_vintf_all_deps)
3723$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3724
3725# Helper alias to check all VINTF of current build.
3726.PHONY: check-vintf-all
3727check-vintf-all: $(check_vintf_all_deps)
3728 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3729
Yifan Hongaf9b0702020-01-21 12:46:57 -08003730check_vintf_has_vendor :=
3731check_vintf_has_system :=
3732check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003733check_vintf_all_deps :=
3734intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003735endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003736
3737# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003738# Check image sizes <= size of super partition
3739
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003740ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003741
3742ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003743
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003744# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003745# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003746define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003747 mkdir -p $(dir $(1))
3748 rm -f $(1)
3749 $(call dump-super-image-info, $(1))
3750 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3751 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003752 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003753endef
3754
Yifan Hong30910932019-10-25 20:36:55 -07003755check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3756droid_targets: $(check_all_partition_sizes_log)
3757$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003758
Yifan Hong30910932019-10-25 20:36:55 -07003759$(check_all_partition_sizes_log): \
3760 $(CHECK_PARTITION_SIZES) \
3761 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3762 $(call check-all-partition-sizes-target, \
3763 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3764 $@)
3765
3766.PHONY: check-all-partition-sizes
3767check-all-partition-sizes: $(check_all_partition_sizes_log)
3768
3769.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003770check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003771 $(call check-all-partition-sizes-target, \
3772 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003773
Yifan Hong2dae5722018-07-31 12:47:27 -07003774endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003775
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003776endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003777
3778# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003779# bring in the installer image generation defines if necessary
3780ifeq ($(TARGET_USE_DISKINSTALLER),true)
3781include bootable/diskinstaller/config.mk
3782endif
3783
3784# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003785# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003786
Ying Wangbd2d0242015-09-22 11:17:52 -07003787ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003788 build_ota_package := false
3789 build_otatools_package := false
3790else
Tao Bao9be20c72019-04-08 21:11:59 -07003791 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003792 build_ota_package := true
3793 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3794 build_ota_package := false
3795 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003796 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003797 build_ota_package := false
3798 endif
3799 ifeq ($(TARGET_PRODUCT),sdk)
3800 build_ota_package := false
3801 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003802 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3803 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3804 build_ota_package := false
3805 endif
3806 ifeq ($(TARGET_NO_KERNEL),true)
3807 build_ota_package := false
3808 endif
3809 ifeq ($(recovery_fstab),)
3810 build_ota_package := false
3811 endif
3812 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003813
Tao Bao9be20c72019-04-08 21:11:59 -07003814 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003815 build_otatools_package := true
3816 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3817 build_otatools_package := false
3818 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003819endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003820
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003821ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003822
3823INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003824 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003825 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003826 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003827 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003828 append2simg \
3829 avbtool \
3830 blk_alloc_to_base_fs \
3831 boot_signer \
3832 brillo_update_payload \
3833 brotli \
3834 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003835 build_image \
3836 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003837 build_verity_metadata \
3838 build_verity_tree \
3839 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003840 check_ota_package_signature \
3841 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003842 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003843 checkvintf \
3844 delta_generator \
3845 e2fsck \
3846 e2fsdroid \
3847 fc_sort \
3848 fec \
3849 fs_config \
3850 generate_verity_key \
3851 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003852 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003853 imgdiff \
3854 libconscrypt_openjdk_jni \
3855 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003856 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003857 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003858 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003859 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003860 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003861 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003862 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003863 mkbootfs \
3864 mkbootimg \
3865 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003866 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003867 mkf2fsuserimg.sh \
3868 mksquashfs \
3869 mksquashfsimage.sh \
3870 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003871 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003872 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003873 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003874 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003875 sign_apex \
3876 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003877 signapk \
3878 simg2img \
3879 sload_f2fs \
3880 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003881 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003882 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003883 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003884 verity_signer \
3885 verity_verifier \
3886 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003887
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003888# Additional tools to unpack and repack the apex file.
3889INTERNAL_OTATOOLS_MODULES += \
3890 apexer \
3891 deapexer \
3892 debugfs_static \
3893 merge_zips \
3894 resize2fs \
3895 soong_zip \
3896
Anton Hansson8dab0a62019-03-28 15:45:40 +00003897ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003898INTERNAL_OTATOOLS_MODULES += \
3899 futility \
3900 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003901endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003902
Tao Bao96daeeb2019-05-01 21:17:13 -07003903INTERNAL_OTATOOLS_FILES := \
3904 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003905
Ying Wang06898662010-06-17 17:52:18 -07003906.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003907otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003908
Tao Bao96daeeb2019-05-01 21:17:13 -07003909# For each module, recursively resolve its host shared library dependencies. Then we have a full
3910# list of modules whose installed files need to be packed.
3911INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3912 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3913 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003914
Tao Bao96daeeb2019-05-01 21:17:13 -07003915INTERNAL_OTATOOLS_PACKAGE_FILES := \
3916 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3917
3918INTERNAL_OTATOOLS_PACKAGE_FILES += \
3919 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3920 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003921
3922ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003923INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003924 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003925 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003926endif
3927ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003928INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003929 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3930 -name "atx_metadata.bin"))
3931endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003932ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003933INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003934 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003935endif
3936
Tao Bao96daeeb2019-05-01 21:17:13 -07003937INTERNAL_OTATOOLS_RELEASETOOLS := \
3938 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3939 \( -type f -o -type l \) -print))
3940
3941BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3942$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3943$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3944$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3945$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003946$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003947 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003948 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3949 mkdir -p $(dir $@)
3950 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3951 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003952 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003953 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003954
3955.PHONY: otatools-package
3956otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3957
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003958endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003959
The Android Open Source Project88b60792009-03-03 19:28:42 -08003960# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003961# misc_info.txt
3962
3963INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3964
3965ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3966# default to common dir for device vendor
3967tool_extensions := $(TARGET_DEVICE_DIR)/../common
3968else
3969tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3970endif
3971.KATI_READONLY := tool_extensions
3972
Steve Muckle903a1ca2020-05-07 17:32:10 -07003973# $1: boot image file name
3974define misc_boot_size
3975$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3976endef
3977
Daniel Normane1e48082019-06-27 13:55:23 -07003978$(INSTALLED_MISC_INFO_TARGET):
3979 rm -f $@
3980 $(call pretty,"Target misc_info.txt: $@")
3981 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3982 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3983ifdef BOARD_FLASH_BLOCK_SIZE
3984 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3985endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07003986ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
3987 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
3988 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07003989endif
3990ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3991 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07003992else
3993 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003994endif
J. Avila98cd4cc2020-06-10 20:09:10 +00003995ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
3996 echo "lz4_ramdisks=true" >> $@
3997endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003998ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3999 echo "vendor_boot=true" >> $@
4000 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4001endif
Daniel Normane1e48082019-06-27 13:55:23 -07004002ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4003 $(hide) echo "no_recovery=true" >> $@
4004endif
4005ifdef BOARD_INCLUDE_RECOVERY_DTBO
4006 $(hide) echo "include_recovery_dtbo=true" >> $@
4007endif
4008ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4009 $(hide) echo "include_recovery_acpio=true" >> $@
4010endif
4011ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4012 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4013endif
4014ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4015 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4016 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4017else
4018 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4019endif
4020 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4021 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4022ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4023 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4024endif
4025 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004026 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004027 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4028 $(hide) echo "multistage_support=1" >> $@
4029 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4030ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4031 $(hide) echo "build_generic_ota_package=true" >> $@
4032endif
4033ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4034 # OTA scripts are only interested in fingerprint related properties
4035 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4036endif
4037ifneq (,$(filter address, $(SANITIZE_TARGET)))
4038 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4039 $(hide) echo "userdata_img_with_data=true" >> $@
4040endif
4041ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4042 $(hide) echo "full_recovery_image=true" >> $@
4043endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004044ifdef BOARD_USES_VENDORIMAGE
4045 $(hide) echo "board_uses_vendorimage=true" >> $@
4046endif
Daniel Normane1e48082019-06-27 13:55:23 -07004047ifeq ($(BOARD_AVB_ENABLE),true)
4048 $(hide) echo "avb_enable=true" >> $@
4049 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4050 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4051 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4052 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4053ifdef BOARD_AVB_BOOT_KEY_PATH
4054 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4055 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4056 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4057endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004058 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4059ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4060 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4061 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4062 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4063endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004064 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4065ifdef BOARD_AVB_RECOVERY_KEY_PATH
4066 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4067 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4068 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4069endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004070ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4071 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4072 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4073 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4074 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4075 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4076 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4077 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4078 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4079endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004080ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4081 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4082 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4083 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4084 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4085 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4086endif # BOARD_AVB_VBMETA_SYSTEM
4087ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4088 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4089 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4090 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4091 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4092 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4093endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4094endif # BOARD_AVB_ENABLE
4095ifdef BOARD_BPT_INPUT_FILES
4096 $(hide) echo "board_bpt_enable=true" >> $@
4097 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4098 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4099endif
4100ifdef BOARD_BPT_DISK_SIZE
4101 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4102endif
4103 $(call generate-userimage-prop-dictionary, $@)
4104ifeq ($(AB_OTA_UPDATER),true)
4105 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4106 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4107 $(hide) echo "ab_update=true" >> $@
4108endif
Yifan Hong65afc072020-04-17 10:08:10 -07004109ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4110 $(hide) echo "allow_non_ab=true" >> $@
4111endif
Daniel Normane1e48082019-06-27 13:55:23 -07004112ifdef BOARD_PREBUILT_DTBOIMAGE
4113 $(hide) echo "has_dtbo=true" >> $@
4114ifeq ($(BOARD_AVB_ENABLE),true)
4115 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4116 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4117ifdef BOARD_AVB_DTBO_KEY_PATH
4118 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4119 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4120 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4121endif # BOARD_AVB_DTBO_KEY_PATH
4122endif # BOARD_AVB_ENABLE
4123endif # BOARD_PREBUILT_DTBOIMAGE
4124 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004125 @# VINTF checks
4126ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4127 $(hide) echo "vintf_enforce=true" >> $@
4128endif
4129ifdef ODM_MANIFEST_SKUS
4130 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4131endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004132ifdef ODM_MANIFEST_FILES
4133 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4134endif
4135ifdef DEVICE_MANIFEST_SKUS
4136 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4137endif
4138ifdef DEVICE_MANIFEST_FILE
4139 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4140endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004141ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4142 $(hide) echo "bootloader_in_update_package=true" >> $@
4143endif
Daniel Normane1e48082019-06-27 13:55:23 -07004144
4145.PHONY: misc_info
4146misc_info: $(INSTALLED_MISC_INFO_TARGET)
4147
4148droidcore: $(INSTALLED_MISC_INFO_TARGET)
4149
4150# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004151# A zip of the directories that map to the target filesystem.
4152# This zip can be used to create an OTA package or filesystem image
4153# as a post-build step.
4154#
4155name := $(TARGET_PRODUCT)
4156ifeq ($(TARGET_BUILD_TYPE),debug)
4157 name := $(name)_debug
4158endif
4159name := $(name)-target_files-$(FILE_NAME_TAG)
4160
4161intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4162BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4163$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4164$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004165 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004166
4167# $(1): Directory to copy
4168# $(2): Location to copy it to
4169# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4170define package_files-copy-root
4171 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4172 mkdir -p $(2) && \
4173 $(ACP) -rd $(strip $(1))/* $(2); \
4174 fi
4175endef
4176
Tao Baoa04fca32015-11-30 12:22:24 -08004177built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004178
4179# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004180ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004181built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004182 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004183endif
4184
The Android Open Source Project88b60792009-03-03 19:28:42 -08004185$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4186
Dan Willemsen653bea92017-03-21 15:47:37 -07004187tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004188$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004189
Sen Jiang4438fd92016-03-07 16:51:01 -08004190ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004191updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004192endif
4193
4194# Build OTA tools if non-A/B is allowed
4195ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004196updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004197endif
Yifan Hong65afc072020-04-17 10:08:10 -07004198
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004199$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004200
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004201# If we are using recovery as boot, output recovery files to BOOT/.
4202ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4203$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4204else
4205$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4206endif
4207
Dan Willemsen653bea92017-03-21 15:47:37 -07004208ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004209 ifdef OSRELEASED_DIRECTORY
4210 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4211 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4212 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4213 endif
Tao Baoa835f382019-07-18 15:55:30 -07004214
4215 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4216 # additionally include radio or bootloader partitions).
4217 ifeq ($(AB_OTA_PARTITIONS),)
4218 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4219 endif
4220endif
4221
4222ifneq ($(AB_OTA_PARTITIONS),)
4223 ifneq ($(AB_OTA_UPDATER),true)
4224 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4225 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004226endif
4227
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004228# Run fs_config while creating the target files package
4229# $1: root directory
4230# $2: add prefix
4231define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004232(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 -08004233endef
4234
Yifan Hong60bfcc42019-11-01 11:39:45 -07004235# Filter out vendor from the list for AOSP targets.
4236# $(1): list
4237define filter-out-missing-vendor
4238$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4239endef
4240
4241# Information related to dynamic partitions and virtual A/B. This information
4242# is needed for building the super image (see dump-super-image-info) and
4243# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004244# $(1): file
4245define dump-dynamic-partitions-info
4246 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4247 echo "use_dynamic_partitions=true" >> $(1))
4248 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4249 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004250 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4251 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4252 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004253 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4254 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004255 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4256 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4257 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4258 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4259 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4260 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004261 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004262 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4263 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4264 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4265 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4266 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004267 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 -07004268 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4269 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004270 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4271 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004272 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4273 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004274 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4275 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4276 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4277 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4278 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4279 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4280 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4281 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004282 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4283 echo "virtual_ab=true" >> $(1))
4284 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4285 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004286endef
4287
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004288# By conditionally including the dependency of the target files package on the
4289# full system image deps, we speed up builds that do not build the system
4290# image.
4291ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004292 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4293endif
4294
4295ifdef BUILDING_USERDATA_IMAGE
4296 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4297endif
4298
4299ifdef BUILDING_SYSTEM_OTHER_IMAGE
4300 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4301endif
4302
4303ifdef BUILDING_VENDOR_BOOT_IMAGE
4304 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
4305endif
4306
4307ifdef BUILDING_RECOVERY_IMAGE
4308 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
4309 # BUILD_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
4310 # commands in build-recoveryimage-target, which would touch the files under
4311 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4312 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4313 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4314 else
4315 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4316 endif
4317 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4318endif
4319
4320# Conditionally depend on the image files if the image is being built so the
4321# target-files.zip rule doesn't wait on the image creation rule, or the image
4322# if it is coming from a prebuilt.
4323
4324ifdef BUILDING_VENDOR_IMAGE
4325 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4326else ifdef BOARD_PREBUILT_VENDORIMAGE
4327 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4328endif
4329
4330ifdef BUILDING_PRODUCT_IMAGE
4331 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4332else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4333 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4334endif
4335
4336ifdef BUILDING_SYSTEM_EXT_IMAGE
4337 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4338else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4339 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4340endif
4341
4342ifdef BUILDING_BOOT_IMAGE
4343 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
4344else ifdef BOARD_PREBUILT_BOOTIMAGE
4345 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4346endif
4347
4348ifdef BUILDING_ODM_IMAGE
4349 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4350else ifdef BOARD_PREBUILT_ODMIMAGE
4351 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4352endif
4353
4354ifdef BUILDING_VENDOR_DLKM_IMAGE
4355 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4356else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4357 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4358endif
4359
4360ifdef BUILDING_ODM_DLKM_IMAGE
4361 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4362else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4363 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004364endif
4365
Isaac Chen9e09d472019-07-05 17:30:41 +08004366ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004367 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4368 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004369endif
4370
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004371ifdef BOARD_PREBUILT_BOOTLOADER
4372$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004373droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004374endif
4375
The Android Open Source Project88b60792009-03-03 19:28:42 -08004376# Depending on the various images guarantees that the underlying
4377# directories are up-to-date.
4378$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004379 $(INSTALLED_RADIOIMAGE_TARGET) \
4380 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004381 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004382 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004383 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004384 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4385 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004386 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004387 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4388 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004389 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004390 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004391 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4392 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4393 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004394 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004395 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004396 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004397 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004398 $(LPMAKE) \
4399 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004400 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004401 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004402 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004403 $(SOONG_ZIP) \
4404 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004405 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004406 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004407 $(BUILT_KERNEL_CONFIGS_FILE) \
4408 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004409 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004410 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004411 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004412 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004413ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004414 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004415 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004416 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004417 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004418ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004419ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004420 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Steve Muckle04b6f052020-08-09 14:36:56 -07004421else # BOARD_USES_RECOVERY_AS_BOOT not true
4422 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4423endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004424endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004425ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004426 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004427else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004428ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004429 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004430endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004431ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004432ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004433 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004434else
Steve Mucklee1b10862019-07-10 10:49:37 -07004435 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004436endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004437endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004438ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004439 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004440endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004441ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004442 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004443endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004444ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004445 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004446endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004447ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004448 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004449endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004450ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004451 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004452endif
Colin Crossa6de2ad2020-08-26 18:40:19 -07004453endif # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004454endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004455 @# Components of the boot image
4456 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004457 $(hide) mkdir -p $(zip_root)/ROOT
4458 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004459 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004460 @# If we are using recovery as boot, this is already done when processing recovery.
4461ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004462ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004463 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004464 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004465endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004466ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004467 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004468endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004469ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004470ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004471 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004472endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004473ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004474 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004475endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004476 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004477ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004478 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004479endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004480ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004481 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004482endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004483else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4484 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4485endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4486endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004487 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4488 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004489 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004490ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4491 mkdir -p $(zip_root)/VENDOR_BOOT
4492 $(call package_files-copy-root, \
4493 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4494ifdef INSTALLED_DTBIMAGE_TARGET
4495 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4496endif
4497ifdef BOARD_KERNEL_BASE
4498 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4499endif
4500ifdef BOARD_KERNEL_PAGESIZE
4501 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4502endif
4503 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4504endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004505ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004506 @# Contents of the system image
4507 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004508 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004509endif
4510ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004511 @# Contents of the data image
4512 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004513 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004514endif
4515ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004516 @# Contents of the vendor image
4517 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004518 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004519endif
Dan Willemsen67495202019-01-16 12:42:05 -08004520ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004521 @# Contents of the product image
4522 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004523 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004524endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004525ifdef BUILDING_SYSTEM_EXT_IMAGE
4526 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004527 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004528 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004529endif
Dan Willemsen67495202019-01-16 12:42:05 -08004530ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004531 @# Contents of the odm image
4532 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004533 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004534endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004535ifdef BUILDING_VENDOR_DLKM_IMAGE
4536 @# Contents of the vendor_dlkm image
4537 $(hide) $(call package_files-copy-root, \
4538 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4539endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004540ifdef BUILDING_ODM_DLKM_IMAGE
4541 @# Contents of the odm_dlkm image
4542 $(hide) $(call package_files-copy-root, \
4543 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4544endif
Dan Willemsen67495202019-01-16 12:42:05 -08004545ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004546 @# Contents of the system_other image
4547 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004548 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004549endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004550 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004551 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004552 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004553ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004554ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004555 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004556 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004557endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004558endif
Doug Zongker8678df42009-06-15 14:30:14 -07004559 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004560 @# build them.
4561 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004562 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004563 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004564ifneq ($(tool_extension),)
4565 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4566endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004567 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004568 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004569 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004570ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4571 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4572 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004573endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004574ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4575 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4576 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004577endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004578ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4579 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4580 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004581endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004582ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4583 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4584 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004585endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004586ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4587 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4588 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004589endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004590ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4591 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4592 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4593endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004594ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4595 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4596 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4597endif
Yifan Hong65afc072020-04-17 10:08:10 -07004598ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004599ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004600 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004601 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004602endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004603endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004604ifeq ($(AB_OTA_UPDATER),true)
4605 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004606 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004607 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004608 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4609 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004610 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4611 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4612 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004613ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004614 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4615 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4616 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004617endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004618endif
Steve Fungdfbab492015-09-24 18:12:33 -07004619ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004620 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004621 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004622endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004623ifdef BOARD_PREBUILT_VENDORIMAGE
4624 $(hide) mkdir -p $(zip_root)/IMAGES
4625 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4626endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004627ifdef BOARD_PREBUILT_PRODUCTIMAGE
4628 $(hide) mkdir -p $(zip_root)/IMAGES
4629 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4630endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004631ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004632 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004633 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004634endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004635ifdef BOARD_PREBUILT_BOOTIMAGE
4636 $(hide) mkdir -p $(zip_root)/IMAGES
4637 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4638endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004639ifdef BOARD_PREBUILT_ODMIMAGE
4640 $(hide) mkdir -p $(zip_root)/IMAGES
4641 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4642endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004643ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004644 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004645 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4646endif
4647ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4648 $(hide) mkdir -p $(zip_root)/IMAGES
4649 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004650endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004651ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004652 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4653 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004654endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004655ifdef BOARD_PREBUILT_BOOTLOADER
4656 $(hide) mkdir -p $(zip_root)/IMAGES
4657 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4658endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004659ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4660 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4661 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4662 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4663endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004664 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4665 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4666 @# INSTALLED_RADIOIMAGE_TARGET.
4667 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4668 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004669 @# Run fs_config on all the system, vendor, boot ramdisk,
4670 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004671ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004672 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004673endif
4674ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004675 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4676endif
Dan Willemsen67495202019-01-16 12:42:05 -08004677ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004678 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4679endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004680ifdef BUILDING_SYSTEM_EXT_IMAGE
4681 $(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 +01004682endif
Dan Willemsen67495202019-01-16 12:42:05 -08004683ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004684 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4685endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004686ifdef BUILDING_VENDOR_DLKM_IMAGE
4687 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4688endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004689ifdef BUILDING_ODM_DLKM_IMAGE
4690 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4691endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004692 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004693 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004694ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004695 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004696 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004697endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004698ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4699 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4700endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004701ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4702 @# 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 -08004703 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4704endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004705ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4706 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4707endif
Dan Willemsen67495202019-01-16 12:42:05 -08004708ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004709 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4710endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004711 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004712ifdef BUILT_KERNEL_CONFIGS_FILE
4713 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4714endif
4715ifdef BUILT_KERNEL_VERSION_FILE
4716 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4717endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004718 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4719ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4720 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4721endif
Tao Baocbd6d492019-10-07 22:46:02 -07004722 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4723 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004724ifeq ($(BUILD_QEMU_IMAGES),true)
4725 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4726 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4727endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004728 @# Zip everything up, preserving symlinks and placing META/ files first to
4729 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004730 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004731 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004732 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004733
Ying Wanga0febe52013-03-20 11:02:05 -07004734.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004735target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4736
Ying Wang4709d7c2014-04-14 17:25:43 -07004737$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07004738
Dan Albert4d323332016-10-14 13:23:06 -07004739# -----------------------------------------------------------------
4740# NDK Sysroot Package
4741NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004742$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004743 @echo Package NDK sysroot...
4744 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4745
4746$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4747
Ying Wang09c4b682015-08-11 11:24:19 -07004748ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004749# -----------------------------------------------------------------
4750# OTA update package
4751
Yifan Hong50e79542018-11-08 17:44:12 -08004752# $(1): output file
4753# $(2): additional args
4754define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004755PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004756 $(OTA_FROM_TARGET_FILES) \
4757 --verbose \
4758 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4759 --path $(HOST_OUT) \
4760 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4761 $(2) \
4762 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004763endef
4764
Doug Zongker8678df42009-06-15 14:30:14 -07004765name := $(TARGET_PRODUCT)
4766ifeq ($(TARGET_BUILD_TYPE),debug)
4767 name := $(name)_debug
4768endif
4769name := $(name)-ota-$(FILE_NAME_TAG)
4770
4771INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004772INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4773
Doug Zongker8678df42009-06-15 14:30:14 -07004774$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004775$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004776$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004777 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004778 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004779
4780.PHONY: otapackage
4781otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4782
Tao Bao519d1822018-12-27 12:47:23 -08004783ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004784name := $(TARGET_PRODUCT)
4785ifeq ($(TARGET_BUILD_TYPE),debug)
4786 name := $(name)_debug
4787endif
4788name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4789
4790INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004791$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004792$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4793 $(BUILT_TARGET_FILES_PACKAGE) \
4794 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004795 @echo "Package OTA (retrofit dynamic partitions): $@"
4796 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4797
4798.PHONY: otardppackage
4799
4800otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4801
Tao Bao519d1822018-12-27 12:47:23 -08004802endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004803
Ying Wang09c4b682015-08-11 11:24:19 -07004804endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004805
Ying Wang09a00a62010-10-20 14:01:09 -07004806# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004807# A zip of the appcompat directory containing logs
4808APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4809# 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))
Colin Crosscda30c72020-08-26 18:43:21 -07004811$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4812 $(INTERNAL_RAMDISK_FILES) \
4813 $(INTERNAL_USERDATAIMAGE_FILES) \
4814 $(INTERNAL_VENDORIMAGE_FILES) \
4815 $(INTERNAL_PRODUCTIMAGE_FILES) \
4816 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01004817endif
4818$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4819$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4820 @echo "appcompat logs: $@"
4821 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4822 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4823 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4824 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4825
Dario Frenid1011272018-07-23 20:20:15 +01004826# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004827# A zip of the symbols directory. Keep the full paths to make it
4828# more obvious where these files came from.
4829#
4830name := $(TARGET_PRODUCT)
4831ifeq ($(TARGET_BUILD_TYPE),debug)
4832 name := $(name)_debug
4833endif
4834name := $(name)-symbols-$(FILE_NAME_TAG)
4835
4836SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004837# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004838ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004839$(SYMBOLS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4840 $(INTERNAL_RAMDISK_FILES) \
4841 $(INTERNAL_USERDATAIMAGE_FILES) \
4842 $(INTERNAL_VENDORIMAGE_FILES) \
4843 $(INTERNAL_PRODUCTIMAGE_FILES) \
4844 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4845 $(INTERNAL_ODMIMAGE_FILES) \
4846 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4847 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Anton Hansson6d814982018-11-26 18:12:05 +00004848 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004849endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004850$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4851$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004852 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004853 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4854 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004855 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004856 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004857# -----------------------------------------------------------------
4858# A zip of the coverage directory.
4859#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004860name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004861ifeq ($(TARGET_BUILD_TYPE),debug)
4862name := $(name)_debug
4863endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004864COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004865ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004866$(COVERAGE_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4867 $(INTERNAL_RAMDISK_FILES) \
4868 $(INTERNAL_USERDATAIMAGE_FILES) \
4869 $(INTERNAL_VENDORIMAGE_FILES) \
4870 $(INTERNAL_PRODUCTIMAGE_FILES) \
4871 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4872 $(INTERNAL_ODMIMAGE_FILES) \
4873 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4874 $(INTERNAL_ODM_DLKMIMAGE_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004875endif
4876$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4877$(COVERAGE_ZIP): $(SOONG_ZIP)
4878 @echo "Package coverage: $@"
4879 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4880 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4881 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4882 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004883
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004884#------------------------------------------------------------------
4885# Export the LLVM profile data tool and dependencies for Clang coverage processing
4886#
4887ifeq (true,$(CLANG_COVERAGE))
4888 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4889 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4890 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4891 $(PROFDATA_ZIP): $(SOONG_ZIP)
4892 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4893
Kun Niud322d8d2020-05-14 16:32:29 -07004894 $(call dist-for-goals,droidcore apps_only,$(PROFDATA_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004895endif
4896
The Android Open Source Project88b60792009-03-03 19:28:42 -08004897# -----------------------------------------------------------------
4898# A zip of the Android Apps. Not keeping full path so that we don't
4899# include product names when distributing
4900#
4901name := $(TARGET_PRODUCT)
4902ifeq ($(TARGET_BUILD_TYPE),debug)
4903 name := $(name)_debug
4904endif
4905name := $(name)-apps-$(FILE_NAME_TAG)
4906
4907APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07004908$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004909 @echo "Package apps: $@"
4910 $(hide) rm -rf $@
4911 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004912 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4913 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004914 echo "No apps to zip up. Generating empty apps archive." ; \
4915 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004916 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004917 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004918 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004919
Ying Wangbc415dd2012-08-15 12:22:44 -07004920ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004921#------------------------------------------------------------------
4922# An archive of classes for use in generating code-coverage reports
4923# These are the uninstrumented versions of any classes that were
4924# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004925# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004926
Colin Crossa6bc3a82017-09-27 14:28:41 -07004927JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004928$(JACOCO_REPORT_CLASSES_ALL) :
4929 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004930 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4931 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004932
Ying Wangbc415dd2012-08-15 12:22:44 -07004933endif # EMMA_INSTRUMENT=true
4934
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004935
Ying Wangae9115a2013-08-22 20:52:47 -07004936#------------------------------------------------------------------
4937# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004938#
Ying Wangc62c92c2013-08-28 18:38:25 -07004939PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004940# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004941ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004942$(PROGUARD_DICT_ZIP): \
Colin Crosscda30c72020-08-26 18:43:21 -07004943 $(FULL_SYSTEMIMAGE_DEPS) \
4944 $(INTERNAL_RAMDISK_FILES) \
4945 $(INTERNAL_USERDATAIMAGE_FILES) \
4946 $(INTERNAL_VENDORIMAGE_FILES) \
4947 $(INTERNAL_PRODUCTIMAGE_FILES) \
4948 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4949 $(INTERNAL_ODMIMAGE_FILES) \
4950 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4951 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Colin Cross114e8df2019-09-05 17:19:35 -07004952 $(updater_dep)
4953endif
4954$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4955$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004956 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004957 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4958 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4959 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4960 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004961
Colin Crossa9b9e6e2020-08-14 17:43:35 -07004962#------------------------------------------------------------------
4963# A zip of Proguard usage files.
4964#
4965PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
4966# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4967ifeq (,$(TARGET_BUILD_UNBUNDLED))
4968$(PROGUARD_USAGE_ZIP): \
4969 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4970 $(INSTALLED_RAMDISK_TARGET) \
4971 $(INSTALLED_BOOTIMAGE_TARGET) \
4972 $(INSTALLED_USERDATAIMAGE_TARGET) \
4973 $(INSTALLED_VENDORIMAGE_TARGET) \
4974 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4975 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4976 $(INSTALLED_ODMIMAGE_TARGET) \
4977 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4978 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
4979 $(updater_dep)
4980endif
4981$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
4982$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
4983 @echo "Packaging Proguard usage files."
4984 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4985 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
4986 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07004987
4988ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4989
4990# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4991# $(1): output file
4992define dump-super-image-info
4993 $(call dump-dynamic-partitions-info,$(1))
4994 $(if $(filter true,$(AB_OTA_UPDATER)), \
4995 echo "ab_update=true" >> $(1))
4996endef
4997
4998endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4999
The Android Open Source Project88b60792009-03-03 19:28:42 -08005000# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005001# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005002
5003ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5004
5005# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5006ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5007
5008ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005009
5010# For real devices and for dist builds, build super image from target files to an intermediate directory.
5011INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5012$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5013$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5014 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005015 PATH=$(dir $(LPMAKE)):$$PATH \
5016 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005017
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005018# Skip packing it in dist package because it is in update package.
5019ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005020$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005021endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005022
5023.PHONY: superimage_dist
5024superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005025
5026endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005027endif # BOARD_SUPER_PARTITION_SIZE != ""
5028endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005029
Yifan Hongacd862a2019-04-16 15:44:30 -07005030# -----------------------------------------------------------------
5031# super partition image for development
5032
5033ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5034ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5035ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5036
5037# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5038# $(1): built image path
5039# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5040define build-superimage-target
5041 mkdir -p $(dir $(2))
5042 rm -rf $(2)
5043 $(call dump-super-image-info,$(2))
5044 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5045 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005046 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5047 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005048 mkdir -p $(dir $(1))
5049 PATH=$(dir $(LPMAKE)):$$PATH \
5050 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5051endef
5052
5053INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5054INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5055 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5056
changho.shina8f9f112019-10-15 13:26:19 +09005057ifdef BUILDING_SYSTEM_OTHER_IMAGE
5058ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5059INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5060endif
5061endif
5062
Yifan Hongacd862a2019-04-16 15:44:30 -07005063# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5064# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5065# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5066# virtual devices.
5067ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5068$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5069 $(call pretty,"Target super fs image for debug: $@")
5070 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005071 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005072
5073droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5074
5075# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5076.PHONY: superimage
5077superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005078
5079$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005080endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5081
5082# Build $(PRODUCT_OUT)/super.img without dependencies.
5083.PHONY: superimage-nodeps supernod
5084superimage-nodeps supernod: intermediates :=
5085superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5086 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5087 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5088 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5089
5090endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5091endif # BOARD_SUPER_PARTITION_SIZE != ""
5092endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5093
5094# -----------------------------------------------------------------
5095# super empty image
5096
Tao Bao48a2feb2019-06-28 11:00:05 -07005097ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005098ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005099
Yifan Hong8b79d162018-11-29 12:32:00 -08005100INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5101$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5102$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5103 $(call pretty,"Target empty super fs image: $@")
5104 mkdir -p $(intermediates)
5105 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005106 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005107 PATH=$(dir $(LPMAKE)):$$PATH \
5108 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005109
5110$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5111
Yifan Hong2b891ac2018-11-29 12:06:31 -08005112endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005113endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005114
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005115
5116# -----------------------------------------------------------------
5117# The update package
5118
5119name := $(TARGET_PRODUCT)
5120ifeq ($(TARGET_BUILD_TYPE),debug)
5121 name := $(name)_debug
5122endif
5123name := $(name)-img-$(FILE_NAME_TAG)
5124
5125INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5126
Tao Bao57f8ed62019-08-14 23:08:18 -07005127$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5128 $(call pretty,"Package: $@")
5129 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5130 $(IMG_FROM_TARGET_FILES) \
5131 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5132 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005133
5134.PHONY: updatepackage
5135updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005136$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005137
5138
Yifan Hong2b891ac2018-11-29 12:06:31 -08005139# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005140# dalvik something
5141.PHONY: dalvikfiles
5142dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5143
Bo Huf0d50bb2017-08-01 19:02:09 +00005144ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005145MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005146MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005147SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005148
5149ifdef INSTALLED_SYSTEMIMAGE_TARGET
5150INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005151INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5152$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5153 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5154 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005155$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005156 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5157 @echo Create system-qemu.img now
5158 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005159 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005160
5161systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5162droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005163endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005164ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005165INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005166$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005167 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005168 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005169
5170vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5171droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5172endif
bohu8fd437c2020-03-30 20:16:13 -07005173
5174ifdef INSTALLED_RAMDISK_TARGET
5175ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5176ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5177INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5178$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5179 @echo Create ramdisk-qemu.img
5180 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5181
5182droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5183endif
5184endif
5185endif
5186
Anton Hansson32c76fe2018-12-13 14:34:18 +00005187ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005188INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005189$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005190 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005191 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005192
5193productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5194droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5195endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005196ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5197INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5198$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5199 @echo Create system_ext-qemu.img
5200 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005201
Justin Yun6151e3f2019-06-25 15:58:13 +09005202systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5203droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005204endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005205ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005206INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5207$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5208 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005209 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005210
5211odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5212droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5213endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005214
Yifan Hongcfb917a2020-05-07 14:58:20 -07005215ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5216INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5217$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5218 @echo Create vendor_dlkm-qemu.img
5219 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5220
5221vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5222droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5223endif
5224
Yifan Hongf496f1b2020-07-15 16:52:59 -07005225ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5226INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5227$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5228 @echo Create odm_dlkm-qemu.img
5229 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5230
5231odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5232droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5233endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005234
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005235QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005236$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5237 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005238 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005239 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5240 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005241
5242systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5243droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005244
Bo Huf0d50bb2017-08-01 19:02:09 +00005245endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005246# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005247# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005248ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005249INTERNAL_EMULATOR_PACKAGE_FILES += \
5250 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005251 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005252 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005253 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5254 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005255
5256name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5257
5258INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5259
Ying Wang5d887702015-11-04 10:06:25 -08005260$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005261 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005262 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005263
Ying Wang7d8c5352012-07-26 10:15:21 -07005264endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005265
The Android Open Source Project88b60792009-03-03 19:28:42 -08005266
5267# -----------------------------------------------------------------
5268# The SDK
5269
The Android Open Source Project88b60792009-03-03 19:28:42 -08005270# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005271sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005272
5273# Build a name that looks like:
5274#
5275# linux-x86 --> android-sdk_12345_linux-x86
5276# darwin-x86 --> android-sdk_12345_mac-x86
5277# windows-x86 --> android-sdk_12345_windows
5278#
5279sdk_name := android-sdk_$(FILE_NAME_TAG)
5280ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005281 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005282else
Joe Onorato03fbe402009-04-13 08:31:16 -07005283 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005284endif
5285ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005286 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005287endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005288sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005289
5290sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5291
5292ATREE_FILES :=
5293-include $(sdk_dep_file)
5294
5295# if we don't have a real list, then use "everything"
5296ifeq ($(strip $(ATREE_FILES)),)
5297ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005298 $(ALL_DEFAULT_INSTALLED_MODULES) \
5299 $(INSTALLED_RAMDISK_TARGET) \
5300 $(ALL_DOCS) \
5301 $(ALL_SDK_FILES)
5302endif
5303
5304atree_dir := development/build
5305
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005306
The Android Open Source Project88b60792009-03-03 19:28:42 -08005307sdk_atree_files := \
5308 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005309 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005310
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005311# development/build/sdk-android-<abi>.atree is used to differentiate
5312# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5313# files like the kernel image. We use TARGET_CPU_ABI because we don't
5314# have a better way to distinguish between CPU models.
5315ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5316 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5317endif
5318
Anton Hansson8dab0a62019-03-28 15:45:40 +00005319ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5320sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005321else
5322sdk_atree_files += $(atree_dir)/sdk.atree
5323endif
5324
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005325include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005326
The Android Open Source Project88b60792009-03-03 19:28:42 -08005327deps := \
5328 $(target_notice_file_txt) \
5329 $(tools_notice_file_txt) \
5330 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005331 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005332 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005333 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005334 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005335 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005336 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005337 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005338 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005339 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005340 $(INSTALLED_USERDATAIMAGE_TARGET) \
5341 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005342 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005343 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005344 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005345 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005346 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005347 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005348 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005349
5350INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5351$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5352$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5353$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5354$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5355
5356# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5357#
5358#SDK_GNU_ERROR := true
5359
Ying Wang5d887702015-11-04 10:06:25 -08005360$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005361 @echo "Package SDK: $@"
5362 $(hide) rm -rf $(PRIVATE_DIR) $@
5363 $(hide) for f in $(target_gnu_MODULES); do \
5364 if [ -f $$f ]; then \
5365 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5366 including GNU target $$f >&2; \
5367 FAIL=$(SDK_GNU_ERROR); \
5368 fi; \
5369 done; \
5370 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005371 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005372 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005373 ATREE_STRIP="$(HOST_STRIP) -x" \
5374 $(HOST_OUT_EXECUTABLES)/atree \
5375 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5376 -m $(PRIVATE_DEP_FILE) \
5377 -I . \
5378 -I $(PRODUCT_OUT) \
5379 -I $(HOST_OUT) \
5380 -I $(TARGET_COMMON_OUT_ROOT) \
5381 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5382 -v "OUT_DIR=$(OUT_DIR)" \
5383 -v "HOST_OUT=$(HOST_OUT)" \
5384 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5385 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5386 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5387 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5388 -o $(PRIVATE_DIR) && \
5389 cp -f $(target_notice_file_txt) \
5390 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5391 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5392 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5393 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5394 chmod -R ug+rwX $(PRIVATE_DIR) && \
5395 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005396 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5397
Raphael3d224a02010-04-16 17:50:09 -07005398
5399# Is a Windows SDK requested? If so, we need some definitions from here
5400# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005401MAIN_SDK_NAME := $(sdk_name)
5402MAIN_SDK_DIR := $(sdk_dir)
5403MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005404ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005405include $(TOPDIR)development/build/tools/windows_sdk.mk
5406endif
5407
The Android Open Source Project88b60792009-03-03 19:28:42 -08005408# -----------------------------------------------------------------
5409# Findbugs
5410INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5411INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5412$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5413 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005414 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005415 > $@
5416$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5417 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005418 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005419 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005420
5421# -----------------------------------------------------------------
5422# Findbugs
5423
5424# -----------------------------------------------------------------
5425# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005426ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005427include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005428-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005429-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005430-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005431# Also the project-specific tasks
5432-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5433-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005434-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005435# Also add test specifc tasks
5436include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005437include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005438endif
Raphaelc4d47312011-02-15 16:09:36 -08005439
Ying Wang67132ba2015-10-28 16:42:39 -07005440include $(BUILD_SYSTEM)/product-graph.mk
5441
Raphaelc4d47312011-02-15 16:09:36 -08005442# -----------------------------------------------------------------
5443# Create SDK repository packages. Must be done after tasks/* since
5444# we need the addon rules defined.
5445ifneq ($(sdk_repo_goal),)
5446include $(TOPDIR)development/build/tools/sdk_repo.mk
5447endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005448
5449# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005450# Soong generates the list of all shared libraries that are depended on by fuzz
5451# targets. It saves this list as a source:destination pair to
5452# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5453# build of the unstripped shared library, and the destination is the
5454# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5455# where fuzz target shared libraries are to be "reinstalled". The
5456# copy-many-files below generates the rules to copy the unstripped shared
5457# libraries to the device or host "reinstallation" directory. These rules are
5458# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5459# a dependency on each shared library that it needs to be "reinstalled".
5460FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5461
5462# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005463# The rule to build all fuzz targets, and package them.
5464# Note: The packages are created in Soong, and in a perfect world,
5465# we'd be able to create the phony rule there. But, if we want to
5466# have dist goals for the fuzz target, we need to have the PHONY
5467# target defined in make. MakeVarsContext.DistForGoal doesn't take
5468# into account that a PHONY rule create by Soong won't be available
5469# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005470# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005471# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005472.PHONY: haiku
5473haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5474$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))