blob: da3ddc77fbdb60fba923d3da41cbbd7a5c64dec6 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
The Android Open Source Project88b60792009-03-03 19:28:42 -08007# -----------------------------------------------------------------
8# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -07009# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080010# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
11# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080012# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070013# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070014#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070015#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070016define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070017$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
18 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080019 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
20$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
21 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
22 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
23 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
24 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
25 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
26 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
27 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
28 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
29 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
30 use vintf_compatibility_matrix / vintf_fragments instead!)) \
31 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
32 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
33 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
34 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
35 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
36 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
37 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
38 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
39 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
40)
Ying Wang68864102011-09-29 13:23:25 -070041endef
Yo Chiang0b49c032020-03-17 17:49:49 +080042
Yo Chiang0b49c032020-03-17 17:49:49 +080043check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080044ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
45check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080046endif
47check_elf_prebuilt_product_copy_files_hint := \
48 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
49
Ying Wang619fccf2012-09-05 18:08:29 -070050# filter out the duplicate <source file>:<dest file> pairs.
51unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080052$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070053 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
54 $(eval unique_product_copy_files_pairs += $(cf))))
55unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080056product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070057$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070058 $(eval _src := $(call word-colon,1,$(cf))) \
59 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070060 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080061 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080062 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070063 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070064 $(if $(filter %.xml,$(_dest)),\
65 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010066 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
67 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070068 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
69 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080070 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
71 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
72 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
73 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070074 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080075
76# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070077pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
78$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
79$(pcf_ignored_file):
80 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080081
Dan Willemsen7537fd02018-10-16 23:15:08 -070082$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
83
84pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080085product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070086unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070087unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080088
89# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080090# Returns the max allowed size for an image suitable for hash verification
91# (e.g., boot.img, recovery.img, etc).
92# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
93# $(1): partition size to flash the image
94define get-hash-image-max-size
95$(if $(1), \
96 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
97 $(eval _hash_meta_size := 69632), \
98 $(eval _hash_meta_size := 0)) \
99 $(1)-$(_hash_meta_size))
100endef
101
102# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800103# Define rules to copy headers defined in copy_headers.mk
104# If more than one makefile declared a header, print a warning,
105# then copy the last one defined. This matches the previous make
106# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700107has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800108$(foreach dest,$(ALL_COPIED_HEADERS), \
109 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800110 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800111 $(if $(call streq,$(_src),$(_srcs)),, \
112 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800113 $(warning _ Using $(_src)) \
114 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
115 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
116 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
117 $(warning _ Ignoring $(src)) \
118 $(warning __ from $(firstword $(_makefiles))) \
119 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
120 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800121 $(eval $(call copy-one-header,$(_src),$(dest))))
122all_copied_headers: $(ALL_COPIED_HEADERS)
123
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700124ifdef has_dup_copy_headers
125 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700126 $(error duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers)
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700127endif
128
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800129$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
130
Dan Willemsen6f60f022016-02-23 13:40:07 -0800131# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100133ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134gen := $(OUT_DOCS)/index.html
135ALL_DOCS += $(gen)
136$(gen): frameworks/base/docs/docs-redirect-index.html
137 @mkdir -p $(dir $@)
138 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700139endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
Dan Albert303e6032017-10-04 10:20:20 -0700141ndk_doxygen_out := $(OUT_NDK_DOCS)
142ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
143ndk_docs_src_dir := frameworks/native/docs
144ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
145ifneq ($(wildcard $(ndk_docs_src_dir)),)
146ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
147 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
148$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
149 @mkdir -p $(ndk_doxygen_out)
150 @echo "Generating NDK docs to $(ndk_doxygen_out)"
151 @( cat $(ndk_doxyfile); \
152 echo "INPUT=$(ndk_headers)"; \
153 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
154 ) | doxygen -
155
156# Note: Not a part of the docs target because we don't have doxygen available.
157# You can run this target locally if you have doxygen installed.
158ndk-docs: $(ndk_doxygen_out)/index.html
159.PHONY: ndk-docs
160endif
161
Colin Crossd60401a2019-04-18 14:46:48 -0700162$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800163
Andres Moralesb8876e12015-05-06 20:44:22 -0700164INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700165ifdef BUILDING_RECOVERY_IMAGE
166ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
167INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
168endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700169endif
170
Jiyong Parke1346862020-05-18 14:31:30 +0900171include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100172
173# ----------------------------------------------------------------
174
175# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800176# sdk-build.prop
177#
178# There are certain things in build.prop that we don't want to
179# ship with the sdk; remove them.
180
181# This must be a list of entire property keys followed by
182# "=" characters, without any internal spaces.
183sdk_build_prop_remove := \
184 ro.build.user= \
185 ro.build.host= \
186 ro.product.brand= \
187 ro.product.manufacturer= \
188 ro.product.device=
189# TODO: Remove this soon-to-be obsolete property
190sdk_build_prop_remove += ro.build.product=
191INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
192$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
193 @echo SDK buildinfo: $@
194 @mkdir -p $(dir $@)
195 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000196 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000198 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800199 $(hide) mv $@.tmp $@
200
201# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700202# kernel modules
203
204# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
205DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
206
J. Avilaa2ceec62020-05-12 23:40:02 +0000207define copy-and-strip-kernel-module
208$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000209 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000210endef
211
Colin Cross4f60e362019-06-05 11:53:43 -0700212# $(1): modules list
213# $(2): output dir
214# $(3): mount point
215# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700216# $(5): module load list
217# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800218# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000219# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700220# $(9): module directory name
Colin Cross4f60e362019-06-05 11:53:43 -0700221# Returns the a list of src:dest pairs to install the modules using copy-many-files.
222define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700223 $(if $(9), \
224 $(eval _dir := $(9)/), \
225 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000226 $(foreach module,$(1), \
227 $(eval _src := $(module)) \
228 $(if $(8), \
229 $(eval _src := $(8)/$(notdir $(module))) \
230 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700231 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700232 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700233 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
234 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
235 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
236 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700237endef
238
239# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700240# $(2): mount point
241# $(3): staging dir
242# $(4): module load list
243# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800244# $(6): module archive
245# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700246# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800247# TODO(b/144844424): If a module archive is being used, this step (which
248# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
249# the output directory. This should be moved to a module with a
250# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
251# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700252define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700253$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle474e4d02019-06-19 12:56:48 -0700254$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
255$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
256$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700257$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700258$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
259$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
260$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800261$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
262$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
263$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700264 @echo depmod $$(PRIVATE_STAGING_DIR)
265 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700266 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800267 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700268 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800269 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700270 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800271 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
272 )
273 $(if $(1),\
274 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
275 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
276 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
277 done; \
278 )
Colin Cross4f60e362019-06-05 11:53:43 -0700279 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
280 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700281 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
282 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700283endef
284
Steve Muckle474e4d02019-06-19 12:56:48 -0700285# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700286# $(2): modules list
287# $(3): module load list
288# $(4): module load list filename
289# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700290define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700291 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
292 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700293endef
294
295# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700296# $(2): modules list
297# $(3): module load list
298# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700299define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700300$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
301$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
302 @echo load-list $$(@)
303 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700304endef
305
Steve Muckle2335d762020-05-28 18:39:38 -0700306# $(1): image name
307# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
308# $(3): mount point
309# $(4): module load filename
310# $(5): stripped staging directory
311# $(6): kernel module directory name (top is an out of band value for no directory)
312define build-image-kernel-modules-dir
313$(if $(filter top,$(6)),\
314 $(eval _kver :=)$(eval _sep :=),\
315 $(eval _kver := $(6))$(eval _sep :=_))\
316$(if $(5),\
317 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
318 $(eval _stripped_staging_dir :=))\
319$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
320 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
321 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
322 $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver))))
323endef
324
325# $(1): kernel module directory name (top is an out of band value for no directory)
326define build-recovery-as-boot-load
327$(if $(filter top,$(1)),\
328 $(eval _kver :=)$(eval _sep :=),\
329 $(eval _kver := $(1))$(eval _sep :=_))\
330 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
331 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_module_list$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load,$(TARGET_RECOVERY_ROOT_OUT))))
332endef
333
334# $(1): kernel module directory name (top is an out of band value for no directory)
335define build-vendor-ramdisk-recovery-load
336$(if $(filter top,$(1)),\
337 $(eval _kver :=)$(eval _sep :=),\
338 $(eval _kver := $(1))$(eval _sep :=_))\
339 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
340 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_RAMDISK_OUT))))
341endef
342
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700343# $(1): kernel module directory name (top is an out of band value for no directory)
344define build-vendor-charger-load
345$(if $(filter top,$(1)),\
346 $(eval _kver :=)$(eval _sep :=),\
347 $(eval _kver := $(1))$(eval _sep :=_))\
348 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
349 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_OUT_VENDOR))))
350endef
351
Steve Mucklee1b10862019-07-10 10:49:37 -0700352ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
353 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
354 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700355 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700356 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
357endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700358
Steve Muckle69280d22019-07-11 12:23:38 -0700359ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
360 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700361endif
362
Steve Mucklee1b10862019-07-10 10:49:37 -0700363ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700364 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700365 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700366 endif
367endif
368
J. Avilaa2ceec62020-05-12 23:40:02 +0000369ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
370 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
371else
372 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
373endif
Colin Cross4f60e362019-06-05 11:53:43 -0700374
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700375ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
376 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
377else
378 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
379endif
380
Steve Muckle2335d762020-05-28 18:39:38 -0700381BOARD_KERNEL_MODULE_DIRS += top
382$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
383 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700384 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(TARGET_VENDOR_RAMDISK_OUT),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700385 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
Yifan Honge51dff22020-06-23 17:26:57 -0700386 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700387 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Yifan Hong3d5e2c22020-07-15 17:01:14 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700389 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
390 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
391 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700392
393# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700395# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900396# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700397# $2 certificate
398# $3 private key
399# $4 compressed
400# $5 partition tag
401# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100402define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700403$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
404$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
405$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
406$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700407
408endef
409
Jaewoong Jung704b4542020-06-29 19:37:53 -0700410# -----------------------------------------------------------------
411# Merge an individual apkcerts output into the final apkcerts.txt output.
412# Use a macro to make it compatible with _apkcerts_write_line
413# $1 apkcerts file to be merged
414# $2 output file
415define _apkcerts_merge
416$(hide) cat $1 >> $2
417
418endef
419
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420name := $(TARGET_PRODUCT)
421ifeq ($(TARGET_BUILD_TYPE),debug)
422 name := $(name)_debug
423endif
424name := $(name)-apkcerts-$(FILE_NAME_TAG)
425intermediates := \
426 $(call intermediates-dir-for,PACKAGING,apkcerts)
427APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700428all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
429$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800430# We don't need to really build all the modules.
431# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700432$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433 @echo APK certs list: $@
434 @mkdir -p $(dir $@)
435 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700436 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700437 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
438 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
439 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
440 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
441 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Ying Wangd9a88d52012-10-26 09:21:28 -0700442 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700443 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444
445.PHONY: apkcerts-list
446apkcerts-list: $(APKCERTS_FILE)
447
Ying Wang15e487a2011-02-15 10:56:18 -0800448ifneq (,$(TARGET_BUILD_APPS))
449 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900450 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800451endif
Ying Wangefb21682010-07-23 16:42:13 -0700452
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900453
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700455# build system stats
456BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
457$(BUILD_SYSTEM_STATS):
458 @rm -f $@
459 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
460 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
461$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700462
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800464# build /product/etc/security/avb/system_other.avbpubkey if needed
465ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800466ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800467INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
468ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800469endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800470endif # BUILDING_SYSTEM_OTHER_IMAGE
471
472# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700473# Modules ready to be converted to Soong, ordered by how many
474# modules depend on them.
475SOONG_CONV := $(sort $(SOONG_CONV))
476SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
477$(SOONG_CONV_DATA):
478 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700479 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS))),$(sort $(SOONG_CONV.$(s).MAKEFILES)),$(sort $(SOONG_CONV.$(s).INSTALLED))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700480
Colin Crossfdea8932017-12-06 14:38:40 -0800481SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700482SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
483$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
484 @rm -f $@
485 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
486$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
487
Joe Onorato02fb89a2020-06-27 00:10:23 -0700488MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
489MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
490$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
491$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
492 @rm -f $@
493 $(hide) $(MK2BP_CATALOG_SCRIPT) \
494 --device=$(TARGET_DEVICE) \
495 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
496 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
497 --out_dir="$(OUT_DIR)" \
498 > $@
499$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
500
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700501# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800502# Modules use -Wno-error, or added default -Wall -Werror
503WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
504$(WALL_WERROR):
505 @rm -f $@
506 echo "# Modules using -Wno-error" >> $@
507 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800508 echo "# Modules added default -Wall" >> $@
509 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
510
511$(call dist-for-goals,droidcore,$(WALL_WERROR))
512
513# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700514# C/C++ flag information for modules
515$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
516
517# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800518# Modules missing profile files
519PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
520$(PGO_PROFILE_MISSING):
521 @rm -f $@
522 echo "# Modules missing PGO profile files" >> $@
523 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
524
525$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
526
527# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700528# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700529# for future OTA packages installed by this system. Actual product
530# deliverables will be re-signed by hand. We expect this file to
531# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700532DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700533
534
Jeff Browne33ba4c2011-07-11 22:11:46 -0700535# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800536# if they don't do anything.
537.PHONY: systemimage
538systemimage:
539
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800540# -----------------------------------------------------------------
541
542.PHONY: event-log-tags
543
Joe Onoratob7510532010-07-14 10:22:54 -0700544# Produce an event logs tag file for everything we know about, in order
545# to properly allocate numbers. Then produce a file that's filtered
546# for what's going to be installed.
547
548all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
549
Colin Crossdc8f8e42012-04-12 13:25:54 -0700550event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
551
Joe Onoratob7510532010-07-14 10:22:54 -0700552# Include tags from all packages that we know about
553all_event_log_tags_src := \
554 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
555
Dan Willemsena3f66322020-05-28 15:46:33 -0700556$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
557$(all_event_log_tags_file): $(all_event_log_tags_src) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700558 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900559 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700560
Doug Zongkera34fa952011-02-23 12:17:29 -0800561# Include tags from all packages included in this product, plus all
562# tags that are part of the system (ie, not in a vendor/ or device/
563# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800564event_log_tags_src := \
565 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800566 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800568 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
569 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800570
Dan Willemsena3f66322020-05-28 15:46:33 -0700571$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700572$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700573$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800574 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900575 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800576
577event-log-tags: $(event_log_tags_file)
578
579ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
580
Joe Onoratob7510532010-07-14 10:22:54 -0700581
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582# #################################################################
583# Targets for boot/OS images
584# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800585ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
586 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000587 ifdef BOARD_PREBUILT_BOOTLOADER
588 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
589 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
590 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800591 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
592 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
593 else
594 INSTALLED_2NDBOOTLOADER_TARGET :=
595 endif
596else
597 INSTALLED_BOOTLOADER_MODULE :=
598 INSTALLED_2NDBOOTLOADER_TARGET :=
599endif # TARGET_NO_BOOTLOADER
600ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700601 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
602 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
603 $(PRODUCT_OUT)/$(k))
604 else
605 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
606 endif
Ying Wangc6349742014-01-13 16:14:20 -0800607else
608 INSTALLED_KERNEL_TARGET :=
609endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610
611# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700612# the root dir
613INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800614 $(ALL_GENERATED_SOURCES) \
615 $(ALL_DEFAULT_INSTALLED_MODULES))
616
Luis Hector Chavezff489932018-07-03 15:41:40 -0700617INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
618INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
619$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700620$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700621 @echo Installed file list: $@
622 @mkdir -p $(dir $@)
623 @rm -f $@
624 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700625 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700626
627$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
628
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800629#------------------------------------------------------------------
630# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700631ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800632INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700633ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800634$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800635 cat $^ > $@
636endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700637endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800638
Tom Cherryd14b8952018-08-09 14:26:00 -0700639# -----------------------------------------------------------------
640# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800641ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700642INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
643 $(ALL_GENERATED_SOURCES) \
644 $(ALL_DEFAULT_INSTALLED_MODULES))
645
646INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
647INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
648$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700649$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700650 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800651 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700652 @mkdir -p $(dir $@)
653 @rm -f $@
654 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700655 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700656
657$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700658BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
659
J. Avila3f6560e2020-05-11 20:20:03 +0000660ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
661# -l enables the legacy format used by the Linux kernel
662COMPRESSION_COMMAND_DEPS := $(LZ4)
663COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
664RAMDISK_EXT := .lz4
665else
666COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
667COMPRESSION_COMMAND := $(MINIGZIP)
668RAMDISK_EXT := .gz
669endif
670
Joe Onorato64d85d02009-04-09 19:31:12 -0700671# We just build this directly to the install location.
672INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000673$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800674 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000675 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800676
Ying Wangad7fd292013-08-08 16:34:29 -0700677.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000678ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700679 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000680 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800681
Dan Willemsen67495202019-01-16 12:42:05 -0800682endif # BUILDING_RAMDISK_IMAGE
683
The Android Open Source Project88b60792009-03-03 19:28:42 -0800684# -----------------------------------------------------------------
685# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700686
687# This is defined here since we may be building recovery as boot
688# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700689ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
690 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
691else
692 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
693endif
694
Steve Muckle04b6f052020-08-09 14:36:56 -0700695# $1: boot image target
696# returns the kernel used to make the bootimage
697define bootimage-to-kernel
698 $(if $(BOARD_KERNEL_BINARIES),\
699 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
700 $(INSTALLED_KERNEL_TARGET))
701endef
702
Steve Muckle903a1ca2020-05-07 17:32:10 -0700703ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
704 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
705endif
706
707# $1: boot image file name
708# $2: boot image variant (boot, boot-debug)
709define get-bootimage-partition-size
710 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
711endef
Chris Grossa784ef12019-04-22 11:09:57 -0700712
713ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700715 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700716
717ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
718INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
719endif
720
Steve Mucklee1b10862019-07-10 10:49:37 -0700721ifndef BUILDING_VENDOR_BOOT_IMAGE
722ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
723 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
724endif
725endif
726
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
728
Anton Hansson8dab0a62019-03-28 15:45:40 +0000729ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700730ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000731VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700732 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
733endif
734endif
735
Anton Hansson72e36f02019-02-26 17:36:30 +0000736INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700737
738ifndef BUILDING_VENDOR_BOOT_IMAGE
739ifdef BOARD_KERNEL_BASE
740 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
741endif
742ifdef BOARD_KERNEL_PAGESIZE
743 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
744endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700745ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700746 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
747endif
748else
749# building vendor boot image, dtb/base/pagesize go there
750ifdef GENERIC_KERNEL_CMDLINE
751 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
752endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700753endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700754
Sami Tolvanen3303d902016-03-15 16:49:30 +0000755INTERNAL_MKBOOTIMG_VERSION_ARGS := \
756 --os_version $(PLATFORM_VERSION) \
757 --os_patch_level $(PLATFORM_SECURITY_PATCH)
758
Chris Grossa784ef12019-04-22 11:09:57 -0700759# Define these only if we are building boot
760ifdef BUILDING_BOOT_IMAGE
761INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
762
The Android Open Source Project88b60792009-03-03 19:28:42 -0800763ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800764$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400765
766else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
767
Steve Muckle04b6f052020-08-09 14:36:56 -0700768# $1: boot image target
769define build_boot_board_avb_enabled
770 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
771 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
772 $(AVBTOOL) add_hash_footer \
773 --image $(1) \
774 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
775 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
776 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
777endef
778
779$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(call bootimage-to-kernel,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400780 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700781 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400782
783.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800784bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400785 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700786 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400787
Anton Hansson8dab0a62019-03-28 15:45:40 +0000788else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700789
Steve Muckle04b6f052020-08-09 14:36:56 -0700790# $1: boot image target
791define build_boot_supports_boot_signer
792 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
793 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
794 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
795endef
796
797$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER) $(call bootimage-to-kernel,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700798 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700799 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700800
801.PHONY: bootimage-nodeps
802bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
803 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700804 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700805
Anton Hansson8dab0a62019-03-28 15:45:40 +0000806else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800807
Steve Muckle04b6f052020-08-09 14:36:56 -0700808# $1: boot image target
809define build_boot_supports_vboot
810 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
811 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
812 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
813endef
814
815$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY) $(call bootimage-to-kernel,$@)
David Riley17be3d32015-03-03 08:54:11 -0800816 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700817 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800818
819.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800820bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800821 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700822 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800823
824else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800825
Steve Muckle04b6f052020-08-09 14:36:56 -0700826# $1: boot image target
827define build_boot_novboot
828 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
829 $(call assert-max-image-size,$1,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
830endef
831
832$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(call bootimage-to-kernel,$@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800833 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700834 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700835
836.PHONY: bootimage-nodeps
837bootimage-nodeps: $(MKBOOTIMG)
838 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700839 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700840
The Android Open Source Project88b60792009-03-03 19:28:42 -0800841endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -0700842endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843
Tao Baob1a2e352018-08-14 16:17:12 -0700844else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700845ifdef BOARD_PREBUILT_BOOTIMAGE
846ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
847# Remove when b/63676296 is resolved.
848$(error Prebuilt bootimage is only supported for AB targets)
849endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900850INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700851$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700852else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700853INSTALLED_BOOTIMAGE_TARGET :=
854endif # BOARD_PREBUILT_BOOTIMAGE
855endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800856
857# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700858# vendor boot image
859ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
860
861ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
862 $(error vboot 1.0 does not support vendor_boot partition)
863endif
864
865INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
866 $(ALL_GENERATED_SOURCES) \
867 $(ALL_DEFAULT_INSTALLED_MODULES))
868
Steve Muckle414dbe12020-06-18 21:38:35 -0700869INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000870$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
871 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700872
873ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
874 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
875endif
876ifdef BOARD_KERNEL_BASE
877 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
878endif
879ifdef BOARD_KERNEL_PAGESIZE
880 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
881endif
882ifdef INTERNAL_KERNEL_CMDLINE
883 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
884endif
885
886INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
887$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
888ifeq ($(BOARD_AVB_ENABLE),true)
889$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
890 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800891 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700892 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
893 $(AVBTOOL) add_hash_footer \
894 --image $@ \
895 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
896 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
897 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
898else
899$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
900 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800901 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700902 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
903endif
904endif # BUILDING_VENDOR_BOOT_IMAGE
905
906# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907# NOTICE files
908#
Steve Blockd14d3b42012-03-01 11:34:41 +0000909# We are required to publish the licenses for all code under BSD, GPL and
910# Apache licenses (and possibly other more exotic ones as well). We err on the
911# side of caution, so the licenses for other third-party code are included here
912# too.
913#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914# This needs to be before the systemimage rules, because it adds to
915# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
916# go into the systemimage.
917
Steve Block495e5852012-02-29 19:18:08 +0000918.PHONY: notice_files
919
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900920# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700921# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
922# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
923# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
924# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900925# $(2) - Plain text output file
926# $(3) - HTML/XML output file
927# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700928# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900930# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800931# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932#
933# The algorithm here is that we go collect a hash for each of the notice
934# files and write the names of the files that match that hash. Then
935# to generate the real files, we go print out all of the files and their
936# hashes.
937#
938# These rules are fairly complex, so they depend on this makefile so if
939# it changes, they'll run again.
940#
941# TODO: We could clean this up so that we just record the locations of the
942# original notice files instead of making rules to copy them somwehere.
943# Then we could traverse that without quite as much bash drama.
944define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700945$(2): PRIVATE_MESSAGE := $(4)
946$(2): PRIVATE_DIR := $(5)
947$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
948$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800949 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -0700950 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
951 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000952 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900953 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700954 $(if $(filter $(1),xml_system),-i system --xml-output, \
955 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700956 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -0700957 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
958 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -0700959 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900960notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800961endef
962
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000963# Notice file logic isn't relevant for TARGET_BUILD_APPS
964ifndef TARGET_BUILD_APPS
965
The Android Open Source Project88b60792009-03-03 19:28:42 -0800966# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
967# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
968# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000969target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000970tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000972kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
973winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974
Bob Badour4b25c902020-01-28 13:23:39 -0800975# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
976# reasons--not to be flashed onto any device. Targets under these directories
977# need no associated notice file on the device UI.
978exclude_target_dirs := apex
979
Steven Morelandae69e572017-12-15 14:49:55 -0800980# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000981ifneq ($(PRODUCT_NOTICE_SPLIT),true)
982target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
983target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
984installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
985$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000986 $(target_notice_file_txt), \
987 $(target_notice_file_html), \
988 "Notices for files contained in the filesystem images in this directory:", \
989 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -0700990 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -0800991 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000992$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
993 $(hide) $(MINIGZIP) -9 < $< > $@
994$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
995 $(copy-file-to-target)
996else
997target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
998target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900999installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1000
1001target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1002target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1003target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1004installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001005
1006target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1007target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1008target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1009installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001010
Justin Yun6151e3f2019-06-25 15:58:13 +09001011target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1012target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1013target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1014installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001015
Chris Gross15d96552019-07-16 14:38:43 -07001016target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1017target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1018target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1019installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1020
Yifan Hong3d3f0302020-05-11 18:35:11 -07001021target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1022target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1023target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1024installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1025
Yifan Hongc83f9e92020-07-15 16:57:47 -07001026target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1027target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1028target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1029installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1030
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001031# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1032# being built. A notice xml file must depend on all modules that could potentially
1033# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001034license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001035# Only files copied to a system image need system image notices.
1036license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001037# Phonys/fakes don't have notice files (though their deps might)
1038license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001039# testcases are not relevant to the system image.
1040license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001041# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001042license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001043license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1044license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001045license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001046license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001047license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001048license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001049license_modules_agg := $(license_modules_system) \
1050 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001051 $(license_modules_product) \
1052 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001053 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001054 $(license_modules_vendor_dlkm) \
1055 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001056# targets used for debug symbols only and do not get copied to the device
1057license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1058
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001059license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001060license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1061
1062# Identify the other targets we expect to have notices for:
1063# targets copied to the device but are not readable by the UI (e.g. must boot
1064# into a different partition to read or don't have an associated /etc
1065# directory) must have their notices built somewhere readable.
1066license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1067license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1068license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1069license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1070license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1071license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1072license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1073license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1074license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1075license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1076license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1077license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1078license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1079
1080# after removing targets in system images, targets reported in system images, and
1081# targets used for debug symbols that do not need notices, nothing must remain.
1082license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1083$(call maybe-print-list-and-error, $(license_modules_rest), \
1084 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001085
Chris Grossaad39b32019-06-13 09:43:26 -07001086# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1087# update its notice file, so include those notices in the system partition instead
1088ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001089license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001090system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1091system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001092else
Bob Badour4b25c902020-01-28 13:23:39 -08001093license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001094system_xml_directories := xml_system
1095system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001096endif
1097
1098$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001099 $(target_notice_file_txt), \
1100 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001101 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001102 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001103 $(license_modules_system), \
1104 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001105$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001106 $(target_vendor_notice_file_txt), \
1107 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001108 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001109 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001110 $(license_modules_vendor), \
1111 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001112$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001113 $(target_product_notice_file_txt), \
1114 $(target_product_notice_file_xml), \
1115 "Notices for files contained in the product filesystem image in this directory:", \
1116 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001117 $(license_modules_product), \
1118 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001119$(eval $(call combine-notice-files, xml_system_ext, \
1120 $(target_system_ext_notice_file_txt), \
1121 $(target_system_ext_notice_file_xml), \
1122 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001123 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001124 $(license_modules_system_ext), \
1125 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001126$(eval $(call combine-notice-files, xml_odm, \
1127 $(target_odm_notice_file_txt), \
1128 $(target_odm_notice_file_xml), \
1129 "Notices for files contained in the odm filesystem image in this directory:", \
1130 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001131 $(license_modules_odm), \
1132 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001133$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1134 $(target_vendor_dlkm_notice_file_txt), \
1135 $(target_vendor_dlkm_notice_file_xml), \
1136 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1137 $(TARGET_OUT_NOTICE_FILES), \
1138 $(license_modules_vendor_dlkm), \
1139 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001140$(eval $(call combine-notice-files, xml_odm_dlkm, \
1141 $(target_odm_dlkm_notice_file_txt), \
1142 $(target_odm_dlkm_notice_file_xml), \
1143 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1144 $(TARGET_OUT_NOTICE_FILES), \
1145 $(license_modules_odm_dlkm), \
1146 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001147
1148$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1149 $(hide) $(MINIGZIP) -9 < $< > $@
1150$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1151 $(hide) $(MINIGZIP) -9 < $< > $@
1152$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1153 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001154$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001155 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001156$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1157 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001158$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1159 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001160$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1161 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001162$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1163 $(copy-file-to-target)
1164$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1165 $(copy-file-to-target)
1166$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1167 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001168$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001169 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001170$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1171 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001172$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1173 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001174$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1175 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001176
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001177ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1178ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1179ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1180ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1181ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001182ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001183ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001184endif # PRODUCT_NOTICE_SPLIT
1185
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001186ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001187
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001188$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001189 $(tools_notice_file_txt), \
1190 $(tools_notice_file_html), \
1191 "Notices for files contained in the tools directory:", \
1192 $(HOST_OUT_NOTICE_FILES), \
1193 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001194 $(winpthreads_notice_file), \
1195 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001196
Ying Wang62c81f82013-08-22 20:02:03 -07001197endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001198
1199# The kernel isn't really a module, so to get its module file in there, we
1200# make the target NOTICE files depend on this particular file too, which will
1201# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001202$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001203
Dan Willemsen288bedf2019-05-28 15:36:47 -07001204$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001205
Doug Zongker8678df42009-06-15 14:30:14 -07001206
The Android Open Source Project88b60792009-03-03 19:28:42 -08001207# #################################################################
1208# Targets for user images
1209# #################################################################
1210
Ying Wang933abf12010-06-16 14:31:34 -07001211INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001213INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1214else
1215ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001216INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1217else
1218ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001219INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1220endif
1221endif
1222endif
1223
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001224# These options tell the recovery updater/installer how to mount the partitions writebale.
1225# <fstype>=<fstype_opts>[|<fstype_opts>]...
1226# fstype_opts := <opt>[,<opt>]...
1227# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001228# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1229DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001230
Ying Wang542903a2010-11-17 15:40:38 -08001231ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1232 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1233endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001234ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1235 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1236endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001237ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1238 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1239endif
Tao Baodba635a2019-06-24 10:39:54 -07001240
1241INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001242 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001243 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001244 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001245
1246ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1247INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001248endif
1249
Yifan Hongcfb917a2020-05-07 14:58:20 -07001250ifneq ($(filter \
1251 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1252 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1253 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1254 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1255 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1256 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001257 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001258 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001259INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1260endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001261
Anton Hansson8dab0a62019-03-28 15:45:40 +00001262ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001263INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001264ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001265INTERNAL_USERIMAGES_DEPS += $(FEC)
1266endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001267endif
1268
Tao Baodba635a2019-06-24 10:39:54 -07001269ifeq ($(BOARD_AVB_ENABLE),true)
1270INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1271endif
1272
1273# Get a colon-separated list of search paths.
1274INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1275
Alex Klyubin092c9022017-03-13 13:28:34 -07001276SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001277INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1278
Yifan Hongc5c01242018-11-09 10:27:23 -08001279ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001280
Anton Hansson8dab0a62019-03-28 15:45:40 +00001281ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001282 $(error vboot 1.0 doesn't support logical partition)
1283endif
1284
Yifan Hongc5c01242018-11-09 10:27:23 -08001285endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001286
Ying Wangbd93d422011-10-28 17:02:30 -07001287# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001288# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001289# $(3): additional "key=value" pairs to append to the dictionary file.
1290define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001291$(if $(filter $(2),system),\
1292 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001293 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001294 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1295 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1296 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1297 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1298 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1299 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1300 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1301 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001302 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1303 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001304 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001305 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001306 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1307)
1308$(if $(filter $(2),system_other),\
1309 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001310)
Yifan Hong760d3c02018-05-30 11:16:46 -07001311$(if $(filter $(2),userdata),\
1312 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1313 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001314 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1315 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001316 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001317 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001318)
Yifan Hong760d3c02018-05-30 11:16:46 -07001319$(if $(filter $(2),cache),\
1320 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1321 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001322 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001323 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001324)
1325$(if $(filter $(2),vendor),\
1326 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1327 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1328 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1329 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1330 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1331 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1332 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1333 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1334 $(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001335 $(if $(PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
Yifan Hong749062d2018-06-19 16:23:16 -07001336 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001337 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001338 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001339)
1340$(if $(filter $(2),product),\
1341 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1342 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1343 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1344 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1345 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1346 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1347 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1348 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1349 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_squashfs_disable_4k_align=$(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001350 $(if $(PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "product_base_fs_file=$(PRODUCT_PRODUCT_BASE_FS_PATH)" >> $(1))
Yifan Hong56a6c3b2018-07-20 15:19:34 -07001351 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001352 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001353 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001354)
Justin Yun6151e3f2019-06-25 15:58:13 +09001355$(if $(filter $(2),system_ext),\
1356 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1357 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1358 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1359 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1360 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1361 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1362 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1363 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1364 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1365 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1366 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001367 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001368)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001369$(if $(filter $(2),odm),\
1370 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1371 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1372 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1373 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1374 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1375 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1376 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1377 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1378 $(if $(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_squashfs_disable_4k_align=$(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001379 $(if $(PRODUCT_ODM_BASE_FS_PATH),$(hide) echo "odm_base_fs_file=$(PRODUCT_ODM_BASE_FS_PATH)" >> $(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001380 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001381 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001382 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001383)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001384$(if $(filter $(2),vendor_dlkm),\
1385 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1386 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1387 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1388 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1389 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1390 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1391 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1392 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1393 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1394 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1395 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1396 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1397)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001398$(if $(filter $(2),odm_dlkm),\
1399 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1400 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1401 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1402 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1403 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1404 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1405 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1406 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1407 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1408 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1409 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1410 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1411)
Yifan Hong760d3c02018-05-30 11:16:46 -07001412$(if $(filter $(2),oem),\
1413 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1414 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1415 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1416 $(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001417 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001418)
Tao Bao3602eca2018-07-10 10:53:55 -07001419$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001420
Tao Bao3602eca2018-07-10 10:53:55 -07001421$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001422$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001423$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001424$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001425$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1426$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1427$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001428$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1429$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1430$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1431$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1432$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001433$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001434$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1435$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1436$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001437$(if $(PRODUCT_SYSTEM_EXT_VERITY_PARTITION),$(hide) echo "system_ext_verity_block_device=$(PRODUCT_SYSTEM_EXT_VERITY_PARTITION)" >> $(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001438$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001439$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001440$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1441$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1442$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1443$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1444$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001445$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001446$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1447$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1448$(if $(BOARD_AVB_ENABLE),\
1449 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1450 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1451 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1452 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001453$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1454$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1455$(if $(BOARD_AVB_ENABLE),\
1456 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1457 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001458 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001459$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1460$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1461$(if $(BOARD_AVB_ENABLE),\
1462 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1463 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1464 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1465 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001466$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1467$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1468$(if $(BOARD_AVB_ENABLE),\
1469 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1470 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1471 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1472 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001473$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001474$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001475 $(hide) echo "avb_system_ext_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001476$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001477 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1478 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1479 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1480 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001481$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1482$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1483$(if $(BOARD_AVB_ENABLE),\
1484 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1485 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1486 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1487 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001488$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1489$(if $(BOARD_AVB_ENABLE),\
1490 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1491$(if $(BOARD_AVB_ENABLE),\
1492 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1493 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1494 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1495 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001496$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1497$(if $(BOARD_AVB_ENABLE),\
1498 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1499$(if $(BOARD_AVB_ENABLE),\
1500 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1501 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1502 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1503 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001504$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1505 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001506$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001507 $(hide) echo "system_root_image=true" >> $(1))
1508$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001509$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1510 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001511$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1512endef
1513
1514# $(1): the path of the output dictionary file
1515# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001516PROP_DICTIONARY_IMAGES := oem
1517ifdef BUILDING_CACHE_IMAGE
1518 PROP_DICTIONARY_IMAGES += cache
1519endif
1520ifdef BUILDING_SYSTEM_IMAGE
1521 PROP_DICTIONARY_IMAGES += system
1522endif
Chris Gross203191b2020-05-30 02:39:12 +00001523ifdef BUILDING_SYSTEM_OTHER_IMAGE
1524 PROP_DICTIONARY_IMAGES += system_other
1525endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001526ifdef BUILDING_USERDATA_IMAGE
1527 PROP_DICTIONARY_IMAGES += userdata
1528endif
1529ifdef BUILDING_VENDOR_IMAGE
1530 PROP_DICTIONARY_IMAGES += vendor
1531endif
1532ifdef BUILDING_PRODUCT_IMAGE
1533 PROP_DICTIONARY_IMAGES += product
1534endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001535ifdef BUILDING_SYSTEM_EXT_IMAGE
1536 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001537endif
1538ifdef BUILDING_ODM_IMAGE
1539 PROP_DICTIONARY_IMAGES += odm
1540endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001541ifdef BUILDING_VENDOR_DLKM_IMAGE
1542 PROP_DICTIONARY_IMAGES += vendor_dlkm
1543endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001544ifdef BUILDING_ODM_DLKM_IMAGE
1545 PROP_DICTIONARY_IMAGES += odm_dlkm
1546endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001547define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001548 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001549endef
1550
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001551# $(1): the path of the input dictionary file, where each line has the format key=value
1552# $(2): the key to look up
1553define read-image-prop-dictionary
1554$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1555endef
1556
The Android Open Source Project88b60792009-03-03 19:28:42 -08001557# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001558# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001559
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001560# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001561ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001562
Ying Wang37526142015-03-10 12:02:57 -07001563INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1564 $(ALL_DEFAULT_INSTALLED_MODULES))
1565
Tao Bao10fc9492018-08-14 12:17:48 -07001566INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1567INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1568
1569# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1570# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1571# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1572# the call to FILELIST.
1573ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001574INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001575$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1576else
1577$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1578endif
1579
1580$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001581$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001582 @echo Installed file list: $@
1583 @mkdir -p $(dir $@)
1584 @rm -f $@
1585 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001586 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001587
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001588recovery_sepolicy := \
1589 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001590 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001591 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001592 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1593 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1594 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001595 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001596 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001597 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1598 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1599 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001600
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001601# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1602# SELinux files
1603IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1604
Steve Muckle04b6f052020-08-09 14:36:56 -07001605# if building multiple boot images from multiple kernels, use the first kernel listed
1606# for the recovery image
1607recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001608recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001609recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001610
Anton Hansson45a40da2019-01-18 14:06:34 +00001611# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1612# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1613# which get remapped to a bucket.
1614recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001615ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1616recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001617# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001618# ------160------240------320----------480------------640------
1619# mdpi hdpi xhdpi xxhdpi xxxhdpi
1620recovery_density := $(strip \
1621 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1622 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1623 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1624 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001625endif
1626
1627ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1628recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1629else
Doug Zongker25d55f82014-04-04 13:51:15 -07001630recovery_resources_common := $(recovery_resources_common)-xhdpi
1631endif
1632
Tao Baoe1e829e2018-08-29 20:36:00 -07001633# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1634# Note that the font selected here can be overridden for a particular device by putting a font.png
1635# in its private recovery resources.
1636ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001637recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001638else
Dan Willemsen97672232020-05-27 00:09:16 -07001639recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001640endif
1641
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001642
1643# We will only generate the recovery background text images if the variable
1644# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1645# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1646# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1647# BoardConfig in order to use this feature.
1648ifeq ($(recovery_density),xxxhdpi)
1649TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1650else ifeq ($(recovery_density),xxhdpi)
1651TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1652endif
1653
1654ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1655# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1656ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1657 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1658else
1659 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1660endif
1661
1662
Dan Willemsen97672232020-05-27 00:09:16 -07001663RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001664RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1665RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1666RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1667RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1668
xunchangcc57d312018-12-07 12:12:17 -08001669RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1670RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1671RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1672RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1673RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1674
1675generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001676 $(RECOVERY_INSTALLING_TEXT_FILE) \
1677 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1678 $(RECOVERY_ERASING_TEXT_FILE) \
1679 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001680 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1681 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1682 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1683 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1684 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1685 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001686
Dan Willemsen97672232020-05-27 00:09:16 -07001687resource_dir := bootable/recovery/tools/recovery_l10n/res/
1688resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001689image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001690zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001691$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001692$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001693$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1694$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001695$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001696$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001697$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001698 recovery_installing \
1699 recovery_installing_security \
1700 recovery_erasing \
1701 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001702 recovery_no_command
1703$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001704 recovery_cancel_wipe_data \
1705 recovery_factory_data_reset \
1706 recovery_try_again \
1707 recovery_wipe_data_menu_header \
1708 recovery_wipe_data_confirmation
1709$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001710$(RECOVERY_INSTALLING_TEXT_FILE): $(image_generator_jar) $(resource_dir_deps) $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep) $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001711 # Prepares the font directory.
1712 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1713 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001714 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001715 @rm -rf $(dir $@)
1716 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001717 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001718 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001719 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001720 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1721 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1722 --text_name $(text_name) \
1723 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1724 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001725 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001726 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001727else
1728RECOVERY_INSTALLING_TEXT_FILE :=
1729RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1730RECOVERY_ERASING_TEXT_FILE :=
1731RECOVERY_ERROR_TEXT_FILE :=
1732RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001733RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1734RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1735RECOVERY_TRY_AGAIN_TEXT_FILE :=
1736RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1737RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001738endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1739
Ying Wang9a175682015-08-06 11:47:47 -07001740ifndef TARGET_PRIVATE_RES_DIRS
1741TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1742endif
Doug Zongker4647f122009-07-02 09:00:54 -07001743recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001744 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001745recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001746
1747
Andrew Boiefa61ff02012-09-28 09:33:45 -07001748ifdef TARGET_RECOVERY_FSTAB
1749recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1750else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001751recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001752endif
Tao Baoc3c17532016-06-10 10:11:54 -07001753ifdef TARGET_RECOVERY_WIPE
1754recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001755else
Tao Baoc3c17532016-06-10 10:11:54 -07001756recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001757endif
Tao Bao8beab692015-07-22 12:33:18 -07001758
Tao Bao6d5d6232018-03-09 17:04:42 -08001759# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001760# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001761# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1762# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001763#
1764# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001765# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001766# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001767# b) We build a single image that contains boot and recovery both - no recovery image to install
1768# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001769# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001770# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001771# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1772# do bsdiff because boot and recovery will contain different number of entries
1773# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001774# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1775# do bsdiff because boot and recovery will contain different number of entries
1776# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001777
Tom Cherry2929cad2018-09-20 11:04:37 -07001778ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001779 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001780# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001781RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1782ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001783else
Tao Bao8beab692015-07-22 12:33:18 -07001784RECOVERY_RESOURCE_ZIP :=
1785endif
Doug Zongker4647f122009-07-02 09:00:54 -07001786
Tao Bao139c7272018-07-31 13:26:54 -07001787INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1788
1789$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001790 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1791 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1792 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1793 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1794 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1795 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1796 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1797 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1798
1799# Parses the given list of build variables and writes their values as build properties if defined.
1800# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1801# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1802# $(1): Map from the build variable names to property names
1803# $(2): Output file
1804define append-recovery-ui-properties
1805echo "#" >> $(2)
1806echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1807echo "#" >> $(2)
1808$(foreach prop,$(1), \
1809 $(eval _varname := $(call word-colon,1,$(prop))) \
1810 $(eval _propname := $(call word-colon,2,$(prop))) \
1811 $(eval _value := $($(_varname))) \
1812 $(if $(_value), \
1813 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1814endef
1815
1816$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001817 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001818 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1819 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1820 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001821 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001822 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001823 $(hide) mkdir -p $(dir $@)
1824 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001825 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001826 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001827 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001828 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001829 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001830 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1831
Steve Mucklef84668e2020-03-16 19:13:46 -07001832ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001833 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001834ifdef GENERIC_KERNEL_CMDLINE
1835 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1836endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001837else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001838 INTERNAL_RECOVERYIMAGE_ARGS := \
1839 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001840 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001841# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001842ifdef INTERNAL_KERNEL_CMDLINE
1843 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001844endif
1845ifdef BOARD_KERNEL_BASE
1846 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1847endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001848ifdef BOARD_KERNEL_PAGESIZE
1849 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1850endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001851ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001852ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1853 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1854else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001855 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1856endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001857endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001858ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1859 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1860endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001861ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1862 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1863endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001864endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001865ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1866 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1867endif
Doug Zongker4647f122009-07-02 09:00:54 -07001868
J. Avila3f6560e2020-05-11 20:20:03 +00001869$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001870 $(INTERNAL_ROOT_FILES) \
1871 $(INSTALLED_RAMDISK_TARGET) \
1872 $(INTERNAL_RECOVERYIMAGE_FILES) \
1873 $(recovery_sepolicy) \
1874 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1875 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1876 $(recovery_resource_deps) \
1877 $(recovery_fstab)
1878 # Making recovery image
1879 mkdir -p $(TARGET_RECOVERY_OUT)
1880 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1881 # Copying baseline ramdisk...
1882 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1883 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1884 # Modifying ramdisk contents...
1885 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1886 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1887 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1888 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1889 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1890 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1891 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1892 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1893 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1894 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1895 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1896 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1897 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1898 $(foreach item,$(recovery_fstab), \
1899 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1900 $(if $(strip $(recovery_wipe)), \
1901 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1902 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1903 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001904 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001905
Ying Wang747b9f12015-01-30 14:05:22 -08001906# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001907# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001908define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001909 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001910 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001911 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001912 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001913 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001914 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001915 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001916 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001917 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001918 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1919 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001920 )\
1921 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001922 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1923 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001924 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001925 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot))), \
Steve Muckleb3dda772020-03-11 16:03:07 -07001926 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001927 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1928 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001929 $(AVBTOOL) add_hash_footer --image $(1) --partition_size $(call get-bootimage-partition-size,$(1),boot) --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS),\
Steve Muckleb3dda772020-03-11 16:03:07 -07001930 $(AVBTOOL) add_hash_footer --image $(1) --partition_size $(BOARD_RECOVERYIMAGE_PARTITION_SIZE) --partition_name recovery $(INTERNAL_AVB_RECOVERY_SIGNING_ARGS) $(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)))
Ying Wang747b9f12015-01-30 14:05:22 -08001931endef
1932
Dan Willemsend120ac62020-06-12 02:39:34 +00001933recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001934ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001935 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001936endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001937ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001938 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001939endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001940ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001941 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001942endif
Tao Baof4866c72018-08-22 14:35:09 -07001943ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001944 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1945 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1946 else
1947 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1948 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001949endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001950ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001951 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001952endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001953ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001954 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001955endif
Tao Baof4866c72018-08-22 14:35:09 -07001956
Dan Willemsend120ac62020-06-12 02:39:34 +00001957ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1958$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001959 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001960 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001961endif # BOARD_USES_RECOVERY_AS_BOOT
1962
Dan Willemsend120ac62020-06-12 02:39:34 +00001963$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001964 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001965
Tao Bao4594d0e2015-12-22 09:47:46 -08001966ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001967$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001968 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001969 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1970 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001971endif
Doug Zongker56588872012-08-20 15:38:58 -07001972
Ying Wang747b9f12015-01-30 14:05:22 -08001973.PHONY: recoveryimage-nodeps
1974recoveryimage-nodeps:
1975 @echo "make $@: ignoring dependencies"
Steve Mucklea21b44a2020-08-09 14:54:42 -07001976 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), $(recovery_kernel))
Ying Wang747b9f12015-01-30 14:05:22 -08001977
Chris Grossa784ef12019-04-22 11:09:57 -07001978else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001979RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001980endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001981
1982.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001983recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001984
Jiyong Park03eb0612017-10-04 21:22:41 +09001985ifneq ($(BOARD_NAND_PAGE_SIZE),)
1986$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001987endif
1988
Jiyong Park03eb0612017-10-04 21:22:41 +09001989ifneq ($(BOARD_NAND_SPARE_SIZE),)
1990$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001991endif
1992
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001993ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07001994# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08001995# the debug ramdisk, which is the original ramdisk plus additional
1996# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
1997# When /force_debuggable is present, /init will load userdebug sepolicy
1998# and property files to allow adb root, if the device is unlocked.
1999
2000ifdef BUILDING_RAMDISK_IMAGE
2001BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2002INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2003
2004INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2005 $(ALL_GENERATED_SOURCES) \
2006 $(ALL_DEFAULT_INSTALLED_MODULES))
2007
2008# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2009# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2010# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2011my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2012
2013INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2014INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2015$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2016$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2017
2018# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2019# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2020# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2021$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002022$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002023 echo Installed file list: $@
2024 mkdir -p $(dir $@)
2025 rm -f $@
2026 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002027 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002028
2029# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2030# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2031ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2032my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2033else
2034my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2035endif # BOARD_USES_RECOVERY_AS_BOOT
2036
2037$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2038$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002039
2040ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2041# ramdisk-recovery.img isn't a make target, need to depend on boot.img if it's for recovery.
Bowgo Tsai0013f552019-03-20 17:59:52 +08002042$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002043else
2044# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2045$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2046endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002047$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002048 $(call pretty,"Target debug ram disk: $@")
2049 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2050 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002051 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002052 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002053
2054.PHONY: ramdisk_debug-nodeps
2055ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2056ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002057ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002058 echo "make $@: ignoring dependencies"
2059 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2060 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002061 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002062 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002063
2064my_debug_ramdisk_sync_dir :=
2065my_debug_ramdisk_root_dir :=
2066
2067endif # BUILDING_RAMDISK_IMAGE
2068
2069# -----------------------------------------------------------------
2070# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2071#
2072# Note: it's intentional to skip signing for boot-debug.img, because it
2073# can only be used if the device is unlocked with verification error.
2074ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002075ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2076 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2077 $(PRODUCT_OUT)/$(k).img)
2078else
2079 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2080endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002081
2082# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2083ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2084INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2085else
2086INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2087endif
2088
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002089# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2090# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2091# Using a test key to sign boot-debug.img to continue booting with the mismatched
2092# public key, if the device is unlocked.
2093ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002094$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002095endif
2096
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002097BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2098INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2099# $(1): the bootimage to sign
2100define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002101$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot-debug)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002102$(AVBTOOL) add_hash_footer \
2103 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002104 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002105 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2106 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002107$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002108endef
2109
Steve Muckleb3dda772020-03-11 16:03:07 -07002110# $(1): output file
2111define build-debug-bootimage-target
2112 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2113 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2114 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2115endef
2116
Bowgo Tsai0013f552019-03-20 17:59:52 +08002117# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2118$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2119 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002120 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002121
2122.PHONY: bootimage_debug-nodeps
2123bootimage_debug-nodeps: $(MKBOOTIMG)
2124 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002125 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002126
2127endif # TARGET_NO_KERNEL
2128
Bowgo Tsai6a683672020-02-14 19:00:15 +08002129ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2130ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2131# -----------------------------------------------------------------
2132# vendor debug ramdisk
2133# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002134INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002135$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2136$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2137
2138INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2139 $(ALL_GENERATED_SOURCES) \
2140 $(ALL_DEFAULT_INSTALLED_MODULES))
2141
2142# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2143# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2144# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2145# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2146$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2147$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002148$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002149 $(call pretty,"Target vendor debug ram disk: $@")
2150 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2151 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2152 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2153 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2154 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002155 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002156
2157INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2158INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2159$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2160$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2161
2162# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2163# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2164$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2165$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2166 echo Installed file list: $@
2167 mkdir -p $(dir $@)
2168 rm -f $@
2169 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2170 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2171
2172# -----------------------------------------------------------------
2173# vendor_boot-debug.img.
2174INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2175
2176# The util to sign vendor_boot-debug.img with a test key.
2177BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2178INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2179# $(1): the vendor bootimage to sign
2180define test-key-sign-vendor-bootimage
2181$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2182$(AVBTOOL) add_hash_footer \
2183 --image $(1) \
2184 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2185 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2186 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2187$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2188endef
2189
2190ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2191$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2192endif
2193
2194# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2195$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2196 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002197 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002198 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2199 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2200
2201endif # BUILDING_RAMDISK_IMAGE
2202endif # BUILDING_VENDOR_BOOT_IMAGE
2203
Bowgo Tsai0013f552019-03-20 17:59:52 +08002204# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002205# The test harness ramdisk, which is based off debug_ramdisk, plus a
2206# few additional test-harness-specific properties in adb_debug.prop.
2207
2208ifdef BUILDING_RAMDISK_IMAGE
2209BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2210INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2211
2212# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2213# appends a few test harness specific properties into the adb_debug.prop.
2214TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2215TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2216
2217# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2218# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2219TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2220ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2221ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2222
2223# $(1): a list of key=value pairs for additional property assignments
2224# $(2): the target .prop file to append the properties from $(1)
2225define append-test-harness-props
2226 echo "#" >> $(2); \
2227 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2228 echo "#" >> $(2);
2229 $(foreach line,$(1), echo "$(line)" >> $(2);)
2230endef
2231
2232$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002233$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002234 $(call pretty,"Target test harness ram disk: $@")
2235 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2236 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002237 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002238
2239.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002240ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002241 echo "make $@: ignoring dependencies"
2242 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2243 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002244 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002245
2246endif # BUILDING_RAMDISK_IMAGE
2247
2248# -----------------------------------------------------------------
2249# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2250#
2251# Note: it's intentional to skip signing for boot-test-harness.img, because it
2252# can only be used if the device is unlocked with verification error.
2253ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2254
Steve Muckle4866bd62020-04-02 11:31:08 -07002255ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2256 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2257 $(PRODUCT_OUT)/$(k).img)
2258else
2259 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2260endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002261
2262# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2263INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2264
2265# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2266# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2267# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2268# public key, if the device is unlocked.
2269ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2270$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2271endif
2272
Steve Muckle4866bd62020-04-02 11:31:08 -07002273# $(1): output file
2274define build-boot-test-harness-target
2275 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2276 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2277 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2278endef
2279
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002280# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2281$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2282 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002283 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002284
2285.PHONY: bootimage_test_harness-nodeps
2286bootimage_test_harness-nodeps: $(MKBOOTIMG)
2287 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002288 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002289
2290endif # TARGET_NO_KERNEL
2291endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2292
Colin Crossbd382142020-08-26 15:08:57 -07002293# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2294# $1: from location (e.g $(TARGET_OUT)/vendor)
2295# $2: destination location (e.g. /vendor)
2296# $3: partition image name (e.g. vendor.img)
2297define create-partition-compat-symlink
2298$(eval \
2299$1:
2300 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2301 mkdir -p $(dir $1)
2302 if [ -d $1 ] && [ ! -h $1 ]; then \
2303 echo 'Non-symlink $1 detected!' 1>&2; \
2304 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2305 exit 1; \
2306 fi
2307 ln -sfn $2 $1
2308)
2309$1
2310endef
2311
2312
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002313# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002314# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002315
Dan Willemsen37a19862018-10-31 16:31:46 -07002316INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002317 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002318 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002319
Colin Crossbd382142020-08-26 15:08:57 -07002320# Create symlink /system/vendor to /vendor if necessary.
2321ifdef BOARD_USES_VENDORIMAGE
2322 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2323endif
2324
2325# Create symlink /system/product to /product if necessary.
2326ifdef BOARD_USES_PRODUCTIMAGE
2327 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2328endif
2329
2330# Create symlink /system/system_ext to /system_ext if necessary.
2331ifdef BOARD_USES_SYSTEM_EXTIMAGE
2332 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2333endif
2334
Ying Wang82cceba2012-08-13 15:03:00 -07002335FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002336
2337# ASAN libraries in the system image - add dependency.
2338ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002339ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002340 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2341 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2342 endif
2343endif
2344
Tom Cherryd14b8952018-08-09 14:26:00 -07002345FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002346
Ying Wange5e8c5f2011-09-09 16:35:53 -07002347# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002348ifdef BUILDING_SYSTEM_IMAGE
2349
Ying Wange5e8c5f2011-09-09 16:35:53 -07002350# installed file list
2351# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2352# We put installed-files.txt ahead of image itself in the dependency graph
2353# so that we can get the size stat even if the build fails due to too large
2354# system image.
2355INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002356INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2357$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002358$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002359 @echo Installed file list: $@
2360 @mkdir -p $(dir $@)
2361 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002362 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002363 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002364
2365.PHONY: installed-file-list
2366installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002367
2368$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002369
2370systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002371 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002372BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2373
The Android Open Source Project88b60792009-03-03 19:28:42 -08002374# $(1): output file
2375define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002376 @echo "Target system fs image: $(1)"
2377 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002378 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002379 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002380 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002381 $(BUILD_IMAGE) \
2382 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2383 || ( mkdir -p $${DIST_DIR}; \
2384 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2385 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002386endef
2387
Dan Willemsen6b72c732019-06-12 21:33:38 +00002388ifeq ($(BOARD_AVB_ENABLE),true)
2389$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2390endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002391$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002392 $(call build-systemimage-target,$@)
2393
Tao Baoe9d61b02018-08-20 21:09:07 -07002394INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002395SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002396
Tao Baoe9d61b02018-08-20 21:09:07 -07002397# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2398# compatibility, in case device-specific Makefiles still refer to the old name.
2399INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2400
Doug Zongker73ef8252009-07-23 15:12:53 -07002401# The system partition needs room for the recovery image as well. We
2402# now store the recovery image as a binary patch using the boot image
2403# as the source (since they are very similar). Generate the patch so
2404# we can see how big it's going to be, and include that in the system
2405# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002406ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002407ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002408ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002409ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002410diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2411else
2412diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2413endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002414intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2415RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002416$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2417$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002418 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002419 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002420 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002421 @echo "Construct recovery from boot"
2422 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002423 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002424else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2425RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002426endif # BOARD_USES_FULL_RECOVERY_IMAGE
2427endif # INSTALLED_RECOVERYIMAGE_TARGET
2428endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002429
Yifan Hong9a3cad92020-04-27 19:06:59 -07002430$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002431 @echo "Install system fs image: $@"
2432 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002433 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002434
Tao Baoe9d61b02018-08-20 21:09:07 -07002435systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002436
2437.PHONY: systemimage-nodeps snod
2438systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002439 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002440 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002441 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002442 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002443ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002444 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002445endif
2446
Dan Willemsen67495202019-01-16 12:42:05 -08002447endif # BUILDING_SYSTEM_IMAGE
2448
Anton Hansson30e061b2018-11-12 13:36:46 +00002449.PHONY: sync syncsys
2450sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002451
Ying Wang3a61eeb2016-03-11 10:32:01 -08002452# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002453# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002454.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002455platform:
2456 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002457
2458.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002459platform-java:
2460 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002461
Ying Wang3a61eeb2016-03-11 10:32:01 -08002462# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002463# data partition image
2464INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002465 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002466
Dan Willemsen67495202019-01-16 12:42:05 -08002467ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002468userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002469 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002470BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2471
Ying Wangbd93d422011-10-28 17:02:30 -07002472define build-userdataimage-target
2473 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2474 @mkdir -p $(TARGET_OUT_DATA)
2475 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002476 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002477 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002478 $(BUILD_IMAGE) \
2479 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2480 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2481 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002482endef
2483
Joe Onorato64d85d02009-04-09 19:31:12 -07002484# We just build this directly to the install location.
2485INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002486INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2487 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002488 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002489$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002490 $(build-userdataimage-target)
2491
2492.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002493userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002494 $(build-userdataimage-target)
2495
Dan Willemsen67495202019-01-16 12:42:05 -08002496endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002497
Andreas Gampe039b5c72017-03-24 16:06:31 -07002498# ASAN libraries in the system image - build rule.
2499ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2500 $(TARGET_OUT_SHARED_LIBRARIES) \
2501 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2502 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2503 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002504# Extra options: Enforce the system user for the files to avoid having to change ownership.
2505ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002506# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2507# enough space.
2508$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002509 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 -07002510
The Android Open Source Project88b60792009-03-03 19:28:42 -08002511# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002512# partition table image
2513ifdef BOARD_BPT_INPUT_FILES
2514
2515BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002516BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002517
2518INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2519 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002520 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002521 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2522
2523ifdef BOARD_BPT_DISK_SIZE
2524INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2525endif
2526
2527define build-bptimage-target
2528 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2529 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2530endef
2531
2532INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002533$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2534 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2535
David Zeuthen25328622016-04-08 15:08:03 -04002536$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2537 $(build-bptimage-target)
2538
2539.PHONY: bptimage-nodeps
2540bptimage-nodeps:
2541 $(build-bptimage-target)
2542
2543endif # BOARD_BPT_INPUT_FILES
2544
2545# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002546# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002547ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002548INTERNAL_CACHEIMAGE_FILES := \
2549 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2550
2551cacheimage_intermediates := \
2552 $(call intermediates-dir-for,PACKAGING,cache)
2553BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2554
2555define build-cacheimage-target
2556 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2557 @mkdir -p $(TARGET_OUT_CACHE)
2558 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002559 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002560 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002561 $(BUILD_IMAGE) \
2562 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2563 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2564 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002565endef
2566
2567# We just build this directly to the install location.
2568INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002569$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002570 $(build-cacheimage-target)
2571
2572.PHONY: cacheimage-nodeps
2573cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2574 $(build-cacheimage-target)
2575
Dan Willemsen67495202019-01-16 12:42:05 -08002576else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002577# we need to ignore the broken cache link when doing the rsync
2578IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002579endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002580
David Zeuthen0eb10972016-09-28 17:55:27 -04002581# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002582# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002583ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002584ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002585# Marker file to identify that odex files are installed
2586INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2587ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2588$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2589 $(hide) touch $@
2590endif
2591
Alex Light4e358ab2016-06-16 14:47:10 -07002592INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2593 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002594 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002595
Colin Cross6db5b0e2018-11-16 21:26:33 -08002596# system_other dex files are installed as a side-effect of installing system image files
2597INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2598
Alex Light4e358ab2016-06-16 14:47:10 -07002599INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002600INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2601$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002602$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002603 @echo Installed file list: $@
2604 @mkdir -p $(dir $@)
2605 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002606 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002607 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002608
Bowgo Tsai867ab662019-01-29 13:30:18 +08002609# Determines partition size for system_other.img.
2610ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2611ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2612INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2613endif
2614endif
2615
2616ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2617INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2618endif
2619
Alex Light4e358ab2016-06-16 14:47:10 -07002620systemotherimage_intermediates := \
2621 $(call intermediates-dir-for,PACKAGING,system_other)
2622BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2623
2624# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2625define build-systemotherimage-target
2626 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2627 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2628 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002629 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002630 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002631 $(BUILD_IMAGE) \
2632 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2633 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2634 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002635endef
2636
2637# We just build this directly to the install location.
2638INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002639ifneq (true,$(SANITIZE_LITE))
2640# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002641$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2642 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002643endif
Alex Light4e358ab2016-06-16 14:47:10 -07002644
2645.PHONY: systemotherimage-nodeps
2646systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2647 $(build-systemotherimage-target)
2648
Dan Willemsen67495202019-01-16 12:42:05 -08002649endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002650
2651
2652# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002653# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002654ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002655INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002656 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002657 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002658
Ying Wang8da19e32015-09-15 14:22:12 -07002659
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002660# Create symlink /vendor/odm to /odm if necessary.
2661ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002662 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002663endif
2664
Yifan Honge51dff22020-06-23 17:26:57 -07002665# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2666# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2667#
2668# On devices with a vendor_dlkm partition,
2669# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2670# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2671# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2672# are hidden.
2673# On devices without a vendor_dlkm partition,
2674# - /vendor/lib/modules stores vendor DLKMs directly.
2675# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2676# See system/core/rootdir/Android.mk for a list of created symlinks.
2677# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2678# are not guaranteed to exist on all devices.
2679ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002680 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/lib/modules,/vendor_dlkm/lib/modules,vendor_dlkm.img)
Yifan Honge51dff22020-06-23 17:26:57 -07002681endif
2682
Colin Crossbd382142020-08-26 15:08:57 -07002683INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2684INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2685$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2686$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2687 @echo Installed file list: $@
2688 @mkdir -p $(dir $@)
2689 @rm -f $@
2690 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2691 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002692
Ying Wanga0febe52013-03-20 11:02:05 -07002693vendorimage_intermediates := \
2694 $(call intermediates-dir-for,PACKAGING,vendor)
2695BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002696define build-vendorimage-target
2697 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2698 @mkdir -p $(TARGET_OUT_VENDOR)
2699 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002700 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002701 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002702 $(BUILD_IMAGE) \
2703 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2704 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002705 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002706endef
2707
2708# We just build this directly to the install location.
2709INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002710$(INSTALLED_VENDORIMAGE_TARGET): \
2711 $(INTERNAL_USERIMAGES_DEPS) \
2712 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002713 $(INSTALLED_FILES_FILE_VENDOR) \
2714 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002715 $(build-vendorimage-target)
2716
Steven Morelanda2e734d2017-03-07 12:10:09 -08002717.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002718vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002719 $(build-vendorimage-target)
2720
Colin Cross91a52272017-06-20 16:57:52 -07002721sync: $(INTERNAL_VENDORIMAGE_FILES)
2722
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002723else ifdef BOARD_PREBUILT_VENDORIMAGE
2724INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2725$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2726endif
Ying Wanga0febe52013-03-20 11:02:05 -07002727
Ying Wang9f8e8db2011-11-04 11:37:01 -07002728# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002729# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002730ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002731INTERNAL_PRODUCTIMAGE_FILES := \
2732 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002733 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002734
2735INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002736INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2737$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002738$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002739 @echo Installed file list: $@
2740 @mkdir -p $(dir $@)
2741 @rm -f $@
2742 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002743 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002744
2745productimage_intermediates := \
2746 $(call intermediates-dir-for,PACKAGING,product)
2747BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2748define build-productimage-target
2749 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2750 @mkdir -p $(TARGET_OUT_PRODUCT)
2751 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002752 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002753 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002754 $(BUILD_IMAGE) \
2755 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2756 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2757 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002758endef
2759
2760# We just build this directly to the install location.
2761INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002762$(INSTALLED_PRODUCTIMAGE_TARGET): \
2763 $(INTERNAL_USERIMAGES_DEPS) \
2764 $(INTERNAL_PRODUCTIMAGE_FILES) \
2765 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002766 $(build-productimage-target)
2767
2768.PHONY: productimage-nodeps pnod
2769productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2770 $(build-productimage-target)
2771
2772sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2773
2774else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2775INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2776$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2777endif
2778
2779# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002780# system_ext partition image
2781ifdef BUILDING_SYSTEM_EXT_IMAGE
2782INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2783 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002784 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002785
Justin Yun6151e3f2019-06-25 15:58:13 +09002786INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2787INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2788$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2789$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002790 @echo Installed file list: $@
2791 @mkdir -p $(dir $@)
2792 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002793 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002794 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002795
Justin Yun6151e3f2019-06-25 15:58:13 +09002796system_extimage_intermediates := \
2797 $(call intermediates-dir-for,PACKAGING,system_ext)
2798BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2799define build-system_extimage-target
2800 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2801 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2802 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2803 $(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 -07002804 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002805 $(BUILD_IMAGE) \
2806 $(TARGET_OUT_SYSTEM_EXT) \
2807 $(system_extimage_intermediates)/system_ext_image_info.txt \
2808 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2809 $(TARGET_OUT)
2810 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002811endef
2812
2813# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002814INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002815$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2816 $(INTERNAL_USERIMAGES_DEPS) \
2817 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2818 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002819 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002820
Justin Yun6151e3f2019-06-25 15:58:13 +09002821.PHONY: systemextimage-nodeps senod
2822systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2823 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002824
Justin Yun6151e3f2019-06-25 15:58:13 +09002825sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002826
Justin Yun6151e3f2019-06-25 15:58:13 +09002827else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2828INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2829$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002830endif
2831
2832# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002833# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002834ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002835INTERNAL_ODMIMAGE_FILES := \
2836 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002837 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002838
Colin Crossbd382142020-08-26 15:08:57 -07002839# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2840# /odm/lib/modules -> /odm_dlkm/lib/modules
2841#
2842# On devices with a odm_dlkm partition,
2843# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2844# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2845# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2846# are hidden.
2847# On devices without a odm_dlkm partition,
2848# - /odm/lib/modules stores odm DLKMs directly.
2849# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2850# See system/core/rootdir/Android.mk for a list of created symlinks.
2851# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2852# are not guaranteed to exist on all devices.
2853ifdef BOARD_USES_ODM_DLKMIMAGE
2854 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
2855endif
2856
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002857INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2858INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2859$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002860$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002861 @echo Installed file list: $@
2862 @mkdir -p $(dir $@)
2863 @rm -f $@
2864 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002865 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002866
2867odmimage_intermediates := \
2868 $(call intermediates-dir-for,PACKAGING,odm)
2869BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2870define build-odmimage-target
2871 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2872 @mkdir -p $(TARGET_OUT_ODM)
2873 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2874 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002875 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002876 $(BUILD_IMAGE) \
2877 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2878 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2879 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002880endef
2881
2882# We just build this directly to the install location.
2883INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002884$(INSTALLED_ODMIMAGE_TARGET): \
2885 $(INTERNAL_USERIMAGES_DEPS) \
2886 $(INTERNAL_ODMIMAGE_FILES) \
2887 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002888 $(build-odmimage-target)
2889
2890.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002891odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002892 $(build-odmimage-target)
2893
2894sync: $(INTERNAL_ODMIMAGE_FILES)
2895
2896else ifdef BOARD_PREBUILT_ODMIMAGE
2897INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2898$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2899endif
2900
2901# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002902# vendor_dlkm partition image
2903ifdef BUILDING_VENDOR_DLKM_IMAGE
2904INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2905 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002906 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002907
2908INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2909INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2910$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2911$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2912 @echo Installed file list: $@
2913 @mkdir -p $(dir $@)
2914 @rm -f $@
2915 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2916 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2917
2918vendor_dlkmimage_intermediates := \
2919 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2920BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2921define build-vendor_dlkmimage-target
2922 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2923 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2924 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2925 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2926 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2927 $(BUILD_IMAGE) \
2928 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2929 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2930 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2931endef
2932
2933# We just build this directly to the install location.
2934INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2935$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2936 $(INTERNAL_USERIMAGES_DEPS) \
2937 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2938 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2939 $(build-vendor_dlkmimage-target)
2940
2941.PHONY: vendor_dlkmimage-nodeps vdnod
2942vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2943 $(build-vendor_dlkmimage-target)
2944
2945sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2946
2947else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2948INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2949$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2950endif
2951
2952# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07002953# odm_dlkm partition image
2954ifdef BUILDING_ODM_DLKM_IMAGE
2955INTERNAL_ODM_DLKMIMAGE_FILES := \
2956 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002957 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002958
2959INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
2960INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
2961$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
2962$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2963 @echo Installed file list: $@
2964 @mkdir -p $(dir $@)
2965 @rm -f $@
2966 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
2967 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2968
2969odm_dlkmimage_intermediates := \
2970 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
2971BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
2972define build-odm_dlkmimage-target
2973 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
2974 @mkdir -p $(TARGET_OUT_ODM_DLKM)
2975 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
2976 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
2977 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2978 $(BUILD_IMAGE) \
2979 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
2980 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
2981 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
2982endef
2983
2984# We just build this directly to the install location.
2985INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
2986$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
2987 $(INTERNAL_USERIMAGES_DEPS) \
2988 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
2989 $(INSTALLED_FILES_FILE_ODM_DLKM)
2990 $(build-odm_dlkmimage-target)
2991
2992.PHONY: odm_dlkmimage-nodeps odnod
2993odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
2994 $(build-odm_dlkmimage-target)
2995
2996sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
2997
2998else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
2999INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3000$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3001endif
3002
3003
3004# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003005# dtbo image
3006ifdef BOARD_PREBUILT_DTBOIMAGE
3007INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3008
3009ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003010$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003011 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3012 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003013 --image $@ \
3014 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3015 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3016 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003017else
3018$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3019 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3020endif
3021
Tao Bao0da43472018-08-22 22:53:41 -07003022endif # BOARD_PREBUILT_DTBOIMAGE
3023
3024# Returns a list of image targets corresponding to the given list of partitions. For example, it
3025# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3026# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003027# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003028define images-for-partitions
3029$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3030endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003031
3032# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003033# custom images
3034INSTALLED_CUSTOMIMAGES_TARGET :=
3035
3036ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3037INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3038
3039# Sign custom image.
3040# $(1): the prebuilt custom image.
3041# $(2): the mount point of the prebuilt custom image.
3042# $(3): the signed custom image target.
3043define sign_custom_image
3044$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3045 @echo Target custom image: $(3)
3046 mkdir -p $(dir $(3))
3047 cp $(1) $(3)
3048ifeq ($(BOARD_AVB_ENABLE),true)
3049 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3050 $(AVBTOOL) add_hashtree_footer \
3051 --image $(3) \
3052 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3053 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3054 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3055 --partition_name $(2) \
3056 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3057 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3058endif
3059INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3060endef
3061
3062$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3063 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3064 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3065endif
3066
3067# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003068# vbmeta image
3069ifeq ($(BOARD_AVB_ENABLE),true)
3070
3071BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003072AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003073
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003074ifdef BOARD_AVB_KEY_PATH
3075$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3076else
3077# If key path isn't specified, use the 4096-bit test key.
3078BOARD_AVB_ALGORITHM := SHA256_RSA4096
3079BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3080endif
3081
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003082# AVB signing for system_other.img.
3083ifdef BUILDING_SYSTEM_OTHER_IMAGE
3084ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3085$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3086else
3087# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3088BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3089BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3090endif
3091
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003092$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3093 @echo Extracting system_other avb key: $@
3094 @rm -f $@
3095 @mkdir -p $(dir $@)
3096 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003097
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003098ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3099BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3100endif
3101
3102BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3103endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3104
Tao Bao744c4c72018-08-20 21:09:07 -07003105INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003106 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003107 $(BOARD_AVB_VBMETA_VENDOR)
3108
3109# Not allowing the same partition to appear in multiple groups.
3110ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003111 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003112endif
3113
cfig1aeef722019-09-20 22:45:06 +08003114# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3115# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3116# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003117ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003118ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3119$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003120 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003121 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3122endif
3123endif
3124
Bowgo Tsai9b548012019-05-14 16:57:03 +08003125# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003126
3127BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003128 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003129 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003130 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3131
3132BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003133 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003134 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003135 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3136
Justin Yun6151e3f2019-06-25 15:58:13 +09003137BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003138 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003139 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3140 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003141
Bowgo Tsai9b548012019-05-14 16:57:03 +08003142BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003143 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003144 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3145
Tao Bao19b02fe2019-10-09 00:04:28 -07003146BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3147 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3148
3149BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3150 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3151
Bowgo Tsai9b548012019-05-14 16:57:03 +08003152BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003153 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003154 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3155
3156BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003157 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003158 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3159
Yifan Hongcfb917a2020-05-07 14:58:20 -07003160BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3161 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3162 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3163
Yifan Hongf496f1b2020-07-15 16:52:59 -07003164BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3165 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3166 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3167
Tao Bao19b02fe2019-10-09 00:04:28 -07003168BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3169 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3170
Bowgo Tsai9b548012019-05-14 16:57:03 +08003171# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003172ifdef BOOT_SECURITY_PATCH
3173BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3174 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3175endif
3176
3177ifdef VENDOR_SECURITY_PATCH
3178BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3179 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3180endif
3181
3182ifdef ODM_SECURITY_PATCH
3183BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3184 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3185endif
3186
Yifan Hongcfb917a2020-05-07 14:58:20 -07003187ifdef VENDOR_DLKM_SECURITY_PATCH
3188BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3189 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3190endif
3191
Yifan Hongf496f1b2020-07-15 16:52:59 -07003192ifdef ODM_DLKM_SECURITY_PATCH
3193BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3194 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3195endif
3196
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003197BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003198VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003199DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3200SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3201VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003202RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003203PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003204SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003205ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003206VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003207ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003208
Tao Bao0da43472018-08-22 22:53:41 -07003209# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003210# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003211define _check-and-set-avb-chain-args
3212$(eval part := $(1))
3213$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003214
3215$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3216$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3217$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3218$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3219$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3220$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3221$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3222$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3223
3224# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3225$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3226$(eval $(_signing_args) := \
3227 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3228
cfig1aeef722019-09-20 22:45:06 +08003229# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3230# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003231$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003232 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3233 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003234
Tao Bao744c4c72018-08-20 21:09:07 -07003235# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003236# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003237$(if $(filter $(part),$(part:vbmeta_%=%)),\
3238 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3239 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003240endef
3241
Tao Bao0da43472018-08-22 22:53:41 -07003242# Checks and sets the required build variables for an AVB partition. The partition will be
3243# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003244# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3245# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003246# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3247# but vbmeta would capture the image descriptor of only the first boot
3248# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003249# $(1): Partition name, e.g. boot or system.
3250define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003251$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003252$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003253 $(if $(_in_chained_vbmeta),\
3254 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003255 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003256 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003257 $(if $(filter boot,$(1)),\
3258 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3259 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3260 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3261 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003262endef
3263
Hongguang Chenf23364d2020-04-27 18:36:36 -07003264# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3265# $(1): the custom partition to enable AVB chain.
3266define check-and-set-custom-avb-chain-args
3267$(eval part := $(1))
3268$(eval PART=$(call to-upper,$(part)))
3269$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3270$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3271
3272INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3273 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3274endef
3275
Tao Baob1a2e352018-08-14 16:17:12 -07003276ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003277$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003278endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003279
Steve Mucklee1b10862019-07-10 10:49:37 -07003280ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3281$(eval $(call check-and-set-avb-args,vendor_boot))
3282endif
3283
Tao Bao0da43472018-08-22 22:53:41 -07003284$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003285
3286ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003287$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003288endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003289
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003290ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003291$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003292endif
3293
Justin Yun6151e3f2019-06-25 15:58:13 +09003294ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3295$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003296endif
3297
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003298ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003299$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003300endif
3301
Yifan Hongcfb917a2020-05-07 14:58:20 -07003302ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3303$(eval $(call check-and-set-avb-args,vendor_dlkm))
3304endif
3305
Yifan Hongf496f1b2020-07-15 16:52:59 -07003306ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3307$(eval $(call check-and-set-avb-args,odm_dlkm))
3308endif
3309
Yueyao Zhu211c9012017-04-27 00:34:50 -07003310ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003311$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003312endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003313
David Zeuthen8fecb282017-12-01 16:24:01 -05003314ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003315$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003316endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003317
David Anderson7709ab22018-10-15 14:41:34 -07003318# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3319ifdef BOARD_AVB_VBMETA_SYSTEM
3320$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003321endif
3322
3323ifdef BOARD_AVB_VBMETA_VENDOR
3324$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3325endif
3326
Hongguang Chenf23364d2020-04-27 18:36:36 -07003327ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3328$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3329 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3330endif
3331
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003332# Add kernel cmdline descriptor for kernel to mount system.img as root with
3333# dm-verity. This works when system.img is either chained or not-chained:
3334# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3335# cmdline descriptor to system.img
3336# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3337# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003338ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003339ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003340BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003341endif
David Anderson8916a2a2018-09-18 15:46:59 -07003342endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003343
Tao Bao0da43472018-08-22 22:53:41 -07003344BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003345BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003346BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3347
3348ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003349# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003350BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003351endif
Tao Bao0da43472018-08-22 22:53:41 -07003352
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003353ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003354BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003355endif
3356
David Anderson7709ab22018-10-15 14:41:34 -07003357ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3358BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3359 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003360endif
3361
3362ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3363BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3364 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003365endif
3366
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003367# $(1): the directory to extract public keys to
3368define extract-avb-chain-public-keys
3369 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3370 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3371 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003372 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3373 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3374 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003375 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3376 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3377 --output $(1)/system.avbpubkey)
3378 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3379 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3380 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003381 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3382 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3383 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003384 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3385 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3386 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003387 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3388 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3389 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003390 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3391 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3392 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003393 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3394 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3395 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003396 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3397 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3398 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003399 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3400 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3401 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003402 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3403 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3404 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003405 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3406 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3407 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003408 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3409 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3410 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3411 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003412endef
3413
Tao Bao744c4c72018-08-20 21:09:07 -07003414# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3415# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003416# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003417# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3418# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003419# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003420# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003421# $(2): Output filename.
3422define build-chained-vbmeta-image
3423 $(call pretty,"Target chained vbmeta image: $@")
3424 $(hide) $(AVBTOOL) make_vbmeta_image \
3425 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3426 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3427 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3428 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3429 --output $@
3430endef
3431
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003432ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003433ifdef BOARD_AVB_VBMETA_SYSTEM
3434INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3435$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003436 $(AVBTOOL) \
3437 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3438 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003439 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003440endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003441endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003442
3443ifdef BOARD_AVB_VBMETA_VENDOR
3444INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3445$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003446 $(AVBTOOL) \
3447 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3448 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003449 $(call build-chained-vbmeta-image,vbmeta_vendor)
3450endif
3451
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003452define build-vbmetaimage-target
3453 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003454 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3455 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003456 $(hide) $(AVBTOOL) make_vbmeta_image \
3457 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003458 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003459 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3460 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003461 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003462endef
3463
Paul Trautrim4e143232019-08-13 16:30:57 +09003464ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003465INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003466$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3467 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3468
David Zeuthen8fecb282017-12-01 16:24:01 -05003469$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003470 $(AVBTOOL) \
3471 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003472 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003473 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3474 $(INSTALLED_VENDORIMAGE_TARGET) \
3475 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003476 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003477 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003478 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003479 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003480 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003481 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003482 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3483 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3484 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3485 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3486 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3487 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003488 $(build-vbmetaimage-target)
3489
3490.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003491vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3492 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003493vbmetaimage-nodeps:
3494 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003495endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003496
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003497endif # BOARD_AVB_ENABLE
3498
3499# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003500# Check VINTF of build
3501
Yifan Hongf496f1b2020-07-15 16:52:59 -07003502# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003503ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003504
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003505intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3506check_vintf_all_deps :=
3507
Yifan Hongaf9b0702020-01-21 12:46:57 -08003508# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3509# because they are only used for prebuilt images.
3510check_vintf_common_srcs_patterns := \
3511 $(TARGET_OUT)/etc/vintf/% \
3512 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3513 $(TARGET_OUT_ODM)/etc/vintf/% \
3514 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3515 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3516
3517check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3518 $(INTERNAL_SYSTEMIMAGE_FILES) \
3519 $(INTERNAL_VENDORIMAGE_FILES) \
3520 $(INTERNAL_ODMIMAGE_FILES) \
3521 $(INTERNAL_PRODUCTIMAGE_FILES) \
3522 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3523))
3524check_vintf_common_srcs_patterns :=
3525
3526check_vintf_has_system :=
3527check_vintf_has_vendor :=
3528
Yifan Hong28ffd732020-03-13 13:11:10 -07003529ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3530$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3531endif
3532ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3533$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3534endif
3535
Yifan Hong605ea042020-01-14 21:36:00 +00003536# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003537check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3538ifneq ($(check_vintf_system_deps),)
3539check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003540check_vintf_system_log := $(intermediates)/check_vintf_system_log
3541check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003542$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003543 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3544check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003545endif # check_vintf_system_deps
3546check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003547
3548# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003549check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3550ifneq ($(check_vintf_vendor_deps),)
3551check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003552check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3553check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003554# Check vendor SKU=(empty) case when:
3555# - DEVICE_MANIFEST_FILE is not empty; OR
3556# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003557$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003558 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3559 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003560 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003561$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003562 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3563 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3564 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3565 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003566check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003567endif # check_vintf_vendor_deps
3568check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003569
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003570# -- Check VINTF compatibility of build.
3571# Skip partial builds; only check full builds. Only check if:
3572# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003573# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003574# - Building product / system_ext / odm images if board has product / system_ext / odm images
3575ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003576ifeq ($(check_vintf_has_system),true)
3577ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003578ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3579ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3580ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3581
3582check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3583check_vintf_all_deps += $(check_vintf_compatible_log)
3584
3585check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003586check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003587
3588# -- Kernel version and configurations.
3589ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3590
Yifan Hong605ea042020-01-14 21:36:00 +00003591BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3592BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3593
3594my_board_extracted_kernel :=
3595
3596# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3597# from INSTALLED_KERNEL_TARGET.
3598ifdef BOARD_KERNEL_CONFIG_FILE
3599ifdef BOARD_KERNEL_VERSION
3600$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3601 cp $< $@
3602$(BUILT_KERNEL_VERSION_FILE):
3603 echo $(BOARD_KERNEL_VERSION) > $@
3604
3605my_board_extracted_kernel := true
3606endif # BOARD_KERNEL_VERSION
3607endif # BOARD_KERNEL_CONFIG_FILE
3608
3609ifneq ($(my_board_extracted_kernel),true)
3610ifndef INSTALLED_KERNEL_TARGET
3611$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3612 is true. Information about the updated kernel cannot be built into OTA update package. \
3613 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3614 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3615 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3616 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3617 manually.)
3618else
3619
3620# Tools for decompression that is not in PATH.
3621# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3622# Algorithms that are in the script but not in this list will be found in PATH.
3623my_decompress_tools := \
3624 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3625
3626$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3627$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3628$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003629$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3630 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003631 --output-configs $@ \
3632 --output-version $(BUILT_KERNEL_VERSION_FILE)
3633
3634my_decompress_tools :=
3635
3636endif # my_board_extracted_kernel
3637my_board_extracted_kernel :=
3638
3639endif # INSTALLED_KERNEL_TARGET
3640
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003641check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3642check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3643
3644endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3645
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003646check_vintf_compatible_args += \
3647 --dirmap /system:$(TARGET_OUT) \
3648 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3649 --dirmap /odm:$(TARGET_OUT_ODM) \
3650 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3651 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3652
3653ifdef PRODUCT_SHIPPING_API_LEVEL
3654check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3655endif # PRODUCT_SHIPPING_API_LEVEL
3656
3657$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3658$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003659# Check ODM SKU=(empty) case when:
3660# - ODM_MANIFEST_FILES is not empty; OR
3661# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003662$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003663 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3664 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003665 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003666# Check vendor SKU=(empty) case when:
3667# - DEVICE_MANIFEST_FILE is not empty; OR
3668# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003669$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003670 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3671 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003672 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003673$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3674 @echo -n -e 'Deps: \n ' > $@
3675 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3676 @echo -n -e 'Args: \n ' >> $@
3677 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003678 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3679 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003680 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003681 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3682 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3683 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003684
3685check_vintf_compatible_log :=
3686check_vintf_compatible_args :=
3687check_vintf_compatible_deps :=
3688
3689endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3690endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3691endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003692endif # check_vintf_has_vendor
3693endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003694endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3695
3696# Add all logs of VINTF checks to dist builds
3697droid_targets: $(check_vintf_all_deps)
3698$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3699
3700# Helper alias to check all VINTF of current build.
3701.PHONY: check-vintf-all
3702check-vintf-all: $(check_vintf_all_deps)
3703 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3704
Yifan Hongaf9b0702020-01-21 12:46:57 -08003705check_vintf_has_vendor :=
3706check_vintf_has_system :=
3707check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003708check_vintf_all_deps :=
3709intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003710endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003711
3712# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003713# Check image sizes <= size of super partition
3714
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003715ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003716
3717ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003718
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003719# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003720# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003721define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003722 mkdir -p $(dir $(1))
3723 rm -f $(1)
3724 $(call dump-super-image-info, $(1))
3725 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3726 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003727 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003728endef
3729
Yifan Hong30910932019-10-25 20:36:55 -07003730check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3731droid_targets: $(check_all_partition_sizes_log)
3732$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003733
Yifan Hong30910932019-10-25 20:36:55 -07003734$(check_all_partition_sizes_log): \
3735 $(CHECK_PARTITION_SIZES) \
3736 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3737 $(call check-all-partition-sizes-target, \
3738 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3739 $@)
3740
3741.PHONY: check-all-partition-sizes
3742check-all-partition-sizes: $(check_all_partition_sizes_log)
3743
3744.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003745check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003746 $(call check-all-partition-sizes-target, \
3747 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003748
Yifan Hong2dae5722018-07-31 12:47:27 -07003749endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003750
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003751endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003752
3753# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003754# bring in the installer image generation defines if necessary
3755ifeq ($(TARGET_USE_DISKINSTALLER),true)
3756include bootable/diskinstaller/config.mk
3757endif
3758
3759# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003760# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003761
Ying Wangbd2d0242015-09-22 11:17:52 -07003762ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003763 build_ota_package := false
3764 build_otatools_package := false
3765else
Tao Bao9be20c72019-04-08 21:11:59 -07003766 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003767 build_ota_package := true
3768 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3769 build_ota_package := false
3770 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003771 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003772 build_ota_package := false
3773 endif
3774 ifeq ($(TARGET_PRODUCT),sdk)
3775 build_ota_package := false
3776 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003777 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3778 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3779 build_ota_package := false
3780 endif
3781 ifeq ($(TARGET_NO_KERNEL),true)
3782 build_ota_package := false
3783 endif
3784 ifeq ($(recovery_fstab),)
3785 build_ota_package := false
3786 endif
3787 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003788
Tao Bao9be20c72019-04-08 21:11:59 -07003789 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003790 build_otatools_package := true
3791 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3792 build_otatools_package := false
3793 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003794endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003795
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003796ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003797
3798INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003799 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003800 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003801 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003802 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003803 append2simg \
3804 avbtool \
3805 blk_alloc_to_base_fs \
3806 boot_signer \
3807 brillo_update_payload \
3808 brotli \
3809 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003810 build_image \
3811 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003812 build_verity_metadata \
3813 build_verity_tree \
3814 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003815 check_ota_package_signature \
3816 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003817 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003818 checkvintf \
3819 delta_generator \
3820 e2fsck \
3821 e2fsdroid \
3822 fc_sort \
3823 fec \
3824 fs_config \
3825 generate_verity_key \
3826 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003827 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003828 imgdiff \
3829 libconscrypt_openjdk_jni \
3830 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003831 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003832 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003833 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003834 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003835 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003836 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003837 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003838 mkbootfs \
3839 mkbootimg \
3840 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003841 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003842 mkf2fsuserimg.sh \
3843 mksquashfs \
3844 mksquashfsimage.sh \
3845 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003846 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003847 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003848 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003849 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003850 sign_apex \
3851 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003852 signapk \
3853 simg2img \
3854 sload_f2fs \
3855 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003856 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003857 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003858 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003859 verity_signer \
3860 verity_verifier \
3861 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003862
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003863# Additional tools to unpack and repack the apex file.
3864INTERNAL_OTATOOLS_MODULES += \
3865 apexer \
3866 deapexer \
3867 debugfs_static \
3868 merge_zips \
3869 resize2fs \
3870 soong_zip \
3871
Anton Hansson8dab0a62019-03-28 15:45:40 +00003872ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003873INTERNAL_OTATOOLS_MODULES += \
3874 futility \
3875 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003876endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003877
Tao Bao96daeeb2019-05-01 21:17:13 -07003878INTERNAL_OTATOOLS_FILES := \
3879 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003880
Ying Wang06898662010-06-17 17:52:18 -07003881.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003882otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003883
Tao Bao96daeeb2019-05-01 21:17:13 -07003884# For each module, recursively resolve its host shared library dependencies. Then we have a full
3885# list of modules whose installed files need to be packed.
3886INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3887 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3888 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003889
Tao Bao96daeeb2019-05-01 21:17:13 -07003890INTERNAL_OTATOOLS_PACKAGE_FILES := \
3891 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3892
3893INTERNAL_OTATOOLS_PACKAGE_FILES += \
3894 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3895 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003896
3897ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003898INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003899 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003900 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003901endif
3902ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003903INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003904 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3905 -name "atx_metadata.bin"))
3906endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003907ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003908INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003909 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003910endif
3911
Tao Bao96daeeb2019-05-01 21:17:13 -07003912INTERNAL_OTATOOLS_RELEASETOOLS := \
3913 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3914 \( -type f -o -type l \) -print))
3915
3916BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3917$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3918$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3919$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3920$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003921$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003922 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003923 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3924 mkdir -p $(dir $@)
3925 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3926 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003927 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003928 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003929
3930.PHONY: otatools-package
3931otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3932
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003933endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003934
The Android Open Source Project88b60792009-03-03 19:28:42 -08003935# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003936# misc_info.txt
3937
3938INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3939
3940ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3941# default to common dir for device vendor
3942tool_extensions := $(TARGET_DEVICE_DIR)/../common
3943else
3944tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3945endif
3946.KATI_READONLY := tool_extensions
3947
Steve Muckle903a1ca2020-05-07 17:32:10 -07003948# $1: boot image file name
3949define misc_boot_size
3950$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3951endef
3952
Daniel Normane1e48082019-06-27 13:55:23 -07003953$(INSTALLED_MISC_INFO_TARGET):
3954 rm -f $@
3955 $(call pretty,"Target misc_info.txt: $@")
3956 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3957 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3958ifdef BOARD_FLASH_BLOCK_SIZE
3959 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3960endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07003961ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
3962 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
3963 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07003964endif
3965ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3966 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07003967else
3968 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003969endif
J. Avila98cd4cc2020-06-10 20:09:10 +00003970ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
3971 echo "lz4_ramdisks=true" >> $@
3972endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003973ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3974 echo "vendor_boot=true" >> $@
3975 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3976endif
Daniel Normane1e48082019-06-27 13:55:23 -07003977ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3978 $(hide) echo "no_recovery=true" >> $@
3979endif
3980ifdef BOARD_INCLUDE_RECOVERY_DTBO
3981 $(hide) echo "include_recovery_dtbo=true" >> $@
3982endif
3983ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3984 $(hide) echo "include_recovery_acpio=true" >> $@
3985endif
3986ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3987 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3988endif
3989ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3990 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3991 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3992else
3993 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3994endif
3995 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
3996 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
3997ifdef PRODUCT_EXTRA_RECOVERY_KEYS
3998 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
3999endif
4000 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004001 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004002 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4003 $(hide) echo "multistage_support=1" >> $@
4004 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4005ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4006 $(hide) echo "build_generic_ota_package=true" >> $@
4007endif
4008ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4009 # OTA scripts are only interested in fingerprint related properties
4010 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4011endif
4012ifneq (,$(filter address, $(SANITIZE_TARGET)))
4013 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4014 $(hide) echo "userdata_img_with_data=true" >> $@
4015endif
4016ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4017 $(hide) echo "full_recovery_image=true" >> $@
4018endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004019ifdef BOARD_USES_VENDORIMAGE
4020 $(hide) echo "board_uses_vendorimage=true" >> $@
4021endif
Daniel Normane1e48082019-06-27 13:55:23 -07004022ifeq ($(BOARD_AVB_ENABLE),true)
4023 $(hide) echo "avb_enable=true" >> $@
4024 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4025 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4026 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4027 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4028ifdef BOARD_AVB_BOOT_KEY_PATH
4029 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4030 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4031 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4032endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004033 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4034ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4035 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4036 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4037 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4038endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004039 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4040ifdef BOARD_AVB_RECOVERY_KEY_PATH
4041 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4042 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4043 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4044endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004045ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4046 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4047 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4048 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4049 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4050 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4051 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4052 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4053 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4054endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004055ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4056 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4057 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4058 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4059 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4060 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4061endif # BOARD_AVB_VBMETA_SYSTEM
4062ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4063 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4064 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4065 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4066 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4067 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4068endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4069endif # BOARD_AVB_ENABLE
4070ifdef BOARD_BPT_INPUT_FILES
4071 $(hide) echo "board_bpt_enable=true" >> $@
4072 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4073 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4074endif
4075ifdef BOARD_BPT_DISK_SIZE
4076 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4077endif
4078 $(call generate-userimage-prop-dictionary, $@)
4079ifeq ($(AB_OTA_UPDATER),true)
4080 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4081 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4082 $(hide) echo "ab_update=true" >> $@
4083endif
Yifan Hong65afc072020-04-17 10:08:10 -07004084ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4085 $(hide) echo "allow_non_ab=true" >> $@
4086endif
Daniel Normane1e48082019-06-27 13:55:23 -07004087ifdef BOARD_PREBUILT_DTBOIMAGE
4088 $(hide) echo "has_dtbo=true" >> $@
4089ifeq ($(BOARD_AVB_ENABLE),true)
4090 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4091 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4092ifdef BOARD_AVB_DTBO_KEY_PATH
4093 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4094 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4095 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4096endif # BOARD_AVB_DTBO_KEY_PATH
4097endif # BOARD_AVB_ENABLE
4098endif # BOARD_PREBUILT_DTBOIMAGE
4099 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004100 @# VINTF checks
4101ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4102 $(hide) echo "vintf_enforce=true" >> $@
4103endif
4104ifdef ODM_MANIFEST_SKUS
4105 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4106endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004107ifdef ODM_MANIFEST_FILES
4108 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4109endif
4110ifdef DEVICE_MANIFEST_SKUS
4111 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4112endif
4113ifdef DEVICE_MANIFEST_FILE
4114 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4115endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004116ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4117 $(hide) echo "bootloader_in_update_package=true" >> $@
4118endif
Daniel Normane1e48082019-06-27 13:55:23 -07004119
4120.PHONY: misc_info
4121misc_info: $(INSTALLED_MISC_INFO_TARGET)
4122
4123droidcore: $(INSTALLED_MISC_INFO_TARGET)
4124
4125# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004126# A zip of the directories that map to the target filesystem.
4127# This zip can be used to create an OTA package or filesystem image
4128# as a post-build step.
4129#
4130name := $(TARGET_PRODUCT)
4131ifeq ($(TARGET_BUILD_TYPE),debug)
4132 name := $(name)_debug
4133endif
4134name := $(name)-target_files-$(FILE_NAME_TAG)
4135
4136intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4137BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4138$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4139$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004140 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004141
4142# $(1): Directory to copy
4143# $(2): Location to copy it to
4144# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4145define package_files-copy-root
4146 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4147 mkdir -p $(2) && \
4148 $(ACP) -rd $(strip $(1))/* $(2); \
4149 fi
4150endef
4151
Tao Baoa04fca32015-11-30 12:22:24 -08004152built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004153
4154# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004155ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004156built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004157 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004158endif
4159
The Android Open Source Project88b60792009-03-03 19:28:42 -08004160$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4161
Dan Willemsen653bea92017-03-21 15:47:37 -07004162tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004163$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004164
Sen Jiang4438fd92016-03-07 16:51:01 -08004165ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004166updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004167endif
4168
4169# Build OTA tools if non-A/B is allowed
4170ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004171updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004172endif
Yifan Hong65afc072020-04-17 10:08:10 -07004173
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004174$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004175
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004176# If we are using recovery as boot, output recovery files to BOOT/.
4177ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4178$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4179else
4180$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4181endif
4182
Dan Willemsen653bea92017-03-21 15:47:37 -07004183ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004184 ifdef OSRELEASED_DIRECTORY
4185 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4186 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4187 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4188 endif
Tao Baoa835f382019-07-18 15:55:30 -07004189
4190 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4191 # additionally include radio or bootloader partitions).
4192 ifeq ($(AB_OTA_PARTITIONS),)
4193 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4194 endif
4195endif
4196
4197ifneq ($(AB_OTA_PARTITIONS),)
4198 ifneq ($(AB_OTA_UPDATER),true)
4199 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4200 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004201endif
4202
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004203# Run fs_config while creating the target files package
4204# $1: root directory
4205# $2: add prefix
4206define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004207(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 -08004208endef
4209
Yifan Hong60bfcc42019-11-01 11:39:45 -07004210# Filter out vendor from the list for AOSP targets.
4211# $(1): list
4212define filter-out-missing-vendor
4213$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4214endef
4215
4216# Information related to dynamic partitions and virtual A/B. This information
4217# is needed for building the super image (see dump-super-image-info) and
4218# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004219# $(1): file
4220define dump-dynamic-partitions-info
4221 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4222 echo "use_dynamic_partitions=true" >> $(1))
4223 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4224 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004225 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4226 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4227 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004228 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4229 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004230 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4231 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4232 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4233 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4234 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4235 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004236 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004237 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4238 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4239 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4240 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4241 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004242 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 -07004243 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4244 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004245 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4246 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004247 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4248 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004249 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4250 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4251 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4252 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4253 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4254 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4255 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4256 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004257 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4258 echo "virtual_ab=true" >> $(1))
4259 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4260 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004261endef
4262
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004263# By conditionally including the dependency of the target files package on the
4264# full system image deps, we speed up builds that do not build the system
4265# image.
4266ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004267 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4268endif
4269
4270ifdef BUILDING_USERDATA_IMAGE
4271 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4272endif
4273
4274ifdef BUILDING_SYSTEM_OTHER_IMAGE
4275 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4276endif
4277
4278ifdef BUILDING_VENDOR_BOOT_IMAGE
4279 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
4280endif
4281
4282ifdef BUILDING_RECOVERY_IMAGE
4283 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
4284 # BUILD_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
4285 # commands in build-recoveryimage-target, which would touch the files under
4286 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4287 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4288 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4289 else
4290 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4291 endif
4292 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4293endif
4294
4295# Conditionally depend on the image files if the image is being built so the
4296# target-files.zip rule doesn't wait on the image creation rule, or the image
4297# if it is coming from a prebuilt.
4298
4299ifdef BUILDING_VENDOR_IMAGE
4300 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4301else ifdef BOARD_PREBUILT_VENDORIMAGE
4302 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4303endif
4304
4305ifdef BUILDING_PRODUCT_IMAGE
4306 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4307else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4308 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4309endif
4310
4311ifdef BUILDING_SYSTEM_EXT_IMAGE
4312 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4313else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4314 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4315endif
4316
4317ifdef BUILDING_BOOT_IMAGE
4318 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
4319else ifdef BOARD_PREBUILT_BOOTIMAGE
4320 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4321endif
4322
4323ifdef BUILDING_ODM_IMAGE
4324 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4325else ifdef BOARD_PREBUILT_ODMIMAGE
4326 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4327endif
4328
4329ifdef BUILDING_VENDOR_DLKM_IMAGE
4330 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4331else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4332 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4333endif
4334
4335ifdef BUILDING_ODM_DLKM_IMAGE
4336 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4337else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4338 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004339endif
4340
Isaac Chen9e09d472019-07-05 17:30:41 +08004341ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004342 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4343 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004344endif
4345
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004346ifdef BOARD_PREBUILT_BOOTLOADER
4347$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004348droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004349endif
4350
The Android Open Source Project88b60792009-03-03 19:28:42 -08004351# Depending on the various images guarantees that the underlying
4352# directories are up-to-date.
4353$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004354 $(INSTALLED_RADIOIMAGE_TARGET) \
4355 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004356 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004357 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004358 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004359 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4360 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004361 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004362 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4363 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004364 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004365 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004366 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4367 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4368 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004369 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004370 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004371 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004372 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004373 $(LPMAKE) \
4374 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004375 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004376 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004377 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004378 $(SOONG_ZIP) \
4379 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004380 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004381 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004382 $(BUILT_KERNEL_CONFIGS_FILE) \
4383 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004384 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004385 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004386 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004387 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004388ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004389 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004390 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004391 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004392 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004393ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004394ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004395 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Steve Muckle04b6f052020-08-09 14:36:56 -07004396else # BOARD_USES_RECOVERY_AS_BOOT not true
4397 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4398endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004399endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004400ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004401 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004402else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004403ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004404 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004405endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004406ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004407ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004408 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004409else
Steve Mucklee1b10862019-07-10 10:49:37 -07004410 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004411endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004412endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004413ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004414 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004415endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004416ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004417 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004418endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004419ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004420 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004421endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004422ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004423 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004424endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004425ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004426 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004427endif
Colin Crossa6de2ad2020-08-26 18:40:19 -07004428endif # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004429endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004430 @# Components of the boot image
4431 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004432 $(hide) mkdir -p $(zip_root)/ROOT
4433 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004434 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004435 @# If we are using recovery as boot, this is already done when processing recovery.
4436ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004437ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004438 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004439 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004440endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004441ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004442 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004443endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004444ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004445ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004446 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004447endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004448ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004449 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004450endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004451 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004452ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004453 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004454endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004455ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004456 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004457endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004458else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4459 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4460endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4461endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004462 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4463 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004464 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004465ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4466 mkdir -p $(zip_root)/VENDOR_BOOT
4467 $(call package_files-copy-root, \
4468 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4469ifdef INSTALLED_DTBIMAGE_TARGET
4470 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4471endif
4472ifdef BOARD_KERNEL_BASE
4473 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4474endif
4475ifdef BOARD_KERNEL_PAGESIZE
4476 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4477endif
4478 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4479endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004480ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004481 @# Contents of the system image
4482 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004483 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004484endif
4485ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004486 @# Contents of the data image
4487 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004488 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004489endif
4490ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004491 @# Contents of the vendor image
4492 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004493 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004494endif
Dan Willemsen67495202019-01-16 12:42:05 -08004495ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004496 @# Contents of the product image
4497 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004498 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004499endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004500ifdef BUILDING_SYSTEM_EXT_IMAGE
4501 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004502 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004503 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004504endif
Dan Willemsen67495202019-01-16 12:42:05 -08004505ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004506 @# Contents of the odm image
4507 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004508 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004509endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004510ifdef BUILDING_VENDOR_DLKM_IMAGE
4511 @# Contents of the vendor_dlkm image
4512 $(hide) $(call package_files-copy-root, \
4513 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4514endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004515ifdef BUILDING_ODM_DLKM_IMAGE
4516 @# Contents of the odm_dlkm image
4517 $(hide) $(call package_files-copy-root, \
4518 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4519endif
Dan Willemsen67495202019-01-16 12:42:05 -08004520ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004521 @# Contents of the system_other image
4522 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004523 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004524endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004525 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004526 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004527 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004528ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004529ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004530 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004531 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004532endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004533endif
Doug Zongker8678df42009-06-15 14:30:14 -07004534 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004535 @# build them.
4536 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004537 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004538 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004539ifneq ($(tool_extension),)
4540 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4541endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004542 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004543 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004544 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004545ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4546 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4547 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004548endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004549ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4550 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4551 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004552endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004553ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4554 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4555 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004556endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004557ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4558 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4559 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004560endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004561ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4562 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4563 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004564endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004565ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4566 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4567 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4568endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004569ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4570 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4571 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4572endif
Yifan Hong65afc072020-04-17 10:08:10 -07004573ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004574ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004575 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004576 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004577endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004578endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004579ifeq ($(AB_OTA_UPDATER),true)
4580 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004581 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004582 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004583 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4584 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004585 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4586 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4587 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004588ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004589 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4590 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4591 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004592endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004593endif
Steve Fungdfbab492015-09-24 18:12:33 -07004594ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004595 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004596 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004597endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004598ifdef BOARD_PREBUILT_VENDORIMAGE
4599 $(hide) mkdir -p $(zip_root)/IMAGES
4600 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4601endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004602ifdef BOARD_PREBUILT_PRODUCTIMAGE
4603 $(hide) mkdir -p $(zip_root)/IMAGES
4604 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4605endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004606ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004607 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004608 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004609endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004610ifdef BOARD_PREBUILT_BOOTIMAGE
4611 $(hide) mkdir -p $(zip_root)/IMAGES
4612 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4613endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004614ifdef BOARD_PREBUILT_ODMIMAGE
4615 $(hide) mkdir -p $(zip_root)/IMAGES
4616 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4617endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004618ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004619 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004620 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4621endif
4622ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4623 $(hide) mkdir -p $(zip_root)/IMAGES
4624 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004625endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004626ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004627 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4628 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004629endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004630ifdef BOARD_PREBUILT_BOOTLOADER
4631 $(hide) mkdir -p $(zip_root)/IMAGES
4632 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4633endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004634ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4635 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4636 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4637 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4638endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004639 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4640 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4641 @# INSTALLED_RADIOIMAGE_TARGET.
4642 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4643 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004644 @# Run fs_config on all the system, vendor, boot ramdisk,
4645 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004646ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004647 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004648endif
4649ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004650 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4651endif
Dan Willemsen67495202019-01-16 12:42:05 -08004652ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004653 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4654endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004655ifdef BUILDING_SYSTEM_EXT_IMAGE
4656 $(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 +01004657endif
Dan Willemsen67495202019-01-16 12:42:05 -08004658ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004659 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4660endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004661ifdef BUILDING_VENDOR_DLKM_IMAGE
4662 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4663endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004664ifdef BUILDING_ODM_DLKM_IMAGE
4665 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4666endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004667 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004668 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004669ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004670 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004671 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004672endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004673ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4674 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4675endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004676ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4677 @# 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 -08004678 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4679endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004680ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4681 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4682endif
Dan Willemsen67495202019-01-16 12:42:05 -08004683ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004684 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4685endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004686 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004687ifdef BUILT_KERNEL_CONFIGS_FILE
4688 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4689endif
4690ifdef BUILT_KERNEL_VERSION_FILE
4691 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4692endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004693 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4694ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4695 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4696endif
Tao Baocbd6d492019-10-07 22:46:02 -07004697 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4698 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004699ifeq ($(BUILD_QEMU_IMAGES),true)
4700 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4701 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4702endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004703 @# Zip everything up, preserving symlinks and placing META/ files first to
4704 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004705 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004706 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004707 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004708
Ying Wanga0febe52013-03-20 11:02:05 -07004709.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004710target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4711
Ying Wang4709d7c2014-04-14 17:25:43 -07004712$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07004713
Dan Albert4d323332016-10-14 13:23:06 -07004714# -----------------------------------------------------------------
4715# NDK Sysroot Package
4716NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004717$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004718 @echo Package NDK sysroot...
4719 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4720
4721$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4722
Ying Wang09c4b682015-08-11 11:24:19 -07004723ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004724# -----------------------------------------------------------------
4725# OTA update package
4726
Yifan Hong50e79542018-11-08 17:44:12 -08004727# $(1): output file
4728# $(2): additional args
4729define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004730PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004731 $(OTA_FROM_TARGET_FILES) \
4732 --verbose \
4733 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4734 --path $(HOST_OUT) \
4735 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4736 $(2) \
4737 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004738endef
4739
Doug Zongker8678df42009-06-15 14:30:14 -07004740name := $(TARGET_PRODUCT)
4741ifeq ($(TARGET_BUILD_TYPE),debug)
4742 name := $(name)_debug
4743endif
4744name := $(name)-ota-$(FILE_NAME_TAG)
4745
4746INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004747INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4748
Doug Zongker8678df42009-06-15 14:30:14 -07004749$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004750$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07004751$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004752 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004753 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004754
4755.PHONY: otapackage
4756otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4757
Tao Bao519d1822018-12-27 12:47:23 -08004758ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004759name := $(TARGET_PRODUCT)
4760ifeq ($(TARGET_BUILD_TYPE),debug)
4761 name := $(name)_debug
4762endif
4763name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4764
4765INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004766$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004767$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4768 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07004769 $(OTA_FROM_TARGET_FILES) \
4770 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004771 @echo "Package OTA (retrofit dynamic partitions): $@"
4772 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4773
4774.PHONY: otardppackage
4775
4776otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4777
Tao Bao519d1822018-12-27 12:47:23 -08004778endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004779
Ying Wang09c4b682015-08-11 11:24:19 -07004780endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004781
Ying Wang09a00a62010-10-20 14:01:09 -07004782# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004783# A zip of the appcompat directory containing logs
4784APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4785# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004786ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004787$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4788 $(INTERNAL_RAMDISK_FILES) \
4789 $(INTERNAL_USERDATAIMAGE_FILES) \
4790 $(INTERNAL_VENDORIMAGE_FILES) \
4791 $(INTERNAL_PRODUCTIMAGE_FILES) \
4792 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01004793endif
4794$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4795$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4796 @echo "appcompat logs: $@"
4797 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4798 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4799 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4800 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4801
Dario Frenid1011272018-07-23 20:20:15 +01004802# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004803# A zip of the symbols directory. Keep the full paths to make it
4804# more obvious where these files came from.
4805#
4806name := $(TARGET_PRODUCT)
4807ifeq ($(TARGET_BUILD_TYPE),debug)
4808 name := $(name)_debug
4809endif
4810name := $(name)-symbols-$(FILE_NAME_TAG)
4811
4812SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004813# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004814ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004815$(SYMBOLS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4816 $(INTERNAL_RAMDISK_FILES) \
4817 $(INTERNAL_USERDATAIMAGE_FILES) \
4818 $(INTERNAL_VENDORIMAGE_FILES) \
4819 $(INTERNAL_PRODUCTIMAGE_FILES) \
4820 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4821 $(INTERNAL_ODMIMAGE_FILES) \
4822 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4823 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Anton Hansson6d814982018-11-26 18:12:05 +00004824 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004825endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004826$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4827$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004828 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004829 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4830 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004831 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004832 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004833# -----------------------------------------------------------------
4834# A zip of the coverage directory.
4835#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004836name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004837ifeq ($(TARGET_BUILD_TYPE),debug)
4838name := $(name)_debug
4839endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004840COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004841ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004842$(COVERAGE_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4843 $(INTERNAL_RAMDISK_FILES) \
4844 $(INTERNAL_USERDATAIMAGE_FILES) \
4845 $(INTERNAL_VENDORIMAGE_FILES) \
4846 $(INTERNAL_PRODUCTIMAGE_FILES) \
4847 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4848 $(INTERNAL_ODMIMAGE_FILES) \
4849 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4850 $(INTERNAL_ODM_DLKMIMAGE_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004851endif
4852$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4853$(COVERAGE_ZIP): $(SOONG_ZIP)
4854 @echo "Package coverage: $@"
4855 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4856 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4857 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4858 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004859
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004860#------------------------------------------------------------------
4861# Export the LLVM profile data tool and dependencies for Clang coverage processing
4862#
4863ifeq (true,$(CLANG_COVERAGE))
4864 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4865 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4866 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4867 $(PROFDATA_ZIP): $(SOONG_ZIP)
4868 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4869
4870 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4871endif
4872
The Android Open Source Project88b60792009-03-03 19:28:42 -08004873# -----------------------------------------------------------------
4874# A zip of the Android Apps. Not keeping full path so that we don't
4875# include product names when distributing
4876#
4877name := $(TARGET_PRODUCT)
4878ifeq ($(TARGET_BUILD_TYPE),debug)
4879 name := $(name)_debug
4880endif
4881name := $(name)-apps-$(FILE_NAME_TAG)
4882
4883APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07004884$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004885 @echo "Package apps: $@"
4886 $(hide) rm -rf $@
4887 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004888 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4889 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004890 echo "No apps to zip up. Generating empty apps archive." ; \
4891 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004892 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004893 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004894 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004895
Ying Wangbc415dd2012-08-15 12:22:44 -07004896ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004897#------------------------------------------------------------------
4898# An archive of classes for use in generating code-coverage reports
4899# These are the uninstrumented versions of any classes that were
4900# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004901# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004902
Colin Crossa6bc3a82017-09-27 14:28:41 -07004903JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004904$(JACOCO_REPORT_CLASSES_ALL) :
4905 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004906 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4907 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004908
Ying Wangbc415dd2012-08-15 12:22:44 -07004909endif # EMMA_INSTRUMENT=true
4910
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004911
Ying Wangae9115a2013-08-22 20:52:47 -07004912#------------------------------------------------------------------
4913# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004914#
Ying Wangc62c92c2013-08-28 18:38:25 -07004915PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004916# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004917ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004918$(PROGUARD_DICT_ZIP): \
Colin Crosscda30c72020-08-26 18:43:21 -07004919 $(FULL_SYSTEMIMAGE_DEPS) \
4920 $(INTERNAL_RAMDISK_FILES) \
4921 $(INTERNAL_USERDATAIMAGE_FILES) \
4922 $(INTERNAL_VENDORIMAGE_FILES) \
4923 $(INTERNAL_PRODUCTIMAGE_FILES) \
4924 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4925 $(INTERNAL_ODMIMAGE_FILES) \
4926 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4927 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Colin Cross114e8df2019-09-05 17:19:35 -07004928 $(updater_dep)
4929endif
4930$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4931$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004932 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004933 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4934 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4935 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4936 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004937
Colin Crossa9b9e6e2020-08-14 17:43:35 -07004938#------------------------------------------------------------------
4939# A zip of Proguard usage files.
4940#
4941PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
4942# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4943ifeq (,$(TARGET_BUILD_UNBUNDLED))
4944$(PROGUARD_USAGE_ZIP): \
4945 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4946 $(INSTALLED_RAMDISK_TARGET) \
4947 $(INSTALLED_BOOTIMAGE_TARGET) \
4948 $(INSTALLED_USERDATAIMAGE_TARGET) \
4949 $(INSTALLED_VENDORIMAGE_TARGET) \
4950 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4951 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4952 $(INSTALLED_ODMIMAGE_TARGET) \
4953 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4954 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
4955 $(updater_dep)
4956endif
4957$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
4958$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
4959 @echo "Packaging Proguard usage files."
4960 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4961 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
4962 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07004963
4964ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4965
4966# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4967# $(1): output file
4968define dump-super-image-info
4969 $(call dump-dynamic-partitions-info,$(1))
4970 $(if $(filter true,$(AB_OTA_UPDATER)), \
4971 echo "ab_update=true" >> $(1))
4972endef
4973
4974endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4975
The Android Open Source Project88b60792009-03-03 19:28:42 -08004976# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004977# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004978
4979ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4980
4981# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4982ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4983
4984ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004985
4986# For real devices and for dist builds, build super image from target files to an intermediate directory.
4987INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4988$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4989$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4990 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004991 PATH=$(dir $(LPMAKE)):$$PATH \
4992 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004993
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004994# Skip packing it in dist package because it is in update package.
4995ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004996$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004997endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004998
4999.PHONY: superimage_dist
5000superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005001
5002endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005003endif # BOARD_SUPER_PARTITION_SIZE != ""
5004endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005005
Yifan Hongacd862a2019-04-16 15:44:30 -07005006# -----------------------------------------------------------------
5007# super partition image for development
5008
5009ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5010ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5011ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5012
5013# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5014# $(1): built image path
5015# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5016define build-superimage-target
5017 mkdir -p $(dir $(2))
5018 rm -rf $(2)
5019 $(call dump-super-image-info,$(2))
5020 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5021 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005022 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5023 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005024 mkdir -p $(dir $(1))
5025 PATH=$(dir $(LPMAKE)):$$PATH \
5026 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5027endef
5028
5029INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5030INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5031 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5032
changho.shina8f9f112019-10-15 13:26:19 +09005033ifdef BUILDING_SYSTEM_OTHER_IMAGE
5034ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5035INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5036endif
5037endif
5038
Yifan Hongacd862a2019-04-16 15:44:30 -07005039# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5040# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5041# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5042# virtual devices.
5043ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5044$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5045 $(call pretty,"Target super fs image for debug: $@")
5046 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005047 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005048
5049droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5050
5051# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5052.PHONY: superimage
5053superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005054
5055$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005056endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5057
5058# Build $(PRODUCT_OUT)/super.img without dependencies.
5059.PHONY: superimage-nodeps supernod
5060superimage-nodeps supernod: intermediates :=
5061superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5062 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5063 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5064 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5065
5066endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5067endif # BOARD_SUPER_PARTITION_SIZE != ""
5068endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5069
5070# -----------------------------------------------------------------
5071# super empty image
5072
Tao Bao48a2feb2019-06-28 11:00:05 -07005073ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005074ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005075
Yifan Hong8b79d162018-11-29 12:32:00 -08005076INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5077$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5078$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5079 $(call pretty,"Target empty super fs image: $@")
5080 mkdir -p $(intermediates)
5081 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005082 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005083 PATH=$(dir $(LPMAKE)):$$PATH \
5084 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005085
5086$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5087
Yifan Hong2b891ac2018-11-29 12:06:31 -08005088endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005089endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005090
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005091
5092# -----------------------------------------------------------------
5093# The update package
5094
5095name := $(TARGET_PRODUCT)
5096ifeq ($(TARGET_BUILD_TYPE),debug)
5097 name := $(name)_debug
5098endif
5099name := $(name)-img-$(FILE_NAME_TAG)
5100
5101INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5102
Tao Bao57f8ed62019-08-14 23:08:18 -07005103$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5104 $(call pretty,"Package: $@")
5105 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5106 $(IMG_FROM_TARGET_FILES) \
5107 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5108 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005109
5110.PHONY: updatepackage
5111updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005112$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005113
5114
Yifan Hong2b891ac2018-11-29 12:06:31 -08005115# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005116# dalvik something
5117.PHONY: dalvikfiles
5118dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5119
Bo Huf0d50bb2017-08-01 19:02:09 +00005120ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005121MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005122MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005123SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005124
5125ifdef INSTALLED_SYSTEMIMAGE_TARGET
5126INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005127INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5128$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5129 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5130 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005131$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005132 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5133 @echo Create system-qemu.img now
5134 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005135 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005136
5137systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5138droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005139endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005140ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005141INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005142$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005143 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005144 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005145
5146vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5147droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5148endif
bohu8fd437c2020-03-30 20:16:13 -07005149
5150ifdef INSTALLED_RAMDISK_TARGET
5151ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5152ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5153INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5154$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5155 @echo Create ramdisk-qemu.img
5156 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5157
5158droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5159endif
5160endif
5161endif
5162
Anton Hansson32c76fe2018-12-13 14:34:18 +00005163ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005164INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005165$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005166 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005167 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005168
5169productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5170droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5171endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005172ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5173INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5174$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5175 @echo Create system_ext-qemu.img
5176 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005177
Justin Yun6151e3f2019-06-25 15:58:13 +09005178systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5179droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005180endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005181ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005182INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5183$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5184 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005185 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005186
5187odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5188droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5189endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005190
Yifan Hongcfb917a2020-05-07 14:58:20 -07005191ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5192INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5193$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5194 @echo Create vendor_dlkm-qemu.img
5195 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5196
5197vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5198droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5199endif
5200
Yifan Hongf496f1b2020-07-15 16:52:59 -07005201ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5202INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5203$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5204 @echo Create odm_dlkm-qemu.img
5205 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5206
5207odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5208droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5209endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005210
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005211QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005212$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5213 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005214 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005215 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5216 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005217
5218systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5219droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005220
Bo Huf0d50bb2017-08-01 19:02:09 +00005221endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005222# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005223# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005224ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005225INTERNAL_EMULATOR_PACKAGE_FILES += \
5226 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005227 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005228 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005229 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5230 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005231
5232name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5233
5234INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5235
Ying Wang5d887702015-11-04 10:06:25 -08005236$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005237 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005238 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005239
Ying Wang7d8c5352012-07-26 10:15:21 -07005240endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005241
The Android Open Source Project88b60792009-03-03 19:28:42 -08005242
5243# -----------------------------------------------------------------
5244# The SDK
5245
The Android Open Source Project88b60792009-03-03 19:28:42 -08005246# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005247sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005248
5249# Build a name that looks like:
5250#
5251# linux-x86 --> android-sdk_12345_linux-x86
5252# darwin-x86 --> android-sdk_12345_mac-x86
5253# windows-x86 --> android-sdk_12345_windows
5254#
5255sdk_name := android-sdk_$(FILE_NAME_TAG)
5256ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005257 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005258else
Joe Onorato03fbe402009-04-13 08:31:16 -07005259 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005260endif
5261ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005262 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005263endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005264sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005265
5266sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5267
5268ATREE_FILES :=
5269-include $(sdk_dep_file)
5270
5271# if we don't have a real list, then use "everything"
5272ifeq ($(strip $(ATREE_FILES)),)
5273ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005274 $(ALL_DEFAULT_INSTALLED_MODULES) \
5275 $(INSTALLED_RAMDISK_TARGET) \
5276 $(ALL_DOCS) \
5277 $(ALL_SDK_FILES)
5278endif
5279
5280atree_dir := development/build
5281
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005282
The Android Open Source Project88b60792009-03-03 19:28:42 -08005283sdk_atree_files := \
5284 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005285 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005286
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005287# development/build/sdk-android-<abi>.atree is used to differentiate
5288# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5289# files like the kernel image. We use TARGET_CPU_ABI because we don't
5290# have a better way to distinguish between CPU models.
5291ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5292 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5293endif
5294
Anton Hansson8dab0a62019-03-28 15:45:40 +00005295ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5296sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005297else
5298sdk_atree_files += $(atree_dir)/sdk.atree
5299endif
5300
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005301include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005302
The Android Open Source Project88b60792009-03-03 19:28:42 -08005303deps := \
5304 $(target_notice_file_txt) \
5305 $(tools_notice_file_txt) \
5306 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005307 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005308 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005309 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005310 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005311 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005312 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005313 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005314 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005315 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005316 $(INSTALLED_USERDATAIMAGE_TARGET) \
5317 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005318 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005319 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005320 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005321 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005322 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005323 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005324 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005325
5326INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5327$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5328$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5329$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5330$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5331
5332# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5333#
5334#SDK_GNU_ERROR := true
5335
Ying Wang5d887702015-11-04 10:06:25 -08005336$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005337 @echo "Package SDK: $@"
5338 $(hide) rm -rf $(PRIVATE_DIR) $@
5339 $(hide) for f in $(target_gnu_MODULES); do \
5340 if [ -f $$f ]; then \
5341 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5342 including GNU target $$f >&2; \
5343 FAIL=$(SDK_GNU_ERROR); \
5344 fi; \
5345 done; \
5346 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005347 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005348 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005349 ATREE_STRIP="$(HOST_STRIP) -x" \
5350 $(HOST_OUT_EXECUTABLES)/atree \
5351 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5352 -m $(PRIVATE_DEP_FILE) \
5353 -I . \
5354 -I $(PRODUCT_OUT) \
5355 -I $(HOST_OUT) \
5356 -I $(TARGET_COMMON_OUT_ROOT) \
5357 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5358 -v "OUT_DIR=$(OUT_DIR)" \
5359 -v "HOST_OUT=$(HOST_OUT)" \
5360 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5361 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5362 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5363 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5364 -o $(PRIVATE_DIR) && \
5365 cp -f $(target_notice_file_txt) \
5366 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5367 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5368 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5369 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5370 chmod -R ug+rwX $(PRIVATE_DIR) && \
5371 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005372 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5373
Raphael3d224a02010-04-16 17:50:09 -07005374
5375# Is a Windows SDK requested? If so, we need some definitions from here
5376# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005377MAIN_SDK_NAME := $(sdk_name)
5378MAIN_SDK_DIR := $(sdk_dir)
5379MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005380ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005381include $(TOPDIR)development/build/tools/windows_sdk.mk
5382endif
5383
The Android Open Source Project88b60792009-03-03 19:28:42 -08005384# -----------------------------------------------------------------
5385# Findbugs
5386INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5387INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5388$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5389 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005390 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005391 > $@
5392$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5393 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005394 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005395 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005396
5397# -----------------------------------------------------------------
5398# Findbugs
5399
5400# -----------------------------------------------------------------
5401# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005402ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005403include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005404-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005405-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005406-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005407# Also the project-specific tasks
5408-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5409-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005410-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005411# Also add test specifc tasks
5412include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005413include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005414endif
Raphaelc4d47312011-02-15 16:09:36 -08005415
Ying Wang67132ba2015-10-28 16:42:39 -07005416include $(BUILD_SYSTEM)/product-graph.mk
5417
Raphaelc4d47312011-02-15 16:09:36 -08005418# -----------------------------------------------------------------
5419# Create SDK repository packages. Must be done after tasks/* since
5420# we need the addon rules defined.
5421ifneq ($(sdk_repo_goal),)
5422include $(TOPDIR)development/build/tools/sdk_repo.mk
5423endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005424
5425# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005426# Soong generates the list of all shared libraries that are depended on by fuzz
5427# targets. It saves this list as a source:destination pair to
5428# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5429# build of the unstripped shared library, and the destination is the
5430# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5431# where fuzz target shared libraries are to be "reinstalled". The
5432# copy-many-files below generates the rules to copy the unstripped shared
5433# libraries to the device or host "reinstallation" directory. These rules are
5434# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5435# a dependency on each shared library that it needs to be "reinstalled".
5436FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5437
5438# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005439# The rule to build all fuzz targets, and package them.
5440# Note: The packages are created in Soong, and in a perfect world,
5441# we'd be able to create the phony rule there. But, if we want to
5442# have dist goals for the fuzz target, we need to have the PHONY
5443# target defined in make. MakeVarsContext.DistForGoal doesn't take
5444# into account that a PHONY rule create by Soong won't be available
5445# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005446# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005447# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005448.PHONY: haiku
5449haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5450$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005451
5452# -----------------------------------------------------------------
5453# The makefile for haiku line coverage.
5454include $(BUILD_SYSTEM)/line_coverage.mk