blob: 2cf337187f5537f8bb4971736e49179fd4b8d884 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
The Android Open Source Project88b60792009-03-03 19:28:42 -08007# -----------------------------------------------------------------
8# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -07009# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080010# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
11# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080012# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070013# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070014#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070015#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070016define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070017$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
18 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080019 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
20$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
21 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
22 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
23 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
24 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
25 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
26 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
27 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
28 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
29 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
30 use vintf_compatibility_matrix / vintf_fragments instead!)) \
31 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
32 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
33 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
34 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
35 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
36 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
37 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
38 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
39 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
40)
Ying Wang68864102011-09-29 13:23:25 -070041endef
Yo Chiang0b49c032020-03-17 17:49:49 +080042
Yo Chiang0b49c032020-03-17 17:49:49 +080043check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080044ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
45check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080046endif
47check_elf_prebuilt_product_copy_files_hint := \
48 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
49
Ying Wang619fccf2012-09-05 18:08:29 -070050# filter out the duplicate <source file>:<dest file> pairs.
51unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080052$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070053 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
54 $(eval unique_product_copy_files_pairs += $(cf))))
55unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080056product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070057$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070058 $(eval _src := $(call word-colon,1,$(cf))) \
59 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070060 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080061 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080062 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070063 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070064 $(if $(filter %.xml,$(_dest)),\
65 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010066 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
67 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070068 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
69 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080070 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
71 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
72 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
73 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070074 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080075
76# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070077pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
78$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
79$(pcf_ignored_file):
80 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080081
Dan Willemsen7537fd02018-10-16 23:15:08 -070082$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
83
84pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080085product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070086unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070087unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080088
89# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080090# Returns the max allowed size for an image suitable for hash verification
91# (e.g., boot.img, recovery.img, etc).
92# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
93# $(1): partition size to flash the image
94define get-hash-image-max-size
95$(if $(1), \
96 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
97 $(eval _hash_meta_size := 69632), \
98 $(eval _hash_meta_size := 0)) \
99 $(1)-$(_hash_meta_size))
100endef
101
102# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800103# Define rules to copy headers defined in copy_headers.mk
104# If more than one makefile declared a header, print a warning,
105# then copy the last one defined. This matches the previous make
106# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700107has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800108$(foreach dest,$(ALL_COPIED_HEADERS), \
109 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800110 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800111 $(if $(call streq,$(_src),$(_srcs)),, \
112 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800113 $(warning _ Using $(_src)) \
114 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
115 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
116 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
117 $(warning _ Ignoring $(src)) \
118 $(warning __ from $(firstword $(_makefiles))) \
119 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
120 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800121 $(eval $(call copy-one-header,$(_src),$(dest))))
122all_copied_headers: $(ALL_COPIED_HEADERS)
123
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700124ifdef has_dup_copy_headers
125 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700126 $(error duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers)
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700127endif
128
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800129$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
130
Dan Willemsen6f60f022016-02-23 13:40:07 -0800131# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100133ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134gen := $(OUT_DOCS)/index.html
135ALL_DOCS += $(gen)
136$(gen): frameworks/base/docs/docs-redirect-index.html
137 @mkdir -p $(dir $@)
138 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700139endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
Dan Albert303e6032017-10-04 10:20:20 -0700141ndk_doxygen_out := $(OUT_NDK_DOCS)
142ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
143ndk_docs_src_dir := frameworks/native/docs
144ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
145ifneq ($(wildcard $(ndk_docs_src_dir)),)
146ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
147 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
148$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
149 @mkdir -p $(ndk_doxygen_out)
150 @echo "Generating NDK docs to $(ndk_doxygen_out)"
151 @( cat $(ndk_doxyfile); \
152 echo "INPUT=$(ndk_headers)"; \
153 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
154 ) | doxygen -
155
156# Note: Not a part of the docs target because we don't have doxygen available.
157# You can run this target locally if you have doxygen installed.
158ndk-docs: $(ndk_doxygen_out)/index.html
159.PHONY: ndk-docs
160endif
161
Colin Crossd60401a2019-04-18 14:46:48 -0700162$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800163
Andres Moralesb8876e12015-05-06 20:44:22 -0700164INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700165ifdef BUILDING_RECOVERY_IMAGE
166ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
167INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
168endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700169endif
170
Jiyong Parke1346862020-05-18 14:31:30 +0900171include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100172
173# ----------------------------------------------------------------
174
175# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800176# sdk-build.prop
177#
178# There are certain things in build.prop that we don't want to
179# ship with the sdk; remove them.
180
181# This must be a list of entire property keys followed by
182# "=" characters, without any internal spaces.
183sdk_build_prop_remove := \
184 ro.build.user= \
185 ro.build.host= \
186 ro.product.brand= \
187 ro.product.manufacturer= \
188 ro.product.device=
189# TODO: Remove this soon-to-be obsolete property
190sdk_build_prop_remove += ro.build.product=
191INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
192$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
193 @echo SDK buildinfo: $@
194 @mkdir -p $(dir $@)
195 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000196 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000198 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800199 $(hide) mv $@.tmp $@
200
201# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700202# kernel modules
203
204# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
205DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
206
J. Avilaa2ceec62020-05-12 23:40:02 +0000207define copy-and-strip-kernel-module
208$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000209 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000210endef
211
Colin Cross4f60e362019-06-05 11:53:43 -0700212# $(1): modules list
213# $(2): output dir
214# $(3): mount point
215# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700216# $(5): module load list
217# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800218# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000219# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700220# $(9): module directory name
Colin Cross4f60e362019-06-05 11:53:43 -0700221# Returns the a list of src:dest pairs to install the modules using copy-many-files.
222define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700223 $(if $(9), \
224 $(eval _dir := $(9)/), \
225 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000226 $(foreach module,$(1), \
227 $(eval _src := $(module)) \
228 $(if $(8), \
229 $(eval _src := $(8)/$(notdir $(module))) \
230 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700231 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700232 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700233 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
234 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
235 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
236 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700237endef
238
239# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700240# $(2): mount point
241# $(3): staging dir
242# $(4): module load list
243# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800244# $(6): module archive
245# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700246# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800247# TODO(b/144844424): If a module archive is being used, this step (which
248# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
249# the output directory. This should be moved to a module with a
250# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
251# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700252define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700253$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle474e4d02019-06-19 12:56:48 -0700254$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
255$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
256$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700257$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700258$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
259$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
260$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800261$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
262$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
263$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700264 @echo depmod $$(PRIVATE_STAGING_DIR)
265 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700266 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800267 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700268 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800269 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700270 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800271 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
272 )
273 $(if $(1),\
274 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
275 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
276 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
277 done; \
278 )
Colin Cross4f60e362019-06-05 11:53:43 -0700279 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
280 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700281 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
282 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700283endef
284
Steve Muckle474e4d02019-06-19 12:56:48 -0700285# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700286# $(2): modules list
287# $(3): module load list
288# $(4): module load list filename
289# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700290define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700291 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
292 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700293endef
294
295# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700296# $(2): modules list
297# $(3): module load list
298# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700299define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700300$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
301$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
302 @echo load-list $$(@)
303 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700304endef
305
Steve Muckle2335d762020-05-28 18:39:38 -0700306# $(1): image name
307# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
308# $(3): mount point
309# $(4): module load filename
310# $(5): stripped staging directory
311# $(6): kernel module directory name (top is an out of band value for no directory)
312define build-image-kernel-modules-dir
313$(if $(filter top,$(6)),\
314 $(eval _kver :=)$(eval _sep :=),\
315 $(eval _kver := $(6))$(eval _sep :=_))\
316$(if $(5),\
317 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
318 $(eval _stripped_staging_dir :=))\
319$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
320 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
321 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
322 $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver))))
323endef
324
325# $(1): kernel module directory name (top is an out of band value for no directory)
326define build-recovery-as-boot-load
327$(if $(filter top,$(1)),\
328 $(eval _kver :=)$(eval _sep :=),\
329 $(eval _kver := $(1))$(eval _sep :=_))\
330 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
331 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_module_list$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load,$(TARGET_RECOVERY_ROOT_OUT))))
332endef
333
334# $(1): kernel module directory name (top is an out of band value for no directory)
335define build-vendor-ramdisk-recovery-load
336$(if $(filter top,$(1)),\
337 $(eval _kver :=)$(eval _sep :=),\
338 $(eval _kver := $(1))$(eval _sep :=_))\
339 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
340 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_RAMDISK_OUT))))
341endef
342
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700343# $(1): kernel module directory name (top is an out of band value for no directory)
344define build-vendor-charger-load
345$(if $(filter top,$(1)),\
346 $(eval _kver :=)$(eval _sep :=),\
347 $(eval _kver := $(1))$(eval _sep :=_))\
348 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
349 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_OUT_VENDOR))))
350endef
351
Steve Mucklee1b10862019-07-10 10:49:37 -0700352ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
353 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
354 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700355 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700356 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
357endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700358
Steve Muckle69280d22019-07-11 12:23:38 -0700359ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
360 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700361endif
362
Steve Mucklee1b10862019-07-10 10:49:37 -0700363ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700364 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700365 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700366 endif
367endif
368
J. Avilaa2ceec62020-05-12 23:40:02 +0000369ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
370 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
371else
372 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
373endif
Colin Cross4f60e362019-06-05 11:53:43 -0700374
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700375ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
376 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
377else
378 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
379endif
380
Steve Muckle2335d762020-05-28 18:39:38 -0700381BOARD_KERNEL_MODULE_DIRS += top
382$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
383 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700384 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(TARGET_VENDOR_RAMDISK_OUT),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700385 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
Yifan Honge51dff22020-06-23 17:26:57 -0700386 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700387 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Yifan Hong3d5e2c22020-07-15 17:01:14 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700389 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
390 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
391 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700392
393# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700395# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900396# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700397# $2 certificate
398# $3 private key
399# $4 compressed
400# $5 partition tag
401# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100402define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700403$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
404$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
405$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
406$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700407
408endef
409
Jaewoong Jung704b4542020-06-29 19:37:53 -0700410# -----------------------------------------------------------------
411# Merge an individual apkcerts output into the final apkcerts.txt output.
412# Use a macro to make it compatible with _apkcerts_write_line
413# $1 apkcerts file to be merged
414# $2 output file
415define _apkcerts_merge
416$(hide) cat $1 >> $2
417
418endef
419
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420name := $(TARGET_PRODUCT)
421ifeq ($(TARGET_BUILD_TYPE),debug)
422 name := $(name)_debug
423endif
424name := $(name)-apkcerts-$(FILE_NAME_TAG)
425intermediates := \
426 $(call intermediates-dir-for,PACKAGING,apkcerts)
427APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700428all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
429$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800430# We don't need to really build all the modules.
431# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700432$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433 @echo APK certs list: $@
434 @mkdir -p $(dir $@)
435 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700436 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700437 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
438 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
439 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
440 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
441 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Ying Wangd9a88d52012-10-26 09:21:28 -0700442 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700443 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444
445.PHONY: apkcerts-list
446apkcerts-list: $(APKCERTS_FILE)
447
Ying Wang15e487a2011-02-15 10:56:18 -0800448ifneq (,$(TARGET_BUILD_APPS))
449 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900450 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800451endif
Ying Wangefb21682010-07-23 16:42:13 -0700452
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900453
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700455# build system stats
456BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
457$(BUILD_SYSTEM_STATS):
458 @rm -f $@
459 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
460 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
461$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700462
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800464# build /product/etc/security/avb/system_other.avbpubkey if needed
465ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800466ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800467INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
468ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800469endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800470endif # BUILDING_SYSTEM_OTHER_IMAGE
471
472# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700473# Modules ready to be converted to Soong, ordered by how many
474# modules depend on them.
475SOONG_CONV := $(sort $(SOONG_CONV))
476SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
477$(SOONG_CONV_DATA):
478 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700479 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS))),$(sort $(SOONG_CONV.$(s).MAKEFILES)),$(sort $(SOONG_CONV.$(s).INSTALLED))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700480
Colin Crossfdea8932017-12-06 14:38:40 -0800481SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700482SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
483$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
484 @rm -f $@
485 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
486$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
487
Joe Onorato02fb89a2020-06-27 00:10:23 -0700488MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
489MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
490$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
491$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
492 @rm -f $@
493 $(hide) $(MK2BP_CATALOG_SCRIPT) \
494 --device=$(TARGET_DEVICE) \
495 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
496 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
497 --out_dir="$(OUT_DIR)" \
498 > $@
499$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
500
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700501# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800502# Modules use -Wno-error, or added default -Wall -Werror
503WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
504$(WALL_WERROR):
505 @rm -f $@
506 echo "# Modules using -Wno-error" >> $@
507 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800508 echo "# Modules added default -Wall" >> $@
509 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
510
511$(call dist-for-goals,droidcore,$(WALL_WERROR))
512
513# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700514# C/C++ flag information for modules
515$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
516
517# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800518# Modules missing profile files
519PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
520$(PGO_PROFILE_MISSING):
521 @rm -f $@
522 echo "# Modules missing PGO profile files" >> $@
523 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
524
525$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
526
527# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700528# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700529# for future OTA packages installed by this system. Actual product
530# deliverables will be re-signed by hand. We expect this file to
531# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700532DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700533
534
Jeff Browne33ba4c2011-07-11 22:11:46 -0700535# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800536# if they don't do anything.
537.PHONY: systemimage
538systemimage:
539
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800540# -----------------------------------------------------------------
541
542.PHONY: event-log-tags
543
Joe Onoratob7510532010-07-14 10:22:54 -0700544# Produce an event logs tag file for everything we know about, in order
545# to properly allocate numbers. Then produce a file that's filtered
546# for what's going to be installed.
547
548all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
549
Colin Crossdc8f8e42012-04-12 13:25:54 -0700550event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
551
Joe Onoratob7510532010-07-14 10:22:54 -0700552# Include tags from all packages that we know about
553all_event_log_tags_src := \
554 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
555
Dan Willemsena3f66322020-05-28 15:46:33 -0700556$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
557$(all_event_log_tags_file): $(all_event_log_tags_src) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700558 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900559 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700560
Doug Zongkera34fa952011-02-23 12:17:29 -0800561# Include tags from all packages included in this product, plus all
562# tags that are part of the system (ie, not in a vendor/ or device/
563# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800564event_log_tags_src := \
565 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800566 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800568 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
569 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800570
Dan Willemsena3f66322020-05-28 15:46:33 -0700571$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700572$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700573$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800574 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900575 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800576
577event-log-tags: $(event_log_tags_file)
578
579ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
580
Joe Onoratob7510532010-07-14 10:22:54 -0700581
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582# #################################################################
583# Targets for boot/OS images
584# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800585ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
586 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000587 ifdef BOARD_PREBUILT_BOOTLOADER
588 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
589 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
590 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800591 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
592 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
593 else
594 INSTALLED_2NDBOOTLOADER_TARGET :=
595 endif
596else
597 INSTALLED_BOOTLOADER_MODULE :=
598 INSTALLED_2NDBOOTLOADER_TARGET :=
599endif # TARGET_NO_BOOTLOADER
600ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700601 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
602 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
603 $(PRODUCT_OUT)/$(k))
604 else
605 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
606 endif
Ying Wangc6349742014-01-13 16:14:20 -0800607else
608 INSTALLED_KERNEL_TARGET :=
609endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610
611# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700612# the root dir
613INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800614 $(ALL_GENERATED_SOURCES) \
615 $(ALL_DEFAULT_INSTALLED_MODULES))
616
Luis Hector Chavezff489932018-07-03 15:41:40 -0700617INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
618INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
619$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700620$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700621 @echo Installed file list: $@
622 @mkdir -p $(dir $@)
623 @rm -f $@
624 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700625 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700626
627$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
628
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800629#------------------------------------------------------------------
630# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700631ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800632INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700633ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800634$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800635 cat $^ > $@
636endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700637endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800638
Tom Cherryd14b8952018-08-09 14:26:00 -0700639# -----------------------------------------------------------------
640# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800641ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700642INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
643 $(ALL_GENERATED_SOURCES) \
644 $(ALL_DEFAULT_INSTALLED_MODULES))
645
646INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
647INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
648$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700649$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700650 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800651 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700652 @mkdir -p $(dir $@)
653 @rm -f $@
654 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700655 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700656
657$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700658BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
659
J. Avila3f6560e2020-05-11 20:20:03 +0000660ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
661# -l enables the legacy format used by the Linux kernel
662COMPRESSION_COMMAND_DEPS := $(LZ4)
663COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
664RAMDISK_EXT := .lz4
665else
666COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
667COMPRESSION_COMMAND := $(MINIGZIP)
668RAMDISK_EXT := .gz
669endif
670
Joe Onorato64d85d02009-04-09 19:31:12 -0700671# We just build this directly to the install location.
672INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000673$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800674 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000675 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800676
Ying Wangad7fd292013-08-08 16:34:29 -0700677.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000678ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700679 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000680 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800681
Dan Willemsen67495202019-01-16 12:42:05 -0800682endif # BUILDING_RAMDISK_IMAGE
683
The Android Open Source Project88b60792009-03-03 19:28:42 -0800684# -----------------------------------------------------------------
685# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700686
687# This is defined here since we may be building recovery as boot
688# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700689ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
690 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
691else
692 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
693endif
694
Steve Muckle04b6f052020-08-09 14:36:56 -0700695# $1: boot image target
696# returns the kernel used to make the bootimage
697define bootimage-to-kernel
698 $(if $(BOARD_KERNEL_BINARIES),\
699 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
700 $(INSTALLED_KERNEL_TARGET))
701endef
702
Steve Muckle903a1ca2020-05-07 17:32:10 -0700703ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
704 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
705endif
706
707# $1: boot image file name
708# $2: boot image variant (boot, boot-debug)
709define get-bootimage-partition-size
710 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
711endef
Chris Grossa784ef12019-04-22 11:09:57 -0700712
713ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700715 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700716
717ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
718INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
719endif
720
Steve Mucklee1b10862019-07-10 10:49:37 -0700721ifndef BUILDING_VENDOR_BOOT_IMAGE
722ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
723 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
724endif
725endif
726
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
728
Anton Hansson8dab0a62019-03-28 15:45:40 +0000729ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700730ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000731VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700732 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
733endif
734endif
735
Anton Hansson72e36f02019-02-26 17:36:30 +0000736INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700737
738ifndef BUILDING_VENDOR_BOOT_IMAGE
739ifdef BOARD_KERNEL_BASE
740 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
741endif
742ifdef BOARD_KERNEL_PAGESIZE
743 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
744endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700745ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700746 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
747endif
748else
749# building vendor boot image, dtb/base/pagesize go there
750ifdef GENERIC_KERNEL_CMDLINE
751 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
752endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700753endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700754
Sami Tolvanen3303d902016-03-15 16:49:30 +0000755INTERNAL_MKBOOTIMG_VERSION_ARGS := \
756 --os_version $(PLATFORM_VERSION) \
757 --os_patch_level $(PLATFORM_SECURITY_PATCH)
758
Chris Grossa784ef12019-04-22 11:09:57 -0700759# Define these only if we are building boot
760ifdef BUILDING_BOOT_IMAGE
761INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
762
The Android Open Source Project88b60792009-03-03 19:28:42 -0800763ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800764$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700765endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400766
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700767$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
768
769ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400770
Steve Muckle04b6f052020-08-09 14:36:56 -0700771# $1: boot image target
772define build_boot_board_avb_enabled
773 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
774 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
775 $(AVBTOOL) add_hash_footer \
776 --image $(1) \
777 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
778 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
779 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
780endef
781
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700782$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400783 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700784 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400785
786.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800787bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400788 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700789 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400790
Anton Hansson8dab0a62019-03-28 15:45:40 +0000791else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700792
Steve Muckle04b6f052020-08-09 14:36:56 -0700793# $1: boot image target
794define build_boot_supports_boot_signer
795 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
796 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
797 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
798endef
799
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700800$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -0700801 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700802 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700803
804.PHONY: bootimage-nodeps
805bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
806 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700807 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700808
Anton Hansson8dab0a62019-03-28 15:45:40 +0000809else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800810
Steve Muckle04b6f052020-08-09 14:36:56 -0700811# $1: boot image target
812define build_boot_supports_vboot
813 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
814 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
815 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
816endef
817
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700818$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800819 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700820 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800821
822.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800823bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800824 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700825 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800826
827else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800828
Steve Muckle04b6f052020-08-09 14:36:56 -0700829# $1: boot image target
830define build_boot_novboot
831 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
832 $(call assert-max-image-size,$1,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
833endef
834
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700835$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800836 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700837 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700838
839.PHONY: bootimage-nodeps
840bootimage-nodeps: $(MKBOOTIMG)
841 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700842 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700843
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700844endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -0700845endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846
Tao Baob1a2e352018-08-14 16:17:12 -0700847else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700848ifdef BOARD_PREBUILT_BOOTIMAGE
849ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
850# Remove when b/63676296 is resolved.
851$(error Prebuilt bootimage is only supported for AB targets)
852endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900853INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700854$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700855else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700856INSTALLED_BOOTIMAGE_TARGET :=
857endif # BOARD_PREBUILT_BOOTIMAGE
858endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800859
860# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700861# vendor boot image
862ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
863
864ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
865 $(error vboot 1.0 does not support vendor_boot partition)
866endif
867
868INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
869 $(ALL_GENERATED_SOURCES) \
870 $(ALL_DEFAULT_INSTALLED_MODULES))
871
Steve Muckle414dbe12020-06-18 21:38:35 -0700872INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000873$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
874 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700875
876ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
877 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
878endif
879ifdef BOARD_KERNEL_BASE
880 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
881endif
882ifdef BOARD_KERNEL_PAGESIZE
883 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
884endif
885ifdef INTERNAL_KERNEL_CMDLINE
886 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
887endif
888
889INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
890$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
891ifeq ($(BOARD_AVB_ENABLE),true)
892$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
893 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800894 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700895 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
896 $(AVBTOOL) add_hash_footer \
897 --image $@ \
898 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
899 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
900 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
901else
902$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
903 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800904 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700905 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
906endif
907endif # BUILDING_VENDOR_BOOT_IMAGE
908
909# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800910# NOTICE files
911#
Steve Blockd14d3b42012-03-01 11:34:41 +0000912# We are required to publish the licenses for all code under BSD, GPL and
913# Apache licenses (and possibly other more exotic ones as well). We err on the
914# side of caution, so the licenses for other third-party code are included here
915# too.
916#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800917# This needs to be before the systemimage rules, because it adds to
918# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
919# go into the systemimage.
920
Steve Block495e5852012-02-29 19:18:08 +0000921.PHONY: notice_files
922
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900923# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700924# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
925# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
926# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
927# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900928# $(2) - Plain text output file
929# $(3) - HTML/XML output file
930# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700931# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900933# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800934# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800935#
936# The algorithm here is that we go collect a hash for each of the notice
937# files and write the names of the files that match that hash. Then
938# to generate the real files, we go print out all of the files and their
939# hashes.
940#
941# These rules are fairly complex, so they depend on this makefile so if
942# it changes, they'll run again.
943#
944# TODO: We could clean this up so that we just record the locations of the
945# original notice files instead of making rules to copy them somwehere.
946# Then we could traverse that without quite as much bash drama.
947define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700948$(2): PRIVATE_MESSAGE := $(4)
949$(2): PRIVATE_DIR := $(5)
950$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
951$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800952 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -0700953 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
954 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000955 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900956 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700957 $(if $(filter $(1),xml_system),-i system --xml-output, \
958 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700959 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -0700960 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
961 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -0700962 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900963notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964endef
965
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000966# Notice file logic isn't relevant for TARGET_BUILD_APPS
967ifndef TARGET_BUILD_APPS
968
The Android Open Source Project88b60792009-03-03 19:28:42 -0800969# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
970# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
971# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000972target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000973tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000975kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
976winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800977
Bob Badour4b25c902020-01-28 13:23:39 -0800978# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
979# reasons--not to be flashed onto any device. Targets under these directories
980# need no associated notice file on the device UI.
981exclude_target_dirs := apex
982
Steven Morelandae69e572017-12-15 14:49:55 -0800983# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000984ifneq ($(PRODUCT_NOTICE_SPLIT),true)
985target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
986target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
987installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
988$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000989 $(target_notice_file_txt), \
990 $(target_notice_file_html), \
991 "Notices for files contained in the filesystem images in this directory:", \
992 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -0700993 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -0800994 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000995$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
996 $(hide) $(MINIGZIP) -9 < $< > $@
997$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
998 $(copy-file-to-target)
999else
1000target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1001target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001002installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1003
1004target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1005target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1006target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1007installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001008
1009target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1010target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1011target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1012installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001013
Justin Yun6151e3f2019-06-25 15:58:13 +09001014target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1015target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1016target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1017installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001018
Chris Gross15d96552019-07-16 14:38:43 -07001019target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1020target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1021target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1022installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1023
Yifan Hong3d3f0302020-05-11 18:35:11 -07001024target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1025target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1026target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1027installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1028
Yifan Hongc83f9e92020-07-15 16:57:47 -07001029target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1030target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1031target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1032installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1033
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001034# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1035# being built. A notice xml file must depend on all modules that could potentially
1036# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001037license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001038# Only files copied to a system image need system image notices.
1039license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001040# Phonys/fakes don't have notice files (though their deps might)
1041license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001042# testcases are not relevant to the system image.
1043license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001044# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001045license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001046license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1047license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001048license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001049license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001050license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001051license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001052license_modules_agg := $(license_modules_system) \
1053 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001054 $(license_modules_product) \
1055 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001056 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001057 $(license_modules_vendor_dlkm) \
1058 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001059# targets used for debug symbols only and do not get copied to the device
1060license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1061
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001062license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001063license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1064
1065# Identify the other targets we expect to have notices for:
1066# targets copied to the device but are not readable by the UI (e.g. must boot
1067# into a different partition to read or don't have an associated /etc
1068# directory) must have their notices built somewhere readable.
1069license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1070license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1071license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1072license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1073license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1074license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1075license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1076license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1077license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1078license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1079license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1080license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1081license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1082
1083# after removing targets in system images, targets reported in system images, and
1084# targets used for debug symbols that do not need notices, nothing must remain.
1085license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1086$(call maybe-print-list-and-error, $(license_modules_rest), \
1087 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001088
Chris Grossaad39b32019-06-13 09:43:26 -07001089# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1090# update its notice file, so include those notices in the system partition instead
1091ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001092license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001093system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1094system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001095else
Bob Badour4b25c902020-01-28 13:23:39 -08001096license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001097system_xml_directories := xml_system
1098system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001099endif
1100
1101$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001102 $(target_notice_file_txt), \
1103 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001104 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001105 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001106 $(license_modules_system), \
1107 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001108$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001109 $(target_vendor_notice_file_txt), \
1110 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001111 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001112 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001113 $(license_modules_vendor), \
1114 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001115$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001116 $(target_product_notice_file_txt), \
1117 $(target_product_notice_file_xml), \
1118 "Notices for files contained in the product filesystem image in this directory:", \
1119 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001120 $(license_modules_product), \
1121 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001122$(eval $(call combine-notice-files, xml_system_ext, \
1123 $(target_system_ext_notice_file_txt), \
1124 $(target_system_ext_notice_file_xml), \
1125 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001126 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001127 $(license_modules_system_ext), \
1128 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001129$(eval $(call combine-notice-files, xml_odm, \
1130 $(target_odm_notice_file_txt), \
1131 $(target_odm_notice_file_xml), \
1132 "Notices for files contained in the odm filesystem image in this directory:", \
1133 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001134 $(license_modules_odm), \
1135 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001136$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1137 $(target_vendor_dlkm_notice_file_txt), \
1138 $(target_vendor_dlkm_notice_file_xml), \
1139 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1140 $(TARGET_OUT_NOTICE_FILES), \
1141 $(license_modules_vendor_dlkm), \
1142 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001143$(eval $(call combine-notice-files, xml_odm_dlkm, \
1144 $(target_odm_dlkm_notice_file_txt), \
1145 $(target_odm_dlkm_notice_file_xml), \
1146 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1147 $(TARGET_OUT_NOTICE_FILES), \
1148 $(license_modules_odm_dlkm), \
1149 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001150
1151$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1152 $(hide) $(MINIGZIP) -9 < $< > $@
1153$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1154 $(hide) $(MINIGZIP) -9 < $< > $@
1155$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1156 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001157$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001158 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001159$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1160 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001161$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1162 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001163$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1164 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001165$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1166 $(copy-file-to-target)
1167$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1168 $(copy-file-to-target)
1169$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1170 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001171$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001172 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001173$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1174 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001175$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1176 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001177$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1178 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001179
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001180ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1181ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1182ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1183ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1184ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001185ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001186ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001187endif # PRODUCT_NOTICE_SPLIT
1188
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001189ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001190
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001191$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001192 $(tools_notice_file_txt), \
1193 $(tools_notice_file_html), \
1194 "Notices for files contained in the tools directory:", \
1195 $(HOST_OUT_NOTICE_FILES), \
1196 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001197 $(winpthreads_notice_file), \
1198 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001199
Ying Wang62c81f82013-08-22 20:02:03 -07001200endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001201
1202# The kernel isn't really a module, so to get its module file in there, we
1203# make the target NOTICE files depend on this particular file too, which will
1204# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001205$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001206
Dan Willemsen288bedf2019-05-28 15:36:47 -07001207$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001208
Doug Zongker8678df42009-06-15 14:30:14 -07001209
The Android Open Source Project88b60792009-03-03 19:28:42 -08001210# #################################################################
1211# Targets for user images
1212# #################################################################
1213
Ying Wang933abf12010-06-16 14:31:34 -07001214INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001215ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001216INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1217else
1218ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001219INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1220else
1221ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001222INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1223endif
1224endif
1225endif
1226
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001227# These options tell the recovery updater/installer how to mount the partitions writebale.
1228# <fstype>=<fstype_opts>[|<fstype_opts>]...
1229# fstype_opts := <opt>[,<opt>]...
1230# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001231# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1232DEFAULT_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 -07001233
Ying Wang542903a2010-11-17 15:40:38 -08001234ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1235 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1236endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001237ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1238 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1239endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001240ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1241 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1242endif
Tao Baodba635a2019-06-24 10:39:54 -07001243
1244INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001245 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001246 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001247 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001248
1249ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1250INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001251endif
1252
Yifan Hongcfb917a2020-05-07 14:58:20 -07001253ifneq ($(filter \
1254 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1255 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1256 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1257 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1258 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1259 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001260 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001261 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001262INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1263endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001264
Anton Hansson8dab0a62019-03-28 15:45:40 +00001265ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001266INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001267ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001268INTERNAL_USERIMAGES_DEPS += $(FEC)
1269endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001270endif
1271
Tao Baodba635a2019-06-24 10:39:54 -07001272ifeq ($(BOARD_AVB_ENABLE),true)
1273INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1274endif
1275
1276# Get a colon-separated list of search paths.
1277INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1278
Alex Klyubin092c9022017-03-13 13:28:34 -07001279SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001280INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1281
Yifan Hongc5c01242018-11-09 10:27:23 -08001282ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001283
Anton Hansson8dab0a62019-03-28 15:45:40 +00001284ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001285 $(error vboot 1.0 doesn't support logical partition)
1286endif
1287
Yifan Hongc5c01242018-11-09 10:27:23 -08001288endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001289
Ying Wangbd93d422011-10-28 17:02:30 -07001290# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001291# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001292# $(3): additional "key=value" pairs to append to the dictionary file.
1293define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001294$(if $(filter $(2),system),\
1295 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001296 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001297 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1298 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1299 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1300 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1301 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1302 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1303 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1304 $(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 +00001305 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1306 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001307 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001308 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001309 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1310)
1311$(if $(filter $(2),system_other),\
1312 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001313)
Yifan Hong760d3c02018-05-30 11:16:46 -07001314$(if $(filter $(2),userdata),\
1315 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1316 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001317 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1318 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001319 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001320 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001321)
Yifan Hong760d3c02018-05-30 11:16:46 -07001322$(if $(filter $(2),cache),\
1323 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1324 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001325 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001326 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001327)
1328$(if $(filter $(2),vendor),\
1329 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1330 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1331 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1332 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1333 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1334 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1335 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1336 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1337 $(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 +00001338 $(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 -07001339 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001340 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001341 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001342)
1343$(if $(filter $(2),product),\
1344 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1345 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1346 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1347 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1348 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1349 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1350 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1351 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1352 $(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 +00001353 $(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 -07001354 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001355 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001356 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001357)
Justin Yun6151e3f2019-06-25 15:58:13 +09001358$(if $(filter $(2),system_ext),\
1359 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1360 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1361 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1362 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1363 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1364 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1365 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1366 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1367 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1368 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1369 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001370 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001371)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001372$(if $(filter $(2),odm),\
1373 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1374 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1375 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1376 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1377 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1378 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1379 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1380 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1381 $(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 +00001382 $(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 +08001383 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001384 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001385 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001386)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001387$(if $(filter $(2),vendor_dlkm),\
1388 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1389 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1390 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1391 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1392 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1393 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1394 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1395 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1396 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1397 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1398 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1399 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1400)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001401$(if $(filter $(2),odm_dlkm),\
1402 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1403 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1404 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1405 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1406 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1407 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1408 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1409 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1410 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1411 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1412 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1413 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1414)
Yifan Hong760d3c02018-05-30 11:16:46 -07001415$(if $(filter $(2),oem),\
1416 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1417 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1418 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1419 $(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 -07001420 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001421)
Tao Bao3602eca2018-07-10 10:53:55 -07001422$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001423
Tao Bao3602eca2018-07-10 10:53:55 -07001424$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001425$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001426$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001427$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001428$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1429$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1430$(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 +00001431$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1432$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1433$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1434$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1435$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001436$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001437$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1438$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1439$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001440$(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 -07001441$(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 -07001442$(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 +00001443$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1444$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1445$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1446$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1447$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001448$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001449$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1450$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1451$(if $(BOARD_AVB_ENABLE),\
1452 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1453 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1454 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1455 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001456$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1457$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1458$(if $(BOARD_AVB_ENABLE),\
1459 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1460 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001461 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001462$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1463$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1464$(if $(BOARD_AVB_ENABLE),\
1465 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1466 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1467 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1468 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001469$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1470$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1471$(if $(BOARD_AVB_ENABLE),\
1472 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1473 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1474 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1475 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001476$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001477$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001478 $(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 +01001479$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001480 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1481 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1482 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1483 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001484$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1485$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1486$(if $(BOARD_AVB_ENABLE),\
1487 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1488 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1489 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1490 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001491$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1492$(if $(BOARD_AVB_ENABLE),\
1493 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1494$(if $(BOARD_AVB_ENABLE),\
1495 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1496 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1497 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1498 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001499$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1500$(if $(BOARD_AVB_ENABLE),\
1501 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1502$(if $(BOARD_AVB_ENABLE),\
1503 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1504 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1505 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1506 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001507$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1508 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001509$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001510 $(hide) echo "system_root_image=true" >> $(1))
1511$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001512$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1513 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001514$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1515endef
1516
1517# $(1): the path of the output dictionary file
1518# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001519PROP_DICTIONARY_IMAGES := oem
1520ifdef BUILDING_CACHE_IMAGE
1521 PROP_DICTIONARY_IMAGES += cache
1522endif
1523ifdef BUILDING_SYSTEM_IMAGE
1524 PROP_DICTIONARY_IMAGES += system
1525endif
Chris Gross203191b2020-05-30 02:39:12 +00001526ifdef BUILDING_SYSTEM_OTHER_IMAGE
1527 PROP_DICTIONARY_IMAGES += system_other
1528endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001529ifdef BUILDING_USERDATA_IMAGE
1530 PROP_DICTIONARY_IMAGES += userdata
1531endif
1532ifdef BUILDING_VENDOR_IMAGE
1533 PROP_DICTIONARY_IMAGES += vendor
1534endif
1535ifdef BUILDING_PRODUCT_IMAGE
1536 PROP_DICTIONARY_IMAGES += product
1537endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001538ifdef BUILDING_SYSTEM_EXT_IMAGE
1539 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001540endif
1541ifdef BUILDING_ODM_IMAGE
1542 PROP_DICTIONARY_IMAGES += odm
1543endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001544ifdef BUILDING_VENDOR_DLKM_IMAGE
1545 PROP_DICTIONARY_IMAGES += vendor_dlkm
1546endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001547ifdef BUILDING_ODM_DLKM_IMAGE
1548 PROP_DICTIONARY_IMAGES += odm_dlkm
1549endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001550define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001551 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001552endef
1553
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001554# $(1): the path of the input dictionary file, where each line has the format key=value
1555# $(2): the key to look up
1556define read-image-prop-dictionary
1557$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1558endef
1559
The Android Open Source Project88b60792009-03-03 19:28:42 -08001560# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001561# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001562
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001563# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001564ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001565
Ying Wang37526142015-03-10 12:02:57 -07001566INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1567 $(ALL_DEFAULT_INSTALLED_MODULES))
1568
Tao Bao10fc9492018-08-14 12:17:48 -07001569INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1570INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1571
1572# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1573# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1574# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1575# the call to FILELIST.
1576ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001577INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001578$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1579else
1580$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1581endif
1582
1583$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001584$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001585 @echo Installed file list: $@
1586 @mkdir -p $(dir $@)
1587 @rm -f $@
1588 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001589 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001590
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001591recovery_sepolicy := \
1592 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001593 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001594 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001595 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1596 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1597 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001598 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001599 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001600 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1601 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1602 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001603
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001604# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1605# SELinux files
1606IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1607
Steve Muckle04b6f052020-08-09 14:36:56 -07001608# if building multiple boot images from multiple kernels, use the first kernel listed
1609# for the recovery image
1610recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001611recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001612recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001613
Anton Hansson45a40da2019-01-18 14:06:34 +00001614# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1615# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1616# which get remapped to a bucket.
1617recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001618ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1619recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001620# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001621# ------160------240------320----------480------------640------
1622# mdpi hdpi xhdpi xxhdpi xxxhdpi
1623recovery_density := $(strip \
1624 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1625 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1626 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1627 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001628endif
1629
1630ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1631recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1632else
Doug Zongker25d55f82014-04-04 13:51:15 -07001633recovery_resources_common := $(recovery_resources_common)-xhdpi
1634endif
1635
Tao Baoe1e829e2018-08-29 20:36:00 -07001636# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1637# Note that the font selected here can be overridden for a particular device by putting a font.png
1638# in its private recovery resources.
1639ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001640recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001641else
Dan Willemsen97672232020-05-27 00:09:16 -07001642recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001643endif
1644
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001645
1646# We will only generate the recovery background text images if the variable
1647# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1648# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1649# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1650# BoardConfig in order to use this feature.
1651ifeq ($(recovery_density),xxxhdpi)
1652TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1653else ifeq ($(recovery_density),xxhdpi)
1654TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1655endif
1656
1657ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1658# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1659ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1660 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1661else
1662 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1663endif
1664
1665
Dan Willemsen97672232020-05-27 00:09:16 -07001666RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001667RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1668RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1669RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1670RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1671
xunchangcc57d312018-12-07 12:12:17 -08001672RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1673RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1674RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1675RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1676RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1677
1678generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001679 $(RECOVERY_INSTALLING_TEXT_FILE) \
1680 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1681 $(RECOVERY_ERASING_TEXT_FILE) \
1682 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001683 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1684 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1685 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1686 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1687 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1688 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001689
Dan Willemsen97672232020-05-27 00:09:16 -07001690resource_dir := bootable/recovery/tools/recovery_l10n/res/
1691resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001692image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001693zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001694$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001695$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001696$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1697$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001698$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001699$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001700$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001701 recovery_installing \
1702 recovery_installing_security \
1703 recovery_erasing \
1704 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001705 recovery_no_command
1706$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001707 recovery_cancel_wipe_data \
1708 recovery_factory_data_reset \
1709 recovery_try_again \
1710 recovery_wipe_data_menu_header \
1711 recovery_wipe_data_confirmation
1712$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001713$(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 -08001714 # Prepares the font directory.
1715 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1716 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001717 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001718 @rm -rf $(dir $@)
1719 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001720 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001721 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001722 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001723 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1724 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1725 --text_name $(text_name) \
1726 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1727 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001728 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001729 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001730else
1731RECOVERY_INSTALLING_TEXT_FILE :=
1732RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1733RECOVERY_ERASING_TEXT_FILE :=
1734RECOVERY_ERROR_TEXT_FILE :=
1735RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001736RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1737RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1738RECOVERY_TRY_AGAIN_TEXT_FILE :=
1739RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1740RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001741endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1742
Ying Wang9a175682015-08-06 11:47:47 -07001743ifndef TARGET_PRIVATE_RES_DIRS
1744TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1745endif
Doug Zongker4647f122009-07-02 09:00:54 -07001746recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001747 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001748recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001749
1750
Andrew Boiefa61ff02012-09-28 09:33:45 -07001751ifdef TARGET_RECOVERY_FSTAB
1752recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1753else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001754recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001755endif
Tao Baoc3c17532016-06-10 10:11:54 -07001756ifdef TARGET_RECOVERY_WIPE
1757recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001758else
Tao Baoc3c17532016-06-10 10:11:54 -07001759recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001760endif
Tao Bao8beab692015-07-22 12:33:18 -07001761
Tao Bao6d5d6232018-03-09 17:04:42 -08001762# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001763# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001764# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1765# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001766#
1767# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001768# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001769# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001770# b) We build a single image that contains boot and recovery both - no recovery image to install
1771# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001772# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001773# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001774# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1775# do bsdiff because boot and recovery will contain different number of entries
1776# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001777# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1778# do bsdiff because boot and recovery will contain different number of entries
1779# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001780
Tom Cherry2929cad2018-09-20 11:04:37 -07001781ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001782 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001783# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001784RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1785ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001786else
Tao Bao8beab692015-07-22 12:33:18 -07001787RECOVERY_RESOURCE_ZIP :=
1788endif
Doug Zongker4647f122009-07-02 09:00:54 -07001789
Tao Bao139c7272018-07-31 13:26:54 -07001790INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1791
1792$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001793 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1794 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1795 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1796 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1797 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1798 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1799 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1800 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1801
1802# Parses the given list of build variables and writes their values as build properties if defined.
1803# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1804# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1805# $(1): Map from the build variable names to property names
1806# $(2): Output file
1807define append-recovery-ui-properties
1808echo "#" >> $(2)
1809echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1810echo "#" >> $(2)
1811$(foreach prop,$(1), \
1812 $(eval _varname := $(call word-colon,1,$(prop))) \
1813 $(eval _propname := $(call word-colon,2,$(prop))) \
1814 $(eval _value := $($(_varname))) \
1815 $(if $(_value), \
1816 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1817endef
1818
1819$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001820 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001821 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1822 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1823 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001824 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001825 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001826 $(hide) mkdir -p $(dir $@)
1827 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001828 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001829 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001830 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001831 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001832 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001833 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1834
Steve Mucklef84668e2020-03-16 19:13:46 -07001835ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001836 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001837ifdef GENERIC_KERNEL_CMDLINE
1838 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1839endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001840else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001841 INTERNAL_RECOVERYIMAGE_ARGS := \
1842 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001843 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001844# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001845ifdef INTERNAL_KERNEL_CMDLINE
1846 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001847endif
1848ifdef BOARD_KERNEL_BASE
1849 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1850endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001851ifdef BOARD_KERNEL_PAGESIZE
1852 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1853endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001854ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001855ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1856 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1857else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001858 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1859endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001860endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001861ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1862 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1863endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001864ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1865 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1866endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001867endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001868ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1869 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1870endif
Doug Zongker4647f122009-07-02 09:00:54 -07001871
J. Avila3f6560e2020-05-11 20:20:03 +00001872$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001873 $(INTERNAL_ROOT_FILES) \
1874 $(INSTALLED_RAMDISK_TARGET) \
1875 $(INTERNAL_RECOVERYIMAGE_FILES) \
1876 $(recovery_sepolicy) \
1877 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1878 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1879 $(recovery_resource_deps) \
1880 $(recovery_fstab)
1881 # Making recovery image
1882 mkdir -p $(TARGET_RECOVERY_OUT)
1883 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1884 # Copying baseline ramdisk...
1885 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1886 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1887 # Modifying ramdisk contents...
1888 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1889 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1890 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1891 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1892 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1893 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1894 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1895 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1896 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1897 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1898 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1899 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1900 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1901 $(foreach item,$(recovery_fstab), \
1902 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1903 $(if $(strip $(recovery_wipe)), \
1904 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1905 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1906 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001907 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001908
Ying Wang747b9f12015-01-30 14:05:22 -08001909# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001910# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001911define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001912 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001913 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001914 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001915 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001916 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001917 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001918 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001919 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001920 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001921 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1922 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001923 )\
1924 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001925 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1926 $(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 +08001927 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001928 $(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 -07001929 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001930 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1931 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001932 $(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 -07001933 $(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 -08001934endef
1935
Dan Willemsend120ac62020-06-12 02:39:34 +00001936recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001937ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001938 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001939endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001940ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001941 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001942endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001943ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001944 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001945endif
Tao Baof4866c72018-08-22 14:35:09 -07001946ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001947 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1948 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1949 else
1950 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1951 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001952endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001953ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001954 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001955endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001956ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001957 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001958endif
Tao Baof4866c72018-08-22 14:35:09 -07001959
Dan Willemsend120ac62020-06-12 02:39:34 +00001960ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001961$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00001962$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001963 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001964 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001965endif # BOARD_USES_RECOVERY_AS_BOOT
1966
Dan Willemsend120ac62020-06-12 02:39:34 +00001967$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001968 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001969
Tao Bao4594d0e2015-12-22 09:47:46 -08001970ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001971$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001972 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001973 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1974 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001975endif
Doug Zongker56588872012-08-20 15:38:58 -07001976
Ying Wang747b9f12015-01-30 14:05:22 -08001977.PHONY: recoveryimage-nodeps
1978recoveryimage-nodeps:
1979 @echo "make $@: ignoring dependencies"
Steve Mucklea21b44a2020-08-09 14:54:42 -07001980 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), $(recovery_kernel))
Ying Wang747b9f12015-01-30 14:05:22 -08001981
Chris Grossa784ef12019-04-22 11:09:57 -07001982else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001983RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001984endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001985
1986.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001987recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001988
Jiyong Park03eb0612017-10-04 21:22:41 +09001989ifneq ($(BOARD_NAND_PAGE_SIZE),)
1990$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001991endif
1992
Jiyong Park03eb0612017-10-04 21:22:41 +09001993ifneq ($(BOARD_NAND_SPARE_SIZE),)
1994$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001995endif
1996
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001997ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07001998# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08001999# the debug ramdisk, which is the original ramdisk plus additional
2000# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2001# When /force_debuggable is present, /init will load userdebug sepolicy
2002# and property files to allow adb root, if the device is unlocked.
2003
2004ifdef BUILDING_RAMDISK_IMAGE
2005BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2006INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2007
2008INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2009 $(ALL_GENERATED_SOURCES) \
2010 $(ALL_DEFAULT_INSTALLED_MODULES))
2011
2012# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2013# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2014# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2015my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2016
2017INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2018INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2019$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2020$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2021
2022# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2023# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2024# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2025$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002026$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002027 echo Installed file list: $@
2028 mkdir -p $(dir $@)
2029 rm -f $@
2030 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002031 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002032
2033# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2034# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2035ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2036my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2037else
2038my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2039endif # BOARD_USES_RECOVERY_AS_BOOT
2040
2041$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2042$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002043
2044ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2045# 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 +08002046$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002047else
2048# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2049$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2050endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002051$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002052 $(call pretty,"Target debug ram disk: $@")
2053 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2054 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002055 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002056 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002057
2058.PHONY: ramdisk_debug-nodeps
2059ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2060ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002061ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002062 echo "make $@: ignoring dependencies"
2063 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2064 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002065 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002066 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002067
2068my_debug_ramdisk_sync_dir :=
2069my_debug_ramdisk_root_dir :=
2070
2071endif # BUILDING_RAMDISK_IMAGE
2072
2073# -----------------------------------------------------------------
2074# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2075#
2076# Note: it's intentional to skip signing for boot-debug.img, because it
2077# can only be used if the device is unlocked with verification error.
2078ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002079ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2080 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2081 $(PRODUCT_OUT)/$(k).img)
2082else
2083 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2084endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002085
2086# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2087ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2088INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2089else
2090INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2091endif
2092
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002093# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2094# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2095# Using a test key to sign boot-debug.img to continue booting with the mismatched
2096# public key, if the device is unlocked.
2097ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002098$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002099endif
2100
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002101BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2102INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2103# $(1): the bootimage to sign
2104define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002105$(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 +08002106$(AVBTOOL) add_hash_footer \
2107 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002108 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002109 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2110 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002111$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002112endef
2113
Steve Muckleb3dda772020-03-11 16:03:07 -07002114# $(1): output file
2115define build-debug-bootimage-target
2116 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2117 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2118 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2119endef
2120
Bowgo Tsai0013f552019-03-20 17:59:52 +08002121# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2122$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2123 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002124 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002125
2126.PHONY: bootimage_debug-nodeps
2127bootimage_debug-nodeps: $(MKBOOTIMG)
2128 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002129 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002130
2131endif # TARGET_NO_KERNEL
2132
Bowgo Tsai6a683672020-02-14 19:00:15 +08002133ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2134ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2135# -----------------------------------------------------------------
2136# vendor debug ramdisk
2137# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002138INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002139$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2140$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2141
2142INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2143 $(ALL_GENERATED_SOURCES) \
2144 $(ALL_DEFAULT_INSTALLED_MODULES))
2145
2146# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2147# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2148# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2149# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2150$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2151$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002152$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002153 $(call pretty,"Target vendor debug ram disk: $@")
2154 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2155 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2156 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2157 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2158 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002159 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002160
2161INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2162INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2163$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2164$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2165
2166# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2167# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2168$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2169$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2170 echo Installed file list: $@
2171 mkdir -p $(dir $@)
2172 rm -f $@
2173 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2174 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2175
2176# -----------------------------------------------------------------
2177# vendor_boot-debug.img.
2178INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2179
2180# The util to sign vendor_boot-debug.img with a test key.
2181BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2182INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2183# $(1): the vendor bootimage to sign
2184define test-key-sign-vendor-bootimage
2185$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2186$(AVBTOOL) add_hash_footer \
2187 --image $(1) \
2188 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2189 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2190 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2191$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2192endef
2193
2194ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2195$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2196endif
2197
2198# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2199$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2200 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002201 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002202 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2203 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2204
2205endif # BUILDING_RAMDISK_IMAGE
2206endif # BUILDING_VENDOR_BOOT_IMAGE
2207
Bowgo Tsai0013f552019-03-20 17:59:52 +08002208# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002209# The test harness ramdisk, which is based off debug_ramdisk, plus a
2210# few additional test-harness-specific properties in adb_debug.prop.
2211
2212ifdef BUILDING_RAMDISK_IMAGE
2213BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2214INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2215
2216# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2217# appends a few test harness specific properties into the adb_debug.prop.
2218TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2219TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2220
2221# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2222# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2223TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2224ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2225ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2226
2227# $(1): a list of key=value pairs for additional property assignments
2228# $(2): the target .prop file to append the properties from $(1)
2229define append-test-harness-props
2230 echo "#" >> $(2); \
2231 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2232 echo "#" >> $(2);
2233 $(foreach line,$(1), echo "$(line)" >> $(2);)
2234endef
2235
2236$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002237$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002238 $(call pretty,"Target test harness ram disk: $@")
2239 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2240 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002241 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002242
2243.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002244ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002245 echo "make $@: ignoring dependencies"
2246 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2247 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002248 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002249
2250endif # BUILDING_RAMDISK_IMAGE
2251
2252# -----------------------------------------------------------------
2253# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2254#
2255# Note: it's intentional to skip signing for boot-test-harness.img, because it
2256# can only be used if the device is unlocked with verification error.
2257ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2258
Steve Muckle4866bd62020-04-02 11:31:08 -07002259ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2260 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2261 $(PRODUCT_OUT)/$(k).img)
2262else
2263 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2264endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002265
2266# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2267INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2268
2269# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2270# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2271# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2272# public key, if the device is unlocked.
2273ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2274$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2275endif
2276
Steve Muckle4866bd62020-04-02 11:31:08 -07002277# $(1): output file
2278define build-boot-test-harness-target
2279 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2280 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2281 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2282endef
2283
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002284# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2285$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2286 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002287 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002288
2289.PHONY: bootimage_test_harness-nodeps
2290bootimage_test_harness-nodeps: $(MKBOOTIMG)
2291 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002292 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002293
2294endif # TARGET_NO_KERNEL
2295endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2296
Colin Crossbd382142020-08-26 15:08:57 -07002297# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2298# $1: from location (e.g $(TARGET_OUT)/vendor)
2299# $2: destination location (e.g. /vendor)
2300# $3: partition image name (e.g. vendor.img)
2301define create-partition-compat-symlink
2302$(eval \
2303$1:
2304 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2305 mkdir -p $(dir $1)
2306 if [ -d $1 ] && [ ! -h $1 ]; then \
2307 echo 'Non-symlink $1 detected!' 1>&2; \
2308 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2309 exit 1; \
2310 fi
2311 ln -sfn $2 $1
2312)
2313$1
2314endef
2315
2316
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002317# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002318# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002319
Dan Willemsen37a19862018-10-31 16:31:46 -07002320INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002321 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002322 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002323
Colin Crossbd382142020-08-26 15:08:57 -07002324# Create symlink /system/vendor to /vendor if necessary.
2325ifdef BOARD_USES_VENDORIMAGE
2326 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2327endif
2328
2329# Create symlink /system/product to /product if necessary.
2330ifdef BOARD_USES_PRODUCTIMAGE
2331 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2332endif
2333
2334# Create symlink /system/system_ext to /system_ext if necessary.
2335ifdef BOARD_USES_SYSTEM_EXTIMAGE
2336 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2337endif
2338
Ying Wang82cceba2012-08-13 15:03:00 -07002339FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002340
2341# ASAN libraries in the system image - add dependency.
2342ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002343ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002344 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2345 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2346 endif
2347endif
2348
Tom Cherryd14b8952018-08-09 14:26:00 -07002349FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002350
Ying Wange5e8c5f2011-09-09 16:35:53 -07002351# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002352ifdef BUILDING_SYSTEM_IMAGE
2353
Ying Wange5e8c5f2011-09-09 16:35:53 -07002354# installed file list
2355# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2356# We put installed-files.txt ahead of image itself in the dependency graph
2357# so that we can get the size stat even if the build fails due to too large
2358# system image.
2359INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002360INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2361$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002362$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002363 @echo Installed file list: $@
2364 @mkdir -p $(dir $@)
2365 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002366 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002367 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002368
2369.PHONY: installed-file-list
2370installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002371
2372$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002373
2374systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002375 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002376BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2377
The Android Open Source Project88b60792009-03-03 19:28:42 -08002378# $(1): output file
2379define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002380 @echo "Target system fs image: $(1)"
2381 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002382 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002383 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002384 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002385 $(BUILD_IMAGE) \
2386 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2387 || ( mkdir -p $${DIST_DIR}; \
2388 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2389 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002390endef
2391
Dan Willemsen6b72c732019-06-12 21:33:38 +00002392ifeq ($(BOARD_AVB_ENABLE),true)
2393$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2394endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002395$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002396 $(call build-systemimage-target,$@)
2397
Tao Baoe9d61b02018-08-20 21:09:07 -07002398INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002399SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002400
Tao Baoe9d61b02018-08-20 21:09:07 -07002401# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2402# compatibility, in case device-specific Makefiles still refer to the old name.
2403INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2404
Doug Zongker73ef8252009-07-23 15:12:53 -07002405# The system partition needs room for the recovery image as well. We
2406# now store the recovery image as a binary patch using the boot image
2407# as the source (since they are very similar). Generate the patch so
2408# we can see how big it's going to be, and include that in the system
2409# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002410ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002411ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002412ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002413ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002414diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2415else
2416diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2417endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002418intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2419RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002420$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2421$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002422 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002423 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002424 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002425 @echo "Construct recovery from boot"
2426 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002427 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002428else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2429RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002430endif # BOARD_USES_FULL_RECOVERY_IMAGE
2431endif # INSTALLED_RECOVERYIMAGE_TARGET
2432endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002433
Yifan Hong9a3cad92020-04-27 19:06:59 -07002434$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002435 @echo "Install system fs image: $@"
2436 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002437 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002438
Tao Baoe9d61b02018-08-20 21:09:07 -07002439systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002440
2441.PHONY: systemimage-nodeps snod
2442systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002443 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002444 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002445 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002446 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002447ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002448 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002449endif
2450
Dan Willemsen67495202019-01-16 12:42:05 -08002451endif # BUILDING_SYSTEM_IMAGE
2452
Anton Hansson30e061b2018-11-12 13:36:46 +00002453.PHONY: sync syncsys
2454sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002455
Ying Wang3a61eeb2016-03-11 10:32:01 -08002456# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002457# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002458.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002459platform:
2460 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002461
2462.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002463platform-java:
2464 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002465
Ying Wang3a61eeb2016-03-11 10:32:01 -08002466# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002467# data partition image
2468INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002469 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002470
Dan Willemsen67495202019-01-16 12:42:05 -08002471ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002472userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002473 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002474BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2475
Ying Wangbd93d422011-10-28 17:02:30 -07002476define build-userdataimage-target
2477 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2478 @mkdir -p $(TARGET_OUT_DATA)
2479 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002480 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002481 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002482 $(BUILD_IMAGE) \
2483 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2484 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2485 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002486endef
2487
Joe Onorato64d85d02009-04-09 19:31:12 -07002488# We just build this directly to the install location.
2489INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002490INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2491 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002492 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002493$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002494 $(build-userdataimage-target)
2495
2496.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002497userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002498 $(build-userdataimage-target)
2499
Dan Willemsen67495202019-01-16 12:42:05 -08002500endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002501
Andreas Gampe039b5c72017-03-24 16:06:31 -07002502# ASAN libraries in the system image - build rule.
2503ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2504 $(TARGET_OUT_SHARED_LIBRARIES) \
2505 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2506 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2507 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002508# Extra options: Enforce the system user for the files to avoid having to change ownership.
2509ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002510# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2511# enough space.
2512$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002513 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 -07002514
The Android Open Source Project88b60792009-03-03 19:28:42 -08002515# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002516# partition table image
2517ifdef BOARD_BPT_INPUT_FILES
2518
2519BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002520BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002521
2522INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2523 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002524 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002525 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2526
2527ifdef BOARD_BPT_DISK_SIZE
2528INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2529endif
2530
2531define build-bptimage-target
2532 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2533 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2534endef
2535
2536INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002537$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2538 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2539
David Zeuthen25328622016-04-08 15:08:03 -04002540$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2541 $(build-bptimage-target)
2542
2543.PHONY: bptimage-nodeps
2544bptimage-nodeps:
2545 $(build-bptimage-target)
2546
2547endif # BOARD_BPT_INPUT_FILES
2548
2549# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002550# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002551ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002552INTERNAL_CACHEIMAGE_FILES := \
2553 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2554
2555cacheimage_intermediates := \
2556 $(call intermediates-dir-for,PACKAGING,cache)
2557BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2558
2559define build-cacheimage-target
2560 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2561 @mkdir -p $(TARGET_OUT_CACHE)
2562 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002563 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002564 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002565 $(BUILD_IMAGE) \
2566 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2567 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2568 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002569endef
2570
2571# We just build this directly to the install location.
2572INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002573$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002574 $(build-cacheimage-target)
2575
2576.PHONY: cacheimage-nodeps
2577cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2578 $(build-cacheimage-target)
2579
Dan Willemsen67495202019-01-16 12:42:05 -08002580else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002581# we need to ignore the broken cache link when doing the rsync
2582IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002583endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002584
David Zeuthen0eb10972016-09-28 17:55:27 -04002585# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002586# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002587ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002588ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002589# Marker file to identify that odex files are installed
2590INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2591ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2592$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2593 $(hide) touch $@
2594endif
2595
Alex Light4e358ab2016-06-16 14:47:10 -07002596INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2597 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002598 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002599
Colin Cross6db5b0e2018-11-16 21:26:33 -08002600# system_other dex files are installed as a side-effect of installing system image files
2601INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2602
Alex Light4e358ab2016-06-16 14:47:10 -07002603INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002604INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2605$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002606$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002607 @echo Installed file list: $@
2608 @mkdir -p $(dir $@)
2609 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002610 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002611 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002612
Bowgo Tsai867ab662019-01-29 13:30:18 +08002613# Determines partition size for system_other.img.
2614ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2615ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2616INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2617endif
2618endif
2619
2620ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2621INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2622endif
2623
Alex Light4e358ab2016-06-16 14:47:10 -07002624systemotherimage_intermediates := \
2625 $(call intermediates-dir-for,PACKAGING,system_other)
2626BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2627
2628# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2629define build-systemotherimage-target
2630 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2631 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2632 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002633 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002634 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002635 $(BUILD_IMAGE) \
2636 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2637 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2638 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002639endef
2640
2641# We just build this directly to the install location.
2642INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002643ifneq (true,$(SANITIZE_LITE))
2644# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002645$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2646 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002647endif
Alex Light4e358ab2016-06-16 14:47:10 -07002648
2649.PHONY: systemotherimage-nodeps
2650systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2651 $(build-systemotherimage-target)
2652
Dan Willemsen67495202019-01-16 12:42:05 -08002653endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002654
2655
2656# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002657# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002658ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002659INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002660 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002661 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002662
Ying Wang8da19e32015-09-15 14:22:12 -07002663
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002664# Create symlink /vendor/odm to /odm if necessary.
2665ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002666 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002667endif
2668
Yifan Honge51dff22020-06-23 17:26:57 -07002669# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2670# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2671#
2672# On devices with a vendor_dlkm partition,
2673# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2674# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2675# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2676# are hidden.
2677# On devices without a vendor_dlkm partition,
2678# - /vendor/lib/modules stores vendor DLKMs directly.
2679# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2680# See system/core/rootdir/Android.mk for a list of created symlinks.
2681# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2682# are not guaranteed to exist on all devices.
2683ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002684 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/lib/modules,/vendor_dlkm/lib/modules,vendor_dlkm.img)
Yifan Honge51dff22020-06-23 17:26:57 -07002685endif
2686
Colin Crossbd382142020-08-26 15:08:57 -07002687INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2688INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2689$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2690$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2691 @echo Installed file list: $@
2692 @mkdir -p $(dir $@)
2693 @rm -f $@
2694 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2695 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002696
Ying Wanga0febe52013-03-20 11:02:05 -07002697vendorimage_intermediates := \
2698 $(call intermediates-dir-for,PACKAGING,vendor)
2699BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002700define build-vendorimage-target
2701 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2702 @mkdir -p $(TARGET_OUT_VENDOR)
2703 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002704 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002705 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002706 $(BUILD_IMAGE) \
2707 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2708 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002709 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002710endef
2711
2712# We just build this directly to the install location.
2713INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002714$(INSTALLED_VENDORIMAGE_TARGET): \
2715 $(INTERNAL_USERIMAGES_DEPS) \
2716 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002717 $(INSTALLED_FILES_FILE_VENDOR) \
2718 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002719 $(build-vendorimage-target)
2720
Steven Morelanda2e734d2017-03-07 12:10:09 -08002721.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002722vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002723 $(build-vendorimage-target)
2724
Colin Cross91a52272017-06-20 16:57:52 -07002725sync: $(INTERNAL_VENDORIMAGE_FILES)
2726
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002727else ifdef BOARD_PREBUILT_VENDORIMAGE
2728INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2729$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2730endif
Ying Wanga0febe52013-03-20 11:02:05 -07002731
Ying Wang9f8e8db2011-11-04 11:37:01 -07002732# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002733# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002734ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002735INTERNAL_PRODUCTIMAGE_FILES := \
2736 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002737 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002738
2739INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002740INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2741$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002742$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002743 @echo Installed file list: $@
2744 @mkdir -p $(dir $@)
2745 @rm -f $@
2746 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002747 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002748
2749productimage_intermediates := \
2750 $(call intermediates-dir-for,PACKAGING,product)
2751BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2752define build-productimage-target
2753 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2754 @mkdir -p $(TARGET_OUT_PRODUCT)
2755 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002756 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002757 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002758 $(BUILD_IMAGE) \
2759 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2760 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2761 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002762endef
2763
2764# We just build this directly to the install location.
2765INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002766$(INSTALLED_PRODUCTIMAGE_TARGET): \
2767 $(INTERNAL_USERIMAGES_DEPS) \
2768 $(INTERNAL_PRODUCTIMAGE_FILES) \
2769 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002770 $(build-productimage-target)
2771
2772.PHONY: productimage-nodeps pnod
2773productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2774 $(build-productimage-target)
2775
2776sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2777
2778else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2779INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2780$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2781endif
2782
2783# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002784# system_ext partition image
2785ifdef BUILDING_SYSTEM_EXT_IMAGE
2786INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2787 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002788 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002789
Justin Yun6151e3f2019-06-25 15:58:13 +09002790INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2791INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2792$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2793$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002794 @echo Installed file list: $@
2795 @mkdir -p $(dir $@)
2796 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002797 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002798 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002799
Justin Yun6151e3f2019-06-25 15:58:13 +09002800system_extimage_intermediates := \
2801 $(call intermediates-dir-for,PACKAGING,system_ext)
2802BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2803define build-system_extimage-target
2804 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2805 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2806 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2807 $(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 -07002808 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002809 $(BUILD_IMAGE) \
2810 $(TARGET_OUT_SYSTEM_EXT) \
2811 $(system_extimage_intermediates)/system_ext_image_info.txt \
2812 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2813 $(TARGET_OUT)
2814 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002815endef
2816
2817# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002818INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002819$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2820 $(INTERNAL_USERIMAGES_DEPS) \
2821 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2822 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002823 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002824
Justin Yun6151e3f2019-06-25 15:58:13 +09002825.PHONY: systemextimage-nodeps senod
2826systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2827 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002828
Justin Yun6151e3f2019-06-25 15:58:13 +09002829sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002830
Justin Yun6151e3f2019-06-25 15:58:13 +09002831else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2832INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2833$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002834endif
2835
2836# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002837# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002838ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002839INTERNAL_ODMIMAGE_FILES := \
2840 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002841 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002842
Colin Crossbd382142020-08-26 15:08:57 -07002843# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2844# /odm/lib/modules -> /odm_dlkm/lib/modules
2845#
2846# On devices with a odm_dlkm partition,
2847# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2848# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2849# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2850# are hidden.
2851# On devices without a odm_dlkm partition,
2852# - /odm/lib/modules stores odm DLKMs directly.
2853# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2854# See system/core/rootdir/Android.mk for a list of created symlinks.
2855# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2856# are not guaranteed to exist on all devices.
2857ifdef BOARD_USES_ODM_DLKMIMAGE
2858 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
2859endif
2860
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002861INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2862INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2863$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002864$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002865 @echo Installed file list: $@
2866 @mkdir -p $(dir $@)
2867 @rm -f $@
2868 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002869 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002870
2871odmimage_intermediates := \
2872 $(call intermediates-dir-for,PACKAGING,odm)
2873BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2874define build-odmimage-target
2875 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2876 @mkdir -p $(TARGET_OUT_ODM)
2877 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2878 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002879 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002880 $(BUILD_IMAGE) \
2881 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2882 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2883 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002884endef
2885
2886# We just build this directly to the install location.
2887INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002888$(INSTALLED_ODMIMAGE_TARGET): \
2889 $(INTERNAL_USERIMAGES_DEPS) \
2890 $(INTERNAL_ODMIMAGE_FILES) \
2891 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002892 $(build-odmimage-target)
2893
2894.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002895odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002896 $(build-odmimage-target)
2897
2898sync: $(INTERNAL_ODMIMAGE_FILES)
2899
2900else ifdef BOARD_PREBUILT_ODMIMAGE
2901INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2902$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2903endif
2904
2905# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002906# vendor_dlkm partition image
2907ifdef BUILDING_VENDOR_DLKM_IMAGE
2908INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2909 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002910 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002911
2912INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2913INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2914$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2915$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2916 @echo Installed file list: $@
2917 @mkdir -p $(dir $@)
2918 @rm -f $@
2919 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2920 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2921
2922vendor_dlkmimage_intermediates := \
2923 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2924BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2925define build-vendor_dlkmimage-target
2926 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2927 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2928 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2929 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2930 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2931 $(BUILD_IMAGE) \
2932 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2933 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2934 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2935endef
2936
2937# We just build this directly to the install location.
2938INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2939$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2940 $(INTERNAL_USERIMAGES_DEPS) \
2941 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2942 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2943 $(build-vendor_dlkmimage-target)
2944
2945.PHONY: vendor_dlkmimage-nodeps vdnod
2946vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2947 $(build-vendor_dlkmimage-target)
2948
2949sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2950
2951else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2952INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2953$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2954endif
2955
2956# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07002957# odm_dlkm partition image
2958ifdef BUILDING_ODM_DLKM_IMAGE
2959INTERNAL_ODM_DLKMIMAGE_FILES := \
2960 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002961 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002962
2963INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
2964INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
2965$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
2966$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2967 @echo Installed file list: $@
2968 @mkdir -p $(dir $@)
2969 @rm -f $@
2970 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
2971 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2972
2973odm_dlkmimage_intermediates := \
2974 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
2975BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
2976define build-odm_dlkmimage-target
2977 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
2978 @mkdir -p $(TARGET_OUT_ODM_DLKM)
2979 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
2980 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
2981 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2982 $(BUILD_IMAGE) \
2983 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
2984 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
2985 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
2986endef
2987
2988# We just build this directly to the install location.
2989INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
2990$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
2991 $(INTERNAL_USERIMAGES_DEPS) \
2992 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
2993 $(INSTALLED_FILES_FILE_ODM_DLKM)
2994 $(build-odm_dlkmimage-target)
2995
2996.PHONY: odm_dlkmimage-nodeps odnod
2997odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
2998 $(build-odm_dlkmimage-target)
2999
3000sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3001
3002else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3003INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3004$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3005endif
3006
3007
3008# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003009# dtbo image
3010ifdef BOARD_PREBUILT_DTBOIMAGE
3011INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3012
3013ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003014$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003015 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3016 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003017 --image $@ \
3018 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3019 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3020 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003021else
3022$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3023 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3024endif
3025
Tao Bao0da43472018-08-22 22:53:41 -07003026endif # BOARD_PREBUILT_DTBOIMAGE
3027
3028# Returns a list of image targets corresponding to the given list of partitions. For example, it
3029# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3030# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003031# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003032define images-for-partitions
3033$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3034endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003035
3036# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003037# custom images
3038INSTALLED_CUSTOMIMAGES_TARGET :=
3039
3040ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3041INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3042
3043# Sign custom image.
3044# $(1): the prebuilt custom image.
3045# $(2): the mount point of the prebuilt custom image.
3046# $(3): the signed custom image target.
3047define sign_custom_image
3048$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3049 @echo Target custom image: $(3)
3050 mkdir -p $(dir $(3))
3051 cp $(1) $(3)
3052ifeq ($(BOARD_AVB_ENABLE),true)
3053 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3054 $(AVBTOOL) add_hashtree_footer \
3055 --image $(3) \
3056 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3057 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3058 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3059 --partition_name $(2) \
3060 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3061 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3062endif
3063INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3064endef
3065
3066$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3067 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3068 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3069endif
3070
3071# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003072# vbmeta image
3073ifeq ($(BOARD_AVB_ENABLE),true)
3074
3075BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003076AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003077
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003078ifdef BOARD_AVB_KEY_PATH
3079$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3080else
3081# If key path isn't specified, use the 4096-bit test key.
3082BOARD_AVB_ALGORITHM := SHA256_RSA4096
3083BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3084endif
3085
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003086# AVB signing for system_other.img.
3087ifdef BUILDING_SYSTEM_OTHER_IMAGE
3088ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3089$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3090else
3091# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3092BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3093BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3094endif
3095
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003096$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3097 @echo Extracting system_other avb key: $@
3098 @rm -f $@
3099 @mkdir -p $(dir $@)
3100 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003101
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003102ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3103BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3104endif
3105
3106BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3107endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3108
Tao Bao744c4c72018-08-20 21:09:07 -07003109INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003110 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003111 $(BOARD_AVB_VBMETA_VENDOR)
3112
3113# Not allowing the same partition to appear in multiple groups.
3114ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003115 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003116endif
3117
cfig1aeef722019-09-20 22:45:06 +08003118# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3119# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3120# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003121ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003122ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3123$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003124 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003125 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3126endif
3127endif
3128
Bowgo Tsai9b548012019-05-14 16:57:03 +08003129# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003130
3131BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003132 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003133 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003134 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3135
3136BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003137 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003138 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003139 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3140
Justin Yun6151e3f2019-06-25 15:58:13 +09003141BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003142 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003143 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3144 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003145
Bowgo Tsai9b548012019-05-14 16:57:03 +08003146BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003147 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003148 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3149
Tao Bao19b02fe2019-10-09 00:04:28 -07003150BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3151 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3152
3153BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3154 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3155
Bowgo Tsai9b548012019-05-14 16:57:03 +08003156BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003157 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003158 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3159
3160BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003161 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003162 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3163
Yifan Hongcfb917a2020-05-07 14:58:20 -07003164BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3165 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3166 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3167
Yifan Hongf496f1b2020-07-15 16:52:59 -07003168BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3169 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3170 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3171
Tao Bao19b02fe2019-10-09 00:04:28 -07003172BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3173 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3174
Bowgo Tsai9b548012019-05-14 16:57:03 +08003175# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003176ifdef BOOT_SECURITY_PATCH
3177BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3178 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3179endif
3180
3181ifdef VENDOR_SECURITY_PATCH
3182BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3183 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3184endif
3185
3186ifdef ODM_SECURITY_PATCH
3187BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3188 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3189endif
3190
Yifan Hongcfb917a2020-05-07 14:58:20 -07003191ifdef VENDOR_DLKM_SECURITY_PATCH
3192BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3193 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3194endif
3195
Yifan Hongf496f1b2020-07-15 16:52:59 -07003196ifdef ODM_DLKM_SECURITY_PATCH
3197BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3198 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3199endif
3200
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003201BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003202VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003203DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3204SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3205VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003206RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003207PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003208SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003209ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003210VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003211ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003212
Tao Bao0da43472018-08-22 22:53:41 -07003213# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003214# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003215define _check-and-set-avb-chain-args
3216$(eval part := $(1))
3217$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003218
3219$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3220$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3221$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3222$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3223$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3224$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3225$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3226$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3227
3228# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3229$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3230$(eval $(_signing_args) := \
3231 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3232
cfig1aeef722019-09-20 22:45:06 +08003233# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3234# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003235$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003236 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3237 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003238
Tao Bao744c4c72018-08-20 21:09:07 -07003239# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003240# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003241$(if $(filter $(part),$(part:vbmeta_%=%)),\
3242 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3243 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003244endef
3245
Tao Bao0da43472018-08-22 22:53:41 -07003246# Checks and sets the required build variables for an AVB partition. The partition will be
3247# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003248# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3249# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003250# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3251# but vbmeta would capture the image descriptor of only the first boot
3252# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003253# $(1): Partition name, e.g. boot or system.
3254define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003255$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003256$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003257 $(if $(_in_chained_vbmeta),\
3258 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003259 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003260 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003261 $(if $(filter boot,$(1)),\
3262 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3263 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3264 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3265 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003266endef
3267
Hongguang Chenf23364d2020-04-27 18:36:36 -07003268# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3269# $(1): the custom partition to enable AVB chain.
3270define check-and-set-custom-avb-chain-args
3271$(eval part := $(1))
3272$(eval PART=$(call to-upper,$(part)))
3273$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3274$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3275
3276INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3277 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3278endef
3279
Tao Baob1a2e352018-08-14 16:17:12 -07003280ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003281$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003282endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003283
Steve Mucklee1b10862019-07-10 10:49:37 -07003284ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3285$(eval $(call check-and-set-avb-args,vendor_boot))
3286endif
3287
Tao Bao0da43472018-08-22 22:53:41 -07003288$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003289
3290ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003291$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003292endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003293
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003294ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003295$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003296endif
3297
Justin Yun6151e3f2019-06-25 15:58:13 +09003298ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3299$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003300endif
3301
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003302ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003303$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003304endif
3305
Yifan Hongcfb917a2020-05-07 14:58:20 -07003306ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3307$(eval $(call check-and-set-avb-args,vendor_dlkm))
3308endif
3309
Yifan Hongf496f1b2020-07-15 16:52:59 -07003310ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3311$(eval $(call check-and-set-avb-args,odm_dlkm))
3312endif
3313
Yueyao Zhu211c9012017-04-27 00:34:50 -07003314ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003315$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003316endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003317
David Zeuthen8fecb282017-12-01 16:24:01 -05003318ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003319$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003320endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003321
David Anderson7709ab22018-10-15 14:41:34 -07003322# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3323ifdef BOARD_AVB_VBMETA_SYSTEM
3324$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003325endif
3326
3327ifdef BOARD_AVB_VBMETA_VENDOR
3328$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3329endif
3330
Hongguang Chenf23364d2020-04-27 18:36:36 -07003331ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3332$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3333 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3334endif
3335
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003336# Add kernel cmdline descriptor for kernel to mount system.img as root with
3337# dm-verity. This works when system.img is either chained or not-chained:
3338# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3339# cmdline descriptor to system.img
3340# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3341# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003342ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003343ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003344BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003345endif
David Anderson8916a2a2018-09-18 15:46:59 -07003346endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003347
Tao Bao0da43472018-08-22 22:53:41 -07003348BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003349BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003350BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3351
3352ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003353# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003354BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003355endif
Tao Bao0da43472018-08-22 22:53:41 -07003356
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003357ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003358BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003359endif
3360
David Anderson7709ab22018-10-15 14:41:34 -07003361ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3362BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3363 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003364endif
3365
3366ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3367BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3368 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003369endif
3370
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003371# $(1): the directory to extract public keys to
3372define extract-avb-chain-public-keys
3373 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3374 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3375 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003376 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3377 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3378 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003379 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3380 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3381 --output $(1)/system.avbpubkey)
3382 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3383 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3384 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003385 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3386 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3387 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003388 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3389 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3390 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003391 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3392 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3393 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003394 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3395 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3396 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003397 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3398 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3399 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003400 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3401 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3402 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003403 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3404 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3405 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003406 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3407 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3408 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003409 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3410 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3411 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003412 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3413 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3414 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3415 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003416endef
3417
Tao Bao744c4c72018-08-20 21:09:07 -07003418# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3419# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003420# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003421# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3422# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003423# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003424# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003425# $(2): Output filename.
3426define build-chained-vbmeta-image
3427 $(call pretty,"Target chained vbmeta image: $@")
3428 $(hide) $(AVBTOOL) make_vbmeta_image \
3429 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3430 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3431 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3432 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3433 --output $@
3434endef
3435
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003436ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003437ifdef BOARD_AVB_VBMETA_SYSTEM
3438INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3439$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003440 $(AVBTOOL) \
3441 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3442 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003443 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003444endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003445endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003446
3447ifdef BOARD_AVB_VBMETA_VENDOR
3448INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3449$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003450 $(AVBTOOL) \
3451 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3452 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003453 $(call build-chained-vbmeta-image,vbmeta_vendor)
3454endif
3455
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003456define build-vbmetaimage-target
3457 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003458 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3459 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003460 $(hide) $(AVBTOOL) make_vbmeta_image \
3461 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003462 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003463 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3464 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003465 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003466endef
3467
Paul Trautrim4e143232019-08-13 16:30:57 +09003468ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003469INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003470$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3471 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3472
David Zeuthen8fecb282017-12-01 16:24:01 -05003473$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003474 $(AVBTOOL) \
3475 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003476 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003477 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3478 $(INSTALLED_VENDORIMAGE_TARGET) \
3479 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003480 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003481 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003482 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003483 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003484 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003485 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003486 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3487 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3488 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3489 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3490 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3491 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003492 $(build-vbmetaimage-target)
3493
3494.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003495vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3496 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003497vbmetaimage-nodeps:
3498 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003499endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003500
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003501endif # BOARD_AVB_ENABLE
3502
3503# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003504# Check VINTF of build
3505
Yifan Hongf496f1b2020-07-15 16:52:59 -07003506# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003507ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003508
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003509intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3510check_vintf_all_deps :=
3511
Yifan Hongaf9b0702020-01-21 12:46:57 -08003512# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3513# because they are only used for prebuilt images.
3514check_vintf_common_srcs_patterns := \
3515 $(TARGET_OUT)/etc/vintf/% \
3516 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3517 $(TARGET_OUT_ODM)/etc/vintf/% \
3518 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3519 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3520
3521check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3522 $(INTERNAL_SYSTEMIMAGE_FILES) \
3523 $(INTERNAL_VENDORIMAGE_FILES) \
3524 $(INTERNAL_ODMIMAGE_FILES) \
3525 $(INTERNAL_PRODUCTIMAGE_FILES) \
3526 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3527))
3528check_vintf_common_srcs_patterns :=
3529
3530check_vintf_has_system :=
3531check_vintf_has_vendor :=
3532
Yifan Hong28ffd732020-03-13 13:11:10 -07003533ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3534$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3535endif
3536ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3537$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3538endif
3539
Yifan Hong605ea042020-01-14 21:36:00 +00003540# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003541check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3542ifneq ($(check_vintf_system_deps),)
3543check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003544check_vintf_system_log := $(intermediates)/check_vintf_system_log
3545check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003546$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003547 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3548check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003549endif # check_vintf_system_deps
3550check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003551
3552# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003553check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3554ifneq ($(check_vintf_vendor_deps),)
3555check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003556check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3557check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003558# Check vendor SKU=(empty) case when:
3559# - DEVICE_MANIFEST_FILE is not empty; OR
3560# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003561$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003562 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3563 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003564 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003565$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003566 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3567 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3568 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3569 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003570check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003571endif # check_vintf_vendor_deps
3572check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003573
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003574# -- Check VINTF compatibility of build.
3575# Skip partial builds; only check full builds. Only check if:
3576# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003577# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003578# - Building product / system_ext / odm images if board has product / system_ext / odm images
3579ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003580ifeq ($(check_vintf_has_system),true)
3581ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003582ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3583ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3584ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3585
3586check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3587check_vintf_all_deps += $(check_vintf_compatible_log)
3588
3589check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003590check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003591
3592# -- Kernel version and configurations.
3593ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3594
Yifan Hong605ea042020-01-14 21:36:00 +00003595BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3596BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3597
3598my_board_extracted_kernel :=
3599
3600# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3601# from INSTALLED_KERNEL_TARGET.
3602ifdef BOARD_KERNEL_CONFIG_FILE
3603ifdef BOARD_KERNEL_VERSION
3604$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3605 cp $< $@
3606$(BUILT_KERNEL_VERSION_FILE):
3607 echo $(BOARD_KERNEL_VERSION) > $@
3608
3609my_board_extracted_kernel := true
3610endif # BOARD_KERNEL_VERSION
3611endif # BOARD_KERNEL_CONFIG_FILE
3612
3613ifneq ($(my_board_extracted_kernel),true)
3614ifndef INSTALLED_KERNEL_TARGET
3615$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3616 is true. Information about the updated kernel cannot be built into OTA update package. \
3617 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3618 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3619 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3620 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3621 manually.)
3622else
3623
3624# Tools for decompression that is not in PATH.
3625# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3626# Algorithms that are in the script but not in this list will be found in PATH.
3627my_decompress_tools := \
3628 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3629
3630$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3631$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3632$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003633$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3634 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003635 --output-configs $@ \
3636 --output-version $(BUILT_KERNEL_VERSION_FILE)
3637
3638my_decompress_tools :=
3639
3640endif # my_board_extracted_kernel
3641my_board_extracted_kernel :=
3642
3643endif # INSTALLED_KERNEL_TARGET
3644
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003645check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3646check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3647
3648endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3649
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003650check_vintf_compatible_args += \
3651 --dirmap /system:$(TARGET_OUT) \
3652 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3653 --dirmap /odm:$(TARGET_OUT_ODM) \
3654 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3655 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3656
3657ifdef PRODUCT_SHIPPING_API_LEVEL
3658check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3659endif # PRODUCT_SHIPPING_API_LEVEL
3660
3661$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3662$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003663# Check ODM SKU=(empty) case when:
3664# - ODM_MANIFEST_FILES is not empty; OR
3665# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003666$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003667 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3668 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003669 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003670# Check vendor SKU=(empty) case when:
3671# - DEVICE_MANIFEST_FILE is not empty; OR
3672# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003673$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003674 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3675 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003676 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003677$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3678 @echo -n -e 'Deps: \n ' > $@
3679 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3680 @echo -n -e 'Args: \n ' >> $@
3681 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003682 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3683 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003684 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003685 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3686 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3687 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003688
3689check_vintf_compatible_log :=
3690check_vintf_compatible_args :=
3691check_vintf_compatible_deps :=
3692
3693endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3694endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3695endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003696endif # check_vintf_has_vendor
3697endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003698endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3699
3700# Add all logs of VINTF checks to dist builds
3701droid_targets: $(check_vintf_all_deps)
3702$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3703
3704# Helper alias to check all VINTF of current build.
3705.PHONY: check-vintf-all
3706check-vintf-all: $(check_vintf_all_deps)
3707 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3708
Yifan Hongaf9b0702020-01-21 12:46:57 -08003709check_vintf_has_vendor :=
3710check_vintf_has_system :=
3711check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003712check_vintf_all_deps :=
3713intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003714endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003715
3716# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003717# Check image sizes <= size of super partition
3718
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003719ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003720
3721ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003722
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003723# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003724# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003725define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003726 mkdir -p $(dir $(1))
3727 rm -f $(1)
3728 $(call dump-super-image-info, $(1))
3729 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3730 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003731 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003732endef
3733
Yifan Hong30910932019-10-25 20:36:55 -07003734check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3735droid_targets: $(check_all_partition_sizes_log)
3736$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003737
Yifan Hong30910932019-10-25 20:36:55 -07003738$(check_all_partition_sizes_log): \
3739 $(CHECK_PARTITION_SIZES) \
3740 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3741 $(call check-all-partition-sizes-target, \
3742 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3743 $@)
3744
3745.PHONY: check-all-partition-sizes
3746check-all-partition-sizes: $(check_all_partition_sizes_log)
3747
3748.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003749check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003750 $(call check-all-partition-sizes-target, \
3751 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003752
Yifan Hong2dae5722018-07-31 12:47:27 -07003753endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003754
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003755endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003756
3757# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003758# bring in the installer image generation defines if necessary
3759ifeq ($(TARGET_USE_DISKINSTALLER),true)
3760include bootable/diskinstaller/config.mk
3761endif
3762
3763# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003764# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003765
Ying Wangbd2d0242015-09-22 11:17:52 -07003766ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003767 build_ota_package := false
3768 build_otatools_package := false
3769else
Tao Bao9be20c72019-04-08 21:11:59 -07003770 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003771 build_ota_package := true
3772 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3773 build_ota_package := false
3774 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003775 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003776 build_ota_package := false
3777 endif
3778 ifeq ($(TARGET_PRODUCT),sdk)
3779 build_ota_package := false
3780 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003781 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3782 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3783 build_ota_package := false
3784 endif
3785 ifeq ($(TARGET_NO_KERNEL),true)
3786 build_ota_package := false
3787 endif
3788 ifeq ($(recovery_fstab),)
3789 build_ota_package := false
3790 endif
3791 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003792
Tao Bao9be20c72019-04-08 21:11:59 -07003793 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003794 build_otatools_package := true
3795 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3796 build_otatools_package := false
3797 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003798endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003799
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003800ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003801
3802INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003803 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003804 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003805 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003806 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003807 append2simg \
3808 avbtool \
3809 blk_alloc_to_base_fs \
3810 boot_signer \
3811 brillo_update_payload \
3812 brotli \
3813 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003814 build_image \
3815 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003816 build_verity_metadata \
3817 build_verity_tree \
3818 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003819 check_ota_package_signature \
3820 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003821 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003822 checkvintf \
3823 delta_generator \
3824 e2fsck \
3825 e2fsdroid \
3826 fc_sort \
3827 fec \
3828 fs_config \
3829 generate_verity_key \
3830 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003831 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003832 imgdiff \
3833 libconscrypt_openjdk_jni \
3834 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003835 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003836 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003837 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003838 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003839 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003840 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003841 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003842 mkbootfs \
3843 mkbootimg \
3844 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003845 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003846 mkf2fsuserimg.sh \
3847 mksquashfs \
3848 mksquashfsimage.sh \
3849 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003850 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003851 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003852 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003853 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003854 sign_apex \
3855 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003856 signapk \
3857 simg2img \
3858 sload_f2fs \
3859 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003860 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003861 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003862 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003863 verity_signer \
3864 verity_verifier \
3865 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003866
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003867# Additional tools to unpack and repack the apex file.
3868INTERNAL_OTATOOLS_MODULES += \
3869 apexer \
3870 deapexer \
3871 debugfs_static \
3872 merge_zips \
3873 resize2fs \
3874 soong_zip \
3875
Anton Hansson8dab0a62019-03-28 15:45:40 +00003876ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003877INTERNAL_OTATOOLS_MODULES += \
3878 futility \
3879 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003880endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003881
Tao Bao96daeeb2019-05-01 21:17:13 -07003882INTERNAL_OTATOOLS_FILES := \
3883 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003884
Ying Wang06898662010-06-17 17:52:18 -07003885.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003886otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003887
Tao Bao96daeeb2019-05-01 21:17:13 -07003888# For each module, recursively resolve its host shared library dependencies. Then we have a full
3889# list of modules whose installed files need to be packed.
3890INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3891 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3892 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003893
Tao Bao96daeeb2019-05-01 21:17:13 -07003894INTERNAL_OTATOOLS_PACKAGE_FILES := \
3895 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3896
3897INTERNAL_OTATOOLS_PACKAGE_FILES += \
3898 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3899 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003900
3901ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003902INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003903 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003904 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003905endif
3906ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003907INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003908 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3909 -name "atx_metadata.bin"))
3910endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003911ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003912INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003913 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003914endif
3915
Tao Bao96daeeb2019-05-01 21:17:13 -07003916INTERNAL_OTATOOLS_RELEASETOOLS := \
3917 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3918 \( -type f -o -type l \) -print))
3919
3920BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3921$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3922$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3923$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3924$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003925$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003926 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003927 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3928 mkdir -p $(dir $@)
3929 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3930 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003931 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003932 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003933
3934.PHONY: otatools-package
3935otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3936
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003937endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003938
The Android Open Source Project88b60792009-03-03 19:28:42 -08003939# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003940# misc_info.txt
3941
3942INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3943
3944ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3945# default to common dir for device vendor
3946tool_extensions := $(TARGET_DEVICE_DIR)/../common
3947else
3948tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3949endif
3950.KATI_READONLY := tool_extensions
3951
Steve Muckle903a1ca2020-05-07 17:32:10 -07003952# $1: boot image file name
3953define misc_boot_size
3954$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3955endef
3956
Daniel Normane1e48082019-06-27 13:55:23 -07003957$(INSTALLED_MISC_INFO_TARGET):
3958 rm -f $@
3959 $(call pretty,"Target misc_info.txt: $@")
3960 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3961 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3962ifdef BOARD_FLASH_BLOCK_SIZE
3963 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3964endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07003965ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
3966 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
3967 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07003968endif
3969ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3970 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07003971else
3972 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003973endif
J. Avila98cd4cc2020-06-10 20:09:10 +00003974ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
3975 echo "lz4_ramdisks=true" >> $@
3976endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003977ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3978 echo "vendor_boot=true" >> $@
3979 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3980endif
Daniel Normane1e48082019-06-27 13:55:23 -07003981ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3982 $(hide) echo "no_recovery=true" >> $@
3983endif
3984ifdef BOARD_INCLUDE_RECOVERY_DTBO
3985 $(hide) echo "include_recovery_dtbo=true" >> $@
3986endif
3987ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3988 $(hide) echo "include_recovery_acpio=true" >> $@
3989endif
3990ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3991 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3992endif
3993ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3994 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3995 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3996else
3997 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3998endif
3999 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4000 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4001ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4002 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4003endif
4004 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004005 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004006 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4007 $(hide) echo "multistage_support=1" >> $@
4008 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4009ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4010 $(hide) echo "build_generic_ota_package=true" >> $@
4011endif
4012ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4013 # OTA scripts are only interested in fingerprint related properties
4014 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4015endif
4016ifneq (,$(filter address, $(SANITIZE_TARGET)))
4017 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4018 $(hide) echo "userdata_img_with_data=true" >> $@
4019endif
4020ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4021 $(hide) echo "full_recovery_image=true" >> $@
4022endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004023ifdef BOARD_USES_VENDORIMAGE
4024 $(hide) echo "board_uses_vendorimage=true" >> $@
4025endif
Daniel Normane1e48082019-06-27 13:55:23 -07004026ifeq ($(BOARD_AVB_ENABLE),true)
4027 $(hide) echo "avb_enable=true" >> $@
4028 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4029 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4030 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4031 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4032ifdef BOARD_AVB_BOOT_KEY_PATH
4033 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4034 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4035 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4036endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004037 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4038ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4039 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4040 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4041 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4042endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004043 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4044ifdef BOARD_AVB_RECOVERY_KEY_PATH
4045 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4046 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4047 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4048endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004049ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4050 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4051 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4052 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4053 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4054 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4055 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4056 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4057 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4058endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004059ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4060 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4061 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4062 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4063 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4064 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4065endif # BOARD_AVB_VBMETA_SYSTEM
4066ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4067 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4068 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4069 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4070 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4071 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4072endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4073endif # BOARD_AVB_ENABLE
4074ifdef BOARD_BPT_INPUT_FILES
4075 $(hide) echo "board_bpt_enable=true" >> $@
4076 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4077 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4078endif
4079ifdef BOARD_BPT_DISK_SIZE
4080 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4081endif
4082 $(call generate-userimage-prop-dictionary, $@)
4083ifeq ($(AB_OTA_UPDATER),true)
4084 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4085 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4086 $(hide) echo "ab_update=true" >> $@
4087endif
Yifan Hong65afc072020-04-17 10:08:10 -07004088ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4089 $(hide) echo "allow_non_ab=true" >> $@
4090endif
Daniel Normane1e48082019-06-27 13:55:23 -07004091ifdef BOARD_PREBUILT_DTBOIMAGE
4092 $(hide) echo "has_dtbo=true" >> $@
4093ifeq ($(BOARD_AVB_ENABLE),true)
4094 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4095 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4096ifdef BOARD_AVB_DTBO_KEY_PATH
4097 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4098 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4099 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4100endif # BOARD_AVB_DTBO_KEY_PATH
4101endif # BOARD_AVB_ENABLE
4102endif # BOARD_PREBUILT_DTBOIMAGE
4103 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004104 @# VINTF checks
4105ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4106 $(hide) echo "vintf_enforce=true" >> $@
4107endif
4108ifdef ODM_MANIFEST_SKUS
4109 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4110endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004111ifdef ODM_MANIFEST_FILES
4112 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4113endif
4114ifdef DEVICE_MANIFEST_SKUS
4115 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4116endif
4117ifdef DEVICE_MANIFEST_FILE
4118 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4119endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004120ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4121 $(hide) echo "bootloader_in_update_package=true" >> $@
4122endif
Daniel Normane1e48082019-06-27 13:55:23 -07004123
4124.PHONY: misc_info
4125misc_info: $(INSTALLED_MISC_INFO_TARGET)
4126
4127droidcore: $(INSTALLED_MISC_INFO_TARGET)
4128
4129# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004130# A zip of the directories that map to the target filesystem.
4131# This zip can be used to create an OTA package or filesystem image
4132# as a post-build step.
4133#
4134name := $(TARGET_PRODUCT)
4135ifeq ($(TARGET_BUILD_TYPE),debug)
4136 name := $(name)_debug
4137endif
4138name := $(name)-target_files-$(FILE_NAME_TAG)
4139
4140intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4141BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4142$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4143$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004144 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004145
4146# $(1): Directory to copy
4147# $(2): Location to copy it to
4148# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4149define package_files-copy-root
4150 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4151 mkdir -p $(2) && \
4152 $(ACP) -rd $(strip $(1))/* $(2); \
4153 fi
4154endef
4155
Tao Baoa04fca32015-11-30 12:22:24 -08004156built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004157
4158# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004159ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004160built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004161 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004162endif
4163
The Android Open Source Project88b60792009-03-03 19:28:42 -08004164$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4165
Dan Willemsen653bea92017-03-21 15:47:37 -07004166tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004167$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004168
Sen Jiang4438fd92016-03-07 16:51:01 -08004169ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004170updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004171endif
4172
4173# Build OTA tools if non-A/B is allowed
4174ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004175updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004176endif
Yifan Hong65afc072020-04-17 10:08:10 -07004177
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004178$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004179
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004180# If we are using recovery as boot, output recovery files to BOOT/.
4181ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4182$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4183else
4184$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4185endif
4186
Dan Willemsen653bea92017-03-21 15:47:37 -07004187ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004188 ifdef OSRELEASED_DIRECTORY
4189 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4190 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4191 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4192 endif
Tao Baoa835f382019-07-18 15:55:30 -07004193
4194 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4195 # additionally include radio or bootloader partitions).
4196 ifeq ($(AB_OTA_PARTITIONS),)
4197 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4198 endif
4199endif
4200
4201ifneq ($(AB_OTA_PARTITIONS),)
4202 ifneq ($(AB_OTA_UPDATER),true)
4203 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4204 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004205endif
4206
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004207# Run fs_config while creating the target files package
4208# $1: root directory
4209# $2: add prefix
4210define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004211(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 -08004212endef
4213
Yifan Hong60bfcc42019-11-01 11:39:45 -07004214# Filter out vendor from the list for AOSP targets.
4215# $(1): list
4216define filter-out-missing-vendor
4217$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4218endef
4219
4220# Information related to dynamic partitions and virtual A/B. This information
4221# is needed for building the super image (see dump-super-image-info) and
4222# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004223# $(1): file
4224define dump-dynamic-partitions-info
4225 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4226 echo "use_dynamic_partitions=true" >> $(1))
4227 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4228 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004229 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4230 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4231 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004232 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4233 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004234 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4235 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4236 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4237 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4238 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4239 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004240 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004241 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4242 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4243 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4244 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4245 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004246 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 -07004247 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4248 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004249 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4250 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004251 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4252 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004253 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4254 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4255 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4256 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4257 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4258 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4259 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4260 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004261 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4262 echo "virtual_ab=true" >> $(1))
4263 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4264 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004265endef
4266
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004267# By conditionally including the dependency of the target files package on the
4268# full system image deps, we speed up builds that do not build the system
4269# image.
4270ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004271 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4272endif
4273
4274ifdef BUILDING_USERDATA_IMAGE
4275 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4276endif
4277
4278ifdef BUILDING_SYSTEM_OTHER_IMAGE
4279 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4280endif
4281
4282ifdef BUILDING_VENDOR_BOOT_IMAGE
4283 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
4284endif
4285
4286ifdef BUILDING_RECOVERY_IMAGE
4287 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
4288 # BUILD_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
4289 # commands in build-recoveryimage-target, which would touch the files under
4290 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4291 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4292 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4293 else
4294 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4295 endif
4296 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4297endif
4298
4299# Conditionally depend on the image files if the image is being built so the
4300# target-files.zip rule doesn't wait on the image creation rule, or the image
4301# if it is coming from a prebuilt.
4302
4303ifdef BUILDING_VENDOR_IMAGE
4304 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4305else ifdef BOARD_PREBUILT_VENDORIMAGE
4306 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4307endif
4308
4309ifdef BUILDING_PRODUCT_IMAGE
4310 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4311else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4312 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4313endif
4314
4315ifdef BUILDING_SYSTEM_EXT_IMAGE
4316 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4317else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4318 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4319endif
4320
4321ifdef BUILDING_BOOT_IMAGE
4322 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
4323else ifdef BOARD_PREBUILT_BOOTIMAGE
4324 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4325endif
4326
4327ifdef BUILDING_ODM_IMAGE
4328 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4329else ifdef BOARD_PREBUILT_ODMIMAGE
4330 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4331endif
4332
4333ifdef BUILDING_VENDOR_DLKM_IMAGE
4334 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4335else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4336 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4337endif
4338
4339ifdef BUILDING_ODM_DLKM_IMAGE
4340 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4341else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4342 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004343endif
4344
Isaac Chen9e09d472019-07-05 17:30:41 +08004345ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004346 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4347 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004348endif
4349
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004350ifdef BOARD_PREBUILT_BOOTLOADER
4351$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004352droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004353endif
4354
The Android Open Source Project88b60792009-03-03 19:28:42 -08004355# Depending on the various images guarantees that the underlying
4356# directories are up-to-date.
4357$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004358 $(INSTALLED_RADIOIMAGE_TARGET) \
4359 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004360 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004361 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004362 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004363 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4364 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004365 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004366 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4367 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004368 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004369 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004370 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4371 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4372 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004373 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004374 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004375 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004376 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004377 $(LPMAKE) \
4378 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004379 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004380 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004381 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004382 $(SOONG_ZIP) \
4383 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004384 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004385 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004386 $(BUILT_KERNEL_CONFIGS_FILE) \
4387 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004388 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004389 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004390 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004391 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004392ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004393 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004394 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004395 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004396 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004397ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004398ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004399 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Steve Muckle04b6f052020-08-09 14:36:56 -07004400else # BOARD_USES_RECOVERY_AS_BOOT not true
4401 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4402endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004403endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004404ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004405 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004406else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004407ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004408 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004409endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004410ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004411ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004412 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004413else
Steve Mucklee1b10862019-07-10 10:49:37 -07004414 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004415endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004416endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004417ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004418 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004419endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004420ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004421 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004422endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004423ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004424 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004425endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004426ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004427 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004428endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004429ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004430 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004431endif
Colin Crossa6de2ad2020-08-26 18:40:19 -07004432endif # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004433endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004434 @# Components of the boot image
4435 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004436 $(hide) mkdir -p $(zip_root)/ROOT
4437 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004438 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004439 @# If we are using recovery as boot, this is already done when processing recovery.
4440ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004441ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004442 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004443 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004444endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004445ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004446 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004447endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004448ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004449ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004450 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004451endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004452ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004453 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004454endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004455 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
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)/BOOT/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)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004461endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004462else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4463 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4464endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4465endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004466 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4467 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004468 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004469ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4470 mkdir -p $(zip_root)/VENDOR_BOOT
4471 $(call package_files-copy-root, \
4472 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4473ifdef INSTALLED_DTBIMAGE_TARGET
4474 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4475endif
4476ifdef BOARD_KERNEL_BASE
4477 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4478endif
4479ifdef BOARD_KERNEL_PAGESIZE
4480 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4481endif
4482 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4483endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004484ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004485 @# Contents of the system image
4486 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004487 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004488endif
4489ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004490 @# Contents of the data image
4491 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004492 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004493endif
4494ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004495 @# Contents of the vendor image
4496 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004497 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004498endif
Dan Willemsen67495202019-01-16 12:42:05 -08004499ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004500 @# Contents of the product image
4501 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004502 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004503endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004504ifdef BUILDING_SYSTEM_EXT_IMAGE
4505 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004506 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004507 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004508endif
Dan Willemsen67495202019-01-16 12:42:05 -08004509ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004510 @# Contents of the odm image
4511 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004512 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004513endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004514ifdef BUILDING_VENDOR_DLKM_IMAGE
4515 @# Contents of the vendor_dlkm image
4516 $(hide) $(call package_files-copy-root, \
4517 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4518endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004519ifdef BUILDING_ODM_DLKM_IMAGE
4520 @# Contents of the odm_dlkm image
4521 $(hide) $(call package_files-copy-root, \
4522 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4523endif
Dan Willemsen67495202019-01-16 12:42:05 -08004524ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004525 @# Contents of the system_other image
4526 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004527 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004528endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004529 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004530 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004531 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004532ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004533ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004534 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004535 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004536endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004537endif
Doug Zongker8678df42009-06-15 14:30:14 -07004538 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004539 @# build them.
4540 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004541 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004542 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004543ifneq ($(tool_extension),)
4544 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4545endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004546 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004547 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004548 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004549ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4550 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4551 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004552endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004553ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4554 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4555 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004556endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004557ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4558 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4559 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004560endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004561ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4562 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4563 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004564endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004565ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4566 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4567 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004568endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004569ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4570 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4571 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4572endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004573ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4574 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4575 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4576endif
Yifan Hong65afc072020-04-17 10:08:10 -07004577ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004578ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004579 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004580 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004581endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004582endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004583ifeq ($(AB_OTA_UPDATER),true)
4584 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004585 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004586 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004587 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4588 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004589 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4590 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4591 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004592ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004593 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4594 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4595 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004596endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004597endif
Steve Fungdfbab492015-09-24 18:12:33 -07004598ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004599 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004600 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004601endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004602ifdef BOARD_PREBUILT_VENDORIMAGE
4603 $(hide) mkdir -p $(zip_root)/IMAGES
4604 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4605endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004606ifdef BOARD_PREBUILT_PRODUCTIMAGE
4607 $(hide) mkdir -p $(zip_root)/IMAGES
4608 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4609endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004610ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004611 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004612 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004613endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004614ifdef BOARD_PREBUILT_BOOTIMAGE
4615 $(hide) mkdir -p $(zip_root)/IMAGES
4616 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4617endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004618ifdef BOARD_PREBUILT_ODMIMAGE
4619 $(hide) mkdir -p $(zip_root)/IMAGES
4620 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4621endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004622ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004623 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004624 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4625endif
4626ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4627 $(hide) mkdir -p $(zip_root)/IMAGES
4628 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004629endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004630ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004631 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4632 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004633endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004634ifdef BOARD_PREBUILT_BOOTLOADER
4635 $(hide) mkdir -p $(zip_root)/IMAGES
4636 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4637endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004638ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4639 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4640 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4641 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4642endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004643 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4644 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4645 @# INSTALLED_RADIOIMAGE_TARGET.
4646 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4647 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004648 @# Run fs_config on all the system, vendor, boot ramdisk,
4649 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004650ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004651 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004652endif
4653ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004654 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4655endif
Dan Willemsen67495202019-01-16 12:42:05 -08004656ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004657 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4658endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004659ifdef BUILDING_SYSTEM_EXT_IMAGE
4660 $(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 +01004661endif
Dan Willemsen67495202019-01-16 12:42:05 -08004662ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004663 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4664endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004665ifdef BUILDING_VENDOR_DLKM_IMAGE
4666 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4667endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004668ifdef BUILDING_ODM_DLKM_IMAGE
4669 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4670endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004671 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004672 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004673ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004674 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004675 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004676endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004677ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4678 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4679endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004680ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4681 @# 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 -08004682 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4683endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004684ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4685 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4686endif
Dan Willemsen67495202019-01-16 12:42:05 -08004687ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004688 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4689endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004690 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004691ifdef BUILT_KERNEL_CONFIGS_FILE
4692 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4693endif
4694ifdef BUILT_KERNEL_VERSION_FILE
4695 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4696endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004697 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4698ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4699 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4700endif
Tao Baocbd6d492019-10-07 22:46:02 -07004701 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4702 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004703ifeq ($(BUILD_QEMU_IMAGES),true)
4704 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4705 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4706endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004707 @# Zip everything up, preserving symlinks and placing META/ files first to
4708 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004709 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004710 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004711 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004712
Ying Wanga0febe52013-03-20 11:02:05 -07004713.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004714target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4715
Ying Wang4709d7c2014-04-14 17:25:43 -07004716$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07004717
Dan Albert4d323332016-10-14 13:23:06 -07004718# -----------------------------------------------------------------
4719# NDK Sysroot Package
4720NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004721$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004722 @echo Package NDK sysroot...
4723 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4724
4725$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4726
Ying Wang09c4b682015-08-11 11:24:19 -07004727ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004728# -----------------------------------------------------------------
4729# OTA update package
4730
Yifan Hong50e79542018-11-08 17:44:12 -08004731# $(1): output file
4732# $(2): additional args
4733define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004734PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004735 $(OTA_FROM_TARGET_FILES) \
4736 --verbose \
4737 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4738 --path $(HOST_OUT) \
4739 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4740 $(2) \
4741 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004742endef
4743
Doug Zongker8678df42009-06-15 14:30:14 -07004744name := $(TARGET_PRODUCT)
4745ifeq ($(TARGET_BUILD_TYPE),debug)
4746 name := $(name)_debug
4747endif
4748name := $(name)-ota-$(FILE_NAME_TAG)
4749
4750INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004751INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4752
Doug Zongker8678df42009-06-15 14:30:14 -07004753$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004754$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004755$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004756 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004757 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004758
4759.PHONY: otapackage
4760otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4761
Tao Bao519d1822018-12-27 12:47:23 -08004762ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004763name := $(TARGET_PRODUCT)
4764ifeq ($(TARGET_BUILD_TYPE),debug)
4765 name := $(name)_debug
4766endif
4767name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4768
4769INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004770$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004771$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4772 $(BUILT_TARGET_FILES_PACKAGE) \
4773 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004774 @echo "Package OTA (retrofit dynamic partitions): $@"
4775 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4776
4777.PHONY: otardppackage
4778
4779otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4780
Tao Bao519d1822018-12-27 12:47:23 -08004781endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004782
Ying Wang09c4b682015-08-11 11:24:19 -07004783endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004784
Ying Wang09a00a62010-10-20 14:01:09 -07004785# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004786# A zip of the appcompat directory containing logs
4787APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4788# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004789ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004790$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4791 $(INTERNAL_RAMDISK_FILES) \
4792 $(INTERNAL_USERDATAIMAGE_FILES) \
4793 $(INTERNAL_VENDORIMAGE_FILES) \
4794 $(INTERNAL_PRODUCTIMAGE_FILES) \
4795 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01004796endif
4797$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4798$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4799 @echo "appcompat logs: $@"
4800 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4801 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4802 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4803 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4804
Dario Frenid1011272018-07-23 20:20:15 +01004805# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004806# A zip of the symbols directory. Keep the full paths to make it
4807# more obvious where these files came from.
4808#
4809name := $(TARGET_PRODUCT)
4810ifeq ($(TARGET_BUILD_TYPE),debug)
4811 name := $(name)_debug
4812endif
4813name := $(name)-symbols-$(FILE_NAME_TAG)
4814
4815SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004816# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004817ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004818$(SYMBOLS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4819 $(INTERNAL_RAMDISK_FILES) \
4820 $(INTERNAL_USERDATAIMAGE_FILES) \
4821 $(INTERNAL_VENDORIMAGE_FILES) \
4822 $(INTERNAL_PRODUCTIMAGE_FILES) \
4823 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4824 $(INTERNAL_ODMIMAGE_FILES) \
4825 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4826 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Anton Hansson6d814982018-11-26 18:12:05 +00004827 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004828endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004829$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4830$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004831 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004832 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4833 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004834 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004835 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004836# -----------------------------------------------------------------
4837# A zip of the coverage directory.
4838#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004839name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004840ifeq ($(TARGET_BUILD_TYPE),debug)
4841name := $(name)_debug
4842endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004843COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004844ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004845$(COVERAGE_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4846 $(INTERNAL_RAMDISK_FILES) \
4847 $(INTERNAL_USERDATAIMAGE_FILES) \
4848 $(INTERNAL_VENDORIMAGE_FILES) \
4849 $(INTERNAL_PRODUCTIMAGE_FILES) \
4850 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4851 $(INTERNAL_ODMIMAGE_FILES) \
4852 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4853 $(INTERNAL_ODM_DLKMIMAGE_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004854endif
4855$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4856$(COVERAGE_ZIP): $(SOONG_ZIP)
4857 @echo "Package coverage: $@"
4858 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4859 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4860 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4861 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004862
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004863#------------------------------------------------------------------
4864# Export the LLVM profile data tool and dependencies for Clang coverage processing
4865#
4866ifeq (true,$(CLANG_COVERAGE))
4867 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4868 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4869 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4870 $(PROFDATA_ZIP): $(SOONG_ZIP)
4871 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4872
4873 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4874endif
4875
The Android Open Source Project88b60792009-03-03 19:28:42 -08004876# -----------------------------------------------------------------
4877# A zip of the Android Apps. Not keeping full path so that we don't
4878# include product names when distributing
4879#
4880name := $(TARGET_PRODUCT)
4881ifeq ($(TARGET_BUILD_TYPE),debug)
4882 name := $(name)_debug
4883endif
4884name := $(name)-apps-$(FILE_NAME_TAG)
4885
4886APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07004887$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004888 @echo "Package apps: $@"
4889 $(hide) rm -rf $@
4890 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004891 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4892 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004893 echo "No apps to zip up. Generating empty apps archive." ; \
4894 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004895 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004896 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004897 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004898
Ying Wangbc415dd2012-08-15 12:22:44 -07004899ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004900#------------------------------------------------------------------
4901# An archive of classes for use in generating code-coverage reports
4902# These are the uninstrumented versions of any classes that were
4903# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004904# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004905
Colin Crossa6bc3a82017-09-27 14:28:41 -07004906JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004907$(JACOCO_REPORT_CLASSES_ALL) :
4908 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004909 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4910 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004911
Ying Wangbc415dd2012-08-15 12:22:44 -07004912endif # EMMA_INSTRUMENT=true
4913
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004914
Ying Wangae9115a2013-08-22 20:52:47 -07004915#------------------------------------------------------------------
4916# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004917#
Ying Wangc62c92c2013-08-28 18:38:25 -07004918PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004919# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004920ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004921$(PROGUARD_DICT_ZIP): \
Colin Crosscda30c72020-08-26 18:43:21 -07004922 $(FULL_SYSTEMIMAGE_DEPS) \
4923 $(INTERNAL_RAMDISK_FILES) \
4924 $(INTERNAL_USERDATAIMAGE_FILES) \
4925 $(INTERNAL_VENDORIMAGE_FILES) \
4926 $(INTERNAL_PRODUCTIMAGE_FILES) \
4927 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4928 $(INTERNAL_ODMIMAGE_FILES) \
4929 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4930 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Colin Cross114e8df2019-09-05 17:19:35 -07004931 $(updater_dep)
4932endif
4933$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4934$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004935 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004936 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4937 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4938 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4939 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004940
Colin Crossa9b9e6e2020-08-14 17:43:35 -07004941#------------------------------------------------------------------
4942# A zip of Proguard usage files.
4943#
4944PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
4945# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4946ifeq (,$(TARGET_BUILD_UNBUNDLED))
4947$(PROGUARD_USAGE_ZIP): \
4948 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4949 $(INSTALLED_RAMDISK_TARGET) \
4950 $(INSTALLED_BOOTIMAGE_TARGET) \
4951 $(INSTALLED_USERDATAIMAGE_TARGET) \
4952 $(INSTALLED_VENDORIMAGE_TARGET) \
4953 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4954 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4955 $(INSTALLED_ODMIMAGE_TARGET) \
4956 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4957 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
4958 $(updater_dep)
4959endif
4960$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
4961$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
4962 @echo "Packaging Proguard usage files."
4963 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4964 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
4965 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07004966
4967ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4968
4969# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4970# $(1): output file
4971define dump-super-image-info
4972 $(call dump-dynamic-partitions-info,$(1))
4973 $(if $(filter true,$(AB_OTA_UPDATER)), \
4974 echo "ab_update=true" >> $(1))
4975endef
4976
4977endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4978
The Android Open Source Project88b60792009-03-03 19:28:42 -08004979# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004980# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004981
4982ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4983
4984# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4985ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4986
4987ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004988
4989# For real devices and for dist builds, build super image from target files to an intermediate directory.
4990INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4991$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4992$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4993 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004994 PATH=$(dir $(LPMAKE)):$$PATH \
4995 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004996
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004997# Skip packing it in dist package because it is in update package.
4998ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004999$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005000endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005001
5002.PHONY: superimage_dist
5003superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005004
5005endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005006endif # BOARD_SUPER_PARTITION_SIZE != ""
5007endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005008
Yifan Hongacd862a2019-04-16 15:44:30 -07005009# -----------------------------------------------------------------
5010# super partition image for development
5011
5012ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5013ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5014ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5015
5016# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5017# $(1): built image path
5018# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5019define build-superimage-target
5020 mkdir -p $(dir $(2))
5021 rm -rf $(2)
5022 $(call dump-super-image-info,$(2))
5023 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5024 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005025 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5026 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005027 mkdir -p $(dir $(1))
5028 PATH=$(dir $(LPMAKE)):$$PATH \
5029 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5030endef
5031
5032INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5033INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5034 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5035
changho.shina8f9f112019-10-15 13:26:19 +09005036ifdef BUILDING_SYSTEM_OTHER_IMAGE
5037ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5038INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5039endif
5040endif
5041
Yifan Hongacd862a2019-04-16 15:44:30 -07005042# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5043# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5044# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5045# virtual devices.
5046ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5047$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5048 $(call pretty,"Target super fs image for debug: $@")
5049 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005050 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005051
5052droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5053
5054# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5055.PHONY: superimage
5056superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005057
5058$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005059endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5060
5061# Build $(PRODUCT_OUT)/super.img without dependencies.
5062.PHONY: superimage-nodeps supernod
5063superimage-nodeps supernod: intermediates :=
5064superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5065 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5066 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5067 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5068
5069endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5070endif # BOARD_SUPER_PARTITION_SIZE != ""
5071endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5072
5073# -----------------------------------------------------------------
5074# super empty image
5075
Tao Bao48a2feb2019-06-28 11:00:05 -07005076ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005077ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005078
Yifan Hong8b79d162018-11-29 12:32:00 -08005079INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5080$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5081$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5082 $(call pretty,"Target empty super fs image: $@")
5083 mkdir -p $(intermediates)
5084 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005085 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005086 PATH=$(dir $(LPMAKE)):$$PATH \
5087 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005088
5089$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5090
Yifan Hong2b891ac2018-11-29 12:06:31 -08005091endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005092endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005093
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005094
5095# -----------------------------------------------------------------
5096# The update package
5097
5098name := $(TARGET_PRODUCT)
5099ifeq ($(TARGET_BUILD_TYPE),debug)
5100 name := $(name)_debug
5101endif
5102name := $(name)-img-$(FILE_NAME_TAG)
5103
5104INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5105
Tao Bao57f8ed62019-08-14 23:08:18 -07005106$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5107 $(call pretty,"Package: $@")
5108 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5109 $(IMG_FROM_TARGET_FILES) \
5110 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5111 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005112
5113.PHONY: updatepackage
5114updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005115$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005116
5117
Yifan Hong2b891ac2018-11-29 12:06:31 -08005118# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005119# dalvik something
5120.PHONY: dalvikfiles
5121dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5122
Bo Huf0d50bb2017-08-01 19:02:09 +00005123ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005124MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005125MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005126SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005127
5128ifdef INSTALLED_SYSTEMIMAGE_TARGET
5129INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005130INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5131$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5132 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5133 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005134$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005135 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5136 @echo Create system-qemu.img now
5137 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005138 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005139
5140systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5141droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005142endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005143ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005144INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005145$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005146 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005147 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005148
5149vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5150droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5151endif
bohu8fd437c2020-03-30 20:16:13 -07005152
5153ifdef INSTALLED_RAMDISK_TARGET
5154ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5155ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5156INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5157$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5158 @echo Create ramdisk-qemu.img
5159 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5160
5161droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5162endif
5163endif
5164endif
5165
Anton Hansson32c76fe2018-12-13 14:34:18 +00005166ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005167INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005168$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005169 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005170 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005171
5172productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5173droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5174endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005175ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5176INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5177$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5178 @echo Create system_ext-qemu.img
5179 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005180
Justin Yun6151e3f2019-06-25 15:58:13 +09005181systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5182droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005183endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005184ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005185INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5186$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5187 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005188 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005189
5190odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5191droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5192endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005193
Yifan Hongcfb917a2020-05-07 14:58:20 -07005194ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5195INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5196$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5197 @echo Create vendor_dlkm-qemu.img
5198 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5199
5200vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5201droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5202endif
5203
Yifan Hongf496f1b2020-07-15 16:52:59 -07005204ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5205INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5206$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5207 @echo Create odm_dlkm-qemu.img
5208 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5209
5210odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5211droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5212endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005213
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005214QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005215$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5216 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005217 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005218 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5219 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005220
5221systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5222droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005223
Bo Huf0d50bb2017-08-01 19:02:09 +00005224endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005225# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005226# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005227ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005228INTERNAL_EMULATOR_PACKAGE_FILES += \
5229 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005230 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005231 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005232 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5233 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005234
5235name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5236
5237INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5238
Ying Wang5d887702015-11-04 10:06:25 -08005239$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005240 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005241 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005242
Ying Wang7d8c5352012-07-26 10:15:21 -07005243endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005244
The Android Open Source Project88b60792009-03-03 19:28:42 -08005245
5246# -----------------------------------------------------------------
5247# The SDK
5248
The Android Open Source Project88b60792009-03-03 19:28:42 -08005249# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005250sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005251
5252# Build a name that looks like:
5253#
5254# linux-x86 --> android-sdk_12345_linux-x86
5255# darwin-x86 --> android-sdk_12345_mac-x86
5256# windows-x86 --> android-sdk_12345_windows
5257#
5258sdk_name := android-sdk_$(FILE_NAME_TAG)
5259ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005260 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005261else
Joe Onorato03fbe402009-04-13 08:31:16 -07005262 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005263endif
5264ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005265 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005266endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005267sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005268
5269sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5270
5271ATREE_FILES :=
5272-include $(sdk_dep_file)
5273
5274# if we don't have a real list, then use "everything"
5275ifeq ($(strip $(ATREE_FILES)),)
5276ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005277 $(ALL_DEFAULT_INSTALLED_MODULES) \
5278 $(INSTALLED_RAMDISK_TARGET) \
5279 $(ALL_DOCS) \
5280 $(ALL_SDK_FILES)
5281endif
5282
5283atree_dir := development/build
5284
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005285
The Android Open Source Project88b60792009-03-03 19:28:42 -08005286sdk_atree_files := \
5287 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005288 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005289
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005290# development/build/sdk-android-<abi>.atree is used to differentiate
5291# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5292# files like the kernel image. We use TARGET_CPU_ABI because we don't
5293# have a better way to distinguish between CPU models.
5294ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5295 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5296endif
5297
Anton Hansson8dab0a62019-03-28 15:45:40 +00005298ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5299sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005300else
5301sdk_atree_files += $(atree_dir)/sdk.atree
5302endif
5303
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005304include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005305
The Android Open Source Project88b60792009-03-03 19:28:42 -08005306deps := \
5307 $(target_notice_file_txt) \
5308 $(tools_notice_file_txt) \
5309 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005310 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005311 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005312 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005313 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005314 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005315 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005316 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005317 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005318 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005319 $(INSTALLED_USERDATAIMAGE_TARGET) \
5320 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005321 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005322 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005323 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005324 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005325 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005326 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005327 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005328
5329INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5330$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5331$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5332$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5333$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5334
5335# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5336#
5337#SDK_GNU_ERROR := true
5338
Ying Wang5d887702015-11-04 10:06:25 -08005339$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005340 @echo "Package SDK: $@"
5341 $(hide) rm -rf $(PRIVATE_DIR) $@
5342 $(hide) for f in $(target_gnu_MODULES); do \
5343 if [ -f $$f ]; then \
5344 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5345 including GNU target $$f >&2; \
5346 FAIL=$(SDK_GNU_ERROR); \
5347 fi; \
5348 done; \
5349 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005350 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005351 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005352 ATREE_STRIP="$(HOST_STRIP) -x" \
5353 $(HOST_OUT_EXECUTABLES)/atree \
5354 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5355 -m $(PRIVATE_DEP_FILE) \
5356 -I . \
5357 -I $(PRODUCT_OUT) \
5358 -I $(HOST_OUT) \
5359 -I $(TARGET_COMMON_OUT_ROOT) \
5360 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5361 -v "OUT_DIR=$(OUT_DIR)" \
5362 -v "HOST_OUT=$(HOST_OUT)" \
5363 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5364 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5365 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5366 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5367 -o $(PRIVATE_DIR) && \
5368 cp -f $(target_notice_file_txt) \
5369 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5370 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5371 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5372 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5373 chmod -R ug+rwX $(PRIVATE_DIR) && \
5374 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005375 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5376
Raphael3d224a02010-04-16 17:50:09 -07005377
5378# Is a Windows SDK requested? If so, we need some definitions from here
5379# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005380MAIN_SDK_NAME := $(sdk_name)
5381MAIN_SDK_DIR := $(sdk_dir)
5382MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005383ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005384include $(TOPDIR)development/build/tools/windows_sdk.mk
5385endif
5386
The Android Open Source Project88b60792009-03-03 19:28:42 -08005387# -----------------------------------------------------------------
5388# Findbugs
5389INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5390INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5391$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5392 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005393 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005394 > $@
5395$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5396 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005397 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005398 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005399
5400# -----------------------------------------------------------------
5401# Findbugs
5402
5403# -----------------------------------------------------------------
5404# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005405ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005406include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005407-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005408-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005409-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005410# Also the project-specific tasks
5411-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5412-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005413-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005414# Also add test specifc tasks
5415include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005416include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005417endif
Raphaelc4d47312011-02-15 16:09:36 -08005418
Ying Wang67132ba2015-10-28 16:42:39 -07005419include $(BUILD_SYSTEM)/product-graph.mk
5420
Raphaelc4d47312011-02-15 16:09:36 -08005421# -----------------------------------------------------------------
5422# Create SDK repository packages. Must be done after tasks/* since
5423# we need the addon rules defined.
5424ifneq ($(sdk_repo_goal),)
5425include $(TOPDIR)development/build/tools/sdk_repo.mk
5426endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005427
5428# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005429# Soong generates the list of all shared libraries that are depended on by fuzz
5430# targets. It saves this list as a source:destination pair to
5431# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5432# build of the unstripped shared library, and the destination is the
5433# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5434# where fuzz target shared libraries are to be "reinstalled". The
5435# copy-many-files below generates the rules to copy the unstripped shared
5436# libraries to the device or host "reinstallation" directory. These rules are
5437# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5438# a dependency on each shared library that it needs to be "reinstalled".
5439FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5440
5441# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005442# The rule to build all fuzz targets, and package them.
5443# Note: The packages are created in Soong, and in a perfect world,
5444# we'd be able to create the phony rule there. But, if we want to
5445# have dist goals for the fuzz target, we need to have the PHONY
5446# target defined in make. MakeVarsContext.DistForGoal doesn't take
5447# into account that a PHONY rule create by Soong won't be available
5448# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005449# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005450# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005451.PHONY: haiku
5452haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5453$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005454
5455# -----------------------------------------------------------------
5456# The makefile for haiku line coverage.
5457include $(BUILD_SYSTEM)/line_coverage.mk