blob: 1e273865ce0dfac9e56abb507364e7d5265fd8ea [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))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(TARGET_OUT_ODM),odm,modules.load,,$(dir))) \
389 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
390 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
391 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700392
393# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700395# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900396# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700397# $2 certificate
398# $3 private key
399# $4 compressed
400# $5 partition tag
401# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100402define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700403$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
404$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
405$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
406$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700407
408endef
409
Jaewoong Jung704b4542020-06-29 19:37:53 -0700410# -----------------------------------------------------------------
411# Merge an individual apkcerts output into the final apkcerts.txt output.
412# Use a macro to make it compatible with _apkcerts_write_line
413# $1 apkcerts file to be merged
414# $2 output file
415define _apkcerts_merge
416$(hide) cat $1 >> $2
417
418endef
419
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420name := $(TARGET_PRODUCT)
421ifeq ($(TARGET_BUILD_TYPE),debug)
422 name := $(name)_debug
423endif
424name := $(name)-apkcerts-$(FILE_NAME_TAG)
425intermediates := \
426 $(call intermediates-dir-for,PACKAGING,apkcerts)
427APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700428all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
429$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800430# We don't need to really build all the modules.
431# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700432$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433 @echo APK certs list: $@
434 @mkdir -p $(dir $@)
435 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700436 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700437 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
438 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
439 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
440 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
441 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Ying Wangd9a88d52012-10-26 09:21:28 -0700442 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700443 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444
445.PHONY: apkcerts-list
446apkcerts-list: $(APKCERTS_FILE)
447
Ying Wang15e487a2011-02-15 10:56:18 -0800448ifneq (,$(TARGET_BUILD_APPS))
449 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900450 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800451endif
Ying Wangefb21682010-07-23 16:42:13 -0700452
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900453
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700455# build system stats
456BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
457$(BUILD_SYSTEM_STATS):
458 @rm -f $@
459 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
460 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
461$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700462
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800464# build /product/etc/security/avb/system_other.avbpubkey if needed
465ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800466ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800467INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
468ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800469endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800470endif # BUILDING_SYSTEM_OTHER_IMAGE
471
472# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700473# Modules ready to be converted to Soong, ordered by how many
474# modules depend on them.
475SOONG_CONV := $(sort $(SOONG_CONV))
476SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
477$(SOONG_CONV_DATA):
478 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800479 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS)))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700480
Colin Crossfdea8932017-12-06 14:38:40 -0800481SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700482SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
483$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
484 @rm -f $@
485 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
486$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
487
488# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800489# Modules use -Wno-error, or added default -Wall -Werror
490WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
491$(WALL_WERROR):
492 @rm -f $@
493 echo "# Modules using -Wno-error" >> $@
494 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800495 echo "# Modules added default -Wall" >> $@
496 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
497
498$(call dist-for-goals,droidcore,$(WALL_WERROR))
499
500# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700501# C/C++ flag information for modules
502$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
503
504# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800505# Modules missing profile files
506PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
507$(PGO_PROFILE_MISSING):
508 @rm -f $@
509 echo "# Modules missing PGO profile files" >> $@
510 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
511
512$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
513
514# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700515# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700516# for future OTA packages installed by this system. Actual product
517# deliverables will be re-signed by hand. We expect this file to
518# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700519DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700520
521
Jeff Browne33ba4c2011-07-11 22:11:46 -0700522# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800523# if they don't do anything.
524.PHONY: systemimage
525systemimage:
526
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800527# -----------------------------------------------------------------
528
529.PHONY: event-log-tags
530
Joe Onoratob7510532010-07-14 10:22:54 -0700531# Produce an event logs tag file for everything we know about, in order
532# to properly allocate numbers. Then produce a file that's filtered
533# for what's going to be installed.
534
535all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
536
Colin Crossdc8f8e42012-04-12 13:25:54 -0700537event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
538
Joe Onoratob7510532010-07-14 10:22:54 -0700539# Include tags from all packages that we know about
540all_event_log_tags_src := \
541 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
542
Colin Crossdc8f8e42012-04-12 13:25:54 -0700543# PDK builds will already have a full list of tags that needs to get merged
544# in with the ones from source
545pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
546
547$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800548$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700549 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900550 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700551
Doug Zongkera34fa952011-02-23 12:17:29 -0800552# Include tags from all packages included in this product, plus all
553# tags that are part of the system (ie, not in a vendor/ or device/
554# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800555event_log_tags_src := \
556 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800557 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800558 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800559 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
560 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800561
Colin Crossdc8f8e42012-04-12 13:25:54 -0700562$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700563$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800564$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800565 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900566 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567
568event-log-tags: $(event_log_tags_file)
569
570ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
571
Joe Onoratob7510532010-07-14 10:22:54 -0700572
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573# #################################################################
574# Targets for boot/OS images
575# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800576ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
577 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
578 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
579 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
580 else
581 INSTALLED_2NDBOOTLOADER_TARGET :=
582 endif
583else
584 INSTALLED_BOOTLOADER_MODULE :=
585 INSTALLED_2NDBOOTLOADER_TARGET :=
586endif # TARGET_NO_BOOTLOADER
587ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700588 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
589 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
590 $(PRODUCT_OUT)/$(k))
591 else
592 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
593 endif
Ying Wangc6349742014-01-13 16:14:20 -0800594else
595 INSTALLED_KERNEL_TARGET :=
596endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597
598# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700599# the root dir
600INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601 $(ALL_GENERATED_SOURCES) \
602 $(ALL_DEFAULT_INSTALLED_MODULES))
603
Luis Hector Chavezff489932018-07-03 15:41:40 -0700604INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
605INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
606$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700607$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700608 @echo Installed file list: $@
609 @mkdir -p $(dir $@)
610 @rm -f $@
611 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700612 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700613
614$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
615
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800616#------------------------------------------------------------------
617# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700618ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800619INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700620ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800621$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800622 cat $^ > $@
623endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700624endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800625
Tom Cherryd14b8952018-08-09 14:26:00 -0700626# -----------------------------------------------------------------
627# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800628ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700629INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
630 $(ALL_GENERATED_SOURCES) \
631 $(ALL_DEFAULT_INSTALLED_MODULES))
632
633INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
634INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
635$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700636$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700637 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800638 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700639 @mkdir -p $(dir $@)
640 @rm -f $@
641 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700642 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700643
644$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700645BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
646
J. Avila3f6560e2020-05-11 20:20:03 +0000647ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
648# -l enables the legacy format used by the Linux kernel
649COMPRESSION_COMMAND_DEPS := $(LZ4)
650COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
651RAMDISK_EXT := .lz4
652else
653COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
654COMPRESSION_COMMAND := $(MINIGZIP)
655RAMDISK_EXT := .gz
656endif
657
Joe Onorato64d85d02009-04-09 19:31:12 -0700658# We just build this directly to the install location.
659INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000660$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800661 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000662 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800663
Ying Wangad7fd292013-08-08 16:34:29 -0700664.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000665ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700666 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000667 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800668
Dan Willemsen67495202019-01-16 12:42:05 -0800669endif # BUILDING_RAMDISK_IMAGE
670
The Android Open Source Project88b60792009-03-03 19:28:42 -0800671# -----------------------------------------------------------------
672# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700673
674# This is defined here since we may be building recovery as boot
675# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700676ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
677 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
678else
679 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
680endif
681
Steve Muckle903a1ca2020-05-07 17:32:10 -0700682ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
683 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
684endif
685
686# $1: boot image file name
687# $2: boot image variant (boot, boot-debug)
688define get-bootimage-partition-size
689 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
690endef
Chris Grossa784ef12019-04-22 11:09:57 -0700691
692ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800693INTERNAL_BOOTIMAGE_ARGS := \
694 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700695 --kernel $(INSTALLED_KERNEL_TARGET)
696
697ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
698INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
699endif
700
Steve Mucklee1b10862019-07-10 10:49:37 -0700701ifndef BUILDING_VENDOR_BOOT_IMAGE
702ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
703 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
704endif
705endif
706
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
708
Anton Hansson8dab0a62019-03-28 15:45:40 +0000709ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700710ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000711VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700712 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
713endif
714endif
715
Anton Hansson72e36f02019-02-26 17:36:30 +0000716INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700717
718ifndef BUILDING_VENDOR_BOOT_IMAGE
719ifdef BOARD_KERNEL_BASE
720 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
721endif
722ifdef BOARD_KERNEL_PAGESIZE
723 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
724endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700725ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700726 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
727endif
728else
729# building vendor boot image, dtb/base/pagesize go there
730ifdef GENERIC_KERNEL_CMDLINE
731 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
732endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700733endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700734
Sami Tolvanen3303d902016-03-15 16:49:30 +0000735INTERNAL_MKBOOTIMG_VERSION_ARGS := \
736 --os_version $(PLATFORM_VERSION) \
737 --os_patch_level $(PLATFORM_SECURITY_PATCH)
738
Chris Grossa784ef12019-04-22 11:09:57 -0700739# Define these only if we are building boot
740ifdef BUILDING_BOOT_IMAGE
741INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
742
The Android Open Source Project88b60792009-03-03 19:28:42 -0800743ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800744$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400745
746else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
747
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800748$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400749 $(call pretty,"Target boot image: $@")
750 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800751 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400752 $(hide) $(AVBTOOL) add_hash_footer \
753 --image $@ \
754 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800755 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400756 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
757
758.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800759bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400760 @echo "make $@: ignoring dependencies"
761 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800762 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400763 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800764 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400765 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800766 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400767 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
768
Anton Hansson8dab0a62019-03-28 15:45:40 +0000769else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700770
771$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
772 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000773 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Anton Hansson8dab0a62019-03-28 15:45:40 +0000774 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -0700775 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
776
777.PHONY: bootimage-nodeps
778bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
779 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000780 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000781 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET)
Geremy Condra740b6632014-07-08 20:07:41 -0700782 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
783
Anton Hansson8dab0a62019-03-28 15:45:40 +0000784else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800785
Tao Bao4b577412017-02-22 22:54:39 -0800786$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800787 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000788 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +0000789 $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@
David Riley17be3d32015-03-03 08:54:11 -0800790 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
791
792.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800793bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800794 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000795 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +0000796 $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
David Riley17be3d32015-03-03 08:54:11 -0800797 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
798
799else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800800
801$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
802 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000803 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700804 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700805
806.PHONY: bootimage-nodeps
807bootimage-nodeps: $(MKBOOTIMG)
808 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000809 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700810 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700811
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -0700813endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800814
Tao Baob1a2e352018-08-14 16:17:12 -0700815else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700816ifdef BOARD_PREBUILT_BOOTIMAGE
817ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
818# Remove when b/63676296 is resolved.
819$(error Prebuilt bootimage is only supported for AB targets)
820endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900821INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700822$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700823else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700824INSTALLED_BOOTIMAGE_TARGET :=
825endif # BOARD_PREBUILT_BOOTIMAGE
826endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800827
828# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700829# vendor boot image
830ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
831
832ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
833 $(error vboot 1.0 does not support vendor_boot partition)
834endif
835
836INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
837 $(ALL_GENERATED_SOURCES) \
838 $(ALL_DEFAULT_INSTALLED_MODULES))
839
Steve Muckle414dbe12020-06-18 21:38:35 -0700840INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000841$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
842 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700843
844ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
845 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
846endif
847ifdef BOARD_KERNEL_BASE
848 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
849endif
850ifdef BOARD_KERNEL_PAGESIZE
851 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
852endif
853ifdef INTERNAL_KERNEL_CMDLINE
854 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
855endif
856
857INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
858$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
859ifeq ($(BOARD_AVB_ENABLE),true)
860$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
861 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800862 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700863 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
864 $(AVBTOOL) add_hash_footer \
865 --image $@ \
866 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
867 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
868 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
869else
870$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
871 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800872 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700873 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
874endif
875endif # BUILDING_VENDOR_BOOT_IMAGE
876
877# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800878# NOTICE files
879#
Steve Blockd14d3b42012-03-01 11:34:41 +0000880# We are required to publish the licenses for all code under BSD, GPL and
881# Apache licenses (and possibly other more exotic ones as well). We err on the
882# side of caution, so the licenses for other third-party code are included here
883# too.
884#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800885# This needs to be before the systemimage rules, because it adds to
886# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
887# go into the systemimage.
888
Steve Block495e5852012-02-29 19:18:08 +0000889.PHONY: notice_files
890
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900891# Create the rule to combine the files into text and html/xml forms
Yifan Hong3d3f0302020-05-11 18:35:11 -0700892# $(1) - xml_excluded_system_product_odm_vendor_dlkm|
893# xml_excluded_vendor_product_odm_vendor_dlkm|
894# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900895# $(2) - Plain text output file
896# $(3) - HTML/XML output file
897# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700898# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800899# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900900# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800901# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902#
903# The algorithm here is that we go collect a hash for each of the notice
904# files and write the names of the files that match that hash. Then
905# to generate the real files, we go print out all of the files and their
906# hashes.
907#
908# These rules are fairly complex, so they depend on this makefile so if
909# it changes, they'll run again.
910#
911# TODO: We could clean this up so that we just record the locations of the
912# original notice files instead of making rules to copy them somwehere.
913# Then we could traverse that without quite as much bash drama.
914define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700915$(2): PRIVATE_MESSAGE := $(4)
916$(2): PRIVATE_DIR := $(5)
917$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
918$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800919 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hong3d3f0302020-05-11 18:35:11 -0700920 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm --xml-output, \
921 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000922 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900923 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700924 $(if $(filter $(1),xml_system),-i system --xml-output, \
925 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700926 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
927 --html-output))))))) $(3) \
Anton Hansson6d814982018-11-26 18:12:05 +0000928 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900929notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930endef
931
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000932# Notice file logic isn't relevant for TARGET_BUILD_APPS
933ifndef TARGET_BUILD_APPS
934
The Android Open Source Project88b60792009-03-03 19:28:42 -0800935# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
936# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
937# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000938target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000939tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000941kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
942winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
943pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800944
Bob Badour4b25c902020-01-28 13:23:39 -0800945# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
946# reasons--not to be flashed onto any device. Targets under these directories
947# need no associated notice file on the device UI.
948exclude_target_dirs := apex
949
Steven Morelandae69e572017-12-15 14:49:55 -0800950# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000951ifneq ($(PRODUCT_NOTICE_SPLIT),true)
952target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
953target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
954installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
955$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000956 $(target_notice_file_txt), \
957 $(target_notice_file_html), \
958 "Notices for files contained in the filesystem images in this directory:", \
959 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -0800960 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files), \
961 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000962$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
963 $(hide) $(MINIGZIP) -9 < $< > $@
964$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
965 $(copy-file-to-target)
966else
967target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
968target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900969installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
970
971target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
972target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
973target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
974installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +0100975
976target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
977target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
978target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
979installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +0100980
Justin Yun6151e3f2019-06-25 15:58:13 +0900981target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
982target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
983target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
984installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900985
Chris Gross15d96552019-07-16 14:38:43 -0700986target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
987target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
988target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
989installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
990
Yifan Hong3d3f0302020-05-11 18:35:11 -0700991target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
992target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
993target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
994installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
995
Anton Hansson6ad6f6c2018-11-12 23:33:47 +0000996# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
997# being built. A notice xml file must depend on all modules that could potentially
998# install a license file relevant to it.
999license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)
Bob Badour4b25c902020-01-28 13:23:39 -08001000# Only files copied to a system image need system image notices.
1001license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001002# Phonys/fakes don't have notice files (though their deps might)
1003license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001004# testcases are not relevant to the system image.
1005license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001006# filesystem images: system, vendor, product, system_ext, odm, and vendor_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001007license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001008license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1009license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001010license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001011license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001012license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001013license_modules_agg := $(license_modules_system) \
1014 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001015 $(license_modules_product) \
1016 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001017 $(license_modules_odm) \
1018 $(license_modules_vendor_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001019# targets used for debug symbols only and do not get copied to the device
1020license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1021
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001022license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001023license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1024
1025# Identify the other targets we expect to have notices for:
1026# targets copied to the device but are not readable by the UI (e.g. must boot
1027# into a different partition to read or don't have an associated /etc
1028# directory) must have their notices built somewhere readable.
1029license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1030license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1031license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1032license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1033license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1034license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1035license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1036license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1037license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1038license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1039license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1040license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1041license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1042
1043# after removing targets in system images, targets reported in system images, and
1044# targets used for debug symbols that do not need notices, nothing must remain.
1045license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1046$(call maybe-print-list-and-error, $(license_modules_rest), \
1047 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001048
Chris Grossaad39b32019-06-13 09:43:26 -07001049# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1050# update its notice file, so include those notices in the system partition instead
1051ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001052license_modules_system += $(license_modules_rehomed)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001053system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm
1054system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001055else
Bob Badour4b25c902020-01-28 13:23:39 -08001056license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001057system_xml_directories := xml_system
1058system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001059endif
1060
1061$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001062 $(target_notice_file_txt), \
1063 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001064 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001065 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001066 $(license_modules_system), \
1067 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001068$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001069 $(target_vendor_notice_file_txt), \
1070 $(target_vendor_notice_file_xml), \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001071 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001072 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001073 $(license_modules_vendor), \
1074 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001075$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001076 $(target_product_notice_file_txt), \
1077 $(target_product_notice_file_xml), \
1078 "Notices for files contained in the product filesystem image in this directory:", \
1079 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001080 $(license_modules_product), \
1081 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001082$(eval $(call combine-notice-files, xml_system_ext, \
1083 $(target_system_ext_notice_file_txt), \
1084 $(target_system_ext_notice_file_xml), \
1085 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001086 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001087 $(license_modules_system_ext), \
1088 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001089$(eval $(call combine-notice-files, xml_odm, \
1090 $(target_odm_notice_file_txt), \
1091 $(target_odm_notice_file_xml), \
1092 "Notices for files contained in the odm filesystem image in this directory:", \
1093 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001094 $(license_modules_odm), \
1095 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001096$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1097 $(target_vendor_dlkm_notice_file_txt), \
1098 $(target_vendor_dlkm_notice_file_xml), \
1099 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1100 $(TARGET_OUT_NOTICE_FILES), \
1101 $(license_modules_vendor_dlkm), \
1102 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001103
1104$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1105 $(hide) $(MINIGZIP) -9 < $< > $@
1106$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1107 $(hide) $(MINIGZIP) -9 < $< > $@
1108$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1109 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001110$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001111 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001112$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1113 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001114$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1115 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001116$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1117 $(copy-file-to-target)
1118$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1119 $(copy-file-to-target)
1120$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1121 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001122$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001123 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001124$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1125 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001126$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1127 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001128
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001129ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1130ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1131ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1132ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1133ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001134ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001135endif # PRODUCT_NOTICE_SPLIT
1136
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001137ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001138
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001139$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001140 $(tools_notice_file_txt), \
1141 $(tools_notice_file_html), \
1142 "Notices for files contained in the tools directory:", \
1143 $(HOST_OUT_NOTICE_FILES), \
1144 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001145 $(winpthreads_notice_file), \
1146 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001147
Ying Wang62c81f82013-08-22 20:02:03 -07001148endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001149
1150# The kernel isn't really a module, so to get its module file in there, we
1151# make the target NOTICE files depend on this particular file too, which will
1152# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001153$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001154
Dan Willemsen288bedf2019-05-28 15:36:47 -07001155$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001156
Doug Zongker8678df42009-06-15 14:30:14 -07001157
The Android Open Source Project88b60792009-03-03 19:28:42 -08001158# #################################################################
1159# Targets for user images
1160# #################################################################
1161
Ying Wang933abf12010-06-16 14:31:34 -07001162INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001163ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001164INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1165else
1166ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001167INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1168else
1169ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001170INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1171endif
1172endif
1173endif
1174
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001175# These options tell the recovery updater/installer how to mount the partitions writebale.
1176# <fstype>=<fstype_opts>[|<fstype_opts>]...
1177# fstype_opts := <opt>[,<opt>]...
1178# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001179# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1180DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001181
Ying Wang542903a2010-11-17 15:40:38 -08001182ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1183 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1184endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001185ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1186 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1187endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001188ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1189 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1190endif
Tao Baodba635a2019-06-24 10:39:54 -07001191
1192INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001193 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001194 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001195 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001196
1197ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1198INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001199endif
1200
Yifan Hongcfb917a2020-05-07 14:58:20 -07001201ifneq ($(filter \
1202 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1203 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1204 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1205 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1206 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1207 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001208 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001209 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001210INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1211endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212
Anton Hansson8dab0a62019-03-28 15:45:40 +00001213ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001214INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001215ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001216INTERNAL_USERIMAGES_DEPS += $(FEC)
1217endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001218endif
1219
Tao Baodba635a2019-06-24 10:39:54 -07001220ifeq ($(BOARD_AVB_ENABLE),true)
1221INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1222endif
1223
1224# Get a colon-separated list of search paths.
1225INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1226
Alex Klyubin092c9022017-03-13 13:28:34 -07001227SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001228INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1229
Yifan Hongc5c01242018-11-09 10:27:23 -08001230ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001231
Anton Hansson8dab0a62019-03-28 15:45:40 +00001232ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001233 $(error vboot 1.0 doesn't support logical partition)
1234endif
1235
Yifan Hongc5c01242018-11-09 10:27:23 -08001236endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001237
Ying Wangbd93d422011-10-28 17:02:30 -07001238# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001239# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001240# $(3): additional "key=value" pairs to append to the dictionary file.
1241define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001242$(if $(filter $(2),system),\
1243 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001244 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001245 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1246 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1247 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1248 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1249 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1250 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1251 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1252 $(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 +00001253 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1254 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001255 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001256 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001257 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1258)
1259$(if $(filter $(2),system_other),\
1260 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001261)
Yifan Hong760d3c02018-05-30 11:16:46 -07001262$(if $(filter $(2),userdata),\
1263 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1264 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001265 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1266 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001267 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001268 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001269)
Yifan Hong760d3c02018-05-30 11:16:46 -07001270$(if $(filter $(2),cache),\
1271 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1272 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001273 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001274 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001275)
1276$(if $(filter $(2),vendor),\
1277 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1278 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1279 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1280 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1281 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1282 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1283 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1284 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1285 $(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 +00001286 $(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 -07001287 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001288 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001289 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001290)
1291$(if $(filter $(2),product),\
1292 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1293 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1294 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1295 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1296 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1297 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1298 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1299 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1300 $(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 +00001301 $(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 -07001302 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001303 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001304 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001305)
Justin Yun6151e3f2019-06-25 15:58:13 +09001306$(if $(filter $(2),system_ext),\
1307 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1308 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1309 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1310 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1311 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1312 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1313 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1314 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1315 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1316 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1317 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001318 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001319)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001320$(if $(filter $(2),odm),\
1321 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1322 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1323 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1324 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1325 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1326 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1327 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1328 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1329 $(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 +00001330 $(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 +08001331 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001332 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001333 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001334)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001335$(if $(filter $(2),vendor_dlkm),\
1336 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1337 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1338 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1339 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1340 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1341 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1342 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1343 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1344 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1345 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1346 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1347 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1348)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001349$(if $(filter $(2),odm_dlkm),\
1350 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1351 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1352 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1353 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1354 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1355 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1356 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1357 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1358 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1359 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1360 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1361 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1362)
Yifan Hong760d3c02018-05-30 11:16:46 -07001363$(if $(filter $(2),oem),\
1364 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1365 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1366 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1367 $(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 -07001368 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001369)
Tao Bao3602eca2018-07-10 10:53:55 -07001370$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001371
Tao Bao3602eca2018-07-10 10:53:55 -07001372$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001373$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001374$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001375$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001376$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1377$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1378$(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 +00001379$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1380$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1381$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1382$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1383$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001384$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001385$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1386$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1387$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001388$(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 -07001389$(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 -07001390$(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 +00001391$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1392$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1393$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1394$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1395$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001396$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001397$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1398$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1399$(if $(BOARD_AVB_ENABLE),\
1400 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1401 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1402 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1403 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001404$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1405$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1406$(if $(BOARD_AVB_ENABLE),\
1407 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1408 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001409 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001410$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1411$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1412$(if $(BOARD_AVB_ENABLE),\
1413 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1414 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1415 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1416 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001417$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1418$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1419$(if $(BOARD_AVB_ENABLE),\
1420 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1421 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1422 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1423 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001424$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001425$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001426 $(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 +01001427$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001428 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1429 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1430 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1431 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001432$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1433$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1434$(if $(BOARD_AVB_ENABLE),\
1435 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1436 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1437 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1438 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001439$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1440$(if $(BOARD_AVB_ENABLE),\
1441 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1442$(if $(BOARD_AVB_ENABLE),\
1443 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1444 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1445 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1446 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001447$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1448$(if $(BOARD_AVB_ENABLE),\
1449 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1450$(if $(BOARD_AVB_ENABLE),\
1451 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1452 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1453 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1454 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001455$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1456 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001457$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001458 $(hide) echo "system_root_image=true" >> $(1))
1459$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001460$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1461 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001462$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1463endef
1464
1465# $(1): the path of the output dictionary file
1466# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001467PROP_DICTIONARY_IMAGES := oem
1468ifdef BUILDING_CACHE_IMAGE
1469 PROP_DICTIONARY_IMAGES += cache
1470endif
1471ifdef BUILDING_SYSTEM_IMAGE
1472 PROP_DICTIONARY_IMAGES += system
1473endif
Chris Gross203191b2020-05-30 02:39:12 +00001474ifdef BUILDING_SYSTEM_OTHER_IMAGE
1475 PROP_DICTIONARY_IMAGES += system_other
1476endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001477ifdef BUILDING_USERDATA_IMAGE
1478 PROP_DICTIONARY_IMAGES += userdata
1479endif
1480ifdef BUILDING_VENDOR_IMAGE
1481 PROP_DICTIONARY_IMAGES += vendor
1482endif
1483ifdef BUILDING_PRODUCT_IMAGE
1484 PROP_DICTIONARY_IMAGES += product
1485endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001486ifdef BUILDING_SYSTEM_EXT_IMAGE
1487 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001488endif
1489ifdef BUILDING_ODM_IMAGE
1490 PROP_DICTIONARY_IMAGES += odm
1491endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001492ifdef BUILDING_VENDOR_DLKM_IMAGE
1493 PROP_DICTIONARY_IMAGES += vendor_dlkm
1494endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001495ifdef BUILDING_ODM_DLKM_IMAGE
1496 PROP_DICTIONARY_IMAGES += odm_dlkm
1497endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001498define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001499 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001500endef
1501
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001502# $(1): the path of the input dictionary file, where each line has the format key=value
1503# $(2): the key to look up
1504define read-image-prop-dictionary
1505$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1506endef
1507
The Android Open Source Project88b60792009-03-03 19:28:42 -08001508# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001509# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001510
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001511# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001512ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001513
Ying Wang37526142015-03-10 12:02:57 -07001514INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1515 $(ALL_DEFAULT_INSTALLED_MODULES))
1516
Tao Bao10fc9492018-08-14 12:17:48 -07001517INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1518INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1519
1520# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1521# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1522# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1523# the call to FILELIST.
1524ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001525INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001526$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1527else
1528$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1529endif
1530
1531$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001532$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001533 @echo Installed file list: $@
1534 @mkdir -p $(dir $@)
1535 @rm -f $@
1536 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001537 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001538
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001539recovery_sepolicy := \
1540 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001541 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001542 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001543 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1544 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1545 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001546 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001547 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001548 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1549 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1550 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001551
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001552# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1553# SELinux files
1554IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1555
Doug Zongker4647f122009-07-02 09:00:54 -07001556recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1557recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001558recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001559
Anton Hansson45a40da2019-01-18 14:06:34 +00001560# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1561# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1562# which get remapped to a bucket.
1563recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001564ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1565recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001566# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001567# ------160------240------320----------480------------640------
1568# mdpi hdpi xhdpi xxhdpi xxxhdpi
1569recovery_density := $(strip \
1570 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1571 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1572 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1573 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001574endif
1575
1576ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1577recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1578else
Doug Zongker25d55f82014-04-04 13:51:15 -07001579recovery_resources_common := $(recovery_resources_common)-xhdpi
1580endif
1581
Tao Baoe1e829e2018-08-29 20:36:00 -07001582# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1583# Note that the font selected here can be overridden for a particular device by putting a font.png
1584# in its private recovery resources.
1585ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001586recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001587else
Dan Willemsen97672232020-05-27 00:09:16 -07001588recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001589endif
1590
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001591
1592# We will only generate the recovery background text images if the variable
1593# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1594# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1595# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1596# BoardConfig in order to use this feature.
1597ifeq ($(recovery_density),xxxhdpi)
1598TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1599else ifeq ($(recovery_density),xxhdpi)
1600TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1601endif
1602
1603ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1604# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1605ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1606 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1607else
1608 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1609endif
1610
1611
Dan Willemsen97672232020-05-27 00:09:16 -07001612RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001613RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1614RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1615RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1616RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1617
xunchangcc57d312018-12-07 12:12:17 -08001618RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1619RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1620RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1621RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1622RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1623
1624generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001625 $(RECOVERY_INSTALLING_TEXT_FILE) \
1626 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1627 $(RECOVERY_ERASING_TEXT_FILE) \
1628 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001629 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1630 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1631 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1632 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1633 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1634 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001635
Dan Willemsen97672232020-05-27 00:09:16 -07001636resource_dir := bootable/recovery/tools/recovery_l10n/res/
1637resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001638image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001639zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001640$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001641$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001642$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1643$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001644$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001645$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001646$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001647 recovery_installing \
1648 recovery_installing_security \
1649 recovery_erasing \
1650 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001651 recovery_no_command
1652$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001653 recovery_cancel_wipe_data \
1654 recovery_factory_data_reset \
1655 recovery_try_again \
1656 recovery_wipe_data_menu_header \
1657 recovery_wipe_data_confirmation
1658$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001659$(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 -08001660 # Prepares the font directory.
1661 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1662 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001663 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001664 @rm -rf $(dir $@)
1665 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001666 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001667 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001668 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001669 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1670 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1671 --text_name $(text_name) \
1672 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1673 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001674 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001675 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001676else
1677RECOVERY_INSTALLING_TEXT_FILE :=
1678RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1679RECOVERY_ERASING_TEXT_FILE :=
1680RECOVERY_ERROR_TEXT_FILE :=
1681RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001682RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1683RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1684RECOVERY_TRY_AGAIN_TEXT_FILE :=
1685RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1686RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001687endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1688
Ying Wang9a175682015-08-06 11:47:47 -07001689ifndef TARGET_PRIVATE_RES_DIRS
1690TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1691endif
Doug Zongker4647f122009-07-02 09:00:54 -07001692recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001693 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001694recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001695
1696
Andrew Boiefa61ff02012-09-28 09:33:45 -07001697ifdef TARGET_RECOVERY_FSTAB
1698recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1699else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001700recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001701endif
Tao Baoc3c17532016-06-10 10:11:54 -07001702ifdef TARGET_RECOVERY_WIPE
1703recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001704else
Tao Baoc3c17532016-06-10 10:11:54 -07001705recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001706endif
Tao Bao8beab692015-07-22 12:33:18 -07001707
Tao Bao6d5d6232018-03-09 17:04:42 -08001708# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001709# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001710# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1711# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001712#
1713# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001714# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001715# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001716# b) We build a single image that contains boot and recovery both - no recovery image to install
1717# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001718# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001719# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001720# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1721# do bsdiff because boot and recovery will contain different number of entries
1722# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001723# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1724# do bsdiff because boot and recovery will contain different number of entries
1725# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001726
Tom Cherry2929cad2018-09-20 11:04:37 -07001727ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001728 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001729# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001730RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1731ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001732else
Tao Bao8beab692015-07-22 12:33:18 -07001733RECOVERY_RESOURCE_ZIP :=
1734endif
Doug Zongker4647f122009-07-02 09:00:54 -07001735
Tao Bao139c7272018-07-31 13:26:54 -07001736INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1737
1738$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001739 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1740 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1741 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1742 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1743 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1744 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1745 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1746 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1747
1748# Parses the given list of build variables and writes their values as build properties if defined.
1749# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1750# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1751# $(1): Map from the build variable names to property names
1752# $(2): Output file
1753define append-recovery-ui-properties
1754echo "#" >> $(2)
1755echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1756echo "#" >> $(2)
1757$(foreach prop,$(1), \
1758 $(eval _varname := $(call word-colon,1,$(prop))) \
1759 $(eval _propname := $(call word-colon,2,$(prop))) \
1760 $(eval _value := $($(_varname))) \
1761 $(if $(_value), \
1762 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1763endef
1764
1765$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001766 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001767 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1768 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1769 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001770 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001771 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001772 $(hide) mkdir -p $(dir $@)
1773 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001774 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001775 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001776 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001777 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001778 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001779 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1780
Steve Mucklef84668e2020-03-16 19:13:46 -07001781ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001782 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001783ifdef GENERIC_KERNEL_CMDLINE
1784 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1785endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001786else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001787 INTERNAL_RECOVERYIMAGE_ARGS := \
1788 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001789 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001790# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001791ifdef INTERNAL_KERNEL_CMDLINE
1792 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001793endif
1794ifdef BOARD_KERNEL_BASE
1795 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1796endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001797ifdef BOARD_KERNEL_PAGESIZE
1798 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1799endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001800ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001801ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1802 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1803else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001804 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1805endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001806endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001807ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1808 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1809endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001810ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1811 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1812endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001813endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001814ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1815 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1816endif
Doug Zongker4647f122009-07-02 09:00:54 -07001817
J. Avila3f6560e2020-05-11 20:20:03 +00001818$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001819 $(INTERNAL_ROOT_FILES) \
1820 $(INSTALLED_RAMDISK_TARGET) \
1821 $(INTERNAL_RECOVERYIMAGE_FILES) \
1822 $(recovery_sepolicy) \
1823 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1824 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1825 $(recovery_resource_deps) \
1826 $(recovery_fstab)
1827 # Making recovery image
1828 mkdir -p $(TARGET_RECOVERY_OUT)
1829 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1830 # Copying baseline ramdisk...
1831 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1832 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1833 # Modifying ramdisk contents...
1834 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1835 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1836 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1837 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1838 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1839 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1840 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1841 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1842 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1843 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1844 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1845 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1846 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1847 $(foreach item,$(recovery_fstab), \
1848 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1849 $(if $(strip $(recovery_wipe)), \
1850 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1851 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1852 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001853 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001854
Ying Wang747b9f12015-01-30 14:05:22 -08001855# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001856# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001857define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001858 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001859 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001860 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001861 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001862 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001863 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001864 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001865 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001866 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001867 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1868 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001869 )\
1870 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001871 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1872 $(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 +08001873 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001874 $(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 -07001875 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001876 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1877 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001878 $(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 -07001879 $(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 -08001880endef
1881
Dan Willemsend120ac62020-06-12 02:39:34 +00001882recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001883ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001884 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001885endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001886ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001887 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001888endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001889ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001890 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001891endif
Tao Baof4866c72018-08-22 14:35:09 -07001892ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001893 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1894 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1895 else
1896 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1897 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001898endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001899ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001900 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001901endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001902ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001903 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001904endif
Tao Baof4866c72018-08-22 14:35:09 -07001905
Dan Willemsend120ac62020-06-12 02:39:34 +00001906ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1907$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001908 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001909 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001910endif # BOARD_USES_RECOVERY_AS_BOOT
1911
Dan Willemsend120ac62020-06-12 02:39:34 +00001912$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001913 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001914
Tao Bao4594d0e2015-12-22 09:47:46 -08001915ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001916$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001917 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001918 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1919 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001920endif
Doug Zongker56588872012-08-20 15:38:58 -07001921
Ying Wang747b9f12015-01-30 14:05:22 -08001922.PHONY: recoveryimage-nodeps
1923recoveryimage-nodeps:
1924 @echo "make $@: ignoring dependencies"
1925 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1926
Chris Grossa784ef12019-04-22 11:09:57 -07001927else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001928RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001929endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001930
1931.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001932recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001933
Jiyong Park03eb0612017-10-04 21:22:41 +09001934ifneq ($(BOARD_NAND_PAGE_SIZE),)
1935$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001936endif
1937
Jiyong Park03eb0612017-10-04 21:22:41 +09001938ifneq ($(BOARD_NAND_SPARE_SIZE),)
1939$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001940endif
1941
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001942ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07001943# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08001944# the debug ramdisk, which is the original ramdisk plus additional
1945# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
1946# When /force_debuggable is present, /init will load userdebug sepolicy
1947# and property files to allow adb root, if the device is unlocked.
1948
1949ifdef BUILDING_RAMDISK_IMAGE
1950BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
1951INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
1952
1953INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
1954 $(ALL_GENERATED_SOURCES) \
1955 $(ALL_DEFAULT_INSTALLED_MODULES))
1956
1957# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
1958# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
1959# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
1960my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
1961
1962INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
1963INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
1964$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
1965$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
1966
1967# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
1968# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
1969# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
1970$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001971$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001972 echo Installed file list: $@
1973 mkdir -p $(dir $@)
1974 rm -f $@
1975 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001976 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08001977
1978# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
1979# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
1980ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1981my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
1982else
1983my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
1984endif # BOARD_USES_RECOVERY_AS_BOOT
1985
1986$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
1987$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08001988
1989ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1990# 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 +08001991$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08001992else
1993# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
1994$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
1995endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00001996$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001997 $(call pretty,"Target debug ram disk: $@")
1998 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
1999 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002000 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002001 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002002
2003.PHONY: ramdisk_debug-nodeps
2004ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2005ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002006ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002007 echo "make $@: ignoring dependencies"
2008 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2009 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002010 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002011 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002012
2013my_debug_ramdisk_sync_dir :=
2014my_debug_ramdisk_root_dir :=
2015
2016endif # BUILDING_RAMDISK_IMAGE
2017
2018# -----------------------------------------------------------------
2019# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2020#
2021# Note: it's intentional to skip signing for boot-debug.img, because it
2022# can only be used if the device is unlocked with verification error.
2023ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002024ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2025 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2026 $(PRODUCT_OUT)/$(k).img)
2027else
2028 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2029endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002030
2031# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2032ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2033INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2034else
2035INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2036endif
2037
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002038# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2039# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2040# Using a test key to sign boot-debug.img to continue booting with the mismatched
2041# public key, if the device is unlocked.
2042ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002043$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002044endif
2045
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002046BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2047INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2048# $(1): the bootimage to sign
2049define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002050$(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 +08002051$(AVBTOOL) add_hash_footer \
2052 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002053 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002054 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2055 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002056$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002057endef
2058
Steve Muckleb3dda772020-03-11 16:03:07 -07002059# $(1): output file
2060define build-debug-bootimage-target
2061 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2062 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2063 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2064endef
2065
Bowgo Tsai0013f552019-03-20 17:59:52 +08002066# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2067$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2068 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002069 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002070
2071.PHONY: bootimage_debug-nodeps
2072bootimage_debug-nodeps: $(MKBOOTIMG)
2073 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002074 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002075
2076endif # TARGET_NO_KERNEL
2077
Bowgo Tsai6a683672020-02-14 19:00:15 +08002078ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2079ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2080# -----------------------------------------------------------------
2081# vendor debug ramdisk
2082# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002083INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002084$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2085$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2086
2087INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2088 $(ALL_GENERATED_SOURCES) \
2089 $(ALL_DEFAULT_INSTALLED_MODULES))
2090
2091# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2092# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2093# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2094# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2095$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2096$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002097$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002098 $(call pretty,"Target vendor debug ram disk: $@")
2099 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2100 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2101 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2102 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2103 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002104 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002105
2106INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2107INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2108$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2109$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2110
2111# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2112# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2113$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2114$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2115 echo Installed file list: $@
2116 mkdir -p $(dir $@)
2117 rm -f $@
2118 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2119 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2120
2121# -----------------------------------------------------------------
2122# vendor_boot-debug.img.
2123INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2124
2125# The util to sign vendor_boot-debug.img with a test key.
2126BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2127INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2128# $(1): the vendor bootimage to sign
2129define test-key-sign-vendor-bootimage
2130$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2131$(AVBTOOL) add_hash_footer \
2132 --image $(1) \
2133 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2134 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2135 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2136$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2137endef
2138
2139ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2140$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2141endif
2142
2143# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2144$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2145 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002146 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002147 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2148 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2149
2150endif # BUILDING_RAMDISK_IMAGE
2151endif # BUILDING_VENDOR_BOOT_IMAGE
2152
Bowgo Tsai0013f552019-03-20 17:59:52 +08002153# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002154# The test harness ramdisk, which is based off debug_ramdisk, plus a
2155# few additional test-harness-specific properties in adb_debug.prop.
2156
2157ifdef BUILDING_RAMDISK_IMAGE
2158BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2159INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2160
2161# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2162# appends a few test harness specific properties into the adb_debug.prop.
2163TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2164TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2165
2166# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2167# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2168TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2169ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2170ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2171
2172# $(1): a list of key=value pairs for additional property assignments
2173# $(2): the target .prop file to append the properties from $(1)
2174define append-test-harness-props
2175 echo "#" >> $(2); \
2176 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2177 echo "#" >> $(2);
2178 $(foreach line,$(1), echo "$(line)" >> $(2);)
2179endef
2180
2181$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002182$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002183 $(call pretty,"Target test harness ram disk: $@")
2184 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2185 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002186 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002187
2188.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002189ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002190 echo "make $@: ignoring dependencies"
2191 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2192 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002193 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002194
2195endif # BUILDING_RAMDISK_IMAGE
2196
2197# -----------------------------------------------------------------
2198# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2199#
2200# Note: it's intentional to skip signing for boot-test-harness.img, because it
2201# can only be used if the device is unlocked with verification error.
2202ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2203
Steve Muckle4866bd62020-04-02 11:31:08 -07002204ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2205 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2206 $(PRODUCT_OUT)/$(k).img)
2207else
2208 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2209endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002210
2211# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2212INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2213
2214# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2215# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2216# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2217# public key, if the device is unlocked.
2218ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2219$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2220endif
2221
Steve Muckle4866bd62020-04-02 11:31:08 -07002222# $(1): output file
2223define build-boot-test-harness-target
2224 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2225 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2226 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2227endef
2228
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002229# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2230$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2231 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002232 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002233
2234.PHONY: bootimage_test_harness-nodeps
2235bootimage_test_harness-nodeps: $(MKBOOTIMG)
2236 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002237 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002238
2239endif # TARGET_NO_KERNEL
2240endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2241
2242# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002243# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002244#
Ying Wang9c649a72012-08-08 15:27:00 -07002245# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2246PDK_FUSION_SYSIMG_FILES := \
2247 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2248 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002249
Dan Willemsen37a19862018-10-31 16:31:46 -07002250INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002251 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002252 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002253 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002254 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002255
Ying Wang82cceba2012-08-13 15:03:00 -07002256FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002257
2258# ASAN libraries in the system image - add dependency.
2259ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002260ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002261 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2262 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2263 endif
2264endif
2265
Tom Cherryd14b8952018-08-09 14:26:00 -07002266FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002267
Ying Wange5e8c5f2011-09-09 16:35:53 -07002268# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002269ifdef BUILDING_SYSTEM_IMAGE
2270
Ying Wange5e8c5f2011-09-09 16:35:53 -07002271# installed file list
2272# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2273# We put installed-files.txt ahead of image itself in the dependency graph
2274# so that we can get the size stat even if the build fails due to too large
2275# system image.
2276INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002277INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2278$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002279$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002280 @echo Installed file list: $@
2281 @mkdir -p $(dir $@)
2282 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002283 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002284 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002285
2286.PHONY: installed-file-list
2287installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002288
2289$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002290
2291systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002292 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002293BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2294
Ying Wang23898df2014-06-18 20:26:24 -07002295# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002296ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002297define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002298$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2299 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2300 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2301 exit 1; \
2302fi
Ying Wang23898df2014-06-18 20:26:24 -07002303$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2304endef
2305else
2306define create-system-vendor-symlink
2307endef
2308endif
2309
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002310# Create symlink /system/product to /product if necessary.
2311ifdef BOARD_USES_PRODUCTIMAGE
2312define create-system-product-symlink
2313$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2314 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2315 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2316 exit 1; \
2317fi
2318$(hide) ln -sf /product $(TARGET_OUT)/product
2319endef
2320else
2321define create-system-product-symlink
2322endef
2323endif
2324
Justin Yun6151e3f2019-06-25 15:58:13 +09002325# Create symlink /system/system_ext to /system_ext if necessary.
2326ifdef BOARD_USES_SYSTEM_EXTIMAGE
2327define create-system-system_ext-symlink
2328$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2329 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2330 echo 'You cannot install files to $(TARGET_OUT)/system_ext while building a separate system_ext.img!' 1>&2; \
Dario Freni5f681e12018-05-29 13:09:01 +01002331 exit 1; \
2332fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002333$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002334endef
2335else
Justin Yun6151e3f2019-06-25 15:58:13 +09002336define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002337endef
2338endif
2339
The Android Open Source Project88b60792009-03-03 19:28:42 -08002340# $(1): output file
2341define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002342 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002343 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002344 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002345 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002346 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002347 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002348 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002349 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002350 $(BUILD_IMAGE) \
2351 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2352 || ( mkdir -p $${DIST_DIR}; \
2353 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2354 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002355endef
2356
Dan Willemsen6b72c732019-06-12 21:33:38 +00002357ifeq ($(BOARD_AVB_ENABLE),true)
2358$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2359endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002360$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002361 $(call build-systemimage-target,$@)
2362
Tao Baoe9d61b02018-08-20 21:09:07 -07002363INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002364SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002365
Tao Baoe9d61b02018-08-20 21:09:07 -07002366# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2367# compatibility, in case device-specific Makefiles still refer to the old name.
2368INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2369
Doug Zongker73ef8252009-07-23 15:12:53 -07002370# The system partition needs room for the recovery image as well. We
2371# now store the recovery image as a binary patch using the boot image
2372# as the source (since they are very similar). Generate the patch so
2373# we can see how big it's going to be, and include that in the system
2374# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002375ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002376ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002377ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002378ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002379diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2380else
2381diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2382endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002383intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2384RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002385$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2386$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002387 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2388 $(INSTALLED_BOOTIMAGE_TARGET) \
2389 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002390 @echo "Construct recovery from boot"
2391 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002392 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002393else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2394RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002395endif # BOARD_USES_FULL_RECOVERY_IMAGE
2396endif # INSTALLED_RECOVERYIMAGE_TARGET
2397endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002398
Yifan Hong9a3cad92020-04-27 19:06:59 -07002399$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002400 @echo "Install system fs image: $@"
2401 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002402 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002403
Tao Baoe9d61b02018-08-20 21:09:07 -07002404systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002405
2406.PHONY: systemimage-nodeps snod
2407systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002408 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002409 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002410 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002411 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002412ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002413 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002414endif
2415
Dan Willemsen67495202019-01-16 12:42:05 -08002416endif # BUILDING_SYSTEM_IMAGE
2417
Anton Hansson30e061b2018-11-12 13:36:46 +00002418.PHONY: sync syncsys
2419sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002420
Ying Wang3a61eeb2016-03-11 10:32:01 -08002421# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002422## platform.zip: system, plus other files to be used in PDK fusion build,
2423## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002424##
2425## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2426## The variable will be typically set from BoardConfig.mk.
2427## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002428ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002429pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002430 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002431pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002432 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002433pdk_classes_dex := $(strip \
2434 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002435 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002436
2437pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2438$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2439$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2440$(pdk_odex_config_mk) :
2441 @echo "PDK odex config makefile: $@"
2442 $(hide) mkdir -p $(dir $@)
2443 $(hide) echo "# Auto-generated. Do not modify." > $@
2444 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2445 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2446 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2447 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2448 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2449 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2450 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2451 )
2452 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002453 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.apk)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002454 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2455 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2456 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2457 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002458 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002459 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2460 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2461 )
2462
keunyoungc0178062013-07-22 14:54:58 -07002463PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002464INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002465
2466$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2467$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002468$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2469# dependencies for the other partitions are defined below after their file lists
2470# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002471$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002472 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002473 rm -f $@ $@.lst
2474 echo "-C $(PRODUCT_OUT)" >> $@.lst
2475 echo "-D $(TARGET_OUT)" >> $@.lst
2476 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2477 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002478ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002479 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002480endif
Dan Willemsen67495202019-01-16 12:42:05 -08002481ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002482 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002483endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002484ifdef BUILDING_SYSTEM_EXT_IMAGE
2485 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002486endif
Dan Willemsen67495202019-01-16 12:42:05 -08002487ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002488 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002489endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002490ifdef BUILDING_VENDOR_DLKM_IMAGE
2491 echo "-D $(TARGET_OUT_VENDOR_DLKM)" >> $@.lst
2492endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07002493ifdef BUILDING_ODM_DLKM_IMAGE
2494 echo "-D $(TARGET_OUT_ODM_DLKM)" >> $@.lst
2495endif
Colin Crossc451a372013-12-18 19:36:44 -08002496ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002497 echo "-C $(OUT_DIR)" >> $@.lst
2498 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2499 if [ -e $$f ]; then \
2500 echo "-f $$f"; \
2501 fi \
2502 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002503endif
keunyoungc0178062013-07-22 14:54:58 -07002504ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002505 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002506endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002507 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002508 $(if $(PRIVATE_DEX_FILES),\
2509 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002510 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002511 touch $(PRODUCT_OUT)/pdk.mk
2512 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2513 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002514
2515.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002516platform: $(INSTALLED_PLATFORM_ZIP)
2517
2518.PHONY: platform-java
2519platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002520
2521# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002522ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2523$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002524endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002525
Colin Cross53c8f972018-09-28 16:19:42 -07002526endif # BUILD_PLATFORM_ZIP
2527
Ying Wang3a61eeb2016-03-11 10:32:01 -08002528# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002529# data partition image
2530INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002531 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002532
Dan Willemsen67495202019-01-16 12:42:05 -08002533ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002534userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002535 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002536BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2537
Ying Wangbd93d422011-10-28 17:02:30 -07002538define build-userdataimage-target
2539 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2540 @mkdir -p $(TARGET_OUT_DATA)
2541 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002542 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002543 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002544 $(BUILD_IMAGE) \
2545 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2546 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2547 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002548endef
2549
Joe Onorato64d85d02009-04-09 19:31:12 -07002550# We just build this directly to the install location.
2551INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002552INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2553 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002554 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002555$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002556 $(build-userdataimage-target)
2557
2558.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002559userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002560 $(build-userdataimage-target)
2561
Dan Willemsen67495202019-01-16 12:42:05 -08002562endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002563
Andreas Gampe039b5c72017-03-24 16:06:31 -07002564# ASAN libraries in the system image - build rule.
2565ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2566 $(TARGET_OUT_SHARED_LIBRARIES) \
2567 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2568 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2569 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002570# Extra options: Enforce the system user for the files to avoid having to change ownership.
2571ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002572# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2573# enough space.
2574$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002575 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 -07002576
The Android Open Source Project88b60792009-03-03 19:28:42 -08002577# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002578# partition table image
2579ifdef BOARD_BPT_INPUT_FILES
2580
2581BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002582BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002583
2584INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2585 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002586 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002587 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2588
2589ifdef BOARD_BPT_DISK_SIZE
2590INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2591endif
2592
2593define build-bptimage-target
2594 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2595 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2596endef
2597
2598INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002599$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2600 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2601
David Zeuthen25328622016-04-08 15:08:03 -04002602$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2603 $(build-bptimage-target)
2604
2605.PHONY: bptimage-nodeps
2606bptimage-nodeps:
2607 $(build-bptimage-target)
2608
2609endif # BOARD_BPT_INPUT_FILES
2610
2611# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002612# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002613ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002614INTERNAL_CACHEIMAGE_FILES := \
2615 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2616
2617cacheimage_intermediates := \
2618 $(call intermediates-dir-for,PACKAGING,cache)
2619BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2620
2621define build-cacheimage-target
2622 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2623 @mkdir -p $(TARGET_OUT_CACHE)
2624 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002625 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002626 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002627 $(BUILD_IMAGE) \
2628 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2629 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2630 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002631endef
2632
2633# We just build this directly to the install location.
2634INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002635$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002636 $(build-cacheimage-target)
2637
2638.PHONY: cacheimage-nodeps
2639cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2640 $(build-cacheimage-target)
2641
Dan Willemsen67495202019-01-16 12:42:05 -08002642else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002643# we need to ignore the broken cache link when doing the rsync
2644IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002645endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002646
David Zeuthen0eb10972016-09-28 17:55:27 -04002647# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002648# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002649ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002650ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002651# Marker file to identify that odex files are installed
2652INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2653ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2654$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2655 $(hide) touch $@
2656endif
2657
Alex Light4e358ab2016-06-16 14:47:10 -07002658INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2659 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2660 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002661 $(ALL_PDK_FUSION_FILES)) \
2662 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002663
Colin Cross6db5b0e2018-11-16 21:26:33 -08002664# system_other dex files are installed as a side-effect of installing system image files
2665INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2666
Alex Light4e358ab2016-06-16 14:47:10 -07002667INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002668INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2669$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002670$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002671 @echo Installed file list: $@
2672 @mkdir -p $(dir $@)
2673 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002674 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002675 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002676
Bowgo Tsai867ab662019-01-29 13:30:18 +08002677# Determines partition size for system_other.img.
2678ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2679ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2680INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2681endif
2682endif
2683
2684ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2685INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2686endif
2687
Alex Light4e358ab2016-06-16 14:47:10 -07002688systemotherimage_intermediates := \
2689 $(call intermediates-dir-for,PACKAGING,system_other)
2690BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2691
2692# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2693define build-systemotherimage-target
2694 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2695 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2696 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002697 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002698 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002699 $(BUILD_IMAGE) \
2700 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2701 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2702 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002703endef
2704
2705# We just build this directly to the install location.
2706INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002707ifneq (true,$(SANITIZE_LITE))
2708# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002709$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2710 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002711endif
Alex Light4e358ab2016-06-16 14:47:10 -07002712
2713.PHONY: systemotherimage-nodeps
2714systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2715 $(build-systemotherimage-target)
2716
Dan Willemsen67495202019-01-16 12:42:05 -08002717endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002718
2719
2720# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002721# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002722ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002723INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002724 $(filter $(TARGET_OUT_VENDOR)/%,\
2725 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002726 $(ALL_PDK_FUSION_FILES)) \
2727 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07002728
2729# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
2730$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07002731
Ying Wang8da19e32015-09-15 14:22:12 -07002732INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002733INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2734$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002735$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07002736 @echo Installed file list: $@
2737 @mkdir -p $(dir $@)
2738 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002739 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002740 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002741
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002742# Create symlink /vendor/odm to /odm if necessary.
2743ifdef BOARD_USES_ODMIMAGE
2744define create-vendor-odm-symlink
2745$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
2746 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
2747 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
2748 exit 1; \
2749fi
2750$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
2751endef
2752else
2753define create-vendor-odm-symlink
2754endef
2755endif
2756
Yifan Honge51dff22020-06-23 17:26:57 -07002757# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2758# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2759#
2760# On devices with a vendor_dlkm partition,
2761# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2762# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2763# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2764# are hidden.
2765# On devices without a vendor_dlkm partition,
2766# - /vendor/lib/modules stores vendor DLKMs directly.
2767# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2768# See system/core/rootdir/Android.mk for a list of created symlinks.
2769# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2770# are not guaranteed to exist on all devices.
2771ifdef BOARD_USES_VENDOR_DLKMIMAGE
2772define create-vendor-vendor_dlkm-symlink
2773$(hide) if [ -d $(TARGET_OUT_VENDOR)/lib/modules ] && [ ! -h $(TARGET_OUT_VENDOR)/lib/modules ]; then \
2774 echo 'Non-symlink $(TARGET_OUT_VENDOR)/lib/modules detected!' 1>&2; \
2775 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/lib/modules while building a separate vendor_dlkm.img!' 1>&2; \
2776 exit 1; \
2777fi
2778$(hide) ln -sf /vendor_dlkm/lib/modules $(TARGET_OUT_VENDOR)/lib/modules
2779endef
2780else
2781define create-vendor-vendor_dlkm-symlink
2782endef
2783endif
2784
Ying Wanga0febe52013-03-20 11:02:05 -07002785vendorimage_intermediates := \
2786 $(call intermediates-dir-for,PACKAGING,vendor)
2787BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002788define build-vendorimage-target
2789 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2790 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002791 $(call create-vendor-odm-symlink)
Yifan Honge51dff22020-06-23 17:26:57 -07002792 $(call create-vendor-vendor_dlkm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002793 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002794 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002795 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002796 $(BUILD_IMAGE) \
2797 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2798 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002799 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002800endef
2801
2802# We just build this directly to the install location.
2803INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002804$(INSTALLED_VENDORIMAGE_TARGET): \
2805 $(INTERNAL_USERIMAGES_DEPS) \
2806 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002807 $(INSTALLED_FILES_FILE_VENDOR) \
2808 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002809 $(build-vendorimage-target)
2810
Steven Morelanda2e734d2017-03-07 12:10:09 -08002811.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002812vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002813 $(build-vendorimage-target)
2814
Colin Cross91a52272017-06-20 16:57:52 -07002815sync: $(INTERNAL_VENDORIMAGE_FILES)
2816
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002817else ifdef BOARD_PREBUILT_VENDORIMAGE
2818INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2819$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2820endif
Ying Wanga0febe52013-03-20 11:02:05 -07002821
Ying Wang9f8e8db2011-11-04 11:37:01 -07002822# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002823# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002824ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002825INTERNAL_PRODUCTIMAGE_FILES := \
2826 $(filter $(TARGET_OUT_PRODUCT)/%,\
2827 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002828 $(ALL_PDK_FUSION_FILES)) \
2829 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002830
2831# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2832$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2833
2834INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002835INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2836$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002837$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002838 @echo Installed file list: $@
2839 @mkdir -p $(dir $@)
2840 @rm -f $@
2841 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002842 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002843
2844productimage_intermediates := \
2845 $(call intermediates-dir-for,PACKAGING,product)
2846BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2847define build-productimage-target
2848 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2849 @mkdir -p $(TARGET_OUT_PRODUCT)
2850 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002851 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002852 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002853 $(BUILD_IMAGE) \
2854 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2855 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2856 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002857endef
2858
2859# We just build this directly to the install location.
2860INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002861$(INSTALLED_PRODUCTIMAGE_TARGET): \
2862 $(INTERNAL_USERIMAGES_DEPS) \
2863 $(INTERNAL_PRODUCTIMAGE_FILES) \
2864 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002865 $(build-productimage-target)
2866
2867.PHONY: productimage-nodeps pnod
2868productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2869 $(build-productimage-target)
2870
2871sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2872
2873else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2874INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2875$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2876endif
2877
2878# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002879# system_ext partition image
2880ifdef BUILDING_SYSTEM_EXT_IMAGE
2881INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2882 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01002883 $(ALL_DEFAULT_INSTALLED_MODULES)\
2884 $(ALL_PDK_FUSION_FILES)) \
2885 $(PDK_FUSION_SYMLINK_STAMP)
2886
Justin Yun6151e3f2019-06-25 15:58:13 +09002887# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
2888$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002889
Justin Yun6151e3f2019-06-25 15:58:13 +09002890INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2891INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2892$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2893$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002894 @echo Installed file list: $@
2895 @mkdir -p $(dir $@)
2896 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002897 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002898 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002899
Justin Yun6151e3f2019-06-25 15:58:13 +09002900system_extimage_intermediates := \
2901 $(call intermediates-dir-for,PACKAGING,system_ext)
2902BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2903define build-system_extimage-target
2904 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2905 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2906 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2907 $(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 -07002908 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002909 $(BUILD_IMAGE) \
2910 $(TARGET_OUT_SYSTEM_EXT) \
2911 $(system_extimage_intermediates)/system_ext_image_info.txt \
2912 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2913 $(TARGET_OUT)
2914 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002915endef
2916
2917# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002918INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002919$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2920 $(INTERNAL_USERIMAGES_DEPS) \
2921 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2922 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002923 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002924
Justin Yun6151e3f2019-06-25 15:58:13 +09002925.PHONY: systemextimage-nodeps senod
2926systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2927 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002928
Justin Yun6151e3f2019-06-25 15:58:13 +09002929sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002930
Justin Yun6151e3f2019-06-25 15:58:13 +09002931else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2932INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2933$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002934endif
2935
2936# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002937# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002938ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002939INTERNAL_ODMIMAGE_FILES := \
2940 $(filter $(TARGET_OUT_ODM)/%,\
2941 $(ALL_DEFAULT_INSTALLED_MODULES)\
2942 $(ALL_PDK_FUSION_FILES)) \
2943 $(PDK_FUSION_SYMLINK_STAMP)
2944# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
2945$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
2946
2947INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2948INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2949$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002950$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002951 @echo Installed file list: $@
2952 @mkdir -p $(dir $@)
2953 @rm -f $@
2954 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002955 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002956
2957odmimage_intermediates := \
2958 $(call intermediates-dir-for,PACKAGING,odm)
2959BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2960define build-odmimage-target
2961 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2962 @mkdir -p $(TARGET_OUT_ODM)
2963 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2964 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002965 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002966 $(BUILD_IMAGE) \
2967 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2968 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2969 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002970endef
2971
2972# We just build this directly to the install location.
2973INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002974$(INSTALLED_ODMIMAGE_TARGET): \
2975 $(INTERNAL_USERIMAGES_DEPS) \
2976 $(INTERNAL_ODMIMAGE_FILES) \
2977 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002978 $(build-odmimage-target)
2979
2980.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002981odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002982 $(build-odmimage-target)
2983
2984sync: $(INTERNAL_ODMIMAGE_FILES)
2985
2986else ifdef BOARD_PREBUILT_ODMIMAGE
2987INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2988$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2989endif
2990
2991# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002992# vendor_dlkm partition image
2993ifdef BUILDING_VENDOR_DLKM_IMAGE
2994INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2995 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
2996 $(ALL_DEFAULT_INSTALLED_MODULES)\
2997 $(ALL_PDK_FUSION_FILES)) \
2998 $(PDK_FUSION_SYMLINK_STAMP)
2999# platform.zip depends on $(INTERNAL_VENDOR_DLKMIMAGE_FILES).
3000$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3001
3002INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3003INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3004$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3005$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3006 @echo Installed file list: $@
3007 @mkdir -p $(dir $@)
3008 @rm -f $@
3009 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3010 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3011
3012vendor_dlkmimage_intermediates := \
3013 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3014BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3015define build-vendor_dlkmimage-target
3016 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3017 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3018 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
3019 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
3020 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3021 $(BUILD_IMAGE) \
3022 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3023 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3024 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3025endef
3026
3027# We just build this directly to the install location.
3028INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3029$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3030 $(INTERNAL_USERIMAGES_DEPS) \
3031 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3032 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3033 $(build-vendor_dlkmimage-target)
3034
3035.PHONY: vendor_dlkmimage-nodeps vdnod
3036vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3037 $(build-vendor_dlkmimage-target)
3038
3039sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3040
3041else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3042INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3043$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3044endif
3045
3046# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003047# odm_dlkm partition image
3048ifdef BUILDING_ODM_DLKM_IMAGE
3049INTERNAL_ODM_DLKMIMAGE_FILES := \
3050 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
3051 $(ALL_DEFAULT_INSTALLED_MODULES)\
3052 $(ALL_PDK_FUSION_FILES)) \
3053 $(PDK_FUSION_SYMLINK_STAMP)
3054# platform.zip depends on $(INTERNAL_ODM_DLKMIMAGE_FILES).
3055$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODM_DLKMIMAGE_FILES)
3056
3057INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3058INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3059$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3060$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3061 @echo Installed file list: $@
3062 @mkdir -p $(dir $@)
3063 @rm -f $@
3064 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3065 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3066
3067odm_dlkmimage_intermediates := \
3068 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3069BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3070define build-odm_dlkmimage-target
3071 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3072 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3073 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3074 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3075 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3076 $(BUILD_IMAGE) \
3077 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3078 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3079 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3080endef
3081
3082# We just build this directly to the install location.
3083INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3084$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3085 $(INTERNAL_USERIMAGES_DEPS) \
3086 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3087 $(INSTALLED_FILES_FILE_ODM_DLKM)
3088 $(build-odm_dlkmimage-target)
3089
3090.PHONY: odm_dlkmimage-nodeps odnod
3091odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3092 $(build-odm_dlkmimage-target)
3093
3094sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3095
3096else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3097INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3098$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3099endif
3100
3101
3102# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003103# dtbo image
3104ifdef BOARD_PREBUILT_DTBOIMAGE
3105INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3106
3107ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003108$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003109 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3110 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003111 --image $@ \
3112 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3113 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3114 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003115else
3116$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3117 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3118endif
3119
Tao Bao0da43472018-08-22 22:53:41 -07003120endif # BOARD_PREBUILT_DTBOIMAGE
3121
3122# Returns a list of image targets corresponding to the given list of partitions. For example, it
3123# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3124# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003125# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003126define images-for-partitions
3127$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3128endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003129
3130# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003131# custom images
3132INSTALLED_CUSTOMIMAGES_TARGET :=
3133
3134ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3135INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3136
3137# Sign custom image.
3138# $(1): the prebuilt custom image.
3139# $(2): the mount point of the prebuilt custom image.
3140# $(3): the signed custom image target.
3141define sign_custom_image
3142$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3143 @echo Target custom image: $(3)
3144 mkdir -p $(dir $(3))
3145 cp $(1) $(3)
3146ifeq ($(BOARD_AVB_ENABLE),true)
3147 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3148 $(AVBTOOL) add_hashtree_footer \
3149 --image $(3) \
3150 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3151 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3152 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3153 --partition_name $(2) \
3154 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3155 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3156endif
3157INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3158endef
3159
3160$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3161 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3162 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3163endif
3164
3165# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003166# vbmeta image
3167ifeq ($(BOARD_AVB_ENABLE),true)
3168
3169BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003170AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003171
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003172ifdef BOARD_AVB_KEY_PATH
3173$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3174else
3175# If key path isn't specified, use the 4096-bit test key.
3176BOARD_AVB_ALGORITHM := SHA256_RSA4096
3177BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3178endif
3179
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003180# AVB signing for system_other.img.
3181ifdef BUILDING_SYSTEM_OTHER_IMAGE
3182ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3183$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3184else
3185# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3186BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3187BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3188endif
3189
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003190$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3191 @echo Extracting system_other avb key: $@
3192 @rm -f $@
3193 @mkdir -p $(dir $@)
3194 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003195
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003196ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3197BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3198endif
3199
3200BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3201endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3202
Tao Bao744c4c72018-08-20 21:09:07 -07003203INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003204 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003205 $(BOARD_AVB_VBMETA_VENDOR)
3206
3207# Not allowing the same partition to appear in multiple groups.
3208ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003209 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003210endif
3211
cfig1aeef722019-09-20 22:45:06 +08003212# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3213# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3214# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003215ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003216ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3217$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003218 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003219 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3220endif
3221endif
3222
Bowgo Tsai9b548012019-05-14 16:57:03 +08003223# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003224
3225BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003226 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003227 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003228 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3229
3230BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003231 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003232 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003233 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3234
Justin Yun6151e3f2019-06-25 15:58:13 +09003235BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003236 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003237 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3238 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003239
Bowgo Tsai9b548012019-05-14 16:57:03 +08003240BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003241 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003242 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3243
Tao Bao19b02fe2019-10-09 00:04:28 -07003244BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3245 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3246
3247BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3248 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3249
Bowgo Tsai9b548012019-05-14 16:57:03 +08003250BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003251 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003252 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3253
3254BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003255 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003256 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3257
Yifan Hongcfb917a2020-05-07 14:58:20 -07003258BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3259 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3260 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3261
Yifan Hongf496f1b2020-07-15 16:52:59 -07003262BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3263 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3264 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3265
Tao Bao19b02fe2019-10-09 00:04:28 -07003266BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3267 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3268
Bowgo Tsai9b548012019-05-14 16:57:03 +08003269# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003270ifdef BOOT_SECURITY_PATCH
3271BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3272 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3273endif
3274
3275ifdef VENDOR_SECURITY_PATCH
3276BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3277 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3278endif
3279
3280ifdef ODM_SECURITY_PATCH
3281BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3282 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3283endif
3284
Yifan Hongcfb917a2020-05-07 14:58:20 -07003285ifdef VENDOR_DLKM_SECURITY_PATCH
3286BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3287 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3288endif
3289
Yifan Hongf496f1b2020-07-15 16:52:59 -07003290ifdef ODM_DLKM_SECURITY_PATCH
3291BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3292 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3293endif
3294
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003295BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003296VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003297DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3298SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3299VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003300RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003301PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003302SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003303ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003304VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003305ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003306
Tao Bao0da43472018-08-22 22:53:41 -07003307# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003308# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003309define _check-and-set-avb-chain-args
3310$(eval part := $(1))
3311$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003312
3313$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3314$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3315$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3316$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3317$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3318$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3319$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3320$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3321
3322# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3323$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3324$(eval $(_signing_args) := \
3325 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3326
cfig1aeef722019-09-20 22:45:06 +08003327# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3328# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003329$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003330 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3331 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003332
Tao Bao744c4c72018-08-20 21:09:07 -07003333# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003334# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003335$(if $(filter $(part),$(part:vbmeta_%=%)),\
3336 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3337 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003338endef
3339
Tao Bao0da43472018-08-22 22:53:41 -07003340# Checks and sets the required build variables for an AVB partition. The partition will be
3341# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003342# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3343# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003344# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3345# but vbmeta would capture the image descriptor of only the first boot
3346# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003347# $(1): Partition name, e.g. boot or system.
3348define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003349$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003350$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003351 $(if $(_in_chained_vbmeta),\
3352 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003353 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003354 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003355 $(if $(filter boot,$(1)),\
3356 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3357 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3358 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3359 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003360endef
3361
Hongguang Chenf23364d2020-04-27 18:36:36 -07003362# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3363# $(1): the custom partition to enable AVB chain.
3364define check-and-set-custom-avb-chain-args
3365$(eval part := $(1))
3366$(eval PART=$(call to-upper,$(part)))
3367$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3368$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3369
3370INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3371 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3372endef
3373
Tao Baob1a2e352018-08-14 16:17:12 -07003374ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003375$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003376endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003377
Steve Mucklee1b10862019-07-10 10:49:37 -07003378ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3379$(eval $(call check-and-set-avb-args,vendor_boot))
3380endif
3381
Tao Bao0da43472018-08-22 22:53:41 -07003382$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003383
3384ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003385$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003386endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003387
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003388ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003389$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003390endif
3391
Justin Yun6151e3f2019-06-25 15:58:13 +09003392ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3393$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003394endif
3395
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003396ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003397$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003398endif
3399
Yifan Hongcfb917a2020-05-07 14:58:20 -07003400ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3401$(eval $(call check-and-set-avb-args,vendor_dlkm))
3402endif
3403
Yifan Hongf496f1b2020-07-15 16:52:59 -07003404ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3405$(eval $(call check-and-set-avb-args,odm_dlkm))
3406endif
3407
Yueyao Zhu211c9012017-04-27 00:34:50 -07003408ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003409$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003410endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003411
David Zeuthen8fecb282017-12-01 16:24:01 -05003412ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003413$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003414endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003415
David Anderson7709ab22018-10-15 14:41:34 -07003416# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3417ifdef BOARD_AVB_VBMETA_SYSTEM
3418$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003419endif
3420
3421ifdef BOARD_AVB_VBMETA_VENDOR
3422$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3423endif
3424
Hongguang Chenf23364d2020-04-27 18:36:36 -07003425ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3426$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3427 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3428endif
3429
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003430# Add kernel cmdline descriptor for kernel to mount system.img as root with
3431# dm-verity. This works when system.img is either chained or not-chained:
3432# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3433# cmdline descriptor to system.img
3434# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3435# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003436ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003437ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003438BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003439endif
David Anderson8916a2a2018-09-18 15:46:59 -07003440endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003441
Tao Bao0da43472018-08-22 22:53:41 -07003442BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003443BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003444BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3445
3446ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003447# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003448BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003449endif
Tao Bao0da43472018-08-22 22:53:41 -07003450
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003451ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003452BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003453endif
3454
David Anderson7709ab22018-10-15 14:41:34 -07003455ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3456BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3457 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003458endif
3459
3460ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3461BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3462 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003463endif
3464
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003465# $(1): the directory to extract public keys to
3466define extract-avb-chain-public-keys
3467 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3468 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3469 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003470 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3471 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3472 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003473 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3474 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3475 --output $(1)/system.avbpubkey)
3476 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3477 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3478 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003479 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3480 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3481 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003482 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3483 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3484 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003485 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3486 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3487 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003488 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3489 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3490 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003491 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3492 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3493 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003494 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3495 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3496 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003497 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3498 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3499 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003500 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3501 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3502 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003503 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3504 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3505 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003506 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3507 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3508 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3509 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003510endef
3511
Tao Bao744c4c72018-08-20 21:09:07 -07003512# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3513# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003514# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003515# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3516# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003517# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003518# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003519# $(2): Output filename.
3520define build-chained-vbmeta-image
3521 $(call pretty,"Target chained vbmeta image: $@")
3522 $(hide) $(AVBTOOL) make_vbmeta_image \
3523 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3524 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3525 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3526 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3527 --output $@
3528endef
3529
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003530ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003531ifdef BOARD_AVB_VBMETA_SYSTEM
3532INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3533$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003534 $(AVBTOOL) \
3535 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3536 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003537 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003538endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003539endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003540
3541ifdef BOARD_AVB_VBMETA_VENDOR
3542INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3543$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003544 $(AVBTOOL) \
3545 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3546 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003547 $(call build-chained-vbmeta-image,vbmeta_vendor)
3548endif
3549
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003550define build-vbmetaimage-target
3551 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003552 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3553 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003554 $(hide) $(AVBTOOL) make_vbmeta_image \
3555 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003556 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003557 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3558 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003559 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003560endef
3561
Paul Trautrim4e143232019-08-13 16:30:57 +09003562ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003563INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003564$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3565 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3566
David Zeuthen8fecb282017-12-01 16:24:01 -05003567$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003568 $(AVBTOOL) \
3569 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003570 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003571 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3572 $(INSTALLED_VENDORIMAGE_TARGET) \
3573 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003574 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003575 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003576 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003577 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003578 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003579 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003580 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3581 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3582 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3583 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3584 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3585 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003586 $(build-vbmetaimage-target)
3587
3588.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003589vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3590 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003591vbmetaimage-nodeps:
3592 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003593endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003594
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003595endif # BOARD_AVB_ENABLE
3596
3597# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003598# Check VINTF of build
3599
Yifan Hongf496f1b2020-07-15 16:52:59 -07003600# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003601ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003602
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003603intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3604check_vintf_all_deps :=
3605
Yifan Hongaf9b0702020-01-21 12:46:57 -08003606# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3607# because they are only used for prebuilt images.
3608check_vintf_common_srcs_patterns := \
3609 $(TARGET_OUT)/etc/vintf/% \
3610 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3611 $(TARGET_OUT_ODM)/etc/vintf/% \
3612 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3613 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3614
3615check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3616 $(INTERNAL_SYSTEMIMAGE_FILES) \
3617 $(INTERNAL_VENDORIMAGE_FILES) \
3618 $(INTERNAL_ODMIMAGE_FILES) \
3619 $(INTERNAL_PRODUCTIMAGE_FILES) \
3620 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3621))
3622check_vintf_common_srcs_patterns :=
3623
3624check_vintf_has_system :=
3625check_vintf_has_vendor :=
3626
Yifan Hong28ffd732020-03-13 13:11:10 -07003627ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3628$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3629endif
3630ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3631$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3632endif
3633
Yifan Hong605ea042020-01-14 21:36:00 +00003634# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003635check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3636ifneq ($(check_vintf_system_deps),)
3637check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003638check_vintf_system_log := $(intermediates)/check_vintf_system_log
3639check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003640$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003641 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3642check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003643endif # check_vintf_system_deps
3644check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003645
3646# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003647check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3648ifneq ($(check_vintf_vendor_deps),)
3649check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003650check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3651check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003652# Check vendor SKU=(empty) case when:
3653# - DEVICE_MANIFEST_FILE is not empty; OR
3654# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003655$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003656 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3657 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003658 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003659$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003660 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3661 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3662 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3663 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003664check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003665endif # check_vintf_vendor_deps
3666check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003667
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003668# -- Check VINTF compatibility of build.
3669# Skip partial builds; only check full builds. Only check if:
3670# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003671# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003672# - Building product / system_ext / odm images if board has product / system_ext / odm images
3673ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003674ifeq ($(check_vintf_has_system),true)
3675ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003676ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3677ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3678ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3679
3680check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3681check_vintf_all_deps += $(check_vintf_compatible_log)
3682
3683check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003684check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003685
3686# -- Kernel version and configurations.
3687ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3688
Yifan Hong605ea042020-01-14 21:36:00 +00003689BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3690BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3691
3692my_board_extracted_kernel :=
3693
3694# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3695# from INSTALLED_KERNEL_TARGET.
3696ifdef BOARD_KERNEL_CONFIG_FILE
3697ifdef BOARD_KERNEL_VERSION
3698$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3699 cp $< $@
3700$(BUILT_KERNEL_VERSION_FILE):
3701 echo $(BOARD_KERNEL_VERSION) > $@
3702
3703my_board_extracted_kernel := true
3704endif # BOARD_KERNEL_VERSION
3705endif # BOARD_KERNEL_CONFIG_FILE
3706
3707ifneq ($(my_board_extracted_kernel),true)
3708ifndef INSTALLED_KERNEL_TARGET
3709$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3710 is true. Information about the updated kernel cannot be built into OTA update package. \
3711 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3712 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3713 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3714 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3715 manually.)
3716else
3717
3718# Tools for decompression that is not in PATH.
3719# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3720# Algorithms that are in the script but not in this list will be found in PATH.
3721my_decompress_tools := \
3722 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3723
3724$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3725$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3726$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003727$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3728 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003729 --output-configs $@ \
3730 --output-version $(BUILT_KERNEL_VERSION_FILE)
3731
3732my_decompress_tools :=
3733
3734endif # my_board_extracted_kernel
3735my_board_extracted_kernel :=
3736
3737endif # INSTALLED_KERNEL_TARGET
3738
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003739check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3740check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3741
3742endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3743
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003744check_vintf_compatible_args += \
3745 --dirmap /system:$(TARGET_OUT) \
3746 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3747 --dirmap /odm:$(TARGET_OUT_ODM) \
3748 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3749 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3750
3751ifdef PRODUCT_SHIPPING_API_LEVEL
3752check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3753endif # PRODUCT_SHIPPING_API_LEVEL
3754
3755$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3756$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003757# Check ODM SKU=(empty) case when:
3758# - ODM_MANIFEST_FILES is not empty; OR
3759# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003760$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003761 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3762 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003763 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003764# Check vendor SKU=(empty) case when:
3765# - DEVICE_MANIFEST_FILE is not empty; OR
3766# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003767$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003768 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3769 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003770 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003771$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3772 @echo -n -e 'Deps: \n ' > $@
3773 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3774 @echo -n -e 'Args: \n ' >> $@
3775 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003776 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3777 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003778 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003779 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3780 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3781 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003782
3783check_vintf_compatible_log :=
3784check_vintf_compatible_args :=
3785check_vintf_compatible_deps :=
3786
3787endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3788endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3789endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003790endif # check_vintf_has_vendor
3791endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003792endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3793
3794# Add all logs of VINTF checks to dist builds
3795droid_targets: $(check_vintf_all_deps)
3796$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3797
3798# Helper alias to check all VINTF of current build.
3799.PHONY: check-vintf-all
3800check-vintf-all: $(check_vintf_all_deps)
3801 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3802
Yifan Hongaf9b0702020-01-21 12:46:57 -08003803check_vintf_has_vendor :=
3804check_vintf_has_system :=
3805check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003806check_vintf_all_deps :=
3807intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003808endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003809
3810# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003811# Check image sizes <= size of super partition
3812
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003813ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003814
3815ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003816
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003817# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003818# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003819define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003820 mkdir -p $(dir $(1))
3821 rm -f $(1)
3822 $(call dump-super-image-info, $(1))
3823 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3824 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003825 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003826endef
3827
Yifan Hong30910932019-10-25 20:36:55 -07003828check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3829droid_targets: $(check_all_partition_sizes_log)
3830$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003831
Yifan Hong30910932019-10-25 20:36:55 -07003832$(check_all_partition_sizes_log): \
3833 $(CHECK_PARTITION_SIZES) \
3834 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3835 $(call check-all-partition-sizes-target, \
3836 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3837 $@)
3838
3839.PHONY: check-all-partition-sizes
3840check-all-partition-sizes: $(check_all_partition_sizes_log)
3841
3842.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003843check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003844 $(call check-all-partition-sizes-target, \
3845 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003846
Yifan Hong2dae5722018-07-31 12:47:27 -07003847endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003848
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003849endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003850
3851# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003852# bring in the installer image generation defines if necessary
3853ifeq ($(TARGET_USE_DISKINSTALLER),true)
3854include bootable/diskinstaller/config.mk
3855endif
3856
3857# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003858# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003859
Ying Wangbd2d0242015-09-22 11:17:52 -07003860ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003861 build_ota_package := false
3862 build_otatools_package := false
3863else
Tao Bao9be20c72019-04-08 21:11:59 -07003864 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003865 build_ota_package := true
3866 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3867 build_ota_package := false
3868 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003869 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003870 build_ota_package := false
3871 endif
3872 ifeq ($(TARGET_PRODUCT),sdk)
3873 build_ota_package := false
3874 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003875 ifeq ($(TARGET_BUILD_PDK),true)
3876 build_ota_package := false
3877 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003878 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3879 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3880 build_ota_package := false
3881 endif
3882 ifeq ($(TARGET_NO_KERNEL),true)
3883 build_ota_package := false
3884 endif
3885 ifeq ($(recovery_fstab),)
3886 build_ota_package := false
3887 endif
3888 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003889
Tao Bao9be20c72019-04-08 21:11:59 -07003890 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003891 build_otatools_package := true
3892 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3893 build_otatools_package := false
3894 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003895endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003896
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003897ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003898
3899INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003900 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003901 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003902 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003903 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003904 append2simg \
3905 avbtool \
3906 blk_alloc_to_base_fs \
3907 boot_signer \
3908 brillo_update_payload \
3909 brotli \
3910 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003911 build_image \
3912 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003913 build_verity_metadata \
3914 build_verity_tree \
3915 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003916 check_ota_package_signature \
3917 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003918 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003919 checkvintf \
3920 delta_generator \
3921 e2fsck \
3922 e2fsdroid \
3923 fc_sort \
3924 fec \
3925 fs_config \
3926 generate_verity_key \
3927 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003928 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003929 imgdiff \
3930 libconscrypt_openjdk_jni \
3931 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003932 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003933 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003934 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07003935 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003936 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003937 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003938 mkbootfs \
3939 mkbootimg \
3940 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003941 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003942 mkf2fsuserimg.sh \
3943 mksquashfs \
3944 mksquashfsimage.sh \
3945 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003946 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003947 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003948 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003949 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003950 sign_apex \
3951 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003952 signapk \
3953 simg2img \
3954 sload_f2fs \
3955 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003956 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003957 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003958 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003959 verity_signer \
3960 verity_verifier \
3961 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003962
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003963# Additional tools to unpack and repack the apex file.
3964INTERNAL_OTATOOLS_MODULES += \
3965 apexer \
3966 deapexer \
3967 debugfs_static \
3968 merge_zips \
3969 resize2fs \
3970 soong_zip \
3971
Anton Hansson8dab0a62019-03-28 15:45:40 +00003972ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003973INTERNAL_OTATOOLS_MODULES += \
3974 futility \
3975 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003976endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003977
Tao Bao96daeeb2019-05-01 21:17:13 -07003978INTERNAL_OTATOOLS_FILES := \
3979 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003980
Ying Wang06898662010-06-17 17:52:18 -07003981.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003982otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003983
Tao Bao96daeeb2019-05-01 21:17:13 -07003984# For each module, recursively resolve its host shared library dependencies. Then we have a full
3985# list of modules whose installed files need to be packed.
3986INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3987 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3988 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003989
Tao Bao96daeeb2019-05-01 21:17:13 -07003990INTERNAL_OTATOOLS_PACKAGE_FILES := \
3991 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3992
3993INTERNAL_OTATOOLS_PACKAGE_FILES += \
3994 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3995 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003996
3997ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003998INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003999 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004000 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004001endif
4002ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004003INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004004 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4005 -name "atx_metadata.bin"))
4006endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004007ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004008INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004009 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004010endif
4011
Tao Bao96daeeb2019-05-01 21:17:13 -07004012INTERNAL_OTATOOLS_RELEASETOOLS := \
4013 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4014 \( -type f -o -type l \) -print))
4015
4016BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4017$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4018$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4019$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4020$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004021$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004022 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004023 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4024 mkdir -p $(dir $@)
4025 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4026 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004027 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004028 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004029
4030.PHONY: otatools-package
4031otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4032
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004033endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004034
The Android Open Source Project88b60792009-03-03 19:28:42 -08004035# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004036# misc_info.txt
4037
4038INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4039
4040ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4041# default to common dir for device vendor
4042tool_extensions := $(TARGET_DEVICE_DIR)/../common
4043else
4044tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4045endif
4046.KATI_READONLY := tool_extensions
4047
Steve Muckle903a1ca2020-05-07 17:32:10 -07004048# $1: boot image file name
4049define misc_boot_size
4050$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4051endef
4052
Daniel Normane1e48082019-06-27 13:55:23 -07004053$(INSTALLED_MISC_INFO_TARGET):
4054 rm -f $@
4055 $(call pretty,"Target misc_info.txt: $@")
4056 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4057 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4058ifdef BOARD_FLASH_BLOCK_SIZE
4059 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4060endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004061ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4062 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4063 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004064endif
4065ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4066 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004067else
4068 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004069endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004070ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4071 echo "lz4_ramdisks=true" >> $@
4072endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004073ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4074 echo "vendor_boot=true" >> $@
4075 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4076endif
Daniel Normane1e48082019-06-27 13:55:23 -07004077ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4078 $(hide) echo "no_recovery=true" >> $@
4079endif
4080ifdef BOARD_INCLUDE_RECOVERY_DTBO
4081 $(hide) echo "include_recovery_dtbo=true" >> $@
4082endif
4083ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4084 $(hide) echo "include_recovery_acpio=true" >> $@
4085endif
4086ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4087 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4088endif
4089ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4090 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4091 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4092else
4093 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4094endif
4095 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4096 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4097ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4098 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4099endif
4100 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004101 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004102 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4103 $(hide) echo "multistage_support=1" >> $@
4104 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4105ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4106 $(hide) echo "build_generic_ota_package=true" >> $@
4107endif
4108ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4109 # OTA scripts are only interested in fingerprint related properties
4110 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4111endif
4112ifneq (,$(filter address, $(SANITIZE_TARGET)))
4113 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4114 $(hide) echo "userdata_img_with_data=true" >> $@
4115endif
4116ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4117 $(hide) echo "full_recovery_image=true" >> $@
4118endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004119ifdef BOARD_USES_VENDORIMAGE
4120 $(hide) echo "board_uses_vendorimage=true" >> $@
4121endif
Daniel Normane1e48082019-06-27 13:55:23 -07004122ifeq ($(BOARD_AVB_ENABLE),true)
4123 $(hide) echo "avb_enable=true" >> $@
4124 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4125 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4126 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4127 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4128ifdef BOARD_AVB_BOOT_KEY_PATH
4129 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4130 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4131 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4132endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004133 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4134ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4135 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4136 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4137 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4138endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004139 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4140ifdef BOARD_AVB_RECOVERY_KEY_PATH
4141 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4142 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4143 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4144endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004145ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4146 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4147 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4148 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4149 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4150 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4151 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4152 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4153 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4154endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004155ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4156 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4157 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4158 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4159 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4160 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4161endif # BOARD_AVB_VBMETA_SYSTEM
4162ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4163 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4164 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4165 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4166 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4167 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4168endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4169endif # BOARD_AVB_ENABLE
4170ifdef BOARD_BPT_INPUT_FILES
4171 $(hide) echo "board_bpt_enable=true" >> $@
4172 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4173 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4174endif
4175ifdef BOARD_BPT_DISK_SIZE
4176 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4177endif
4178 $(call generate-userimage-prop-dictionary, $@)
4179ifeq ($(AB_OTA_UPDATER),true)
4180 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4181 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4182 $(hide) echo "ab_update=true" >> $@
4183endif
Yifan Hong65afc072020-04-17 10:08:10 -07004184ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4185 $(hide) echo "allow_non_ab=true" >> $@
4186endif
Daniel Normane1e48082019-06-27 13:55:23 -07004187ifdef BOARD_PREBUILT_DTBOIMAGE
4188 $(hide) echo "has_dtbo=true" >> $@
4189ifeq ($(BOARD_AVB_ENABLE),true)
4190 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4191 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4192ifdef BOARD_AVB_DTBO_KEY_PATH
4193 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4194 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4195 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4196endif # BOARD_AVB_DTBO_KEY_PATH
4197endif # BOARD_AVB_ENABLE
4198endif # BOARD_PREBUILT_DTBOIMAGE
4199 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004200 @# VINTF checks
4201ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4202 $(hide) echo "vintf_enforce=true" >> $@
4203endif
4204ifdef ODM_MANIFEST_SKUS
4205 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4206endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004207ifdef ODM_MANIFEST_FILES
4208 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4209endif
4210ifdef DEVICE_MANIFEST_SKUS
4211 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4212endif
4213ifdef DEVICE_MANIFEST_FILE
4214 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4215endif
Daniel Normane1e48082019-06-27 13:55:23 -07004216
4217.PHONY: misc_info
4218misc_info: $(INSTALLED_MISC_INFO_TARGET)
4219
4220droidcore: $(INSTALLED_MISC_INFO_TARGET)
4221
4222# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004223# A zip of the directories that map to the target filesystem.
4224# This zip can be used to create an OTA package or filesystem image
4225# as a post-build step.
4226#
4227name := $(TARGET_PRODUCT)
4228ifeq ($(TARGET_BUILD_TYPE),debug)
4229 name := $(name)_debug
4230endif
4231name := $(name)-target_files-$(FILE_NAME_TAG)
4232
4233intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4234BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4235$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4236$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004237 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004238
4239# $(1): Directory to copy
4240# $(2): Location to copy it to
4241# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4242define package_files-copy-root
4243 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4244 mkdir -p $(2) && \
4245 $(ACP) -rd $(strip $(1))/* $(2); \
4246 fi
4247endef
4248
Tao Baoa04fca32015-11-30 12:22:24 -08004249built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004250
4251# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004252ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004253built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004254 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004255endif
4256
The Android Open Source Project88b60792009-03-03 19:28:42 -08004257$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4258
Dan Willemsen653bea92017-03-21 15:47:37 -07004259tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004260$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004261
Sen Jiang4438fd92016-03-07 16:51:01 -08004262ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004263updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004264endif
4265
4266# Build OTA tools if non-A/B is allowed
4267ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004268updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004269endif
Yifan Hong65afc072020-04-17 10:08:10 -07004270
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004271$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004272
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004273# If we are using recovery as boot, output recovery files to BOOT/.
4274ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4275$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4276else
4277$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4278endif
4279
Dan Willemsen653bea92017-03-21 15:47:37 -07004280ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004281 ifdef OSRELEASED_DIRECTORY
4282 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4283 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4284 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4285 endif
Tao Baoa835f382019-07-18 15:55:30 -07004286
4287 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4288 # additionally include radio or bootloader partitions).
4289 ifeq ($(AB_OTA_PARTITIONS),)
4290 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4291 endif
4292endif
4293
4294ifneq ($(AB_OTA_PARTITIONS),)
4295 ifneq ($(AB_OTA_UPDATER),true)
4296 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4297 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004298endif
4299
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004300# Run fs_config while creating the target files package
4301# $1: root directory
4302# $2: add prefix
4303define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004304(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 -08004305endef
4306
Yifan Hong60bfcc42019-11-01 11:39:45 -07004307# Filter out vendor from the list for AOSP targets.
4308# $(1): list
4309define filter-out-missing-vendor
4310$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4311endef
4312
4313# Information related to dynamic partitions and virtual A/B. This information
4314# is needed for building the super image (see dump-super-image-info) and
4315# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004316# $(1): file
4317define dump-dynamic-partitions-info
4318 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4319 echo "use_dynamic_partitions=true" >> $(1))
4320 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4321 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004322 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4323 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4324 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004325 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4326 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004327 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4328 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4329 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4330 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4331 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4332 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004333 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004334 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4335 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4336 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4337 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4338 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004339 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 -07004340 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4341 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004342 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4343 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004344 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4345 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004346 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4347 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4348 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4349 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4350 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4351 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4352 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4353 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004354 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4355 echo "virtual_ab=true" >> $(1))
4356 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4357 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004358endef
4359
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004360# By conditionally including the dependency of the target files package on the
4361# full system image deps, we speed up builds that do not build the system
4362# image.
4363ifdef BUILDING_SYSTEM_IMAGE
4364$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4365endif
4366
Isaac Chen9e09d472019-07-05 17:30:41 +08004367ifeq ($(BUILD_QEMU_IMAGES),true)
4368MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4369$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4370endif
4371
The Android Open Source Project88b60792009-03-03 19:28:42 -08004372# Depending on the various images guarantees that the underlying
4373# directories are up-to-date.
4374$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004375 $(INSTALLED_RAMDISK_TARGET) \
4376 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004377 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004378 $(INSTALLED_RADIOIMAGE_TARGET) \
4379 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004380 $(INSTALLED_USERDATAIMAGE_TARGET) \
4381 $(INSTALLED_CACHEIMAGE_TARGET) \
4382 $(INSTALLED_VENDORIMAGE_TARGET) \
4383 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004384 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004385 $(INSTALLED_VBMETAIMAGE_TARGET) \
4386 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004387 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004388 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004389 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004390 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004391 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4392 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4393 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004394 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004395 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4396 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004397 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004398 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004399 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4400 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4401 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004402 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004403 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004404 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004405 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004406 $(LPMAKE) \
4407 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004408 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004409 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004410 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004411 $(SOONG_ZIP) \
4412 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004413 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004414 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004415 $(BUILT_KERNEL_CONFIGS_FILE) \
4416 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004417 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004418 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004419 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004420 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004421 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004422 $(call create-vendor-odm-symlink)
Yifan Honge51dff22020-06-23 17:26:57 -07004423 $(call create-vendor-vendor_dlkm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004424 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004425 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004426ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004427 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004428 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004429 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004430 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004431ifdef INSTALLED_KERNEL_TARGET
Steve Muckleb3dda772020-03-11 16:03:07 -07004432 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004433endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004434ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004435 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004436else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004437ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004438 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004439endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004440ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004441ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004442 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004443else
Steve Mucklee1b10862019-07-10 10:49:37 -07004444 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004445endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004446endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004447ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004448 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004449endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004450ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004451 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004452endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004453ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004454 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004455endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004456ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004457 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004458endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004459ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004460 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004461endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004462endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004463endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004464 @# Components of the boot image
4465 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004466 $(hide) mkdir -p $(zip_root)/ROOT
4467 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004468 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004469 @# If we are using recovery as boot, this is already done when processing recovery.
4470ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004471ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004472 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004473 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004474endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004475ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004476 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004477endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004478ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004479ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004480 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004481endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004482ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004483 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004484endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004485 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004486ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004487 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004488endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004489ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004490 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004491endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004492else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4493 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4494endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4495endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004496 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4497 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004498 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004499ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4500 mkdir -p $(zip_root)/VENDOR_BOOT
4501 $(call package_files-copy-root, \
4502 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4503ifdef INSTALLED_DTBIMAGE_TARGET
4504 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4505endif
4506ifdef BOARD_KERNEL_BASE
4507 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4508endif
4509ifdef BOARD_KERNEL_PAGESIZE
4510 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4511endif
4512 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4513endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004514ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004515 @# Contents of the system image
4516 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004517 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004518endif
4519ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004520 @# Contents of the data image
4521 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004522 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004523endif
4524ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004525 @# Contents of the vendor image
4526 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004527 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004528endif
Dan Willemsen67495202019-01-16 12:42:05 -08004529ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004530 @# Contents of the product image
4531 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004532 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004533endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004534ifdef BUILDING_SYSTEM_EXT_IMAGE
4535 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004536 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004537 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004538endif
Dan Willemsen67495202019-01-16 12:42:05 -08004539ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004540 @# Contents of the odm image
4541 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004542 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004543endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004544ifdef BUILDING_VENDOR_DLKM_IMAGE
4545 @# Contents of the vendor_dlkm image
4546 $(hide) $(call package_files-copy-root, \
4547 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4548endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004549ifdef BUILDING_ODM_DLKM_IMAGE
4550 @# Contents of the odm_dlkm image
4551 $(hide) $(call package_files-copy-root, \
4552 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4553endif
Dan Willemsen67495202019-01-16 12:42:05 -08004554ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004555 @# Contents of the system_other image
4556 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004557 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004558endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004559 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004560 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004561 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004562ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004563ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004564 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004565 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004566endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004567endif
Doug Zongker8678df42009-06-15 14:30:14 -07004568 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004569 @# build them.
4570 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004571 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004572 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004573ifneq ($(tool_extension),)
4574 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4575endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004576 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004577 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004578 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004579ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4580 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4581 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004582endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004583ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4584 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4585 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004586endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004587ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4588 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4589 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004590endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004591ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4592 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4593 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004594endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004595ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4596 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4597 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004598endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004599ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4600 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4601 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4602endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004603ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4604 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4605 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4606endif
Yifan Hong65afc072020-04-17 10:08:10 -07004607ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004608ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004609 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004610 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004611endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004612endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004613ifeq ($(AB_OTA_UPDATER),true)
4614 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004615 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004616 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004617 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4618 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004619 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4620 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4621 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004622ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004623 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4624 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4625 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004626endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004627endif
Steve Fungdfbab492015-09-24 18:12:33 -07004628ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004629 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004630 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004631endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004632ifdef BOARD_PREBUILT_VENDORIMAGE
4633 $(hide) mkdir -p $(zip_root)/IMAGES
4634 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4635endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004636ifdef BOARD_PREBUILT_PRODUCTIMAGE
4637 $(hide) mkdir -p $(zip_root)/IMAGES
4638 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4639endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004640ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004641 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004642 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004643endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004644ifdef BOARD_PREBUILT_BOOTIMAGE
4645 $(hide) mkdir -p $(zip_root)/IMAGES
4646 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4647endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004648ifdef BOARD_PREBUILT_ODMIMAGE
4649 $(hide) mkdir -p $(zip_root)/IMAGES
4650 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4651endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004652ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4653 $(hide) mkdir -p $(zip_root)/IMAGES
4654 $(hide) cp $(INSTALLED_VENDOR_DLKIMMAGE_TARGET) $(zip_root)/IMAGES/
4655endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004656ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004657 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4658 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004659endif # BOARD_PREBUILT_DTBOIMAGE
Hongguang Chenf23364d2020-04-27 18:36:36 -07004660ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4661 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4662 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4663 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4664endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004665 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4666 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4667 @# INSTALLED_RADIOIMAGE_TARGET.
4668 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4669 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004670 @# Run fs_config on all the system, vendor, boot ramdisk,
4671 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004672ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004673 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004674endif
4675ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004676 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4677endif
Dan Willemsen67495202019-01-16 12:42:05 -08004678ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004679 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4680endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004681ifdef BUILDING_SYSTEM_EXT_IMAGE
4682 $(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 +01004683endif
Dan Willemsen67495202019-01-16 12:42:05 -08004684ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004685 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4686endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004687ifdef BUILDING_VENDOR_DLKM_IMAGE
4688 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4689endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004690ifdef BUILDING_ODM_DLKM_IMAGE
4691 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4692endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004693 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004694 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004695ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004696 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004697 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004698endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004699ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4700 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4701endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004702ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4703 @# 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 -08004704 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4705endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004706ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4707 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4708endif
Dan Willemsen67495202019-01-16 12:42:05 -08004709ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004710 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4711endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004712 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004713ifdef BUILT_KERNEL_CONFIGS_FILE
4714 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4715endif
4716ifdef BUILT_KERNEL_VERSION_FILE
4717 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4718endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004719 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4720ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4721 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4722endif
Tao Baocbd6d492019-10-07 22:46:02 -07004723 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4724 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004725ifeq ($(BUILD_QEMU_IMAGES),true)
4726 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4727 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4728endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004729 @# Zip everything up, preserving symlinks and placing META/ files first to
4730 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004731 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004732 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004733 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004734
Ying Wanga0febe52013-03-20 11:02:05 -07004735.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004736target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4737
Ying Wang4709d7c2014-04-14 17:25:43 -07004738ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4739$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4740endif
Doug Zongker367910f2009-06-15 18:56:51 -07004741
Dan Albert4d323332016-10-14 13:23:06 -07004742# -----------------------------------------------------------------
4743# NDK Sysroot Package
4744NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004745$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004746 @echo Package NDK sysroot...
4747 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4748
4749$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4750
Ying Wang09c4b682015-08-11 11:24:19 -07004751ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004752# -----------------------------------------------------------------
4753# OTA update package
4754
Yifan Hong50e79542018-11-08 17:44:12 -08004755# $(1): output file
4756# $(2): additional args
4757define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004758PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004759 $(OTA_FROM_TARGET_FILES) \
4760 --verbose \
4761 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4762 --path $(HOST_OUT) \
4763 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4764 $(2) \
4765 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004766endef
4767
Doug Zongker8678df42009-06-15 14:30:14 -07004768name := $(TARGET_PRODUCT)
4769ifeq ($(TARGET_BUILD_TYPE),debug)
4770 name := $(name)_debug
4771endif
4772name := $(name)-ota-$(FILE_NAME_TAG)
4773
4774INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004775INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4776
Doug Zongker8678df42009-06-15 14:30:14 -07004777$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004778$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004779$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004780 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004781 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004782
4783.PHONY: otapackage
4784otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4785
Tao Bao519d1822018-12-27 12:47:23 -08004786ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004787name := $(TARGET_PRODUCT)
4788ifeq ($(TARGET_BUILD_TYPE),debug)
4789 name := $(name)_debug
4790endif
4791name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4792
4793INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004794$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004795$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4796 $(BUILT_TARGET_FILES_PACKAGE) \
4797 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004798 @echo "Package OTA (retrofit dynamic partitions): $@"
4799 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4800
4801.PHONY: otardppackage
4802
4803otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4804
Tao Bao519d1822018-12-27 12:47:23 -08004805endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004806
Ying Wang09c4b682015-08-11 11:24:19 -07004807endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004808
Ying Wang09a00a62010-10-20 14:01:09 -07004809# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004810# A zip of the appcompat directory containing logs
4811APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4812# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004813ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004814$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004815 $(INSTALLED_RAMDISK_TARGET) \
4816 $(INSTALLED_BOOTIMAGE_TARGET) \
4817 $(INSTALLED_USERDATAIMAGE_TARGET) \
4818 $(INSTALLED_VENDORIMAGE_TARGET) \
4819 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004820 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004821endif
4822$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4823$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4824 @echo "appcompat logs: $@"
4825 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4826 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4827 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4828 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4829
Dario Frenid1011272018-07-23 20:20:15 +01004830# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004831# A zip of the symbols directory. Keep the full paths to make it
4832# more obvious where these files came from.
4833#
4834name := $(TARGET_PRODUCT)
4835ifeq ($(TARGET_BUILD_TYPE),debug)
4836 name := $(name)_debug
4837endif
4838name := $(name)-symbols-$(FILE_NAME_TAG)
4839
4840SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004841# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004842ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004843$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004844 $(INSTALLED_RAMDISK_TARGET) \
4845 $(INSTALLED_BOOTIMAGE_TARGET) \
4846 $(INSTALLED_USERDATAIMAGE_TARGET) \
4847 $(INSTALLED_VENDORIMAGE_TARGET) \
4848 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004849 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004850 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004851 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004852 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004853 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004854endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004855$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4856$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004857 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004858 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4859 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004860 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004861 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004862# -----------------------------------------------------------------
4863# A zip of the coverage directory.
4864#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004865name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004866ifeq ($(TARGET_BUILD_TYPE),debug)
4867name := $(name)_debug
4868endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004869COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004870ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004871$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004872 $(INSTALLED_RAMDISK_TARGET) \
4873 $(INSTALLED_BOOTIMAGE_TARGET) \
4874 $(INSTALLED_USERDATAIMAGE_TARGET) \
4875 $(INSTALLED_VENDORIMAGE_TARGET) \
4876 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004877 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004878 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004879 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4880 $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004881endif
4882$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4883$(COVERAGE_ZIP): $(SOONG_ZIP)
4884 @echo "Package coverage: $@"
4885 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4886 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4887 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4888 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004889
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004890#------------------------------------------------------------------
4891# Export the LLVM profile data tool and dependencies for Clang coverage processing
4892#
4893ifeq (true,$(CLANG_COVERAGE))
4894 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4895 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4896 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4897 $(PROFDATA_ZIP): $(SOONG_ZIP)
4898 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4899
4900 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4901endif
4902
The Android Open Source Project88b60792009-03-03 19:28:42 -08004903# -----------------------------------------------------------------
4904# A zip of the Android Apps. Not keeping full path so that we don't
4905# include product names when distributing
4906#
4907name := $(TARGET_PRODUCT)
4908ifeq ($(TARGET_BUILD_TYPE),debug)
4909 name := $(name)_debug
4910endif
4911name := $(name)-apps-$(FILE_NAME_TAG)
4912
4913APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004914$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004915 @echo "Package apps: $@"
4916 $(hide) rm -rf $@
4917 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004918 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4919 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004920 echo "No apps to zip up. Generating empty apps archive." ; \
4921 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004922 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004923 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004924 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004925
Ying Wangbc415dd2012-08-15 12:22:44 -07004926ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004927#------------------------------------------------------------------
4928# An archive of classes for use in generating code-coverage reports
4929# These are the uninstrumented versions of any classes that were
4930# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004931# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004932
Colin Crossa6bc3a82017-09-27 14:28:41 -07004933JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004934$(JACOCO_REPORT_CLASSES_ALL) :
4935 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004936 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4937 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004938
Ying Wangbc415dd2012-08-15 12:22:44 -07004939endif # EMMA_INSTRUMENT=true
4940
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004941
Ying Wangae9115a2013-08-22 20:52:47 -07004942#------------------------------------------------------------------
4943# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004944#
Ying Wangc62c92c2013-08-28 18:38:25 -07004945PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004946# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004947ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004948$(PROGUARD_DICT_ZIP): \
4949 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4950 $(INSTALLED_RAMDISK_TARGET) \
4951 $(INSTALLED_BOOTIMAGE_TARGET) \
4952 $(INSTALLED_USERDATAIMAGE_TARGET) \
4953 $(INSTALLED_VENDORIMAGE_TARGET) \
4954 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4955 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4956 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004957 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004958 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Colin Cross114e8df2019-09-05 17:19:35 -07004959 $(updater_dep)
4960endif
4961$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4962$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004963 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004964 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4965 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4966 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4967 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004968
Tao Bao48a2feb2019-06-28 11:00:05 -07004969
4970ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4971
4972# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4973# $(1): output file
4974define dump-super-image-info
4975 $(call dump-dynamic-partitions-info,$(1))
4976 $(if $(filter true,$(AB_OTA_UPDATER)), \
4977 echo "ab_update=true" >> $(1))
4978endef
4979
4980endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4981
The Android Open Source Project88b60792009-03-03 19:28:42 -08004982# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004983# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004984
4985ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4986
4987# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4988ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4989
4990ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004991
4992# For real devices and for dist builds, build super image from target files to an intermediate directory.
4993INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4994$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4995$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4996 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004997 PATH=$(dir $(LPMAKE)):$$PATH \
4998 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004999
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005000# Skip packing it in dist package because it is in update package.
5001ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005002$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005003endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005004
5005.PHONY: superimage_dist
5006superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005007
5008endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005009endif # BOARD_SUPER_PARTITION_SIZE != ""
5010endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005011
Yifan Hongacd862a2019-04-16 15:44:30 -07005012# -----------------------------------------------------------------
5013# super partition image for development
5014
5015ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5016ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5017ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5018
5019# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5020# $(1): built image path
5021# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5022define build-superimage-target
5023 mkdir -p $(dir $(2))
5024 rm -rf $(2)
5025 $(call dump-super-image-info,$(2))
5026 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5027 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005028 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5029 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005030 mkdir -p $(dir $(1))
5031 PATH=$(dir $(LPMAKE)):$$PATH \
5032 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5033endef
5034
5035INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5036INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5037 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5038
changho.shina8f9f112019-10-15 13:26:19 +09005039ifdef BUILDING_SYSTEM_OTHER_IMAGE
5040ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5041INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5042endif
5043endif
5044
Yifan Hongacd862a2019-04-16 15:44:30 -07005045# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5046# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5047# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5048# virtual devices.
5049ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5050$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5051 $(call pretty,"Target super fs image for debug: $@")
5052 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005053 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005054
5055droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5056
5057# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5058.PHONY: superimage
5059superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005060
5061$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005062endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5063
5064# Build $(PRODUCT_OUT)/super.img without dependencies.
5065.PHONY: superimage-nodeps supernod
5066superimage-nodeps supernod: intermediates :=
5067superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5068 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5069 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5070 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5071
5072endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5073endif # BOARD_SUPER_PARTITION_SIZE != ""
5074endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5075
5076# -----------------------------------------------------------------
5077# super empty image
5078
Tao Bao48a2feb2019-06-28 11:00:05 -07005079ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005080ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005081
Yifan Hong8b79d162018-11-29 12:32:00 -08005082INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5083$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5084$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5085 $(call pretty,"Target empty super fs image: $@")
5086 mkdir -p $(intermediates)
5087 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005088 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005089 PATH=$(dir $(LPMAKE)):$$PATH \
5090 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005091
5092$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5093
Yifan Hong2b891ac2018-11-29 12:06:31 -08005094endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005095endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005096
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005097
5098# -----------------------------------------------------------------
5099# The update package
5100
5101name := $(TARGET_PRODUCT)
5102ifeq ($(TARGET_BUILD_TYPE),debug)
5103 name := $(name)_debug
5104endif
5105name := $(name)-img-$(FILE_NAME_TAG)
5106
5107INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5108
Tao Bao57f8ed62019-08-14 23:08:18 -07005109$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5110 $(call pretty,"Package: $@")
5111 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5112 $(IMG_FROM_TARGET_FILES) \
5113 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5114 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005115
5116.PHONY: updatepackage
5117updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005118$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005119
5120
Yifan Hong2b891ac2018-11-29 12:06:31 -08005121# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005122# dalvik something
5123.PHONY: dalvikfiles
5124dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5125
Bo Huf0d50bb2017-08-01 19:02:09 +00005126ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005127MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005128MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005129SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005130
5131ifdef INSTALLED_SYSTEMIMAGE_TARGET
5132INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005133INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5134$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5135 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5136 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005137$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005138 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5139 @echo Create system-qemu.img now
5140 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005141 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005142
5143systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5144droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005145endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005146ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005147INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005148$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005149 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005150 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005151
5152vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5153droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5154endif
bohu8fd437c2020-03-30 20:16:13 -07005155
5156ifdef INSTALLED_RAMDISK_TARGET
5157ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5158ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5159INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5160$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5161 @echo Create ramdisk-qemu.img
5162 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5163
5164droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5165endif
5166endif
5167endif
5168
Anton Hansson32c76fe2018-12-13 14:34:18 +00005169ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005170INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005171$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005172 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005173 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005174
5175productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5176droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5177endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005178ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5179INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5180$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5181 @echo Create system_ext-qemu.img
5182 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005183
Justin Yun6151e3f2019-06-25 15:58:13 +09005184systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5185droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005186endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005187ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005188INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5189$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5190 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005191 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005192
5193odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5194droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5195endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005196
Yifan Hongcfb917a2020-05-07 14:58:20 -07005197ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5198INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5199$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5200 @echo Create vendor_dlkm-qemu.img
5201 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5202
5203vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5204droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5205endif
5206
Yifan Hongf496f1b2020-07-15 16:52:59 -07005207ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5208INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5209$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5210 @echo Create odm_dlkm-qemu.img
5211 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5212
5213odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5214droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5215endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005216
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005217QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005218$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5219 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005220 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005221 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5222 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005223
5224systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5225droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005226
Bo Huf0d50bb2017-08-01 19:02:09 +00005227endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005228# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005229# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005230ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005231INTERNAL_EMULATOR_PACKAGE_FILES += \
5232 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005233 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005234 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005235 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5236 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005237
5238name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5239
5240INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5241
Ying Wang5d887702015-11-04 10:06:25 -08005242$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005243 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005244 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005245
Ying Wang7d8c5352012-07-26 10:15:21 -07005246endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005247# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005248# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005249# The pdk package (Platform Development Kit)
5250
Keun young Park7fc7aad2012-02-27 15:49:23 -08005251#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5252# include development/pdk/Pdk.mk
5253#endif
5254
The Android Open Source Project88b60792009-03-03 19:28:42 -08005255
5256# -----------------------------------------------------------------
5257# The SDK
5258
The Android Open Source Project88b60792009-03-03 19:28:42 -08005259# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005260sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005261
5262# Build a name that looks like:
5263#
5264# linux-x86 --> android-sdk_12345_linux-x86
5265# darwin-x86 --> android-sdk_12345_mac-x86
5266# windows-x86 --> android-sdk_12345_windows
5267#
5268sdk_name := android-sdk_$(FILE_NAME_TAG)
5269ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005270 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005271else
Joe Onorato03fbe402009-04-13 08:31:16 -07005272 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005273endif
5274ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005275 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005276endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005277sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005278
5279sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5280
5281ATREE_FILES :=
5282-include $(sdk_dep_file)
5283
5284# if we don't have a real list, then use "everything"
5285ifeq ($(strip $(ATREE_FILES)),)
5286ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005287 $(ALL_DEFAULT_INSTALLED_MODULES) \
5288 $(INSTALLED_RAMDISK_TARGET) \
5289 $(ALL_DOCS) \
5290 $(ALL_SDK_FILES)
5291endif
5292
5293atree_dir := development/build
5294
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005295
The Android Open Source Project88b60792009-03-03 19:28:42 -08005296sdk_atree_files := \
5297 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005298 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005299
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005300# development/build/sdk-android-<abi>.atree is used to differentiate
5301# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5302# files like the kernel image. We use TARGET_CPU_ABI because we don't
5303# have a better way to distinguish between CPU models.
5304ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5305 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5306endif
5307
Anton Hansson8dab0a62019-03-28 15:45:40 +00005308ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5309sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005310else
5311sdk_atree_files += $(atree_dir)/sdk.atree
5312endif
5313
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005314include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005315
The Android Open Source Project88b60792009-03-03 19:28:42 -08005316deps := \
5317 $(target_notice_file_txt) \
5318 $(tools_notice_file_txt) \
5319 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005320 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005321 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005322 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005323 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005324 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005325 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005326 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005327 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005328 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005329 $(INSTALLED_USERDATAIMAGE_TARGET) \
5330 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005331 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005332 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005333 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005334 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005335 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005336 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005337 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005338
5339INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5340$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5341$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5342$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5343$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5344
5345# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5346#
5347#SDK_GNU_ERROR := true
5348
Ying Wang5d887702015-11-04 10:06:25 -08005349$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005350 @echo "Package SDK: $@"
5351 $(hide) rm -rf $(PRIVATE_DIR) $@
5352 $(hide) for f in $(target_gnu_MODULES); do \
5353 if [ -f $$f ]; then \
5354 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5355 including GNU target $$f >&2; \
5356 FAIL=$(SDK_GNU_ERROR); \
5357 fi; \
5358 done; \
5359 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005360 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005361 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005362 ATREE_STRIP="$(HOST_STRIP) -x" \
5363 $(HOST_OUT_EXECUTABLES)/atree \
5364 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5365 -m $(PRIVATE_DEP_FILE) \
5366 -I . \
5367 -I $(PRODUCT_OUT) \
5368 -I $(HOST_OUT) \
5369 -I $(TARGET_COMMON_OUT_ROOT) \
5370 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5371 -v "OUT_DIR=$(OUT_DIR)" \
5372 -v "HOST_OUT=$(HOST_OUT)" \
5373 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5374 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5375 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5376 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5377 -o $(PRIVATE_DIR) && \
5378 cp -f $(target_notice_file_txt) \
5379 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5380 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5381 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5382 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5383 chmod -R ug+rwX $(PRIVATE_DIR) && \
5384 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005385 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5386
Raphael3d224a02010-04-16 17:50:09 -07005387
5388# Is a Windows SDK requested? If so, we need some definitions from here
5389# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005390MAIN_SDK_NAME := $(sdk_name)
5391MAIN_SDK_DIR := $(sdk_dir)
5392MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005393ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005394include $(TOPDIR)development/build/tools/windows_sdk.mk
5395endif
5396
The Android Open Source Project88b60792009-03-03 19:28:42 -08005397# -----------------------------------------------------------------
5398# Findbugs
5399INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5400INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5401$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5402 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005403 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005404 > $@
5405$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5406 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005407 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005408 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005409
5410# -----------------------------------------------------------------
5411# Findbugs
5412
5413# -----------------------------------------------------------------
5414# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005415ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005416include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005417-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005418-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005419-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005420# Also the project-specific tasks
5421-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5422-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005423-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005424# Also add test specifc tasks
5425include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005426include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005427endif
Raphaelc4d47312011-02-15 16:09:36 -08005428
Ying Wang67132ba2015-10-28 16:42:39 -07005429include $(BUILD_SYSTEM)/product-graph.mk
5430
Raphaelc4d47312011-02-15 16:09:36 -08005431# -----------------------------------------------------------------
5432# Create SDK repository packages. Must be done after tasks/* since
5433# we need the addon rules defined.
5434ifneq ($(sdk_repo_goal),)
5435include $(TOPDIR)development/build/tools/sdk_repo.mk
5436endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005437
5438# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005439# Soong generates the list of all shared libraries that are depended on by fuzz
5440# targets. It saves this list as a source:destination pair to
5441# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5442# build of the unstripped shared library, and the destination is the
5443# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5444# where fuzz target shared libraries are to be "reinstalled". The
5445# copy-many-files below generates the rules to copy the unstripped shared
5446# libraries to the device or host "reinstallation" directory. These rules are
5447# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5448# a dependency on each shared library that it needs to be "reinstalled".
5449FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5450
5451# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005452# The rule to build all fuzz targets, and package them.
5453# Note: The packages are created in Soong, and in a perfect world,
5454# we'd be able to create the phony rule there. But, if we want to
5455# have dist goals for the fuzz target, we need to have the PHONY
5456# target defined in make. MakeVarsContext.DistForGoal doesn't take
5457# into account that a PHONY rule create by Soong won't be available
5458# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005459# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005460# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005461.PHONY: haiku
5462haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5463$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005464
5465# -----------------------------------------------------------------
5466# The makefile for haiku line coverage.
5467include $(BUILD_SYSTEM)/line_coverage.mk