blob: 15e073cebd3578ce1b8af48b514234b1bb240dd6 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
The Android Open Source Project88b60792009-03-03 19:28:42 -08007# -----------------------------------------------------------------
8# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -07009# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080010# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
11# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080012# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070013# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070014#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070015#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070016define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070017$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
18 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080019 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
20$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
21 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
22 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
23 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
24 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
25 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
26 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
27 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
28 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
29 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
30 use vintf_compatibility_matrix / vintf_fragments instead!)) \
31 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
32 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
33 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
34 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
35 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
36 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
37 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
38 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
39 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
40)
Ying Wang68864102011-09-29 13:23:25 -070041endef
Yo Chiang0b49c032020-03-17 17:49:49 +080042
Yo Chiang0b49c032020-03-17 17:49:49 +080043check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080044ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
45check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080046endif
47check_elf_prebuilt_product_copy_files_hint := \
48 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
49
Ying Wang619fccf2012-09-05 18:08:29 -070050# filter out the duplicate <source file>:<dest file> pairs.
51unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080052$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070053 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
54 $(eval unique_product_copy_files_pairs += $(cf))))
55unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080056product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070057$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070058 $(eval _src := $(call word-colon,1,$(cf))) \
59 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070060 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080061 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080062 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070063 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070064 $(if $(filter %.xml,$(_dest)),\
65 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010066 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
67 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070068 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
69 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080070 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
71 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
72 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
73 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070074 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080075
76# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070077pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
78$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
79$(pcf_ignored_file):
80 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080081
Dan Willemsen7537fd02018-10-16 23:15:08 -070082$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
83
84pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080085product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070086unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070087unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080088
89# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080090# Returns the max allowed size for an image suitable for hash verification
91# (e.g., boot.img, recovery.img, etc).
92# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
93# $(1): partition size to flash the image
94define get-hash-image-max-size
95$(if $(1), \
96 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
97 $(eval _hash_meta_size := 69632), \
98 $(eval _hash_meta_size := 0)) \
99 $(1)-$(_hash_meta_size))
100endef
101
102# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800103# Define rules to copy headers defined in copy_headers.mk
104# If more than one makefile declared a header, print a warning,
105# then copy the last one defined. This matches the previous make
106# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700107has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800108$(foreach dest,$(ALL_COPIED_HEADERS), \
109 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800110 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800111 $(if $(call streq,$(_src),$(_srcs)),, \
112 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800113 $(warning _ Using $(_src)) \
114 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
115 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
116 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
117 $(warning _ Ignoring $(src)) \
118 $(warning __ from $(firstword $(_makefiles))) \
119 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
120 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800121 $(eval $(call copy-one-header,$(_src),$(dest))))
122all_copied_headers: $(ALL_COPIED_HEADERS)
123
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700124ifdef has_dup_copy_headers
125 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700126 $(error duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers)
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700127endif
128
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800129$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
130
Dan Willemsen6f60f022016-02-23 13:40:07 -0800131# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100133ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134gen := $(OUT_DOCS)/index.html
135ALL_DOCS += $(gen)
136$(gen): frameworks/base/docs/docs-redirect-index.html
137 @mkdir -p $(dir $@)
138 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700139endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
Dan Albert303e6032017-10-04 10:20:20 -0700141ndk_doxygen_out := $(OUT_NDK_DOCS)
142ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
143ndk_docs_src_dir := frameworks/native/docs
144ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
145ifneq ($(wildcard $(ndk_docs_src_dir)),)
146ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
147 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
148$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
149 @mkdir -p $(ndk_doxygen_out)
150 @echo "Generating NDK docs to $(ndk_doxygen_out)"
151 @( cat $(ndk_doxyfile); \
152 echo "INPUT=$(ndk_headers)"; \
153 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
154 ) | doxygen -
155
156# Note: Not a part of the docs target because we don't have doxygen available.
157# You can run this target locally if you have doxygen installed.
158ndk-docs: $(ndk_doxygen_out)/index.html
159.PHONY: ndk-docs
160endif
161
Colin Crossd60401a2019-04-18 14:46:48 -0700162$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800163
Andres Moralesb8876e12015-05-06 20:44:22 -0700164INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700165ifdef BUILDING_RECOVERY_IMAGE
166ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
167INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
168endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700169endif
170
Jiyong Parke1346862020-05-18 14:31:30 +0900171include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100172
173# ----------------------------------------------------------------
174
175# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800176# sdk-build.prop
177#
178# There are certain things in build.prop that we don't want to
179# ship with the sdk; remove them.
180
181# This must be a list of entire property keys followed by
182# "=" characters, without any internal spaces.
183sdk_build_prop_remove := \
184 ro.build.user= \
185 ro.build.host= \
186 ro.product.brand= \
187 ro.product.manufacturer= \
188 ro.product.device=
189# TODO: Remove this soon-to-be obsolete property
190sdk_build_prop_remove += ro.build.product=
191INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
192$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
193 @echo SDK buildinfo: $@
194 @mkdir -p $(dir $@)
195 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000196 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000198 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800199 $(hide) mv $@.tmp $@
200
201# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700202# kernel modules
203
204# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
205DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
206
J. Avilaa2ceec62020-05-12 23:40:02 +0000207define copy-and-strip-kernel-module
208$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000209 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000210endef
211
Colin Cross4f60e362019-06-05 11:53:43 -0700212# $(1): modules list
213# $(2): output dir
214# $(3): mount point
215# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700216# $(5): module load list
217# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800218# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000219# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700220# $(9): module directory name
Colin Cross4f60e362019-06-05 11:53:43 -0700221# Returns the a list of src:dest pairs to install the modules using copy-many-files.
222define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700223 $(if $(9), \
224 $(eval _dir := $(9)/), \
225 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000226 $(foreach module,$(1), \
227 $(eval _src := $(module)) \
228 $(if $(8), \
229 $(eval _src := $(8)/$(notdir $(module))) \
230 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700231 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700232 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700233 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
234 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
235 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
236 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700237endef
238
239# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700240# $(2): mount point
241# $(3): staging dir
242# $(4): module load list
243# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800244# $(6): module archive
245# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700246# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800247# TODO(b/144844424): If a module archive is being used, this step (which
248# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
249# the output directory. This should be moved to a module with a
250# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
251# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700252define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700253$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle474e4d02019-06-19 12:56:48 -0700254$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
255$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
256$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700257$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700258$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
259$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
260$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800261$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
262$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
263$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700264 @echo depmod $$(PRIVATE_STAGING_DIR)
265 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700266 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800267 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700268 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800269 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700270 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800271 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
272 )
273 $(if $(1),\
274 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
275 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
276 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
277 done; \
278 )
Colin Cross4f60e362019-06-05 11:53:43 -0700279 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
280 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700281 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
282 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700283endef
284
Steve Muckle474e4d02019-06-19 12:56:48 -0700285# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700286# $(2): modules list
287# $(3): module load list
288# $(4): module load list filename
289# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700290define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700291 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
292 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700293endef
294
295# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700296# $(2): modules list
297# $(3): module load list
298# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700299define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700300$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
301$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
302 @echo load-list $$(@)
303 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700304endef
305
Steve Muckle2335d762020-05-28 18:39:38 -0700306# $(1): image name
307# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
308# $(3): mount point
309# $(4): module load filename
310# $(5): stripped staging directory
311# $(6): kernel module directory name (top is an out of band value for no directory)
312define build-image-kernel-modules-dir
313$(if $(filter top,$(6)),\
314 $(eval _kver :=)$(eval _sep :=),\
315 $(eval _kver := $(6))$(eval _sep :=_))\
316$(if $(5),\
317 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
318 $(eval _stripped_staging_dir :=))\
319$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
320 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
321 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
322 $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver))))
323endef
324
325# $(1): kernel module directory name (top is an out of band value for no directory)
326define build-recovery-as-boot-load
327$(if $(filter top,$(1)),\
328 $(eval _kver :=)$(eval _sep :=),\
329 $(eval _kver := $(1))$(eval _sep :=_))\
330 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
331 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_module_list$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load,$(TARGET_RECOVERY_ROOT_OUT))))
332endef
333
334# $(1): kernel module directory name (top is an out of band value for no directory)
335define build-vendor-ramdisk-recovery-load
336$(if $(filter top,$(1)),\
337 $(eval _kver :=)$(eval _sep :=),\
338 $(eval _kver := $(1))$(eval _sep :=_))\
339 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
340 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_RAMDISK_OUT))))
341endef
342
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700343# $(1): kernel module directory name (top is an out of band value for no directory)
344define build-vendor-charger-load
345$(if $(filter top,$(1)),\
346 $(eval _kver :=)$(eval _sep :=),\
347 $(eval _kver := $(1))$(eval _sep :=_))\
348 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
349 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_OUT_VENDOR))))
350endef
351
Steve Mucklee1b10862019-07-10 10:49:37 -0700352ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
353 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
354 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700355 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700356 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
357endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700358
Steve Muckle69280d22019-07-11 12:23:38 -0700359ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
360 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700361endif
362
Steve Mucklee1b10862019-07-10 10:49:37 -0700363ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700364 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700365 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700366 endif
367endif
368
J. Avilaa2ceec62020-05-12 23:40:02 +0000369ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
370 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
371else
372 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
373endif
Colin Cross4f60e362019-06-05 11:53:43 -0700374
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700375ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
376 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
377else
378 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
379endif
380
Steve Muckle2335d762020-05-28 18:39:38 -0700381BOARD_KERNEL_MODULE_DIRS += top
382$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
383 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700384 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(TARGET_VENDOR_RAMDISK_OUT),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700385 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
386 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(TARGET_OUT_VENDOR),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700387 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(TARGET_OUT_ODM),odm,modules.load,,$(dir))) \
389 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
390 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
391 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700392
393# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700395# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900396# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700397# $2 certificate
398# $3 private key
399# $4 compressed
400# $5 partition tag
401# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100402define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700403$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
404$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
405$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
406$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700407
408endef
409
Jaewoong Jung704b4542020-06-29 19:37:53 -0700410# -----------------------------------------------------------------
411# Merge an individual apkcerts output into the final apkcerts.txt output.
412# Use a macro to make it compatible with _apkcerts_write_line
413# $1 apkcerts file to be merged
414# $2 output file
415define _apkcerts_merge
416$(hide) cat $1 >> $2
417
418endef
419
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420name := $(TARGET_PRODUCT)
421ifeq ($(TARGET_BUILD_TYPE),debug)
422 name := $(name)_debug
423endif
424name := $(name)-apkcerts-$(FILE_NAME_TAG)
425intermediates := \
426 $(call intermediates-dir-for,PACKAGING,apkcerts)
427APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700428all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
429$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800430# We don't need to really build all the modules.
431# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700432$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433 @echo APK certs list: $@
434 @mkdir -p $(dir $@)
435 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700436 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700437 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
438 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
439 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
440 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
441 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Ying Wangd9a88d52012-10-26 09:21:28 -0700442 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700443 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444
445.PHONY: apkcerts-list
446apkcerts-list: $(APKCERTS_FILE)
447
Ying Wang15e487a2011-02-15 10:56:18 -0800448ifneq (,$(TARGET_BUILD_APPS))
449 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900450 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800451endif
Ying Wangefb21682010-07-23 16:42:13 -0700452
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900453
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700455# build system stats
456BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
457$(BUILD_SYSTEM_STATS):
458 @rm -f $@
459 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
460 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
461$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700462
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800464# build /product/etc/security/avb/system_other.avbpubkey if needed
465ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800466ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800467INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
468ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800469endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800470endif # BUILDING_SYSTEM_OTHER_IMAGE
471
472# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700473# Modules ready to be converted to Soong, ordered by how many
474# modules depend on them.
475SOONG_CONV := $(sort $(SOONG_CONV))
476SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
477$(SOONG_CONV_DATA):
478 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800479 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS)))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700480
Colin Crossfdea8932017-12-06 14:38:40 -0800481SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700482SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
483$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
484 @rm -f $@
485 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
486$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
487
488# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800489# Modules use -Wno-error, or added default -Wall -Werror
490WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
491$(WALL_WERROR):
492 @rm -f $@
493 echo "# Modules using -Wno-error" >> $@
494 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800495 echo "# Modules added default -Wall" >> $@
496 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
497
498$(call dist-for-goals,droidcore,$(WALL_WERROR))
499
500# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700501# C/C++ flag information for modules
502$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
503
504# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800505# Modules missing profile files
506PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
507$(PGO_PROFILE_MISSING):
508 @rm -f $@
509 echo "# Modules missing PGO profile files" >> $@
510 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
511
512$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
513
514# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700515# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700516# for future OTA packages installed by this system. Actual product
517# deliverables will be re-signed by hand. We expect this file to
518# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700519DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700520
521
Jeff Browne33ba4c2011-07-11 22:11:46 -0700522# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800523# if they don't do anything.
524.PHONY: systemimage
525systemimage:
526
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800527# -----------------------------------------------------------------
528
529.PHONY: event-log-tags
530
Joe Onoratob7510532010-07-14 10:22:54 -0700531# Produce an event logs tag file for everything we know about, in order
532# to properly allocate numbers. Then produce a file that's filtered
533# for what's going to be installed.
534
535all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
536
Colin Crossdc8f8e42012-04-12 13:25:54 -0700537event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
538
Joe Onoratob7510532010-07-14 10:22:54 -0700539# Include tags from all packages that we know about
540all_event_log_tags_src := \
541 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
542
Colin Crossdc8f8e42012-04-12 13:25:54 -0700543# PDK builds will already have a full list of tags that needs to get merged
544# in with the ones from source
545pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
546
547$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800548$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700549 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900550 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700551
Doug Zongkera34fa952011-02-23 12:17:29 -0800552# Include tags from all packages included in this product, plus all
553# tags that are part of the system (ie, not in a vendor/ or device/
554# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800555event_log_tags_src := \
556 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800557 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800558 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800559 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
560 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800561
Colin Crossdc8f8e42012-04-12 13:25:54 -0700562$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700563$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800564$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800565 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900566 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567
568event-log-tags: $(event_log_tags_file)
569
570ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
571
Joe Onoratob7510532010-07-14 10:22:54 -0700572
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573# #################################################################
574# Targets for boot/OS images
575# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800576ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
577 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
578 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
579 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
580 else
581 INSTALLED_2NDBOOTLOADER_TARGET :=
582 endif
583else
584 INSTALLED_BOOTLOADER_MODULE :=
585 INSTALLED_2NDBOOTLOADER_TARGET :=
586endif # TARGET_NO_BOOTLOADER
587ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700588 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
589 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
590 $(PRODUCT_OUT)/$(k))
591 else
592 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
593 endif
Ying Wangc6349742014-01-13 16:14:20 -0800594else
595 INSTALLED_KERNEL_TARGET :=
596endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597
598# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700599# the root dir
600INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601 $(ALL_GENERATED_SOURCES) \
602 $(ALL_DEFAULT_INSTALLED_MODULES))
603
Luis Hector Chavezff489932018-07-03 15:41:40 -0700604INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
605INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
606$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700607$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700608 @echo Installed file list: $@
609 @mkdir -p $(dir $@)
610 @rm -f $@
611 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700612 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700613
614$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
615
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800616#------------------------------------------------------------------
617# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700618ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800619INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700620ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800621$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800622 cat $^ > $@
623endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700624endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800625
Tom Cherryd14b8952018-08-09 14:26:00 -0700626# -----------------------------------------------------------------
627# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800628ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700629INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
630 $(ALL_GENERATED_SOURCES) \
631 $(ALL_DEFAULT_INSTALLED_MODULES))
632
633INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
634INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
635$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700636$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700637 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800638 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700639 @mkdir -p $(dir $@)
640 @rm -f $@
641 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700642 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700643
644$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700645BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
646
J. Avila3f6560e2020-05-11 20:20:03 +0000647ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
648# -l enables the legacy format used by the Linux kernel
649COMPRESSION_COMMAND_DEPS := $(LZ4)
650COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
651RAMDISK_EXT := .lz4
652else
653COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
654COMPRESSION_COMMAND := $(MINIGZIP)
655RAMDISK_EXT := .gz
656endif
657
Joe Onorato64d85d02009-04-09 19:31:12 -0700658# We just build this directly to the install location.
659INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000660$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800661 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000662 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800663
Ying Wangad7fd292013-08-08 16:34:29 -0700664.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000665ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700666 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000667 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800668
Dan Willemsen67495202019-01-16 12:42:05 -0800669endif # BUILDING_RAMDISK_IMAGE
670
The Android Open Source Project88b60792009-03-03 19:28:42 -0800671# -----------------------------------------------------------------
672# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700673
674# This is defined here since we may be building recovery as boot
675# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700676ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
677 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
678else
679 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
680endif
681
Steve Muckle903a1ca2020-05-07 17:32:10 -0700682ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
683 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
684endif
685
686# $1: boot image file name
687# $2: boot image variant (boot, boot-debug)
688define get-bootimage-partition-size
689 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
690endef
Chris Grossa784ef12019-04-22 11:09:57 -0700691
692ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800693INTERNAL_BOOTIMAGE_ARGS := \
694 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700695 --kernel $(INSTALLED_KERNEL_TARGET)
696
697ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
698INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
699endif
700
Steve Mucklee1b10862019-07-10 10:49:37 -0700701ifndef BUILDING_VENDOR_BOOT_IMAGE
702ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
703 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
704endif
705endif
706
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
708
Anton Hansson8dab0a62019-03-28 15:45:40 +0000709ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700710ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000711VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700712 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
713endif
714endif
715
Anton Hansson72e36f02019-02-26 17:36:30 +0000716INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700717
718ifndef BUILDING_VENDOR_BOOT_IMAGE
719ifdef BOARD_KERNEL_BASE
720 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
721endif
722ifdef BOARD_KERNEL_PAGESIZE
723 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
724endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700725ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700726 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
727endif
728else
729# building vendor boot image, dtb/base/pagesize go there
730ifdef GENERIC_KERNEL_CMDLINE
731 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
732endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700733endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700734
Sami Tolvanen3303d902016-03-15 16:49:30 +0000735INTERNAL_MKBOOTIMG_VERSION_ARGS := \
736 --os_version $(PLATFORM_VERSION) \
737 --os_patch_level $(PLATFORM_SECURITY_PATCH)
738
Chris Grossa784ef12019-04-22 11:09:57 -0700739# Define these only if we are building boot
740ifdef BUILDING_BOOT_IMAGE
741INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
742
The Android Open Source Project88b60792009-03-03 19:28:42 -0800743ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800744$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400745
746else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
747
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800748$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400749 $(call pretty,"Target boot image: $@")
750 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800751 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400752 $(hide) $(AVBTOOL) add_hash_footer \
753 --image $@ \
754 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800755 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400756 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
757
758.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800759bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400760 @echo "make $@: ignoring dependencies"
761 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800762 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400763 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800764 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400765 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800766 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400767 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
768
Anton Hansson8dab0a62019-03-28 15:45:40 +0000769else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700770
771$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
772 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000773 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Anton Hansson8dab0a62019-03-28 15:45:40 +0000774 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -0700775 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
776
777.PHONY: bootimage-nodeps
778bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
779 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000780 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000781 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET)
Geremy Condra740b6632014-07-08 20:07:41 -0700782 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
783
Anton Hansson8dab0a62019-03-28 15:45:40 +0000784else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800785
Tao Bao4b577412017-02-22 22:54:39 -0800786$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800787 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000788 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +0000789 $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@
David Riley17be3d32015-03-03 08:54:11 -0800790 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
791
792.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800793bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800794 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000795 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +0000796 $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
David Riley17be3d32015-03-03 08:54:11 -0800797 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
798
799else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800800
801$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
802 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000803 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700804 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700805
806.PHONY: bootimage-nodeps
807bootimage-nodeps: $(MKBOOTIMG)
808 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000809 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700810 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700811
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -0700813endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800814
Tao Baob1a2e352018-08-14 16:17:12 -0700815else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700816ifdef BOARD_PREBUILT_BOOTIMAGE
817ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
818# Remove when b/63676296 is resolved.
819$(error Prebuilt bootimage is only supported for AB targets)
820endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900821INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700822$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700823else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700824INSTALLED_BOOTIMAGE_TARGET :=
825endif # BOARD_PREBUILT_BOOTIMAGE
826endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800827
828# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700829# vendor boot image
830ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
831
832ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
833 $(error vboot 1.0 does not support vendor_boot partition)
834endif
835
836INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
837 $(ALL_GENERATED_SOURCES) \
838 $(ALL_DEFAULT_INSTALLED_MODULES))
839
Steve Muckle414dbe12020-06-18 21:38:35 -0700840INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000841$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
842 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700843
844ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
845 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
846endif
847ifdef BOARD_KERNEL_BASE
848 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
849endif
850ifdef BOARD_KERNEL_PAGESIZE
851 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
852endif
853ifdef INTERNAL_KERNEL_CMDLINE
854 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
855endif
856
857INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
858$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
859ifeq ($(BOARD_AVB_ENABLE),true)
860$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
861 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800862 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700863 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
864 $(AVBTOOL) add_hash_footer \
865 --image $@ \
866 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
867 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
868 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
869else
870$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
871 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800872 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700873 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
874endif
875endif # BUILDING_VENDOR_BOOT_IMAGE
876
877# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800878# NOTICE files
879#
Steve Blockd14d3b42012-03-01 11:34:41 +0000880# We are required to publish the licenses for all code under BSD, GPL and
881# Apache licenses (and possibly other more exotic ones as well). We err on the
882# side of caution, so the licenses for other third-party code are included here
883# too.
884#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800885# This needs to be before the systemimage rules, because it adds to
886# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
887# go into the systemimage.
888
Steve Block495e5852012-02-29 19:18:08 +0000889.PHONY: notice_files
890
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900891# Create the rule to combine the files into text and html/xml forms
Chris Grossaad39b32019-06-13 09:43:26 -0700892# $(1) - xml_excluded_system_product_odm|xml_excluded_vendor_product_odm
893# xml_product|xml_odm|xml_system_ext|xml_system|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900894# $(2) - Plain text output file
895# $(3) - HTML/XML output file
896# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700897# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800898# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900899# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800900# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800901#
902# The algorithm here is that we go collect a hash for each of the notice
903# files and write the names of the files that match that hash. Then
904# to generate the real files, we go print out all of the files and their
905# hashes.
906#
907# These rules are fairly complex, so they depend on this makefile so if
908# it changes, they'll run again.
909#
910# TODO: We could clean this up so that we just record the locations of the
911# original notice files instead of making rules to copy them somwehere.
912# Then we could traverse that without quite as much bash drama.
913define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700914$(2): PRIVATE_MESSAGE := $(4)
915$(2): PRIVATE_DIR := $(5)
916$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
917$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800918 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Chris Grossaad39b32019-06-13 09:43:26 -0700919 $(if $(filter $(1),xml_excluded_vendor_product_odm),-e vendor -e product -e system_ext -e odm --xml-output, \
920 $(if $(filter $(1),xml_excluded_system_product_odm),-e system -e product -e system_ext -e odm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000921 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900922 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700923 $(if $(filter $(1),xml_system),-i system --xml-output, \
924 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
925 --html-output)))))) $(3) \
Anton Hansson6d814982018-11-26 18:12:05 +0000926 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900927notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928endef
929
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000930# Notice file logic isn't relevant for TARGET_BUILD_APPS
931ifndef TARGET_BUILD_APPS
932
The Android Open Source Project88b60792009-03-03 19:28:42 -0800933# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
934# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
935# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000936target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000937tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800938tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000939kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
940winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
941pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800942
Bob Badour4b25c902020-01-28 13:23:39 -0800943# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
944# reasons--not to be flashed onto any device. Targets under these directories
945# need no associated notice file on the device UI.
946exclude_target_dirs := apex
947
Steven Morelandae69e572017-12-15 14:49:55 -0800948# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000949ifneq ($(PRODUCT_NOTICE_SPLIT),true)
950target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
951target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
952installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
953$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000954 $(target_notice_file_txt), \
955 $(target_notice_file_html), \
956 "Notices for files contained in the filesystem images in this directory:", \
957 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -0800958 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files), \
959 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000960$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
961 $(hide) $(MINIGZIP) -9 < $< > $@
962$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
963 $(copy-file-to-target)
964else
965target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
966target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900967installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
968
969target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
970target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
971target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
972installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +0100973
974target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
975target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
976target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
977installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +0100978
Justin Yun6151e3f2019-06-25 15:58:13 +0900979target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
980target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
981target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
982installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900983
Chris Gross15d96552019-07-16 14:38:43 -0700984target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
985target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
986target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
987installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
988
Anton Hansson6ad6f6c2018-11-12 23:33:47 +0000989# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
990# being built. A notice xml file must depend on all modules that could potentially
991# install a license file relevant to it.
992license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)
Bob Badour4b25c902020-01-28 13:23:39 -0800993# Only files copied to a system image need system image notices.
994license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +0000995# Phonys/fakes don't have notice files (though their deps might)
996license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +0900997# testcases are not relevant to the system image.
998license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -0800999# filesystem images: system, vendor, product, system_ext, and odm
Chris Grossaad39b32019-06-13 09:43:26 -07001000license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001001license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1002license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001003license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001004license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001005license_modules_agg := $(license_modules_system) \
1006 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001007 $(license_modules_product) \
1008 $(license_modules_system_ext) \
1009 $(license_modules_odm)
Bob Badour4b25c902020-01-28 13:23:39 -08001010# targets used for debug symbols only and do not get copied to the device
1011license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1012
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001013license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001014license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1015
1016# Identify the other targets we expect to have notices for:
1017# targets copied to the device but are not readable by the UI (e.g. must boot
1018# into a different partition to read or don't have an associated /etc
1019# directory) must have their notices built somewhere readable.
1020license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1021license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1022license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1023license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1024license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1025license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1026license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1027license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1028license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1029license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1030license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1031license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1032license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1033
1034# after removing targets in system images, targets reported in system images, and
1035# targets used for debug symbols that do not need notices, nothing must remain.
1036license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1037$(call maybe-print-list-and-error, $(license_modules_rest), \
1038 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001039
Chris Grossaad39b32019-06-13 09:43:26 -07001040# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1041# update its notice file, so include those notices in the system partition instead
1042ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001043license_modules_system += $(license_modules_rehomed)
Chris Grossaad39b32019-06-13 09:43:26 -07001044system_xml_directories := xml_excluded_vendor_product_odm
1045system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001046else
Bob Badour4b25c902020-01-28 13:23:39 -08001047license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001048system_xml_directories := xml_system
1049system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001050endif
1051
1052$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001053 $(target_notice_file_txt), \
1054 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001055 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001056 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001057 $(license_modules_system), \
1058 $(exclude_target_dirs)))
Chris Grossaad39b32019-06-13 09:43:26 -07001059$(eval $(call combine-notice-files, xml_excluded_system_product_odm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001060 $(target_vendor_notice_file_txt), \
1061 $(target_vendor_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001062 "Notices for files contained in all filesystem images except system/system_ext/product/odm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001063 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001064 $(license_modules_vendor), \
1065 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001066$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001067 $(target_product_notice_file_txt), \
1068 $(target_product_notice_file_xml), \
1069 "Notices for files contained in the product filesystem image in this directory:", \
1070 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001071 $(license_modules_product), \
1072 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001073$(eval $(call combine-notice-files, xml_system_ext, \
1074 $(target_system_ext_notice_file_txt), \
1075 $(target_system_ext_notice_file_xml), \
1076 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001077 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001078 $(license_modules_system_ext), \
1079 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001080$(eval $(call combine-notice-files, xml_odm, \
1081 $(target_odm_notice_file_txt), \
1082 $(target_odm_notice_file_xml), \
1083 "Notices for files contained in the odm filesystem image in this directory:", \
1084 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001085 $(license_modules_odm), \
1086 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001087
1088$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1089 $(hide) $(MINIGZIP) -9 < $< > $@
1090$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1091 $(hide) $(MINIGZIP) -9 < $< > $@
1092$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1093 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001094$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001095 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001096$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1097 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001098$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1099 $(copy-file-to-target)
1100$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1101 $(copy-file-to-target)
1102$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1103 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001104$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001105 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001106$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1107 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001108
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001109ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1110ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1111ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1112ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1113ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001114endif # PRODUCT_NOTICE_SPLIT
1115
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001116ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001117
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001118$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001119 $(tools_notice_file_txt), \
1120 $(tools_notice_file_html), \
1121 "Notices for files contained in the tools directory:", \
1122 $(HOST_OUT_NOTICE_FILES), \
1123 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001124 $(winpthreads_notice_file), \
1125 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001126
Ying Wang62c81f82013-08-22 20:02:03 -07001127endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001128
1129# The kernel isn't really a module, so to get its module file in there, we
1130# make the target NOTICE files depend on this particular file too, which will
1131# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001132$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001133
Dan Willemsen288bedf2019-05-28 15:36:47 -07001134$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001135
Doug Zongker8678df42009-06-15 14:30:14 -07001136
The Android Open Source Project88b60792009-03-03 19:28:42 -08001137# #################################################################
1138# Targets for user images
1139# #################################################################
1140
Ying Wang933abf12010-06-16 14:31:34 -07001141INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001142ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001143INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1144else
1145ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001146INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1147else
1148ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001149INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1150endif
1151endif
1152endif
1153
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001154# These options tell the recovery updater/installer how to mount the partitions writebale.
1155# <fstype>=<fstype_opts>[|<fstype_opts>]...
1156# fstype_opts := <opt>[,<opt>]...
1157# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001158# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1159DEFAULT_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 -07001160
Ying Wang542903a2010-11-17 15:40:38 -08001161ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1162 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1163endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001164ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1165 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1166endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001167ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1168 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1169endif
Tao Baodba635a2019-06-24 10:39:54 -07001170
1171INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001172 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001173 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001174 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001175
1176ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1177INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001178endif
1179
Yifan Hongcfb917a2020-05-07 14:58:20 -07001180ifneq ($(filter \
1181 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1182 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1183 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1184 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1185 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1186 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1187 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001188INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1189endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001190
Anton Hansson8dab0a62019-03-28 15:45:40 +00001191ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001192INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001193ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001194INTERNAL_USERIMAGES_DEPS += $(FEC)
1195endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001196endif
1197
Tao Baodba635a2019-06-24 10:39:54 -07001198ifeq ($(BOARD_AVB_ENABLE),true)
1199INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1200endif
1201
1202# Get a colon-separated list of search paths.
1203INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1204
Alex Klyubin092c9022017-03-13 13:28:34 -07001205SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001206INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1207
Yifan Hongc5c01242018-11-09 10:27:23 -08001208ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001209
Anton Hansson8dab0a62019-03-28 15:45:40 +00001210ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001211 $(error vboot 1.0 doesn't support logical partition)
1212endif
1213
Yifan Hongc5c01242018-11-09 10:27:23 -08001214endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001215
Ying Wangbd93d422011-10-28 17:02:30 -07001216# $(1): the path of the output dictionary file
Yifan Hongcfb917a2020-05-07 14:58:20 -07001217# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001218# $(3): additional "key=value" pairs to append to the dictionary file.
1219define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001220$(if $(filter $(2),system),\
1221 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001222 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001223 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1224 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1225 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1226 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1227 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1228 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1229 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1230 $(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 +00001231 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1232 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001233 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001234 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001235 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1236)
1237$(if $(filter $(2),system_other),\
1238 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001239)
Yifan Hong760d3c02018-05-30 11:16:46 -07001240$(if $(filter $(2),userdata),\
1241 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1242 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001243 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1244 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001245 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001246 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001247)
Yifan Hong760d3c02018-05-30 11:16:46 -07001248$(if $(filter $(2),cache),\
1249 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1250 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001251 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001252 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001253)
1254$(if $(filter $(2),vendor),\
1255 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1256 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1257 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1258 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1259 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1260 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1261 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1262 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1263 $(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 +00001264 $(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 -07001265 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001266 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001267 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001268)
1269$(if $(filter $(2),product),\
1270 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1271 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1272 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1273 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1274 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1275 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1276 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1277 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1278 $(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 +00001279 $(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 -07001280 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001281 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001282 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001283)
Justin Yun6151e3f2019-06-25 15:58:13 +09001284$(if $(filter $(2),system_ext),\
1285 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1286 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1287 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1288 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1289 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1290 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1291 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1292 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1293 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1294 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1295 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001296 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001297)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001298$(if $(filter $(2),odm),\
1299 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1300 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1301 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1302 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1303 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1304 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1305 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1306 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1307 $(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 +00001308 $(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 +08001309 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001310 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001311 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001312)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001313$(if $(filter $(2),vendor_dlkm),\
1314 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1315 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1316 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1317 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1318 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1319 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1320 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1321 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1322 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1323 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1324 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1325 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1326)
Yifan Hong760d3c02018-05-30 11:16:46 -07001327$(if $(filter $(2),oem),\
1328 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1329 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1330 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1331 $(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 -07001332 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001333)
Tao Bao3602eca2018-07-10 10:53:55 -07001334$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001335
Tao Bao3602eca2018-07-10 10:53:55 -07001336$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001337$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001338$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001339$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001340$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1341$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1342$(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 +00001343$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1344$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1345$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1346$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1347$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001348$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001349$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1350$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1351$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001352$(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 -07001353$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001354$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1355$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1356$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1357$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1358$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001359$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001360$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1361$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1362$(if $(BOARD_AVB_ENABLE),\
1363 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1364 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1365 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1366 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001367$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1368$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1369$(if $(BOARD_AVB_ENABLE),\
1370 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1371 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001372 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001373$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1374$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1375$(if $(BOARD_AVB_ENABLE),\
1376 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1377 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1378 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1379 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001380$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1381$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1382$(if $(BOARD_AVB_ENABLE),\
1383 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1384 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1385 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1386 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001387$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001388$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001389 $(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 +01001390$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001391 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1392 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1393 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1394 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001395$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1396$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1397$(if $(BOARD_AVB_ENABLE),\
1398 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1399 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1400 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1401 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001402$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1403$(if $(BOARD_AVB_ENABLE),\
1404 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1405$(if $(BOARD_AVB_ENABLE),\
1406 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1407 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1408 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1409 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001410$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1411 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001412$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001413 $(hide) echo "system_root_image=true" >> $(1))
1414$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001415$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1416 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001417$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1418endef
1419
1420# $(1): the path of the output dictionary file
1421# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001422PROP_DICTIONARY_IMAGES := oem
1423ifdef BUILDING_CACHE_IMAGE
1424 PROP_DICTIONARY_IMAGES += cache
1425endif
1426ifdef BUILDING_SYSTEM_IMAGE
1427 PROP_DICTIONARY_IMAGES += system
1428endif
Chris Gross203191b2020-05-30 02:39:12 +00001429ifdef BUILDING_SYSTEM_OTHER_IMAGE
1430 PROP_DICTIONARY_IMAGES += system_other
1431endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001432ifdef BUILDING_USERDATA_IMAGE
1433 PROP_DICTIONARY_IMAGES += userdata
1434endif
1435ifdef BUILDING_VENDOR_IMAGE
1436 PROP_DICTIONARY_IMAGES += vendor
1437endif
1438ifdef BUILDING_PRODUCT_IMAGE
1439 PROP_DICTIONARY_IMAGES += product
1440endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001441ifdef BUILDING_SYSTEM_EXT_IMAGE
1442 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001443endif
1444ifdef BUILDING_ODM_IMAGE
1445 PROP_DICTIONARY_IMAGES += odm
1446endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001447ifdef BUILDING_VENDOR_DLKM_IMAGE
1448 PROP_DICTIONARY_IMAGES += vendor_dlkm
1449endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001450define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001451 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001452endef
1453
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001454# $(1): the path of the input dictionary file, where each line has the format key=value
1455# $(2): the key to look up
1456define read-image-prop-dictionary
1457$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1458endef
1459
The Android Open Source Project88b60792009-03-03 19:28:42 -08001460# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001461# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001462
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001463# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001464ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001465
Ying Wang37526142015-03-10 12:02:57 -07001466INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1467 $(ALL_DEFAULT_INSTALLED_MODULES))
1468
Tao Bao10fc9492018-08-14 12:17:48 -07001469INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1470INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1471
1472# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1473# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1474# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1475# the call to FILELIST.
1476ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001477INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001478$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1479else
1480$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1481endif
1482
1483$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001484$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001485 @echo Installed file list: $@
1486 @mkdir -p $(dir $@)
1487 @rm -f $@
1488 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001489 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001490
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001491recovery_sepolicy := \
1492 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001493 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001494 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001495 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1496 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1497 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001498 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001499 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001500 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1501 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1502 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001503
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001504# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1505# SELinux files
1506IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1507
Doug Zongker4647f122009-07-02 09:00:54 -07001508recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1509recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001510recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001511
Anton Hansson45a40da2019-01-18 14:06:34 +00001512# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1513# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1514# which get remapped to a bucket.
1515recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001516ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1517recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001518# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001519# ------160------240------320----------480------------640------
1520# mdpi hdpi xhdpi xxhdpi xxxhdpi
1521recovery_density := $(strip \
1522 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1523 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1524 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1525 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001526endif
1527
1528ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1529recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1530else
Doug Zongker25d55f82014-04-04 13:51:15 -07001531recovery_resources_common := $(recovery_resources_common)-xhdpi
1532endif
1533
Tao Baoe1e829e2018-08-29 20:36:00 -07001534# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1535# Note that the font selected here can be overridden for a particular device by putting a font.png
1536# in its private recovery resources.
1537ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001538recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001539else
Dan Willemsen97672232020-05-27 00:09:16 -07001540recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001541endif
1542
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001543
1544# We will only generate the recovery background text images if the variable
1545# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1546# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1547# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1548# BoardConfig in order to use this feature.
1549ifeq ($(recovery_density),xxxhdpi)
1550TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1551else ifeq ($(recovery_density),xxhdpi)
1552TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1553endif
1554
1555ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1556# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1557ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1558 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1559else
1560 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1561endif
1562
1563
Dan Willemsen97672232020-05-27 00:09:16 -07001564RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001565RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1566RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1567RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1568RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1569
xunchangcc57d312018-12-07 12:12:17 -08001570RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1571RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1572RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1573RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1574RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1575
1576generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001577 $(RECOVERY_INSTALLING_TEXT_FILE) \
1578 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1579 $(RECOVERY_ERASING_TEXT_FILE) \
1580 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001581 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1582 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1583 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1584 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1585 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1586 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001587
Dan Willemsen97672232020-05-27 00:09:16 -07001588resource_dir := bootable/recovery/tools/recovery_l10n/res/
1589resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001590image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001591zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001592$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001593$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001594$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1595$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001596$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001597$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001598$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001599 recovery_installing \
1600 recovery_installing_security \
1601 recovery_erasing \
1602 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001603 recovery_no_command
1604$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001605 recovery_cancel_wipe_data \
1606 recovery_factory_data_reset \
1607 recovery_try_again \
1608 recovery_wipe_data_menu_header \
1609 recovery_wipe_data_confirmation
1610$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001611$(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 -08001612 # Prepares the font directory.
1613 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1614 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001615 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001616 @rm -rf $(dir $@)
1617 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001618 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001619 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001620 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001621 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1622 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1623 --text_name $(text_name) \
1624 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1625 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001626 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001627 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001628else
1629RECOVERY_INSTALLING_TEXT_FILE :=
1630RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1631RECOVERY_ERASING_TEXT_FILE :=
1632RECOVERY_ERROR_TEXT_FILE :=
1633RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001634RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1635RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1636RECOVERY_TRY_AGAIN_TEXT_FILE :=
1637RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1638RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001639endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1640
Ying Wang9a175682015-08-06 11:47:47 -07001641ifndef TARGET_PRIVATE_RES_DIRS
1642TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1643endif
Doug Zongker4647f122009-07-02 09:00:54 -07001644recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001645 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001646recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001647
1648
Andrew Boiefa61ff02012-09-28 09:33:45 -07001649ifdef TARGET_RECOVERY_FSTAB
1650recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1651else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001652recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001653endif
Tao Baoc3c17532016-06-10 10:11:54 -07001654ifdef TARGET_RECOVERY_WIPE
1655recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001656else
Tao Baoc3c17532016-06-10 10:11:54 -07001657recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001658endif
Tao Bao8beab692015-07-22 12:33:18 -07001659
Tao Bao6d5d6232018-03-09 17:04:42 -08001660# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001661# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001662# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1663# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001664#
1665# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001666# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001667# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001668# b) We build a single image that contains boot and recovery both - no recovery image to install
1669# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001670# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001671# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001672# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1673# do bsdiff because boot and recovery will contain different number of entries
1674# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001675# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1676# do bsdiff because boot and recovery will contain different number of entries
1677# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001678
Tom Cherry2929cad2018-09-20 11:04:37 -07001679ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001680 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001681# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001682RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1683ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001684else
Tao Bao8beab692015-07-22 12:33:18 -07001685RECOVERY_RESOURCE_ZIP :=
1686endif
Doug Zongker4647f122009-07-02 09:00:54 -07001687
Tao Bao139c7272018-07-31 13:26:54 -07001688INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1689
1690$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001691 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1692 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1693 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1694 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1695 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1696 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1697 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1698 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1699
1700# Parses the given list of build variables and writes their values as build properties if defined.
1701# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1702# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1703# $(1): Map from the build variable names to property names
1704# $(2): Output file
1705define append-recovery-ui-properties
1706echo "#" >> $(2)
1707echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1708echo "#" >> $(2)
1709$(foreach prop,$(1), \
1710 $(eval _varname := $(call word-colon,1,$(prop))) \
1711 $(eval _propname := $(call word-colon,2,$(prop))) \
1712 $(eval _value := $($(_varname))) \
1713 $(if $(_value), \
1714 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1715endef
1716
1717$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001718 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001719 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1720 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1721 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001722 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001723 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001724 $(hide) mkdir -p $(dir $@)
1725 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001726 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001727 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001728 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001729 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001730 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001731 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1732
Steve Mucklef84668e2020-03-16 19:13:46 -07001733ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001734 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001735ifdef GENERIC_KERNEL_CMDLINE
1736 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1737endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001738else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001739 INTERNAL_RECOVERYIMAGE_ARGS := \
1740 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001741 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001742# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001743ifdef INTERNAL_KERNEL_CMDLINE
1744 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001745endif
1746ifdef BOARD_KERNEL_BASE
1747 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1748endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001749ifdef BOARD_KERNEL_PAGESIZE
1750 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1751endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001752ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001753ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1754 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1755else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001756 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1757endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001758endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001759ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1760 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1761endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001762ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1763 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1764endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001765endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001766ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1767 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1768endif
Doug Zongker4647f122009-07-02 09:00:54 -07001769
J. Avila3f6560e2020-05-11 20:20:03 +00001770$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001771 $(INTERNAL_ROOT_FILES) \
1772 $(INSTALLED_RAMDISK_TARGET) \
1773 $(INTERNAL_RECOVERYIMAGE_FILES) \
1774 $(recovery_sepolicy) \
1775 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1776 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1777 $(recovery_resource_deps) \
1778 $(recovery_fstab)
1779 # Making recovery image
1780 mkdir -p $(TARGET_RECOVERY_OUT)
1781 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1782 # Copying baseline ramdisk...
1783 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1784 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1785 # Modifying ramdisk contents...
1786 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1787 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1788 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1789 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1790 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1791 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1792 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1793 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1794 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1795 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1796 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1797 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1798 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1799 $(foreach item,$(recovery_fstab), \
1800 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1801 $(if $(strip $(recovery_wipe)), \
1802 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1803 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1804 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001805 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001806
Ying Wang747b9f12015-01-30 14:05:22 -08001807# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001808# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001809define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001810 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001811 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001812 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001813 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001814 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001815 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001816 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001817 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001818 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001819 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1820 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001821 )\
1822 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001823 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1824 $(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 +08001825 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001826 $(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 -07001827 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001828 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1829 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001830 $(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 -07001831 $(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 -08001832endef
1833
Dan Willemsend120ac62020-06-12 02:39:34 +00001834recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001835ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001836 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001837endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001838ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001839 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001840endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001841ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001842 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001843endif
Tao Baof4866c72018-08-22 14:35:09 -07001844ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001845 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1846 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1847 else
1848 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1849 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001850endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001851ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001852 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001853endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001854ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001855 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001856endif
Tao Baof4866c72018-08-22 14:35:09 -07001857
Dan Willemsend120ac62020-06-12 02:39:34 +00001858ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1859$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001860 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001861 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001862endif # BOARD_USES_RECOVERY_AS_BOOT
1863
Dan Willemsend120ac62020-06-12 02:39:34 +00001864$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001865 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001866
Tao Bao4594d0e2015-12-22 09:47:46 -08001867ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001868$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001869 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001870 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1871 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001872endif
Doug Zongker56588872012-08-20 15:38:58 -07001873
Ying Wang747b9f12015-01-30 14:05:22 -08001874.PHONY: recoveryimage-nodeps
1875recoveryimage-nodeps:
1876 @echo "make $@: ignoring dependencies"
1877 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1878
Chris Grossa784ef12019-04-22 11:09:57 -07001879else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001880RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001881endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001882
1883.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001884recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001885
Jiyong Park03eb0612017-10-04 21:22:41 +09001886ifneq ($(BOARD_NAND_PAGE_SIZE),)
1887$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001888endif
1889
Jiyong Park03eb0612017-10-04 21:22:41 +09001890ifneq ($(BOARD_NAND_SPARE_SIZE),)
1891$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001892endif
1893
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001894ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07001895# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08001896# the debug ramdisk, which is the original ramdisk plus additional
1897# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
1898# When /force_debuggable is present, /init will load userdebug sepolicy
1899# and property files to allow adb root, if the device is unlocked.
1900
1901ifdef BUILDING_RAMDISK_IMAGE
1902BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
1903INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
1904
1905INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
1906 $(ALL_GENERATED_SOURCES) \
1907 $(ALL_DEFAULT_INSTALLED_MODULES))
1908
1909# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
1910# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
1911# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
1912my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
1913
1914INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
1915INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
1916$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
1917$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
1918
1919# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
1920# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
1921# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
1922$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001923$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001924 echo Installed file list: $@
1925 mkdir -p $(dir $@)
1926 rm -f $@
1927 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001928 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08001929
1930# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
1931# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
1932ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1933my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
1934else
1935my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
1936endif # BOARD_USES_RECOVERY_AS_BOOT
1937
1938$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
1939$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08001940
1941ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1942# 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 +08001943$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08001944else
1945# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
1946$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
1947endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00001948$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001949 $(call pretty,"Target debug ram disk: $@")
1950 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
1951 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08001952 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00001953 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08001954
1955.PHONY: ramdisk_debug-nodeps
1956ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
1957ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00001958ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001959 echo "make $@: ignoring dependencies"
1960 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
1961 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08001962 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00001963 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001964
1965my_debug_ramdisk_sync_dir :=
1966my_debug_ramdisk_root_dir :=
1967
1968endif # BUILDING_RAMDISK_IMAGE
1969
1970# -----------------------------------------------------------------
1971# the boot-debug.img, which is the kernel plus ramdisk-debug.img
1972#
1973# Note: it's intentional to skip signing for boot-debug.img, because it
1974# can only be used if the device is unlocked with verification error.
1975ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07001976ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
1977 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
1978 $(PRODUCT_OUT)/$(k).img)
1979else
1980 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
1981endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08001982
1983# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
1984ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1985INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
1986else
1987INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
1988endif
1989
Bowgo Tsai26b0a262019-05-03 16:38:34 +08001990# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
1991# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
1992# Using a test key to sign boot-debug.img to continue booting with the mismatched
1993# public key, if the device is unlocked.
1994ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001995$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08001996endif
1997
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001998BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
1999INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2000# $(1): the bootimage to sign
2001define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002002$(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 +08002003$(AVBTOOL) add_hash_footer \
2004 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002005 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002006 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2007 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002008$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002009endef
2010
Steve Muckleb3dda772020-03-11 16:03:07 -07002011# $(1): output file
2012define build-debug-bootimage-target
2013 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2014 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2015 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2016endef
2017
Bowgo Tsai0013f552019-03-20 17:59:52 +08002018# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2019$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2020 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002021 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002022
2023.PHONY: bootimage_debug-nodeps
2024bootimage_debug-nodeps: $(MKBOOTIMG)
2025 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002026 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002027
2028endif # TARGET_NO_KERNEL
2029
Bowgo Tsai6a683672020-02-14 19:00:15 +08002030ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2031ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2032# -----------------------------------------------------------------
2033# vendor debug ramdisk
2034# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002035INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002036$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2037$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2038
2039INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2040 $(ALL_GENERATED_SOURCES) \
2041 $(ALL_DEFAULT_INSTALLED_MODULES))
2042
2043# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2044# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2045# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2046# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2047$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2048$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002049$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002050 $(call pretty,"Target vendor debug ram disk: $@")
2051 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2052 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2053 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2054 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2055 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002056 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002057
2058INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2059INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2060$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2061$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2062
2063# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2064# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2065$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2066$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2067 echo Installed file list: $@
2068 mkdir -p $(dir $@)
2069 rm -f $@
2070 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2071 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2072
2073# -----------------------------------------------------------------
2074# vendor_boot-debug.img.
2075INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2076
2077# The util to sign vendor_boot-debug.img with a test key.
2078BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2079INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2080# $(1): the vendor bootimage to sign
2081define test-key-sign-vendor-bootimage
2082$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2083$(AVBTOOL) add_hash_footer \
2084 --image $(1) \
2085 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2086 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2087 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2088$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2089endef
2090
2091ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2092$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2093endif
2094
2095# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2096$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2097 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002098 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002099 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2100 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2101
2102endif # BUILDING_RAMDISK_IMAGE
2103endif # BUILDING_VENDOR_BOOT_IMAGE
2104
Bowgo Tsai0013f552019-03-20 17:59:52 +08002105# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002106# The test harness ramdisk, which is based off debug_ramdisk, plus a
2107# few additional test-harness-specific properties in adb_debug.prop.
2108
2109ifdef BUILDING_RAMDISK_IMAGE
2110BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2111INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2112
2113# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2114# appends a few test harness specific properties into the adb_debug.prop.
2115TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2116TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2117
2118# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2119# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2120TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2121ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2122ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2123
2124# $(1): a list of key=value pairs for additional property assignments
2125# $(2): the target .prop file to append the properties from $(1)
2126define append-test-harness-props
2127 echo "#" >> $(2); \
2128 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2129 echo "#" >> $(2);
2130 $(foreach line,$(1), echo "$(line)" >> $(2);)
2131endef
2132
2133$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002134$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002135 $(call pretty,"Target test harness ram disk: $@")
2136 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2137 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002138 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002139
2140.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002141ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002142 echo "make $@: ignoring dependencies"
2143 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2144 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002145 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002146
2147endif # BUILDING_RAMDISK_IMAGE
2148
2149# -----------------------------------------------------------------
2150# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2151#
2152# Note: it's intentional to skip signing for boot-test-harness.img, because it
2153# can only be used if the device is unlocked with verification error.
2154ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2155
Steve Muckle4866bd62020-04-02 11:31:08 -07002156ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2157 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2158 $(PRODUCT_OUT)/$(k).img)
2159else
2160 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2161endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002162
2163# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2164INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2165
2166# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2167# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2168# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2169# public key, if the device is unlocked.
2170ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2171$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2172endif
2173
Steve Muckle4866bd62020-04-02 11:31:08 -07002174# $(1): output file
2175define build-boot-test-harness-target
2176 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2177 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2178 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2179endef
2180
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002181# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2182$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2183 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002184 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002185
2186.PHONY: bootimage_test_harness-nodeps
2187bootimage_test_harness-nodeps: $(MKBOOTIMG)
2188 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002189 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002190
2191endif # TARGET_NO_KERNEL
2192endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2193
2194# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002195# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002196#
Ying Wang9c649a72012-08-08 15:27:00 -07002197# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2198PDK_FUSION_SYSIMG_FILES := \
2199 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2200 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002201
Dan Willemsen37a19862018-10-31 16:31:46 -07002202INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002203 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002204 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002205 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002206 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002207
Ying Wang82cceba2012-08-13 15:03:00 -07002208FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002209
2210# ASAN libraries in the system image - add dependency.
2211ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002212ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002213 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2214 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2215 endif
2216endif
2217
Tom Cherryd14b8952018-08-09 14:26:00 -07002218FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002219
Ying Wange5e8c5f2011-09-09 16:35:53 -07002220# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002221ifdef BUILDING_SYSTEM_IMAGE
2222
Ying Wange5e8c5f2011-09-09 16:35:53 -07002223# installed file list
2224# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2225# We put installed-files.txt ahead of image itself in the dependency graph
2226# so that we can get the size stat even if the build fails due to too large
2227# system image.
2228INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002229INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2230$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002231$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002232 @echo Installed file list: $@
2233 @mkdir -p $(dir $@)
2234 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002235 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002236 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002237
2238.PHONY: installed-file-list
2239installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002240
2241$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002242
2243systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002244 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002245BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2246
Ying Wang23898df2014-06-18 20:26:24 -07002247# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002248ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002249define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002250$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2251 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2252 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2253 exit 1; \
2254fi
Ying Wang23898df2014-06-18 20:26:24 -07002255$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2256endef
2257else
2258define create-system-vendor-symlink
2259endef
2260endif
2261
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002262# Create symlink /system/product to /product if necessary.
2263ifdef BOARD_USES_PRODUCTIMAGE
2264define create-system-product-symlink
2265$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2266 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2267 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2268 exit 1; \
2269fi
2270$(hide) ln -sf /product $(TARGET_OUT)/product
2271endef
2272else
2273define create-system-product-symlink
2274endef
2275endif
2276
Justin Yun6151e3f2019-06-25 15:58:13 +09002277# Create symlink /system/system_ext to /system_ext if necessary.
2278ifdef BOARD_USES_SYSTEM_EXTIMAGE
2279define create-system-system_ext-symlink
2280$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2281 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2282 echo 'You cannot install files to $(TARGET_OUT)/system_ext while building a separate system_ext.img!' 1>&2; \
Dario Freni5f681e12018-05-29 13:09:01 +01002283 exit 1; \
2284fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002285$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002286endef
2287else
Justin Yun6151e3f2019-06-25 15:58:13 +09002288define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002289endef
2290endif
2291
The Android Open Source Project88b60792009-03-03 19:28:42 -08002292# $(1): output file
2293define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002294 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002295 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002296 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002297 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002298 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002299 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002300 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002301 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002302 $(BUILD_IMAGE) \
2303 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2304 || ( mkdir -p $${DIST_DIR}; \
2305 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2306 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002307endef
2308
Dan Willemsen6b72c732019-06-12 21:33:38 +00002309ifeq ($(BOARD_AVB_ENABLE),true)
2310$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2311endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002312$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002313 $(call build-systemimage-target,$@)
2314
Tao Baoe9d61b02018-08-20 21:09:07 -07002315INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002316SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002317
Tao Baoe9d61b02018-08-20 21:09:07 -07002318# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2319# compatibility, in case device-specific Makefiles still refer to the old name.
2320INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2321
Doug Zongker73ef8252009-07-23 15:12:53 -07002322# The system partition needs room for the recovery image as well. We
2323# now store the recovery image as a binary patch using the boot image
2324# as the source (since they are very similar). Generate the patch so
2325# we can see how big it's going to be, and include that in the system
2326# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002327ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002328ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002329ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002330ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002331diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2332else
2333diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2334endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002335intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2336RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002337$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2338$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002339 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2340 $(INSTALLED_BOOTIMAGE_TARGET) \
2341 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002342 @echo "Construct recovery from boot"
2343 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002344 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002345else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2346RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002347endif # BOARD_USES_FULL_RECOVERY_IMAGE
2348endif # INSTALLED_RECOVERYIMAGE_TARGET
2349endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002350
Yifan Hong9a3cad92020-04-27 19:06:59 -07002351$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002352 @echo "Install system fs image: $@"
2353 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002354 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002355
Tao Baoe9d61b02018-08-20 21:09:07 -07002356systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002357
2358.PHONY: systemimage-nodeps snod
2359systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002360 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002361 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002362 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002363 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002364ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002365 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002366endif
2367
Dan Willemsen67495202019-01-16 12:42:05 -08002368endif # BUILDING_SYSTEM_IMAGE
2369
Anton Hansson30e061b2018-11-12 13:36:46 +00002370.PHONY: sync syncsys
2371sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002372
Ying Wang3a61eeb2016-03-11 10:32:01 -08002373# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002374## platform.zip: system, plus other files to be used in PDK fusion build,
2375## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002376##
2377## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2378## The variable will be typically set from BoardConfig.mk.
2379## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002380ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002381pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002382 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002383pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002384 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002385pdk_classes_dex := $(strip \
2386 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002387 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002388
2389pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2390$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2391$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2392$(pdk_odex_config_mk) :
2393 @echo "PDK odex config makefile: $@"
2394 $(hide) mkdir -p $(dir $@)
2395 $(hide) echo "# Auto-generated. Do not modify." > $@
2396 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2397 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2398 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2399 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2400 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2401 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2402 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2403 )
2404 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002405 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.apk)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002406 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2407 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2408 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2409 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002410 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002411 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2412 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2413 )
2414
keunyoungc0178062013-07-22 14:54:58 -07002415PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002416INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002417
2418$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2419$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002420$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2421# dependencies for the other partitions are defined below after their file lists
2422# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002423$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002424 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002425 rm -f $@ $@.lst
2426 echo "-C $(PRODUCT_OUT)" >> $@.lst
2427 echo "-D $(TARGET_OUT)" >> $@.lst
2428 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2429 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002430ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002431 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002432endif
Dan Willemsen67495202019-01-16 12:42:05 -08002433ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002434 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002435endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002436ifdef BUILDING_SYSTEM_EXT_IMAGE
2437 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002438endif
Dan Willemsen67495202019-01-16 12:42:05 -08002439ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002440 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002441endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002442ifdef BUILDING_VENDOR_DLKM_IMAGE
2443 echo "-D $(TARGET_OUT_VENDOR_DLKM)" >> $@.lst
2444endif
Colin Crossc451a372013-12-18 19:36:44 -08002445ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002446 echo "-C $(OUT_DIR)" >> $@.lst
2447 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2448 if [ -e $$f ]; then \
2449 echo "-f $$f"; \
2450 fi \
2451 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002452endif
keunyoungc0178062013-07-22 14:54:58 -07002453ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002454 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002455endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002456 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002457 $(if $(PRIVATE_DEX_FILES),\
2458 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002459 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002460 touch $(PRODUCT_OUT)/pdk.mk
2461 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2462 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002463
2464.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002465platform: $(INSTALLED_PLATFORM_ZIP)
2466
2467.PHONY: platform-java
2468platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002469
2470# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002471ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2472$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002473endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002474
Colin Cross53c8f972018-09-28 16:19:42 -07002475endif # BUILD_PLATFORM_ZIP
2476
Ying Wang3a61eeb2016-03-11 10:32:01 -08002477# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002478# data partition image
2479INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002480 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002481
Dan Willemsen67495202019-01-16 12:42:05 -08002482ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002483userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002484 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002485BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2486
Ying Wangbd93d422011-10-28 17:02:30 -07002487define build-userdataimage-target
2488 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2489 @mkdir -p $(TARGET_OUT_DATA)
2490 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002491 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002492 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002493 $(BUILD_IMAGE) \
2494 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2495 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2496 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002497endef
2498
Joe Onorato64d85d02009-04-09 19:31:12 -07002499# We just build this directly to the install location.
2500INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002501INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2502 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002503 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002504$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002505 $(build-userdataimage-target)
2506
2507.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002508userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002509 $(build-userdataimage-target)
2510
Dan Willemsen67495202019-01-16 12:42:05 -08002511endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002512
Andreas Gampe039b5c72017-03-24 16:06:31 -07002513# ASAN libraries in the system image - build rule.
2514ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2515 $(TARGET_OUT_SHARED_LIBRARIES) \
2516 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2517 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2518 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002519# Extra options: Enforce the system user for the files to avoid having to change ownership.
2520ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002521# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2522# enough space.
2523$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002524 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 -07002525
The Android Open Source Project88b60792009-03-03 19:28:42 -08002526# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002527# partition table image
2528ifdef BOARD_BPT_INPUT_FILES
2529
2530BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002531BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002532
2533INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2534 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002535 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002536 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2537
2538ifdef BOARD_BPT_DISK_SIZE
2539INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2540endif
2541
2542define build-bptimage-target
2543 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2544 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2545endef
2546
2547INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002548$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2549 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2550
David Zeuthen25328622016-04-08 15:08:03 -04002551$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2552 $(build-bptimage-target)
2553
2554.PHONY: bptimage-nodeps
2555bptimage-nodeps:
2556 $(build-bptimage-target)
2557
2558endif # BOARD_BPT_INPUT_FILES
2559
2560# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002561# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002562ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002563INTERNAL_CACHEIMAGE_FILES := \
2564 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2565
2566cacheimage_intermediates := \
2567 $(call intermediates-dir-for,PACKAGING,cache)
2568BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2569
2570define build-cacheimage-target
2571 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2572 @mkdir -p $(TARGET_OUT_CACHE)
2573 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002574 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002575 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002576 $(BUILD_IMAGE) \
2577 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2578 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2579 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002580endef
2581
2582# We just build this directly to the install location.
2583INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002584$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002585 $(build-cacheimage-target)
2586
2587.PHONY: cacheimage-nodeps
2588cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2589 $(build-cacheimage-target)
2590
Dan Willemsen67495202019-01-16 12:42:05 -08002591else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002592# we need to ignore the broken cache link when doing the rsync
2593IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002594endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002595
David Zeuthen0eb10972016-09-28 17:55:27 -04002596# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002597# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002598ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002599ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002600# Marker file to identify that odex files are installed
2601INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2602ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2603$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2604 $(hide) touch $@
2605endif
2606
Alex Light4e358ab2016-06-16 14:47:10 -07002607INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2608 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2609 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002610 $(ALL_PDK_FUSION_FILES)) \
2611 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002612
Colin Cross6db5b0e2018-11-16 21:26:33 -08002613# system_other dex files are installed as a side-effect of installing system image files
2614INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2615
Alex Light4e358ab2016-06-16 14:47:10 -07002616INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002617INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2618$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002619$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002620 @echo Installed file list: $@
2621 @mkdir -p $(dir $@)
2622 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002623 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002624 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002625
Bowgo Tsai867ab662019-01-29 13:30:18 +08002626# Determines partition size for system_other.img.
2627ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2628ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2629INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2630endif
2631endif
2632
2633ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2634INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2635endif
2636
Alex Light4e358ab2016-06-16 14:47:10 -07002637systemotherimage_intermediates := \
2638 $(call intermediates-dir-for,PACKAGING,system_other)
2639BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2640
2641# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2642define build-systemotherimage-target
2643 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2644 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2645 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002646 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002647 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002648 $(BUILD_IMAGE) \
2649 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2650 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2651 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002652endef
2653
2654# We just build this directly to the install location.
2655INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002656ifneq (true,$(SANITIZE_LITE))
2657# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002658$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2659 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002660endif
Alex Light4e358ab2016-06-16 14:47:10 -07002661
2662.PHONY: systemotherimage-nodeps
2663systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2664 $(build-systemotherimage-target)
2665
Dan Willemsen67495202019-01-16 12:42:05 -08002666endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002667
2668
2669# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002670# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002671ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002672INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002673 $(filter $(TARGET_OUT_VENDOR)/%,\
2674 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002675 $(ALL_PDK_FUSION_FILES)) \
2676 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07002677
2678# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
2679$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07002680
Ying Wang8da19e32015-09-15 14:22:12 -07002681INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002682INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2683$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002684$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07002685 @echo Installed file list: $@
2686 @mkdir -p $(dir $@)
2687 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002688 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002689 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002690
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002691# Create symlink /vendor/odm to /odm if necessary.
2692ifdef BOARD_USES_ODMIMAGE
2693define create-vendor-odm-symlink
2694$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
2695 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
2696 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
2697 exit 1; \
2698fi
2699$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
2700endef
2701else
2702define create-vendor-odm-symlink
2703endef
2704endif
2705
Ying Wanga0febe52013-03-20 11:02:05 -07002706vendorimage_intermediates := \
2707 $(call intermediates-dir-for,PACKAGING,vendor)
2708BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002709define build-vendorimage-target
2710 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2711 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002712 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002713 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002714 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002715 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002716 $(BUILD_IMAGE) \
2717 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2718 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002719 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002720endef
2721
2722# We just build this directly to the install location.
2723INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002724$(INSTALLED_VENDORIMAGE_TARGET): \
2725 $(INTERNAL_USERIMAGES_DEPS) \
2726 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002727 $(INSTALLED_FILES_FILE_VENDOR) \
2728 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002729 $(build-vendorimage-target)
2730
Steven Morelanda2e734d2017-03-07 12:10:09 -08002731.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002732vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002733 $(build-vendorimage-target)
2734
Colin Cross91a52272017-06-20 16:57:52 -07002735sync: $(INTERNAL_VENDORIMAGE_FILES)
2736
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002737else ifdef BOARD_PREBUILT_VENDORIMAGE
2738INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2739$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2740endif
Ying Wanga0febe52013-03-20 11:02:05 -07002741
Ying Wang9f8e8db2011-11-04 11:37:01 -07002742# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002743# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002744ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002745INTERNAL_PRODUCTIMAGE_FILES := \
2746 $(filter $(TARGET_OUT_PRODUCT)/%,\
2747 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002748 $(ALL_PDK_FUSION_FILES)) \
2749 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002750
2751# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2752$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2753
2754INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002755INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2756$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002757$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002758 @echo Installed file list: $@
2759 @mkdir -p $(dir $@)
2760 @rm -f $@
2761 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002762 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002763
2764productimage_intermediates := \
2765 $(call intermediates-dir-for,PACKAGING,product)
2766BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2767define build-productimage-target
2768 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2769 @mkdir -p $(TARGET_OUT_PRODUCT)
2770 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002771 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002772 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002773 $(BUILD_IMAGE) \
2774 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2775 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2776 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002777endef
2778
2779# We just build this directly to the install location.
2780INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002781$(INSTALLED_PRODUCTIMAGE_TARGET): \
2782 $(INTERNAL_USERIMAGES_DEPS) \
2783 $(INTERNAL_PRODUCTIMAGE_FILES) \
2784 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002785 $(build-productimage-target)
2786
2787.PHONY: productimage-nodeps pnod
2788productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2789 $(build-productimage-target)
2790
2791sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2792
2793else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2794INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2795$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2796endif
2797
2798# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002799# system_ext partition image
2800ifdef BUILDING_SYSTEM_EXT_IMAGE
2801INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2802 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01002803 $(ALL_DEFAULT_INSTALLED_MODULES)\
2804 $(ALL_PDK_FUSION_FILES)) \
2805 $(PDK_FUSION_SYMLINK_STAMP)
2806
Justin Yun6151e3f2019-06-25 15:58:13 +09002807# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
2808$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002809
Justin Yun6151e3f2019-06-25 15:58:13 +09002810INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2811INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2812$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2813$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002814 @echo Installed file list: $@
2815 @mkdir -p $(dir $@)
2816 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002817 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002818 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002819
Justin Yun6151e3f2019-06-25 15:58:13 +09002820system_extimage_intermediates := \
2821 $(call intermediates-dir-for,PACKAGING,system_ext)
2822BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2823define build-system_extimage-target
2824 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2825 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2826 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2827 $(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 -07002828 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002829 $(BUILD_IMAGE) \
2830 $(TARGET_OUT_SYSTEM_EXT) \
2831 $(system_extimage_intermediates)/system_ext_image_info.txt \
2832 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2833 $(TARGET_OUT)
2834 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002835endef
2836
2837# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002838INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002839$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2840 $(INTERNAL_USERIMAGES_DEPS) \
2841 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2842 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002843 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002844
Justin Yun6151e3f2019-06-25 15:58:13 +09002845.PHONY: systemextimage-nodeps senod
2846systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2847 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002848
Justin Yun6151e3f2019-06-25 15:58:13 +09002849sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002850
Justin Yun6151e3f2019-06-25 15:58:13 +09002851else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2852INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2853$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002854endif
2855
2856# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002857# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002858ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002859INTERNAL_ODMIMAGE_FILES := \
2860 $(filter $(TARGET_OUT_ODM)/%,\
2861 $(ALL_DEFAULT_INSTALLED_MODULES)\
2862 $(ALL_PDK_FUSION_FILES)) \
2863 $(PDK_FUSION_SYMLINK_STAMP)
2864# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
2865$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
2866
2867INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2868INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2869$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002870$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002871 @echo Installed file list: $@
2872 @mkdir -p $(dir $@)
2873 @rm -f $@
2874 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002875 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002876
2877odmimage_intermediates := \
2878 $(call intermediates-dir-for,PACKAGING,odm)
2879BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2880define build-odmimage-target
2881 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2882 @mkdir -p $(TARGET_OUT_ODM)
2883 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2884 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002885 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002886 $(BUILD_IMAGE) \
2887 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2888 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2889 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002890endef
2891
2892# We just build this directly to the install location.
2893INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002894$(INSTALLED_ODMIMAGE_TARGET): \
2895 $(INTERNAL_USERIMAGES_DEPS) \
2896 $(INTERNAL_ODMIMAGE_FILES) \
2897 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002898 $(build-odmimage-target)
2899
2900.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002901odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002902 $(build-odmimage-target)
2903
2904sync: $(INTERNAL_ODMIMAGE_FILES)
2905
2906else ifdef BOARD_PREBUILT_ODMIMAGE
2907INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2908$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2909endif
2910
2911# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002912# vendor_dlkm partition image
2913ifdef BUILDING_VENDOR_DLKM_IMAGE
2914INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2915 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
2916 $(ALL_DEFAULT_INSTALLED_MODULES)\
2917 $(ALL_PDK_FUSION_FILES)) \
2918 $(PDK_FUSION_SYMLINK_STAMP)
2919# platform.zip depends on $(INTERNAL_VENDOR_DLKMIMAGE_FILES).
2920$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2921
2922INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2923INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2924$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2925$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2926 @echo Installed file list: $@
2927 @mkdir -p $(dir $@)
2928 @rm -f $@
2929 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2930 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2931
2932vendor_dlkmimage_intermediates := \
2933 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2934BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2935define build-vendor_dlkmimage-target
2936 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2937 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2938 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2939 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2940 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2941 $(BUILD_IMAGE) \
2942 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2943 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2944 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2945endef
2946
2947# We just build this directly to the install location.
2948INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2949$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2950 $(INTERNAL_USERIMAGES_DEPS) \
2951 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2952 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2953 $(build-vendor_dlkmimage-target)
2954
2955.PHONY: vendor_dlkmimage-nodeps vdnod
2956vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2957 $(build-vendor_dlkmimage-target)
2958
2959sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2960
2961else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2962INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2963$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2964endif
2965
2966# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07002967# dtbo image
2968ifdef BOARD_PREBUILT_DTBOIMAGE
2969INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
2970
2971ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002972$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002973 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2974 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00002975 --image $@ \
2976 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
2977 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
2978 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002979else
2980$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2981 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2982endif
2983
Tao Bao0da43472018-08-22 22:53:41 -07002984endif # BOARD_PREBUILT_DTBOIMAGE
2985
2986# Returns a list of image targets corresponding to the given list of partitions. For example, it
2987# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
2988# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09002989# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07002990define images-for-partitions
2991$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
2992endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07002993
2994# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07002995# custom images
2996INSTALLED_CUSTOMIMAGES_TARGET :=
2997
2998ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
2999INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3000
3001# Sign custom image.
3002# $(1): the prebuilt custom image.
3003# $(2): the mount point of the prebuilt custom image.
3004# $(3): the signed custom image target.
3005define sign_custom_image
3006$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3007 @echo Target custom image: $(3)
3008 mkdir -p $(dir $(3))
3009 cp $(1) $(3)
3010ifeq ($(BOARD_AVB_ENABLE),true)
3011 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3012 $(AVBTOOL) add_hashtree_footer \
3013 --image $(3) \
3014 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3015 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3016 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3017 --partition_name $(2) \
3018 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3019 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3020endif
3021INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3022endef
3023
3024$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3025 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3026 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3027endif
3028
3029# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003030# vbmeta image
3031ifeq ($(BOARD_AVB_ENABLE),true)
3032
3033BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003034AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003035
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003036ifdef BOARD_AVB_KEY_PATH
3037$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3038else
3039# If key path isn't specified, use the 4096-bit test key.
3040BOARD_AVB_ALGORITHM := SHA256_RSA4096
3041BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3042endif
3043
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003044# AVB signing for system_other.img.
3045ifdef BUILDING_SYSTEM_OTHER_IMAGE
3046ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3047$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3048else
3049# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3050BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3051BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3052endif
3053
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003054$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3055 @echo Extracting system_other avb key: $@
3056 @rm -f $@
3057 @mkdir -p $(dir $@)
3058 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003059
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003060ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3061BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3062endif
3063
3064BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3065endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3066
Tao Bao744c4c72018-08-20 21:09:07 -07003067INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003068 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003069 $(BOARD_AVB_VBMETA_VENDOR)
3070
3071# Not allowing the same partition to appear in multiple groups.
3072ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003073 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003074endif
3075
cfig1aeef722019-09-20 22:45:06 +08003076# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3077# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3078# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003079ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003080ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3081$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003082 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003083 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3084endif
3085endif
3086
Bowgo Tsai9b548012019-05-14 16:57:03 +08003087# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003088
3089BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003090 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003091 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003092 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3093
3094BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003095 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003096 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003097 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3098
Justin Yun6151e3f2019-06-25 15:58:13 +09003099BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003100 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003101 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3102 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003103
Bowgo Tsai9b548012019-05-14 16:57:03 +08003104BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003105 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003106 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3107
Tao Bao19b02fe2019-10-09 00:04:28 -07003108BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3109 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3110
3111BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3112 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3113
Bowgo Tsai9b548012019-05-14 16:57:03 +08003114BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003115 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003116 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3117
3118BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003119 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003120 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3121
Yifan Hongcfb917a2020-05-07 14:58:20 -07003122BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3123 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3124 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3125
Tao Bao19b02fe2019-10-09 00:04:28 -07003126BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3127 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3128
Bowgo Tsai9b548012019-05-14 16:57:03 +08003129# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003130ifdef BOOT_SECURITY_PATCH
3131BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3132 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3133endif
3134
3135ifdef VENDOR_SECURITY_PATCH
3136BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3137 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3138endif
3139
3140ifdef ODM_SECURITY_PATCH
3141BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3142 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3143endif
3144
Yifan Hongcfb917a2020-05-07 14:58:20 -07003145ifdef VENDOR_DLKM_SECURITY_PATCH
3146BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3147 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3148endif
3149
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003150BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003151VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003152DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3153SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3154VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003155RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003156PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003157SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003158ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003159VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003160
Tao Bao0da43472018-08-22 22:53:41 -07003161# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003162# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003163define _check-and-set-avb-chain-args
3164$(eval part := $(1))
3165$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003166
3167$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3168$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3169$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3170$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3171$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3172$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3173$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3174$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3175
3176# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3177$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3178$(eval $(_signing_args) := \
3179 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3180
cfig1aeef722019-09-20 22:45:06 +08003181# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3182# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003183$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003184 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3185 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003186
Tao Bao744c4c72018-08-20 21:09:07 -07003187# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003188# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003189$(if $(filter $(part),$(part:vbmeta_%=%)),\
3190 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3191 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003192endef
3193
Tao Bao0da43472018-08-22 22:53:41 -07003194# Checks and sets the required build variables for an AVB partition. The partition will be
3195# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003196# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3197# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003198# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3199# but vbmeta would capture the image descriptor of only the first boot
3200# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003201# $(1): Partition name, e.g. boot or system.
3202define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003203$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003204$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003205 $(if $(_in_chained_vbmeta),\
3206 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003207 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003208 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003209 $(if $(filter boot,$(1)),\
3210 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3211 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3212 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3213 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003214endef
3215
Hongguang Chenf23364d2020-04-27 18:36:36 -07003216# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3217# $(1): the custom partition to enable AVB chain.
3218define check-and-set-custom-avb-chain-args
3219$(eval part := $(1))
3220$(eval PART=$(call to-upper,$(part)))
3221$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3222$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3223
3224INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3225 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3226endef
3227
Tao Baob1a2e352018-08-14 16:17:12 -07003228ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003229$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003230endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003231
Steve Mucklee1b10862019-07-10 10:49:37 -07003232ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3233$(eval $(call check-and-set-avb-args,vendor_boot))
3234endif
3235
Tao Bao0da43472018-08-22 22:53:41 -07003236$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003237
3238ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003239$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003240endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003241
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003242ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003243$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003244endif
3245
Justin Yun6151e3f2019-06-25 15:58:13 +09003246ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3247$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003248endif
3249
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003250ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003251$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003252endif
3253
Yifan Hongcfb917a2020-05-07 14:58:20 -07003254ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3255$(eval $(call check-and-set-avb-args,vendor_dlkm))
3256endif
3257
Yueyao Zhu211c9012017-04-27 00:34:50 -07003258ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003259$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003260endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003261
David Zeuthen8fecb282017-12-01 16:24:01 -05003262ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003263$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003264endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003265
David Anderson7709ab22018-10-15 14:41:34 -07003266# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3267ifdef BOARD_AVB_VBMETA_SYSTEM
3268$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003269endif
3270
3271ifdef BOARD_AVB_VBMETA_VENDOR
3272$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3273endif
3274
Hongguang Chenf23364d2020-04-27 18:36:36 -07003275ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3276$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3277 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3278endif
3279
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003280# Add kernel cmdline descriptor for kernel to mount system.img as root with
3281# dm-verity. This works when system.img is either chained or not-chained:
3282# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3283# cmdline descriptor to system.img
3284# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3285# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003286ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003287ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003288BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003289endif
David Anderson8916a2a2018-09-18 15:46:59 -07003290endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003291
Tao Bao0da43472018-08-22 22:53:41 -07003292BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003293BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003294BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3295
3296ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003297# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003298BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003299endif
Tao Bao0da43472018-08-22 22:53:41 -07003300
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003301ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003302BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003303endif
3304
David Anderson7709ab22018-10-15 14:41:34 -07003305ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3306BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3307 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003308endif
3309
3310ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3311BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3312 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003313endif
3314
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003315# $(1): the directory to extract public keys to
3316define extract-avb-chain-public-keys
3317 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3318 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3319 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003320 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3321 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3322 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003323 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3324 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3325 --output $(1)/system.avbpubkey)
3326 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3327 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3328 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003329 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3330 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3331 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003332 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3333 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3334 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003335 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3336 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3337 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003338 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3339 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3340 --output $(1)/vendor_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003341 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3342 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3343 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003344 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3345 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3346 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003347 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3348 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3349 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003350 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3351 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3352 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003353 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3354 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3355 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3356 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003357endef
3358
Tao Bao744c4c72018-08-20 21:09:07 -07003359# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3360# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003361# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003362# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3363# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003364# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003365# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003366# $(2): Output filename.
3367define build-chained-vbmeta-image
3368 $(call pretty,"Target chained vbmeta image: $@")
3369 $(hide) $(AVBTOOL) make_vbmeta_image \
3370 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3371 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3372 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3373 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3374 --output $@
3375endef
3376
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003377ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003378ifdef BOARD_AVB_VBMETA_SYSTEM
3379INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3380$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003381 $(AVBTOOL) \
3382 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3383 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003384 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003385endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003386endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003387
3388ifdef BOARD_AVB_VBMETA_VENDOR
3389INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3390$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003391 $(AVBTOOL) \
3392 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3393 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003394 $(call build-chained-vbmeta-image,vbmeta_vendor)
3395endif
3396
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003397define build-vbmetaimage-target
3398 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003399 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3400 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003401 $(hide) $(AVBTOOL) make_vbmeta_image \
3402 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003403 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003404 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3405 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003406 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003407endef
3408
Paul Trautrim4e143232019-08-13 16:30:57 +09003409ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003410INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003411$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3412 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3413
David Zeuthen8fecb282017-12-01 16:24:01 -05003414$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003415 $(AVBTOOL) \
3416 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003417 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003418 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3419 $(INSTALLED_VENDORIMAGE_TARGET) \
3420 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003421 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003422 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003423 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003424 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003425 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003426 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3427 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3428 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3429 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3430 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3431 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003432 $(build-vbmetaimage-target)
3433
3434.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003435vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3436 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003437vbmetaimage-nodeps:
3438 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003439endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003440
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003441endif # BOARD_AVB_ENABLE
3442
3443# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003444# Check VINTF of build
3445
Yifan Hongcfb917a2020-05-07 14:58:20 -07003446# Note: vendor_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003447ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003448
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003449intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3450check_vintf_all_deps :=
3451
Yifan Hongaf9b0702020-01-21 12:46:57 -08003452# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3453# because they are only used for prebuilt images.
3454check_vintf_common_srcs_patterns := \
3455 $(TARGET_OUT)/etc/vintf/% \
3456 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3457 $(TARGET_OUT_ODM)/etc/vintf/% \
3458 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3459 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3460
3461check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3462 $(INTERNAL_SYSTEMIMAGE_FILES) \
3463 $(INTERNAL_VENDORIMAGE_FILES) \
3464 $(INTERNAL_ODMIMAGE_FILES) \
3465 $(INTERNAL_PRODUCTIMAGE_FILES) \
3466 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3467))
3468check_vintf_common_srcs_patterns :=
3469
3470check_vintf_has_system :=
3471check_vintf_has_vendor :=
3472
Yifan Hong28ffd732020-03-13 13:11:10 -07003473ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3474$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3475endif
3476ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3477$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3478endif
3479
Yifan Hong605ea042020-01-14 21:36:00 +00003480# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003481check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3482ifneq ($(check_vintf_system_deps),)
3483check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003484check_vintf_system_log := $(intermediates)/check_vintf_system_log
3485check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003486$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003487 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3488check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003489endif # check_vintf_system_deps
3490check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003491
3492# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003493check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3494ifneq ($(check_vintf_vendor_deps),)
3495check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003496check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3497check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003498# Check vendor SKU=(empty) case when:
3499# - DEVICE_MANIFEST_FILE is not empty; OR
3500# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003501$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003502 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3503 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003504 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003505$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003506 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3507 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3508 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3509 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003510check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003511endif # check_vintf_vendor_deps
3512check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003513
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003514# -- Check VINTF compatibility of build.
3515# Skip partial builds; only check full builds. Only check if:
3516# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003517# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003518# - Building product / system_ext / odm images if board has product / system_ext / odm images
3519ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003520ifeq ($(check_vintf_has_system),true)
3521ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003522ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3523ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3524ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3525
3526check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3527check_vintf_all_deps += $(check_vintf_compatible_log)
3528
3529check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003530check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003531
3532# -- Kernel version and configurations.
3533ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3534
Yifan Hong605ea042020-01-14 21:36:00 +00003535BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3536BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3537
3538my_board_extracted_kernel :=
3539
3540# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3541# from INSTALLED_KERNEL_TARGET.
3542ifdef BOARD_KERNEL_CONFIG_FILE
3543ifdef BOARD_KERNEL_VERSION
3544$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3545 cp $< $@
3546$(BUILT_KERNEL_VERSION_FILE):
3547 echo $(BOARD_KERNEL_VERSION) > $@
3548
3549my_board_extracted_kernel := true
3550endif # BOARD_KERNEL_VERSION
3551endif # BOARD_KERNEL_CONFIG_FILE
3552
3553ifneq ($(my_board_extracted_kernel),true)
3554ifndef INSTALLED_KERNEL_TARGET
3555$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3556 is true. Information about the updated kernel cannot be built into OTA update package. \
3557 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3558 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3559 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3560 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3561 manually.)
3562else
3563
3564# Tools for decompression that is not in PATH.
3565# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3566# Algorithms that are in the script but not in this list will be found in PATH.
3567my_decompress_tools := \
3568 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3569
3570$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3571$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3572$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003573$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3574 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003575 --output-configs $@ \
3576 --output-version $(BUILT_KERNEL_VERSION_FILE)
3577
3578my_decompress_tools :=
3579
3580endif # my_board_extracted_kernel
3581my_board_extracted_kernel :=
3582
3583endif # INSTALLED_KERNEL_TARGET
3584
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003585check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3586check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3587
3588endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3589
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003590check_vintf_compatible_args += \
3591 --dirmap /system:$(TARGET_OUT) \
3592 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3593 --dirmap /odm:$(TARGET_OUT_ODM) \
3594 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3595 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3596
3597ifdef PRODUCT_SHIPPING_API_LEVEL
3598check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3599endif # PRODUCT_SHIPPING_API_LEVEL
3600
3601$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3602$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003603# Check ODM SKU=(empty) case when:
3604# - ODM_MANIFEST_FILES is not empty; OR
3605# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003606$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003607 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3608 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003609 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003610# Check vendor SKU=(empty) case when:
3611# - DEVICE_MANIFEST_FILE is not empty; OR
3612# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003613$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003614 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3615 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003616 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003617$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3618 @echo -n -e 'Deps: \n ' > $@
3619 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3620 @echo -n -e 'Args: \n ' >> $@
3621 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003622 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3623 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003624 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003625 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3626 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3627 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003628
3629check_vintf_compatible_log :=
3630check_vintf_compatible_args :=
3631check_vintf_compatible_deps :=
3632
3633endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3634endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3635endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003636endif # check_vintf_has_vendor
3637endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003638endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3639
3640# Add all logs of VINTF checks to dist builds
3641droid_targets: $(check_vintf_all_deps)
3642$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3643
3644# Helper alias to check all VINTF of current build.
3645.PHONY: check-vintf-all
3646check-vintf-all: $(check_vintf_all_deps)
3647 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3648
Yifan Hongaf9b0702020-01-21 12:46:57 -08003649check_vintf_has_vendor :=
3650check_vintf_has_system :=
3651check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003652check_vintf_all_deps :=
3653intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003654endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003655
3656# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003657# Check image sizes <= size of super partition
3658
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003659ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003660
3661ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003662
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003663# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003664# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003665define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003666 mkdir -p $(dir $(1))
3667 rm -f $(1)
3668 $(call dump-super-image-info, $(1))
3669 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3670 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003671 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003672endef
3673
Yifan Hong30910932019-10-25 20:36:55 -07003674check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3675droid_targets: $(check_all_partition_sizes_log)
3676$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003677
Yifan Hong30910932019-10-25 20:36:55 -07003678$(check_all_partition_sizes_log): \
3679 $(CHECK_PARTITION_SIZES) \
3680 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3681 $(call check-all-partition-sizes-target, \
3682 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3683 $@)
3684
3685.PHONY: check-all-partition-sizes
3686check-all-partition-sizes: $(check_all_partition_sizes_log)
3687
3688.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003689check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003690 $(call check-all-partition-sizes-target, \
3691 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003692
Yifan Hong2dae5722018-07-31 12:47:27 -07003693endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003694
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003695endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003696
3697# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003698# bring in the installer image generation defines if necessary
3699ifeq ($(TARGET_USE_DISKINSTALLER),true)
3700include bootable/diskinstaller/config.mk
3701endif
3702
3703# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003704# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003705
Ying Wangbd2d0242015-09-22 11:17:52 -07003706ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003707 build_ota_package := false
3708 build_otatools_package := false
3709else
Tao Bao9be20c72019-04-08 21:11:59 -07003710 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003711 build_ota_package := true
3712 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3713 build_ota_package := false
3714 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003715 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003716 build_ota_package := false
3717 endif
3718 ifeq ($(TARGET_PRODUCT),sdk)
3719 build_ota_package := false
3720 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003721 ifeq ($(TARGET_BUILD_PDK),true)
3722 build_ota_package := false
3723 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003724 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3725 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3726 build_ota_package := false
3727 endif
3728 ifeq ($(TARGET_NO_KERNEL),true)
3729 build_ota_package := false
3730 endif
3731 ifeq ($(recovery_fstab),)
3732 build_ota_package := false
3733 endif
3734 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003735
Tao Bao9be20c72019-04-08 21:11:59 -07003736 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003737 build_otatools_package := true
3738 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3739 build_otatools_package := false
3740 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003741endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003742
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003743ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003744
3745INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003746 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003747 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003748 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003749 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003750 append2simg \
3751 avbtool \
3752 blk_alloc_to_base_fs \
3753 boot_signer \
3754 brillo_update_payload \
3755 brotli \
3756 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003757 build_image \
3758 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003759 build_verity_metadata \
3760 build_verity_tree \
3761 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003762 check_ota_package_signature \
3763 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003764 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003765 checkvintf \
3766 delta_generator \
3767 e2fsck \
3768 e2fsdroid \
3769 fc_sort \
3770 fec \
3771 fs_config \
3772 generate_verity_key \
3773 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003774 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003775 imgdiff \
3776 libconscrypt_openjdk_jni \
3777 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003778 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003779 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003780 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07003781 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003782 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003783 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003784 mkbootfs \
3785 mkbootimg \
3786 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003787 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003788 mkf2fsuserimg.sh \
3789 mksquashfs \
3790 mksquashfsimage.sh \
3791 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003792 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003793 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003794 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003795 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003796 sign_apex \
3797 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003798 signapk \
3799 simg2img \
3800 sload_f2fs \
3801 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003802 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003803 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003804 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003805 verity_signer \
3806 verity_verifier \
3807 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003808
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003809# Additional tools to unpack and repack the apex file.
3810INTERNAL_OTATOOLS_MODULES += \
3811 apexer \
3812 deapexer \
3813 debugfs_static \
3814 merge_zips \
3815 resize2fs \
3816 soong_zip \
3817
Anton Hansson8dab0a62019-03-28 15:45:40 +00003818ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003819INTERNAL_OTATOOLS_MODULES += \
3820 futility \
3821 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003822endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003823
Tao Bao96daeeb2019-05-01 21:17:13 -07003824INTERNAL_OTATOOLS_FILES := \
3825 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003826
Ying Wang06898662010-06-17 17:52:18 -07003827.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003828otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003829
Tao Bao96daeeb2019-05-01 21:17:13 -07003830# For each module, recursively resolve its host shared library dependencies. Then we have a full
3831# list of modules whose installed files need to be packed.
3832INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3833 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3834 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003835
Tao Bao96daeeb2019-05-01 21:17:13 -07003836INTERNAL_OTATOOLS_PACKAGE_FILES := \
3837 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3838
3839INTERNAL_OTATOOLS_PACKAGE_FILES += \
3840 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3841 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003842
3843ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003844INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003845 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003846 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003847endif
3848ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003849INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003850 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3851 -name "atx_metadata.bin"))
3852endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003853ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003854INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003855 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003856endif
3857
Tao Bao96daeeb2019-05-01 21:17:13 -07003858INTERNAL_OTATOOLS_RELEASETOOLS := \
3859 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3860 \( -type f -o -type l \) -print))
3861
3862BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3863$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3864$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3865$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3866$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003867$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003868 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003869 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3870 mkdir -p $(dir $@)
3871 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3872 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003873 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003874 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003875
3876.PHONY: otatools-package
3877otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3878
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003879endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003880
The Android Open Source Project88b60792009-03-03 19:28:42 -08003881# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003882# misc_info.txt
3883
3884INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3885
3886ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3887# default to common dir for device vendor
3888tool_extensions := $(TARGET_DEVICE_DIR)/../common
3889else
3890tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3891endif
3892.KATI_READONLY := tool_extensions
3893
Steve Muckle903a1ca2020-05-07 17:32:10 -07003894# $1: boot image file name
3895define misc_boot_size
3896$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3897endef
3898
Daniel Normane1e48082019-06-27 13:55:23 -07003899$(INSTALLED_MISC_INFO_TARGET):
3900 rm -f $@
3901 $(call pretty,"Target misc_info.txt: $@")
3902 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3903 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3904ifdef BOARD_FLASH_BLOCK_SIZE
3905 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3906endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07003907ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
3908 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
3909 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07003910endif
3911ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3912 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07003913else
3914 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003915endif
J. Avila98cd4cc2020-06-10 20:09:10 +00003916ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
3917 echo "lz4_ramdisks=true" >> $@
3918endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003919ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3920 echo "vendor_boot=true" >> $@
3921 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3922endif
Daniel Normane1e48082019-06-27 13:55:23 -07003923ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3924 $(hide) echo "no_recovery=true" >> $@
3925endif
3926ifdef BOARD_INCLUDE_RECOVERY_DTBO
3927 $(hide) echo "include_recovery_dtbo=true" >> $@
3928endif
3929ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3930 $(hide) echo "include_recovery_acpio=true" >> $@
3931endif
3932ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3933 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3934endif
3935ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3936 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3937 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3938else
3939 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3940endif
3941 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
3942 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
3943ifdef PRODUCT_EXTRA_RECOVERY_KEYS
3944 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
3945endif
3946 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07003947 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003948 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
3949 $(hide) echo "multistage_support=1" >> $@
3950 $(hide) echo "blockimgdiff_versions=3,4" >> $@
3951ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3952 $(hide) echo "build_generic_ota_package=true" >> $@
3953endif
3954ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
3955 # OTA scripts are only interested in fingerprint related properties
3956 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
3957endif
3958ifneq (,$(filter address, $(SANITIZE_TARGET)))
3959 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
3960 $(hide) echo "userdata_img_with_data=true" >> $@
3961endif
3962ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
3963 $(hide) echo "full_recovery_image=true" >> $@
3964endif
Bill Peckhame868aec2019-09-17 17:06:47 -07003965ifdef BOARD_USES_VENDORIMAGE
3966 $(hide) echo "board_uses_vendorimage=true" >> $@
3967endif
Daniel Normane1e48082019-06-27 13:55:23 -07003968ifeq ($(BOARD_AVB_ENABLE),true)
3969 $(hide) echo "avb_enable=true" >> $@
3970 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
3971 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
3972 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
3973 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
3974ifdef BOARD_AVB_BOOT_KEY_PATH
3975 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
3976 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
3977 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
3978endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07003979 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
3980ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
3981 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
3982 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
3983 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
3984endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07003985 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
3986ifdef BOARD_AVB_RECOVERY_KEY_PATH
3987 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
3988 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
3989 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
3990endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07003991ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
3992 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
3993 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3994 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
3995 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
3996 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
3997 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
3998 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
3999 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4000endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004001ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4002 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4003 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4004 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4005 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4006 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4007endif # BOARD_AVB_VBMETA_SYSTEM
4008ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4009 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4010 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4011 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4012 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4013 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4014endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4015endif # BOARD_AVB_ENABLE
4016ifdef BOARD_BPT_INPUT_FILES
4017 $(hide) echo "board_bpt_enable=true" >> $@
4018 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4019 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4020endif
4021ifdef BOARD_BPT_DISK_SIZE
4022 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4023endif
4024 $(call generate-userimage-prop-dictionary, $@)
4025ifeq ($(AB_OTA_UPDATER),true)
4026 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4027 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4028 $(hide) echo "ab_update=true" >> $@
4029endif
Yifan Hong65afc072020-04-17 10:08:10 -07004030ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4031 $(hide) echo "allow_non_ab=true" >> $@
4032endif
Daniel Normane1e48082019-06-27 13:55:23 -07004033ifdef BOARD_PREBUILT_DTBOIMAGE
4034 $(hide) echo "has_dtbo=true" >> $@
4035ifeq ($(BOARD_AVB_ENABLE),true)
4036 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4037 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4038ifdef BOARD_AVB_DTBO_KEY_PATH
4039 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4040 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4041 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4042endif # BOARD_AVB_DTBO_KEY_PATH
4043endif # BOARD_AVB_ENABLE
4044endif # BOARD_PREBUILT_DTBOIMAGE
4045 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004046 @# VINTF checks
4047ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4048 $(hide) echo "vintf_enforce=true" >> $@
4049endif
4050ifdef ODM_MANIFEST_SKUS
4051 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4052endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004053ifdef ODM_MANIFEST_FILES
4054 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4055endif
4056ifdef DEVICE_MANIFEST_SKUS
4057 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4058endif
4059ifdef DEVICE_MANIFEST_FILE
4060 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4061endif
Daniel Normane1e48082019-06-27 13:55:23 -07004062
4063.PHONY: misc_info
4064misc_info: $(INSTALLED_MISC_INFO_TARGET)
4065
4066droidcore: $(INSTALLED_MISC_INFO_TARGET)
4067
4068# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004069# A zip of the directories that map to the target filesystem.
4070# This zip can be used to create an OTA package or filesystem image
4071# as a post-build step.
4072#
4073name := $(TARGET_PRODUCT)
4074ifeq ($(TARGET_BUILD_TYPE),debug)
4075 name := $(name)_debug
4076endif
4077name := $(name)-target_files-$(FILE_NAME_TAG)
4078
4079intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4080BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4081$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4082$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004083 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004084
4085# $(1): Directory to copy
4086# $(2): Location to copy it to
4087# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4088define package_files-copy-root
4089 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4090 mkdir -p $(2) && \
4091 $(ACP) -rd $(strip $(1))/* $(2); \
4092 fi
4093endef
4094
Tao Baoa04fca32015-11-30 12:22:24 -08004095built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004096
4097# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004098ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004099built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004100 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004101endif
4102
The Android Open Source Project88b60792009-03-03 19:28:42 -08004103$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4104
Dan Willemsen653bea92017-03-21 15:47:37 -07004105tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004106$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004107
Sen Jiang4438fd92016-03-07 16:51:01 -08004108ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004109updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004110endif
4111
4112# Build OTA tools if non-A/B is allowed
4113ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004114updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004115endif
Yifan Hong65afc072020-04-17 10:08:10 -07004116
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004117$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004118
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004119# If we are using recovery as boot, output recovery files to BOOT/.
4120ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4121$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4122else
4123$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4124endif
4125
Dan Willemsen653bea92017-03-21 15:47:37 -07004126ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004127 ifdef OSRELEASED_DIRECTORY
4128 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4129 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4130 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4131 endif
Tao Baoa835f382019-07-18 15:55:30 -07004132
4133 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4134 # additionally include radio or bootloader partitions).
4135 ifeq ($(AB_OTA_PARTITIONS),)
4136 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4137 endif
4138endif
4139
4140ifneq ($(AB_OTA_PARTITIONS),)
4141 ifneq ($(AB_OTA_UPDATER),true)
4142 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4143 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004144endif
4145
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004146# Run fs_config while creating the target files package
4147# $1: root directory
4148# $2: add prefix
4149define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004150(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 -08004151endef
4152
Yifan Hong60bfcc42019-11-01 11:39:45 -07004153# Filter out vendor from the list for AOSP targets.
4154# $(1): list
4155define filter-out-missing-vendor
4156$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4157endef
4158
4159# Information related to dynamic partitions and virtual A/B. This information
4160# is needed for building the super image (see dump-super-image-info) and
4161# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004162# $(1): file
4163define dump-dynamic-partitions-info
4164 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4165 echo "use_dynamic_partitions=true" >> $(1))
4166 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4167 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004168 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4169 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4170 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004171 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4172 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004173 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4174 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4175 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4176 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4177 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4178 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004179 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004180 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4181 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4182 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4183 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4184 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004185 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 -07004186 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4187 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004188 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4189 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004190 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4191 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004192 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4193 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4194 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4195 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4196 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4197 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4198 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4199 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004200 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4201 echo "virtual_ab=true" >> $(1))
4202 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4203 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004204endef
4205
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004206# By conditionally including the dependency of the target files package on the
4207# full system image deps, we speed up builds that do not build the system
4208# image.
4209ifdef BUILDING_SYSTEM_IMAGE
4210$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4211endif
4212
Isaac Chen9e09d472019-07-05 17:30:41 +08004213ifeq ($(BUILD_QEMU_IMAGES),true)
4214MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4215$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4216endif
4217
The Android Open Source Project88b60792009-03-03 19:28:42 -08004218# Depending on the various images guarantees that the underlying
4219# directories are up-to-date.
4220$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004221 $(INSTALLED_RAMDISK_TARGET) \
4222 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004223 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004224 $(INSTALLED_RADIOIMAGE_TARGET) \
4225 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004226 $(INSTALLED_USERDATAIMAGE_TARGET) \
4227 $(INSTALLED_CACHEIMAGE_TARGET) \
4228 $(INSTALLED_VENDORIMAGE_TARGET) \
4229 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004230 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004231 $(INSTALLED_VBMETAIMAGE_TARGET) \
4232 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004233 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004234 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004235 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004236 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4237 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4238 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004239 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004240 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4241 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004242 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004243 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004244 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4245 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4246 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004247 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004248 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004249 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004250 $(LPMAKE) \
4251 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004252 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004253 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004254 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004255 $(SOONG_ZIP) \
4256 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004257 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004258 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004259 $(BUILT_KERNEL_CONFIGS_FILE) \
4260 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004261 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004262 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004263 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004264 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004265 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004266 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004267 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004268 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004269ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004270 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004271 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004272 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004273 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004274ifdef INSTALLED_KERNEL_TARGET
Steve Muckleb3dda772020-03-11 16:03:07 -07004275 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004276endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004277ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004278 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004279else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004280ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004281 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004282endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004283ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004284ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004285 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004286else
Steve Mucklee1b10862019-07-10 10:49:37 -07004287 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004288endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004289endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004290ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004291 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004292endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004293ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004294 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004295endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004296ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004297 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004298endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004299ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004300 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004301endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004302ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004303 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004304endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004305endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004306endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004307 @# Components of the boot image
4308 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004309 $(hide) mkdir -p $(zip_root)/ROOT
4310 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004311 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004312 @# If we are using recovery as boot, this is already done when processing recovery.
4313ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004314ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004315 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004316 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004317endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004318ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004319 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004320endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004321ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004322ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004323 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004324endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004325ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004326 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004327endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004328 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004329ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004330 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004331endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004332ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004333 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004334endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004335else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4336 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4337endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4338endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004339 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4340 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004341 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004342ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4343 mkdir -p $(zip_root)/VENDOR_BOOT
4344 $(call package_files-copy-root, \
4345 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4346ifdef INSTALLED_DTBIMAGE_TARGET
4347 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4348endif
4349ifdef BOARD_KERNEL_BASE
4350 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4351endif
4352ifdef BOARD_KERNEL_PAGESIZE
4353 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4354endif
4355 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4356endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004357ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004358 @# Contents of the system image
4359 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004360 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004361endif
4362ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004363 @# Contents of the data image
4364 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004365 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004366endif
4367ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004368 @# Contents of the vendor image
4369 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004370 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004371endif
Dan Willemsen67495202019-01-16 12:42:05 -08004372ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004373 @# Contents of the product image
4374 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004375 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004376endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004377ifdef BUILDING_SYSTEM_EXT_IMAGE
4378 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004379 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004380 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004381endif
Dan Willemsen67495202019-01-16 12:42:05 -08004382ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004383 @# Contents of the odm image
4384 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004385 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004386endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004387ifdef BUILDING_VENDOR_DLKM_IMAGE
4388 @# Contents of the vendor_dlkm image
4389 $(hide) $(call package_files-copy-root, \
4390 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4391endif
Dan Willemsen67495202019-01-16 12:42:05 -08004392ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004393 @# Contents of the system_other image
4394 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004395 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004396endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004397 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004398 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004399 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004400ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004401ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004402 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004403 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004404endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004405endif
Doug Zongker8678df42009-06-15 14:30:14 -07004406 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004407 @# build them.
4408 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004409 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004410 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004411ifneq ($(tool_extension),)
4412 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4413endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004414 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004415 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004416 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004417ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4418 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4419 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004420endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004421ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4422 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4423 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004424endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004425ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4426 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4427 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004428endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004429ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4430 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4431 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004432endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004433ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4434 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4435 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004436endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004437ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4438 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4439 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4440endif
Yifan Hong65afc072020-04-17 10:08:10 -07004441ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004442ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004443 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004444 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004445endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004446endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004447ifeq ($(AB_OTA_UPDATER),true)
4448 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004449 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004450 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004451 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4452 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004453 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4454 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4455 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004456ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004457 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4458 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4459 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004460endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004461endif
Steve Fungdfbab492015-09-24 18:12:33 -07004462ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004463 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004464 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004465endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004466ifdef BOARD_PREBUILT_VENDORIMAGE
4467 $(hide) mkdir -p $(zip_root)/IMAGES
4468 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4469endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004470ifdef BOARD_PREBUILT_PRODUCTIMAGE
4471 $(hide) mkdir -p $(zip_root)/IMAGES
4472 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4473endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004474ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004475 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004476 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004477endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004478ifdef BOARD_PREBUILT_BOOTIMAGE
4479 $(hide) mkdir -p $(zip_root)/IMAGES
4480 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4481endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004482ifdef BOARD_PREBUILT_ODMIMAGE
4483 $(hide) mkdir -p $(zip_root)/IMAGES
4484 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4485endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004486ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4487 $(hide) mkdir -p $(zip_root)/IMAGES
4488 $(hide) cp $(INSTALLED_VENDOR_DLKIMMAGE_TARGET) $(zip_root)/IMAGES/
4489endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004490ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004491 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4492 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004493endif # BOARD_PREBUILT_DTBOIMAGE
Hongguang Chenf23364d2020-04-27 18:36:36 -07004494ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4495 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4496 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4497 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4498endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004499 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4500 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4501 @# INSTALLED_RADIOIMAGE_TARGET.
4502 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4503 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004504 @# Run fs_config on all the system, vendor, boot ramdisk,
4505 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004506ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004507 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004508endif
4509ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004510 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4511endif
Dan Willemsen67495202019-01-16 12:42:05 -08004512ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004513 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4514endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004515ifdef BUILDING_SYSTEM_EXT_IMAGE
4516 $(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 +01004517endif
Dan Willemsen67495202019-01-16 12:42:05 -08004518ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004519 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4520endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004521ifdef BUILDING_VENDOR_DLKM_IMAGE
4522 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4523endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004524 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004525 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004526ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004527 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004528 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004529endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004530ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4531 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4532endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004533ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4534 @# 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 -08004535 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4536endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004537ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4538 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4539endif
Dan Willemsen67495202019-01-16 12:42:05 -08004540ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004541 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4542endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004543 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004544ifdef BUILT_KERNEL_CONFIGS_FILE
4545 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4546endif
4547ifdef BUILT_KERNEL_VERSION_FILE
4548 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4549endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004550 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4551ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4552 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4553endif
Tao Baocbd6d492019-10-07 22:46:02 -07004554 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4555 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004556ifeq ($(BUILD_QEMU_IMAGES),true)
4557 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4558 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4559endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004560 @# Zip everything up, preserving symlinks and placing META/ files first to
4561 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004562 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004563 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004564 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004565
Ying Wanga0febe52013-03-20 11:02:05 -07004566.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004567target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4568
Ying Wang4709d7c2014-04-14 17:25:43 -07004569ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4570$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4571endif
Doug Zongker367910f2009-06-15 18:56:51 -07004572
Dan Albert4d323332016-10-14 13:23:06 -07004573# -----------------------------------------------------------------
4574# NDK Sysroot Package
4575NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004576$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004577 @echo Package NDK sysroot...
4578 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4579
4580$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4581
Ying Wang09c4b682015-08-11 11:24:19 -07004582ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004583# -----------------------------------------------------------------
4584# OTA update package
4585
Yifan Hong50e79542018-11-08 17:44:12 -08004586# $(1): output file
4587# $(2): additional args
4588define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004589PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004590 $(OTA_FROM_TARGET_FILES) \
4591 --verbose \
4592 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4593 --path $(HOST_OUT) \
4594 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4595 $(2) \
4596 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004597endef
4598
Doug Zongker8678df42009-06-15 14:30:14 -07004599name := $(TARGET_PRODUCT)
4600ifeq ($(TARGET_BUILD_TYPE),debug)
4601 name := $(name)_debug
4602endif
4603name := $(name)-ota-$(FILE_NAME_TAG)
4604
4605INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004606INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4607
Doug Zongker8678df42009-06-15 14:30:14 -07004608$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004609$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004610$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004611 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004612 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004613
4614.PHONY: otapackage
4615otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4616
Tao Bao519d1822018-12-27 12:47:23 -08004617ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004618name := $(TARGET_PRODUCT)
4619ifeq ($(TARGET_BUILD_TYPE),debug)
4620 name := $(name)_debug
4621endif
4622name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4623
4624INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004625$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004626$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4627 $(BUILT_TARGET_FILES_PACKAGE) \
4628 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004629 @echo "Package OTA (retrofit dynamic partitions): $@"
4630 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4631
4632.PHONY: otardppackage
4633
4634otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4635
Tao Bao519d1822018-12-27 12:47:23 -08004636endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004637
Ying Wang09c4b682015-08-11 11:24:19 -07004638endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004639
Ying Wang09a00a62010-10-20 14:01:09 -07004640# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004641# A zip of the appcompat directory containing logs
4642APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4643# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004644ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004645$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004646 $(INSTALLED_RAMDISK_TARGET) \
4647 $(INSTALLED_BOOTIMAGE_TARGET) \
4648 $(INSTALLED_USERDATAIMAGE_TARGET) \
4649 $(INSTALLED_VENDORIMAGE_TARGET) \
4650 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004651 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004652endif
4653$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4654$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4655 @echo "appcompat logs: $@"
4656 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4657 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4658 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4659 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4660
Dario Frenid1011272018-07-23 20:20:15 +01004661# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004662# A zip of the symbols directory. Keep the full paths to make it
4663# more obvious where these files came from.
4664#
4665name := $(TARGET_PRODUCT)
4666ifeq ($(TARGET_BUILD_TYPE),debug)
4667 name := $(name)_debug
4668endif
4669name := $(name)-symbols-$(FILE_NAME_TAG)
4670
4671SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004672# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004673ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004674$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004675 $(INSTALLED_RAMDISK_TARGET) \
4676 $(INSTALLED_BOOTIMAGE_TARGET) \
4677 $(INSTALLED_USERDATAIMAGE_TARGET) \
4678 $(INSTALLED_VENDORIMAGE_TARGET) \
4679 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004680 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004681 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004682 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004683 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004684endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004685$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4686$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004687 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004688 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4689 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004690 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004691 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004692# -----------------------------------------------------------------
4693# A zip of the coverage directory.
4694#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004695name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004696ifeq ($(TARGET_BUILD_TYPE),debug)
4697name := $(name)_debug
4698endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004699COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004700ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004701$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004702 $(INSTALLED_RAMDISK_TARGET) \
4703 $(INSTALLED_BOOTIMAGE_TARGET) \
4704 $(INSTALLED_USERDATAIMAGE_TARGET) \
4705 $(INSTALLED_VENDORIMAGE_TARGET) \
4706 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004707 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004708 $(INSTALLED_ODMIMAGE_TARGET) \
4709 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004710endif
4711$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4712$(COVERAGE_ZIP): $(SOONG_ZIP)
4713 @echo "Package coverage: $@"
4714 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4715 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4716 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4717 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004718
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004719#------------------------------------------------------------------
4720# Export the LLVM profile data tool and dependencies for Clang coverage processing
4721#
4722ifeq (true,$(CLANG_COVERAGE))
4723 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4724 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4725 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4726 $(PROFDATA_ZIP): $(SOONG_ZIP)
4727 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4728
4729 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4730endif
4731
The Android Open Source Project88b60792009-03-03 19:28:42 -08004732# -----------------------------------------------------------------
4733# A zip of the Android Apps. Not keeping full path so that we don't
4734# include product names when distributing
4735#
4736name := $(TARGET_PRODUCT)
4737ifeq ($(TARGET_BUILD_TYPE),debug)
4738 name := $(name)_debug
4739endif
4740name := $(name)-apps-$(FILE_NAME_TAG)
4741
4742APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004743$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004744 @echo "Package apps: $@"
4745 $(hide) rm -rf $@
4746 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004747 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4748 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004749 echo "No apps to zip up. Generating empty apps archive." ; \
4750 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004751 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004752 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004753 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004754
Ying Wangbc415dd2012-08-15 12:22:44 -07004755ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004756#------------------------------------------------------------------
4757# An archive of classes for use in generating code-coverage reports
4758# These are the uninstrumented versions of any classes that were
4759# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004760# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004761
Colin Crossa6bc3a82017-09-27 14:28:41 -07004762JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004763$(JACOCO_REPORT_CLASSES_ALL) :
4764 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004765 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4766 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004767
Ying Wangbc415dd2012-08-15 12:22:44 -07004768endif # EMMA_INSTRUMENT=true
4769
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004770
Ying Wangae9115a2013-08-22 20:52:47 -07004771#------------------------------------------------------------------
4772# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004773#
Ying Wangc62c92c2013-08-28 18:38:25 -07004774PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004775# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004776ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004777$(PROGUARD_DICT_ZIP): \
4778 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4779 $(INSTALLED_RAMDISK_TARGET) \
4780 $(INSTALLED_BOOTIMAGE_TARGET) \
4781 $(INSTALLED_USERDATAIMAGE_TARGET) \
4782 $(INSTALLED_VENDORIMAGE_TARGET) \
4783 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4784 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4785 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004786 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Colin Cross114e8df2019-09-05 17:19:35 -07004787 $(updater_dep)
4788endif
4789$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4790$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004791 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004792 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4793 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4794 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4795 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004796
Tao Bao48a2feb2019-06-28 11:00:05 -07004797
4798ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4799
4800# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4801# $(1): output file
4802define dump-super-image-info
4803 $(call dump-dynamic-partitions-info,$(1))
4804 $(if $(filter true,$(AB_OTA_UPDATER)), \
4805 echo "ab_update=true" >> $(1))
4806endef
4807
4808endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4809
The Android Open Source Project88b60792009-03-03 19:28:42 -08004810# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004811# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004812
4813ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4814
4815# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4816ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4817
4818ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004819
4820# For real devices and for dist builds, build super image from target files to an intermediate directory.
4821INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4822$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4823$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4824 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004825 PATH=$(dir $(LPMAKE)):$$PATH \
4826 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004827
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004828# Skip packing it in dist package because it is in update package.
4829ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004830$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004831endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004832
4833.PHONY: superimage_dist
4834superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07004835
4836endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07004837endif # BOARD_SUPER_PARTITION_SIZE != ""
4838endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004839
Yifan Hongacd862a2019-04-16 15:44:30 -07004840# -----------------------------------------------------------------
4841# super partition image for development
4842
4843ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4844ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4845ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
4846
4847# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
4848# $(1): built image path
4849# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
4850define build-superimage-target
4851 mkdir -p $(dir $(2))
4852 rm -rf $(2)
4853 $(call dump-super-image-info,$(2))
4854 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4855 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09004856 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
4857 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07004858 mkdir -p $(dir $(1))
4859 PATH=$(dir $(LPMAKE)):$$PATH \
4860 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
4861endef
4862
4863INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
4864INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
4865 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
4866
changho.shina8f9f112019-10-15 13:26:19 +09004867ifdef BUILDING_SYSTEM_OTHER_IMAGE
4868ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
4869INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
4870endif
4871endif
4872
Yifan Hongacd862a2019-04-16 15:44:30 -07004873# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
4874# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
4875# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
4876# virtual devices.
4877ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
4878$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4879 $(call pretty,"Target super fs image for debug: $@")
4880 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08004881 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004882
4883droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
4884
4885# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
4886.PHONY: superimage
4887superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08004888
4889$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004890endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
4891
4892# Build $(PRODUCT_OUT)/super.img without dependencies.
4893.PHONY: superimage-nodeps supernod
4894superimage-nodeps supernod: intermediates :=
4895superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4896 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
4897 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
4898 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
4899
4900endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
4901endif # BOARD_SUPER_PARTITION_SIZE != ""
4902endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
4903
4904# -----------------------------------------------------------------
4905# super empty image
4906
Tao Bao48a2feb2019-06-28 11:00:05 -07004907ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004908ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004909
Yifan Hong8b79d162018-11-29 12:32:00 -08004910INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
4911$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
4912$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
4913 $(call pretty,"Target empty super fs image: $@")
4914 mkdir -p $(intermediates)
4915 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07004916 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08004917 PATH=$(dir $(LPMAKE)):$$PATH \
4918 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08004919
4920$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
4921
Yifan Hong2b891ac2018-11-29 12:06:31 -08004922endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07004923endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004924
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004925
4926# -----------------------------------------------------------------
4927# The update package
4928
4929name := $(TARGET_PRODUCT)
4930ifeq ($(TARGET_BUILD_TYPE),debug)
4931 name := $(name)_debug
4932endif
4933name := $(name)-img-$(FILE_NAME_TAG)
4934
4935INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
4936
Tao Bao57f8ed62019-08-14 23:08:18 -07004937$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
4938 $(call pretty,"Package: $@")
4939 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
4940 $(IMG_FROM_TARGET_FILES) \
4941 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
4942 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004943
4944.PHONY: updatepackage
4945updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07004946$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004947
4948
Yifan Hong2b891ac2018-11-29 12:06:31 -08004949# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004950# dalvik something
4951.PHONY: dalvikfiles
4952dalvikfiles: $(INTERNAL_DALVIK_MODULES)
4953
Bo Huf0d50bb2017-08-01 19:02:09 +00004954ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00004955MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08004956MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00004957SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08004958
4959ifdef INSTALLED_SYSTEMIMAGE_TARGET
4960INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08004961INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
4962$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
4963 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
4964 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08004965$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08004966 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
4967 @echo Create system-qemu.img now
4968 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08004969 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00004970
4971systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
4972droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08004973endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004974ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00004975INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004976$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00004977 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004978 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00004979
4980vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
4981droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
4982endif
bohu8fd437c2020-03-30 20:16:13 -07004983
4984ifdef INSTALLED_RAMDISK_TARGET
4985ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4986ifdef INTERNAL_VENDOR_RAMDISK_TARGET
4987INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
4988$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
4989 @echo Create ramdisk-qemu.img
4990 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
4991
4992droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
4993endif
4994endif
4995endif
4996
Anton Hansson32c76fe2018-12-13 14:34:18 +00004997ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004998INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004999$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005000 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005001 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005002
5003productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5004droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5005endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005006ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5007INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5008$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5009 @echo Create system_ext-qemu.img
5010 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005011
Justin Yun6151e3f2019-06-25 15:58:13 +09005012systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5013droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005014endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005015ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005016INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5017$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5018 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005019 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005020
5021odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5022droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5023endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005024
Yifan Hongcfb917a2020-05-07 14:58:20 -07005025ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5026INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5027$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5028 @echo Create vendor_dlkm-qemu.img
5029 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5030
5031vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5032droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5033endif
5034
5035
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005036QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005037$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5038 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005039 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005040 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5041 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005042
5043systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5044droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005045
Bo Huf0d50bb2017-08-01 19:02:09 +00005046endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005047# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005048# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005049ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005050INTERNAL_EMULATOR_PACKAGE_FILES += \
5051 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005052 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005053 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005054 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5055 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005056
5057name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5058
5059INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5060
Ying Wang5d887702015-11-04 10:06:25 -08005061$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005062 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005063 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005064
Ying Wang7d8c5352012-07-26 10:15:21 -07005065endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005066# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005067# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005068# The pdk package (Platform Development Kit)
5069
Keun young Park7fc7aad2012-02-27 15:49:23 -08005070#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5071# include development/pdk/Pdk.mk
5072#endif
5073
The Android Open Source Project88b60792009-03-03 19:28:42 -08005074
5075# -----------------------------------------------------------------
5076# The SDK
5077
The Android Open Source Project88b60792009-03-03 19:28:42 -08005078# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005079sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005080
5081# Build a name that looks like:
5082#
5083# linux-x86 --> android-sdk_12345_linux-x86
5084# darwin-x86 --> android-sdk_12345_mac-x86
5085# windows-x86 --> android-sdk_12345_windows
5086#
5087sdk_name := android-sdk_$(FILE_NAME_TAG)
5088ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005089 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005090else
Joe Onorato03fbe402009-04-13 08:31:16 -07005091 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005092endif
5093ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005094 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005095endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005096sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005097
5098sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5099
5100ATREE_FILES :=
5101-include $(sdk_dep_file)
5102
5103# if we don't have a real list, then use "everything"
5104ifeq ($(strip $(ATREE_FILES)),)
5105ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005106 $(ALL_DEFAULT_INSTALLED_MODULES) \
5107 $(INSTALLED_RAMDISK_TARGET) \
5108 $(ALL_DOCS) \
5109 $(ALL_SDK_FILES)
5110endif
5111
5112atree_dir := development/build
5113
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005114
The Android Open Source Project88b60792009-03-03 19:28:42 -08005115sdk_atree_files := \
5116 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005117 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005118
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005119# development/build/sdk-android-<abi>.atree is used to differentiate
5120# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5121# files like the kernel image. We use TARGET_CPU_ABI because we don't
5122# have a better way to distinguish between CPU models.
5123ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5124 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5125endif
5126
Anton Hansson8dab0a62019-03-28 15:45:40 +00005127ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5128sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005129else
5130sdk_atree_files += $(atree_dir)/sdk.atree
5131endif
5132
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005133include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005134
The Android Open Source Project88b60792009-03-03 19:28:42 -08005135deps := \
5136 $(target_notice_file_txt) \
5137 $(tools_notice_file_txt) \
5138 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005139 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005140 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005141 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005142 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005143 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005144 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005145 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005146 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005147 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005148 $(INSTALLED_USERDATAIMAGE_TARGET) \
5149 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005150 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005151 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005152 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005153 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005154 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005155 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005156 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005157
5158INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5159$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5160$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5161$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5162$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5163
5164# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5165#
5166#SDK_GNU_ERROR := true
5167
Ying Wang5d887702015-11-04 10:06:25 -08005168$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005169 @echo "Package SDK: $@"
5170 $(hide) rm -rf $(PRIVATE_DIR) $@
5171 $(hide) for f in $(target_gnu_MODULES); do \
5172 if [ -f $$f ]; then \
5173 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5174 including GNU target $$f >&2; \
5175 FAIL=$(SDK_GNU_ERROR); \
5176 fi; \
5177 done; \
5178 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005179 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005180 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005181 ATREE_STRIP="$(HOST_STRIP) -x" \
5182 $(HOST_OUT_EXECUTABLES)/atree \
5183 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5184 -m $(PRIVATE_DEP_FILE) \
5185 -I . \
5186 -I $(PRODUCT_OUT) \
5187 -I $(HOST_OUT) \
5188 -I $(TARGET_COMMON_OUT_ROOT) \
5189 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5190 -v "OUT_DIR=$(OUT_DIR)" \
5191 -v "HOST_OUT=$(HOST_OUT)" \
5192 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5193 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5194 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5195 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5196 -o $(PRIVATE_DIR) && \
5197 cp -f $(target_notice_file_txt) \
5198 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5199 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5200 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5201 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5202 chmod -R ug+rwX $(PRIVATE_DIR) && \
5203 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005204 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5205
Raphael3d224a02010-04-16 17:50:09 -07005206
5207# Is a Windows SDK requested? If so, we need some definitions from here
5208# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005209MAIN_SDK_NAME := $(sdk_name)
5210MAIN_SDK_DIR := $(sdk_dir)
5211MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005212ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005213include $(TOPDIR)development/build/tools/windows_sdk.mk
5214endif
5215
The Android Open Source Project88b60792009-03-03 19:28:42 -08005216# -----------------------------------------------------------------
5217# Findbugs
5218INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5219INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5220$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5221 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005222 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005223 > $@
5224$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5225 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005226 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005227 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005228
5229# -----------------------------------------------------------------
5230# Findbugs
5231
5232# -----------------------------------------------------------------
5233# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005234ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005235include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005236-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005237-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005238-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005239# Also the project-specific tasks
5240-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5241-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005242-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005243# Also add test specifc tasks
5244include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005245include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005246endif
Raphaelc4d47312011-02-15 16:09:36 -08005247
Ying Wang67132ba2015-10-28 16:42:39 -07005248include $(BUILD_SYSTEM)/product-graph.mk
5249
Raphaelc4d47312011-02-15 16:09:36 -08005250# -----------------------------------------------------------------
5251# Create SDK repository packages. Must be done after tasks/* since
5252# we need the addon rules defined.
5253ifneq ($(sdk_repo_goal),)
5254include $(TOPDIR)development/build/tools/sdk_repo.mk
5255endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005256
5257# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005258# Soong generates the list of all shared libraries that are depended on by fuzz
5259# targets. It saves this list as a source:destination pair to
5260# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5261# build of the unstripped shared library, and the destination is the
5262# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5263# where fuzz target shared libraries are to be "reinstalled". The
5264# copy-many-files below generates the rules to copy the unstripped shared
5265# libraries to the device or host "reinstallation" directory. These rules are
5266# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5267# a dependency on each shared library that it needs to be "reinstalled".
5268FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5269
5270# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005271# The rule to build all fuzz targets, and package them.
5272# Note: The packages are created in Soong, and in a perfect world,
5273# we'd be able to create the phony rule there. But, if we want to
5274# have dist goals for the fuzz target, we need to have the PHONY
5275# target defined in make. MakeVarsContext.DistForGoal doesn't take
5276# into account that a PHONY rule create by Soong won't be available
5277# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005278# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005279# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005280.PHONY: haiku
5281haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5282$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005283
5284# -----------------------------------------------------------------
5285# The makefile for haiku line coverage.
5286include $(BUILD_SYSTEM)/line_coverage.mk