blob: dd4190aec5d331bbe734481d85588c318814aa17 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
The Android Open Source Project88b60792009-03-03 19:28:42 -08007# -----------------------------------------------------------------
8# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -07009# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080010# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
11# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080012# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070013# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070014#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070015#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070016define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070017$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
18 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080019 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
20$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
21 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
22 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
23 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
24 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
25 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
26 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
27 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
28 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
29 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
30 use vintf_compatibility_matrix / vintf_fragments instead!)) \
31 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
32 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
33 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
34 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
35 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
36 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
37 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
38 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
39 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
40)
Ying Wang68864102011-09-29 13:23:25 -070041endef
Yo Chiang0b49c032020-03-17 17:49:49 +080042
Yo Chiang0b49c032020-03-17 17:49:49 +080043check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080044ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
45check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080046endif
47check_elf_prebuilt_product_copy_files_hint := \
48 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
49
Ying Wang619fccf2012-09-05 18:08:29 -070050# filter out the duplicate <source file>:<dest file> pairs.
51unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080052$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070053 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
54 $(eval unique_product_copy_files_pairs += $(cf))))
55unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080056product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070057$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070058 $(eval _src := $(call word-colon,1,$(cf))) \
59 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070060 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080061 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080062 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070063 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070064 $(if $(filter %.xml,$(_dest)),\
65 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010066 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
67 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070068 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
69 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080070 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
71 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
72 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
73 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070074 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080075
76# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070077pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
78$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
79$(pcf_ignored_file):
80 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080081
Dan Willemsen7537fd02018-10-16 23:15:08 -070082$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
83
84pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080085product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070086unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070087unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080088
89# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080090# Returns the max allowed size for an image suitable for hash verification
91# (e.g., boot.img, recovery.img, etc).
92# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
93# $(1): partition size to flash the image
94define get-hash-image-max-size
95$(if $(1), \
96 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
97 $(eval _hash_meta_size := 69632), \
98 $(eval _hash_meta_size := 0)) \
99 $(1)-$(_hash_meta_size))
100endef
101
102# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800103# Define rules to copy headers defined in copy_headers.mk
104# If more than one makefile declared a header, print a warning,
105# then copy the last one defined. This matches the previous make
106# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700107has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800108$(foreach dest,$(ALL_COPIED_HEADERS), \
109 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800110 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800111 $(if $(call streq,$(_src),$(_srcs)),, \
112 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800113 $(warning _ Using $(_src)) \
114 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
115 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
116 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
117 $(warning _ Ignoring $(src)) \
118 $(warning __ from $(firstword $(_makefiles))) \
119 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
120 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800121 $(eval $(call copy-one-header,$(_src),$(dest))))
122all_copied_headers: $(ALL_COPIED_HEADERS)
123
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700124ifdef has_dup_copy_headers
125 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700126 $(error duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers)
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700127endif
128
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800129$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
130
Dan Willemsen6f60f022016-02-23 13:40:07 -0800131# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100133ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134gen := $(OUT_DOCS)/index.html
135ALL_DOCS += $(gen)
136$(gen): frameworks/base/docs/docs-redirect-index.html
137 @mkdir -p $(dir $@)
138 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700139endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
Dan Albert303e6032017-10-04 10:20:20 -0700141ndk_doxygen_out := $(OUT_NDK_DOCS)
142ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
143ndk_docs_src_dir := frameworks/native/docs
144ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
145ifneq ($(wildcard $(ndk_docs_src_dir)),)
146ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
147 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
148$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
149 @mkdir -p $(ndk_doxygen_out)
150 @echo "Generating NDK docs to $(ndk_doxygen_out)"
151 @( cat $(ndk_doxyfile); \
152 echo "INPUT=$(ndk_headers)"; \
153 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
154 ) | doxygen -
155
156# Note: Not a part of the docs target because we don't have doxygen available.
157# You can run this target locally if you have doxygen installed.
158ndk-docs: $(ndk_doxygen_out)/index.html
159.PHONY: ndk-docs
160endif
161
Colin Crossd60401a2019-04-18 14:46:48 -0700162$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800163
Andres Moralesb8876e12015-05-06 20:44:22 -0700164INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700165ifdef BUILDING_RECOVERY_IMAGE
166ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
167INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
168endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700169endif
170
Jiyong Parke1346862020-05-18 14:31:30 +0900171include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100172
173# ----------------------------------------------------------------
174
175# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800176# sdk-build.prop
177#
178# There are certain things in build.prop that we don't want to
179# ship with the sdk; remove them.
180
181# This must be a list of entire property keys followed by
182# "=" characters, without any internal spaces.
183sdk_build_prop_remove := \
184 ro.build.user= \
185 ro.build.host= \
186 ro.product.brand= \
187 ro.product.manufacturer= \
188 ro.product.device=
189# TODO: Remove this soon-to-be obsolete property
190sdk_build_prop_remove += ro.build.product=
191INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
192$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
193 @echo SDK buildinfo: $@
194 @mkdir -p $(dir $@)
195 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000196 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000198 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800199 $(hide) mv $@.tmp $@
200
201# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700202# kernel modules
203
204# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
205DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
206
J. Avilaa2ceec62020-05-12 23:40:02 +0000207define copy-and-strip-kernel-module
208$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000209 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000210endef
211
Colin Cross4f60e362019-06-05 11:53:43 -0700212# $(1): modules list
213# $(2): output dir
214# $(3): mount point
215# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700216# $(5): module load list
217# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800218# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000219# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700220# $(9): module directory name
Colin Cross4f60e362019-06-05 11:53:43 -0700221# Returns the a list of src:dest pairs to install the modules using copy-many-files.
222define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700223 $(if $(9), \
224 $(eval _dir := $(9)/), \
225 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000226 $(foreach module,$(1), \
227 $(eval _src := $(module)) \
228 $(if $(8), \
229 $(eval _src := $(8)/$(notdir $(module))) \
230 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700231 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700232 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700233 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
234 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
235 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
236 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700237endef
238
239# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700240# $(2): mount point
241# $(3): staging dir
242# $(4): module load list
243# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800244# $(6): module archive
245# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700246# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800247# TODO(b/144844424): If a module archive is being used, this step (which
248# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
249# the output directory. This should be moved to a module with a
250# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
251# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700252define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700253$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle474e4d02019-06-19 12:56:48 -0700254$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
255$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
256$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700257$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700258$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
259$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
260$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800261$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
262$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
263$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700264 @echo depmod $$(PRIVATE_STAGING_DIR)
265 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700266 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800267 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700268 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800269 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700270 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800271 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
272 )
273 $(if $(1),\
274 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
275 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
276 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
277 done; \
278 )
Colin Cross4f60e362019-06-05 11:53:43 -0700279 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
280 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700281 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
282 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700283endef
284
Steve Muckle474e4d02019-06-19 12:56:48 -0700285# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700286# $(2): modules list
287# $(3): module load list
288# $(4): module load list filename
289# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700290define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700291 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
292 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700293endef
294
295# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700296# $(2): modules list
297# $(3): module load list
298# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700299define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700300$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
301$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
302 @echo load-list $$(@)
303 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700304endef
305
Steve Muckle2335d762020-05-28 18:39:38 -0700306# $(1): image name
307# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
308# $(3): mount point
309# $(4): module load filename
310# $(5): stripped staging directory
311# $(6): kernel module directory name (top is an out of band value for no directory)
312define build-image-kernel-modules-dir
313$(if $(filter top,$(6)),\
314 $(eval _kver :=)$(eval _sep :=),\
315 $(eval _kver := $(6))$(eval _sep :=_))\
316$(if $(5),\
317 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
318 $(eval _stripped_staging_dir :=))\
319$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
320 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
321 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
322 $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver))))
323endef
324
325# $(1): kernel module directory name (top is an out of band value for no directory)
326define build-recovery-as-boot-load
327$(if $(filter top,$(1)),\
328 $(eval _kver :=)$(eval _sep :=),\
329 $(eval _kver := $(1))$(eval _sep :=_))\
330 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
331 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_module_list$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load,$(TARGET_RECOVERY_ROOT_OUT))))
332endef
333
334# $(1): kernel module directory name (top is an out of band value for no directory)
335define build-vendor-ramdisk-recovery-load
336$(if $(filter top,$(1)),\
337 $(eval _kver :=)$(eval _sep :=),\
338 $(eval _kver := $(1))$(eval _sep :=_))\
339 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
340 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_RAMDISK_OUT))))
341endef
342
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700343# $(1): kernel module directory name (top is an out of band value for no directory)
344define build-vendor-charger-load
345$(if $(filter top,$(1)),\
346 $(eval _kver :=)$(eval _sep :=),\
347 $(eval _kver := $(1))$(eval _sep :=_))\
348 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
349 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_OUT_VENDOR))))
350endef
351
Steve Mucklee1b10862019-07-10 10:49:37 -0700352ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
353 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
354 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700355 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700356 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
357endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700358
Steve Muckle69280d22019-07-11 12:23:38 -0700359ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
360 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700361endif
362
Steve Mucklee1b10862019-07-10 10:49:37 -0700363ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700364 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700365 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700366 endif
367endif
368
J. Avilaa2ceec62020-05-12 23:40:02 +0000369ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
370 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
371else
372 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
373endif
Colin Cross4f60e362019-06-05 11:53:43 -0700374
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700375ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
376 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
377else
378 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
379endif
380
Steve Muckle2335d762020-05-28 18:39:38 -0700381BOARD_KERNEL_MODULE_DIRS += top
382$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
383 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700384 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(TARGET_VENDOR_RAMDISK_OUT),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700385 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
Yifan Honge51dff22020-06-23 17:26:57 -0700386 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700387 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Yifan Hong3d5e2c22020-07-15 17:01:14 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700389 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
390 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
391 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700392
393# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700395# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900396# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700397# $2 certificate
398# $3 private key
399# $4 compressed
400# $5 partition tag
401# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100402define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700403$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
404$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
405$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
406$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700407
408endef
409
Jaewoong Jung704b4542020-06-29 19:37:53 -0700410# -----------------------------------------------------------------
411# Merge an individual apkcerts output into the final apkcerts.txt output.
412# Use a macro to make it compatible with _apkcerts_write_line
413# $1 apkcerts file to be merged
414# $2 output file
415define _apkcerts_merge
416$(hide) cat $1 >> $2
417
418endef
419
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420name := $(TARGET_PRODUCT)
421ifeq ($(TARGET_BUILD_TYPE),debug)
422 name := $(name)_debug
423endif
424name := $(name)-apkcerts-$(FILE_NAME_TAG)
425intermediates := \
426 $(call intermediates-dir-for,PACKAGING,apkcerts)
427APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700428all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
429$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800430# We don't need to really build all the modules.
431# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700432$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433 @echo APK certs list: $@
434 @mkdir -p $(dir $@)
435 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700436 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700437 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
438 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
439 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
440 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
441 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Ying Wangd9a88d52012-10-26 09:21:28 -0700442 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700443 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444
445.PHONY: apkcerts-list
446apkcerts-list: $(APKCERTS_FILE)
447
Ying Wang15e487a2011-02-15 10:56:18 -0800448ifneq (,$(TARGET_BUILD_APPS))
449 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900450 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800451endif
Ying Wangefb21682010-07-23 16:42:13 -0700452
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900453
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700455# build system stats
456BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
457$(BUILD_SYSTEM_STATS):
458 @rm -f $@
459 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
460 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
461$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700462
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800464# build /product/etc/security/avb/system_other.avbpubkey if needed
465ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800466ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800467INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
468ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800469endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800470endif # BUILDING_SYSTEM_OTHER_IMAGE
471
472# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700473# Modules ready to be converted to Soong, ordered by how many
474# modules depend on them.
475SOONG_CONV := $(sort $(SOONG_CONV))
476SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
477$(SOONG_CONV_DATA):
478 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700479 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS))),$(sort $(SOONG_CONV.$(s).MAKEFILES)),$(sort $(SOONG_CONV.$(s).INSTALLED))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700480
Colin Crossfdea8932017-12-06 14:38:40 -0800481SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700482SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
483$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
484 @rm -f $@
485 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
486$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
487
Joe Onorato02fb89a2020-06-27 00:10:23 -0700488MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
489MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
490$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
491$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
492 @rm -f $@
493 $(hide) $(MK2BP_CATALOG_SCRIPT) \
494 --device=$(TARGET_DEVICE) \
495 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
496 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
497 --out_dir="$(OUT_DIR)" \
498 > $@
499$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
500
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700501# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800502# Modules use -Wno-error, or added default -Wall -Werror
503WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
504$(WALL_WERROR):
505 @rm -f $@
506 echo "# Modules using -Wno-error" >> $@
507 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800508 echo "# Modules added default -Wall" >> $@
509 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
510
511$(call dist-for-goals,droidcore,$(WALL_WERROR))
512
513# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700514# C/C++ flag information for modules
515$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
516
517# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800518# Modules missing profile files
519PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
520$(PGO_PROFILE_MISSING):
521 @rm -f $@
522 echo "# Modules missing PGO profile files" >> $@
523 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
524
525$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
526
527# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700528# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700529# for future OTA packages installed by this system. Actual product
530# deliverables will be re-signed by hand. We expect this file to
531# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700532DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700533
534
Jeff Browne33ba4c2011-07-11 22:11:46 -0700535# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800536# if they don't do anything.
537.PHONY: systemimage
538systemimage:
539
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800540# -----------------------------------------------------------------
541
542.PHONY: event-log-tags
543
Joe Onoratob7510532010-07-14 10:22:54 -0700544# Produce an event logs tag file for everything we know about, in order
545# to properly allocate numbers. Then produce a file that's filtered
546# for what's going to be installed.
547
548all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
549
Colin Crossdc8f8e42012-04-12 13:25:54 -0700550event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
551
Joe Onoratob7510532010-07-14 10:22:54 -0700552# Include tags from all packages that we know about
553all_event_log_tags_src := \
554 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
555
Dan Willemsena3f66322020-05-28 15:46:33 -0700556$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
557$(all_event_log_tags_file): $(all_event_log_tags_src) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700558 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900559 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700560
Doug Zongkera34fa952011-02-23 12:17:29 -0800561# Include tags from all packages included in this product, plus all
562# tags that are part of the system (ie, not in a vendor/ or device/
563# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800564event_log_tags_src := \
565 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800566 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800568 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
569 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800570
Dan Willemsena3f66322020-05-28 15:46:33 -0700571$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700572$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700573$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800574 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900575 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800576
577event-log-tags: $(event_log_tags_file)
578
579ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
580
Joe Onoratob7510532010-07-14 10:22:54 -0700581
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582# #################################################################
583# Targets for boot/OS images
584# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800585ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
586 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000587 ifdef BOARD_PREBUILT_BOOTLOADER
588 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
589 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
590 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800591 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
592 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
593 else
594 INSTALLED_2NDBOOTLOADER_TARGET :=
595 endif
596else
597 INSTALLED_BOOTLOADER_MODULE :=
598 INSTALLED_2NDBOOTLOADER_TARGET :=
599endif # TARGET_NO_BOOTLOADER
600ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700601 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
602 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
603 $(PRODUCT_OUT)/$(k))
604 else
605 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
606 endif
Ying Wangc6349742014-01-13 16:14:20 -0800607else
608 INSTALLED_KERNEL_TARGET :=
609endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610
611# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700612# the root dir
613INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800614 $(ALL_GENERATED_SOURCES) \
615 $(ALL_DEFAULT_INSTALLED_MODULES))
616
Luis Hector Chavezff489932018-07-03 15:41:40 -0700617INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
618INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
619$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700620$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700621 @echo Installed file list: $@
622 @mkdir -p $(dir $@)
623 @rm -f $@
624 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700625 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700626
627$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
628
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800629#------------------------------------------------------------------
630# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700631ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800632INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700633ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800634$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800635 cat $^ > $@
636endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700637endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800638
Tom Cherryd14b8952018-08-09 14:26:00 -0700639# -----------------------------------------------------------------
640# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800641ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700642INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
643 $(ALL_GENERATED_SOURCES) \
644 $(ALL_DEFAULT_INSTALLED_MODULES))
645
646INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
647INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
648$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700649$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700650 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800651 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700652 @mkdir -p $(dir $@)
653 @rm -f $@
654 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700655 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700656
657$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700658BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
659
J. Avila3f6560e2020-05-11 20:20:03 +0000660ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
661# -l enables the legacy format used by the Linux kernel
662COMPRESSION_COMMAND_DEPS := $(LZ4)
663COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
664RAMDISK_EXT := .lz4
665else
666COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
667COMPRESSION_COMMAND := $(MINIGZIP)
668RAMDISK_EXT := .gz
669endif
670
Joe Onorato64d85d02009-04-09 19:31:12 -0700671# We just build this directly to the install location.
672INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000673$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800674 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000675 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800676
Ying Wangad7fd292013-08-08 16:34:29 -0700677.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000678ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700679 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000680 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800681
Dan Willemsen67495202019-01-16 12:42:05 -0800682endif # BUILDING_RAMDISK_IMAGE
683
The Android Open Source Project88b60792009-03-03 19:28:42 -0800684# -----------------------------------------------------------------
685# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700686
687# This is defined here since we may be building recovery as boot
688# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700689ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
690 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
691else
692 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
693endif
694
Steve Muckle04b6f052020-08-09 14:36:56 -0700695# $1: boot image target
696# returns the kernel used to make the bootimage
697define bootimage-to-kernel
698 $(if $(BOARD_KERNEL_BINARIES),\
699 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
700 $(INSTALLED_KERNEL_TARGET))
701endef
702
Steve Muckle903a1ca2020-05-07 17:32:10 -0700703ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
704 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
705endif
706
707# $1: boot image file name
708# $2: boot image variant (boot, boot-debug)
709define get-bootimage-partition-size
710 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
711endef
Chris Grossa784ef12019-04-22 11:09:57 -0700712
713ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700715 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700716
717ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
718INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
719endif
720
Steve Mucklee1b10862019-07-10 10:49:37 -0700721ifndef BUILDING_VENDOR_BOOT_IMAGE
722ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
723 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
724endif
725endif
726
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
728
Anton Hansson8dab0a62019-03-28 15:45:40 +0000729ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700730ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000731VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700732 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
733endif
734endif
735
Anton Hansson72e36f02019-02-26 17:36:30 +0000736INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700737
738ifndef BUILDING_VENDOR_BOOT_IMAGE
739ifdef BOARD_KERNEL_BASE
740 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
741endif
742ifdef BOARD_KERNEL_PAGESIZE
743 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
744endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700745ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700746 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
747endif
748else
749# building vendor boot image, dtb/base/pagesize go there
750ifdef GENERIC_KERNEL_CMDLINE
751 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
752endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700753endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700754
Sami Tolvanen3303d902016-03-15 16:49:30 +0000755INTERNAL_MKBOOTIMG_VERSION_ARGS := \
756 --os_version $(PLATFORM_VERSION) \
757 --os_patch_level $(PLATFORM_SECURITY_PATCH)
758
Chris Grossa784ef12019-04-22 11:09:57 -0700759# Define these only if we are building boot
760ifdef BUILDING_BOOT_IMAGE
761INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
762
The Android Open Source Project88b60792009-03-03 19:28:42 -0800763ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800764$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400765
766else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
767
Steve Muckle04b6f052020-08-09 14:36:56 -0700768# $1: boot image target
769define build_boot_board_avb_enabled
770 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
771 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
772 $(AVBTOOL) add_hash_footer \
773 --image $(1) \
774 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
775 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
776 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
777endef
778
779$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(call bootimage-to-kernel,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400780 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700781 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400782
783.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800784bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400785 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700786 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400787
Anton Hansson8dab0a62019-03-28 15:45:40 +0000788else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700789
Steve Muckle04b6f052020-08-09 14:36:56 -0700790# $1: boot image target
791define build_boot_supports_boot_signer
792 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
793 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
794 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
795endef
796
797$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER) $(call bootimage-to-kernel,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700798 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700799 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700800
801.PHONY: bootimage-nodeps
802bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
803 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700804 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700805
Anton Hansson8dab0a62019-03-28 15:45:40 +0000806else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800807
Steve Muckle04b6f052020-08-09 14:36:56 -0700808# $1: boot image target
809define build_boot_supports_vboot
810 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
811 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
812 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
813endef
814
815$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY) $(call bootimage-to-kernel,$@)
David Riley17be3d32015-03-03 08:54:11 -0800816 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700817 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800818
819.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800820bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800821 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700822 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800823
824else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800825
Steve Muckle04b6f052020-08-09 14:36:56 -0700826# $1: boot image target
827define build_boot_novboot
828 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
829 $(call assert-max-image-size,$1,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
830endef
831
832$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(call bootimage-to-kernel,$@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800833 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700834 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700835
836.PHONY: bootimage-nodeps
837bootimage-nodeps: $(MKBOOTIMG)
838 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700839 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700840
The Android Open Source Project88b60792009-03-03 19:28:42 -0800841endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -0700842endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843
Tao Baob1a2e352018-08-14 16:17:12 -0700844else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700845ifdef BOARD_PREBUILT_BOOTIMAGE
846ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
847# Remove when b/63676296 is resolved.
848$(error Prebuilt bootimage is only supported for AB targets)
849endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900850INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700851$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700852else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700853INSTALLED_BOOTIMAGE_TARGET :=
854endif # BOARD_PREBUILT_BOOTIMAGE
855endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800856
857# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700858# vendor boot image
859ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
860
861ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
862 $(error vboot 1.0 does not support vendor_boot partition)
863endif
864
865INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
866 $(ALL_GENERATED_SOURCES) \
867 $(ALL_DEFAULT_INSTALLED_MODULES))
868
Steve Muckle414dbe12020-06-18 21:38:35 -0700869INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000870$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
871 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700872
873ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
874 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
875endif
876ifdef BOARD_KERNEL_BASE
877 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
878endif
879ifdef BOARD_KERNEL_PAGESIZE
880 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
881endif
882ifdef INTERNAL_KERNEL_CMDLINE
883 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
884endif
885
886INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
887$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
888ifeq ($(BOARD_AVB_ENABLE),true)
889$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
890 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800891 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700892 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
893 $(AVBTOOL) add_hash_footer \
894 --image $@ \
895 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
896 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
897 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
898else
899$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
900 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800901 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700902 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
903endif
904endif # BUILDING_VENDOR_BOOT_IMAGE
905
906# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907# NOTICE files
908#
Steve Blockd14d3b42012-03-01 11:34:41 +0000909# We are required to publish the licenses for all code under BSD, GPL and
910# Apache licenses (and possibly other more exotic ones as well). We err on the
911# side of caution, so the licenses for other third-party code are included here
912# too.
913#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914# This needs to be before the systemimage rules, because it adds to
915# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
916# go into the systemimage.
917
Steve Block495e5852012-02-29 19:18:08 +0000918.PHONY: notice_files
919
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900920# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700921# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
922# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
923# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
924# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900925# $(2) - Plain text output file
926# $(3) - HTML/XML output file
927# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700928# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900930# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800931# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932#
933# The algorithm here is that we go collect a hash for each of the notice
934# files and write the names of the files that match that hash. Then
935# to generate the real files, we go print out all of the files and their
936# hashes.
937#
938# These rules are fairly complex, so they depend on this makefile so if
939# it changes, they'll run again.
940#
941# TODO: We could clean this up so that we just record the locations of the
942# original notice files instead of making rules to copy them somwehere.
943# Then we could traverse that without quite as much bash drama.
944define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700945$(2): PRIVATE_MESSAGE := $(4)
946$(2): PRIVATE_DIR := $(5)
947$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
948$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800949 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -0700950 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
951 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000952 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900953 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700954 $(if $(filter $(1),xml_system),-i system --xml-output, \
955 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700956 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -0700957 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
958 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -0700959 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900960notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800961endef
962
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000963# Notice file logic isn't relevant for TARGET_BUILD_APPS
964ifndef TARGET_BUILD_APPS
965
The Android Open Source Project88b60792009-03-03 19:28:42 -0800966# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
967# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
968# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000969target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000970tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000972kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
973winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974
Bob Badour4b25c902020-01-28 13:23:39 -0800975# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
976# reasons--not to be flashed onto any device. Targets under these directories
977# need no associated notice file on the device UI.
978exclude_target_dirs := apex
979
Steven Morelandae69e572017-12-15 14:49:55 -0800980# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000981ifneq ($(PRODUCT_NOTICE_SPLIT),true)
982target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
983target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
984installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
985$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000986 $(target_notice_file_txt), \
987 $(target_notice_file_html), \
988 "Notices for files contained in the filesystem images in this directory:", \
989 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -0700990 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -0800991 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000992$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
993 $(hide) $(MINIGZIP) -9 < $< > $@
994$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
995 $(copy-file-to-target)
996else
997target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
998target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900999installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1000
1001target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1002target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1003target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1004installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001005
1006target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1007target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1008target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1009installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001010
Justin Yun6151e3f2019-06-25 15:58:13 +09001011target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1012target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1013target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1014installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001015
Chris Gross15d96552019-07-16 14:38:43 -07001016target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1017target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1018target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1019installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1020
Yifan Hong3d3f0302020-05-11 18:35:11 -07001021target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1022target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1023target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1024installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1025
Yifan Hongc83f9e92020-07-15 16:57:47 -07001026target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1027target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1028target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1029installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1030
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001031# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1032# being built. A notice xml file must depend on all modules that could potentially
1033# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001034license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001035# Only files copied to a system image need system image notices.
1036license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001037# Phonys/fakes don't have notice files (though their deps might)
1038license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001039# testcases are not relevant to the system image.
1040license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001041# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001042license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001043license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1044license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001045license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001046license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001047license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001048license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001049license_modules_agg := $(license_modules_system) \
1050 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001051 $(license_modules_product) \
1052 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001053 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001054 $(license_modules_vendor_dlkm) \
1055 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001056# targets used for debug symbols only and do not get copied to the device
1057license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1058
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001059license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001060license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1061
1062# Identify the other targets we expect to have notices for:
1063# targets copied to the device but are not readable by the UI (e.g. must boot
1064# into a different partition to read or don't have an associated /etc
1065# directory) must have their notices built somewhere readable.
1066license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1067license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1068license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1069license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1070license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1071license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1072license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1073license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1074license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1075license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1076license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1077license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1078license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1079
1080# after removing targets in system images, targets reported in system images, and
1081# targets used for debug symbols that do not need notices, nothing must remain.
1082license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1083$(call maybe-print-list-and-error, $(license_modules_rest), \
1084 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001085
Chris Grossaad39b32019-06-13 09:43:26 -07001086# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1087# update its notice file, so include those notices in the system partition instead
1088ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001089license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001090system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1091system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001092else
Bob Badour4b25c902020-01-28 13:23:39 -08001093license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001094system_xml_directories := xml_system
1095system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001096endif
1097
1098$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001099 $(target_notice_file_txt), \
1100 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001101 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001102 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001103 $(license_modules_system), \
1104 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001105$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001106 $(target_vendor_notice_file_txt), \
1107 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001108 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001109 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001110 $(license_modules_vendor), \
1111 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001112$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001113 $(target_product_notice_file_txt), \
1114 $(target_product_notice_file_xml), \
1115 "Notices for files contained in the product filesystem image in this directory:", \
1116 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001117 $(license_modules_product), \
1118 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001119$(eval $(call combine-notice-files, xml_system_ext, \
1120 $(target_system_ext_notice_file_txt), \
1121 $(target_system_ext_notice_file_xml), \
1122 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001123 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001124 $(license_modules_system_ext), \
1125 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001126$(eval $(call combine-notice-files, xml_odm, \
1127 $(target_odm_notice_file_txt), \
1128 $(target_odm_notice_file_xml), \
1129 "Notices for files contained in the odm filesystem image in this directory:", \
1130 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001131 $(license_modules_odm), \
1132 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001133$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1134 $(target_vendor_dlkm_notice_file_txt), \
1135 $(target_vendor_dlkm_notice_file_xml), \
1136 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1137 $(TARGET_OUT_NOTICE_FILES), \
1138 $(license_modules_vendor_dlkm), \
1139 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001140$(eval $(call combine-notice-files, xml_odm_dlkm, \
1141 $(target_odm_dlkm_notice_file_txt), \
1142 $(target_odm_dlkm_notice_file_xml), \
1143 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1144 $(TARGET_OUT_NOTICE_FILES), \
1145 $(license_modules_odm_dlkm), \
1146 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001147
1148$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1149 $(hide) $(MINIGZIP) -9 < $< > $@
1150$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1151 $(hide) $(MINIGZIP) -9 < $< > $@
1152$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1153 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001154$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001155 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001156$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1157 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001158$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1159 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001160$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1161 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001162$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1163 $(copy-file-to-target)
1164$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1165 $(copy-file-to-target)
1166$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1167 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001168$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001169 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001170$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1171 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001172$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1173 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001174$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1175 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001176
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001177ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1178ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1179ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1180ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1181ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001182ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001183ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001184endif # PRODUCT_NOTICE_SPLIT
1185
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001186ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001187
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001188$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001189 $(tools_notice_file_txt), \
1190 $(tools_notice_file_html), \
1191 "Notices for files contained in the tools directory:", \
1192 $(HOST_OUT_NOTICE_FILES), \
1193 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001194 $(winpthreads_notice_file), \
1195 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001196
Ying Wang62c81f82013-08-22 20:02:03 -07001197endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001198
1199# The kernel isn't really a module, so to get its module file in there, we
1200# make the target NOTICE files depend on this particular file too, which will
1201# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001202$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001203
Dan Willemsen288bedf2019-05-28 15:36:47 -07001204$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001205
Doug Zongker8678df42009-06-15 14:30:14 -07001206
The Android Open Source Project88b60792009-03-03 19:28:42 -08001207# #################################################################
1208# Targets for user images
1209# #################################################################
1210
Ying Wang933abf12010-06-16 14:31:34 -07001211INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001213INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1214else
1215ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001216INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1217else
1218ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001219INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1220endif
1221endif
1222endif
1223
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001224# These options tell the recovery updater/installer how to mount the partitions writebale.
1225# <fstype>=<fstype_opts>[|<fstype_opts>]...
1226# fstype_opts := <opt>[,<opt>]...
1227# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001228# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1229DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001230
Ying Wang542903a2010-11-17 15:40:38 -08001231ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1232 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1233endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001234ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1235 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1236endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001237ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1238 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1239endif
Tao Baodba635a2019-06-24 10:39:54 -07001240
1241INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001242 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001243 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001244 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001245
1246ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1247INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001248endif
1249
Yifan Hongcfb917a2020-05-07 14:58:20 -07001250ifneq ($(filter \
1251 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1252 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1253 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1254 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1255 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1256 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001257 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001258 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001259INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1260endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001261
Anton Hansson8dab0a62019-03-28 15:45:40 +00001262ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001263INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001264ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001265INTERNAL_USERIMAGES_DEPS += $(FEC)
1266endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001267endif
1268
Tao Baodba635a2019-06-24 10:39:54 -07001269ifeq ($(BOARD_AVB_ENABLE),true)
1270INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1271endif
1272
1273# Get a colon-separated list of search paths.
1274INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1275
Alex Klyubin092c9022017-03-13 13:28:34 -07001276SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001277INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1278
Yifan Hongc5c01242018-11-09 10:27:23 -08001279ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001280
Anton Hansson8dab0a62019-03-28 15:45:40 +00001281ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001282 $(error vboot 1.0 doesn't support logical partition)
1283endif
1284
Yifan Hongc5c01242018-11-09 10:27:23 -08001285endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001286
Ying Wangbd93d422011-10-28 17:02:30 -07001287# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001288# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001289# $(3): additional "key=value" pairs to append to the dictionary file.
1290define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001291$(if $(filter $(2),system),\
1292 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001293 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001294 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1295 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1296 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1297 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1298 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1299 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1300 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1301 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001302 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1303 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001304 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001305 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001306 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1307)
1308$(if $(filter $(2),system_other),\
1309 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001310)
Yifan Hong760d3c02018-05-30 11:16:46 -07001311$(if $(filter $(2),userdata),\
1312 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1313 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001314 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1315 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001316 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001317 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001318)
Yifan Hong760d3c02018-05-30 11:16:46 -07001319$(if $(filter $(2),cache),\
1320 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1321 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001322 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001323 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001324)
1325$(if $(filter $(2),vendor),\
1326 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1327 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1328 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1329 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1330 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1331 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1332 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1333 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1334 $(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001335 $(if $(PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
Yifan Hong749062d2018-06-19 16:23:16 -07001336 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001337 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001338 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001339)
1340$(if $(filter $(2),product),\
1341 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1342 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1343 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1344 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1345 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1346 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1347 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1348 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1349 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_squashfs_disable_4k_align=$(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001350 $(if $(PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "product_base_fs_file=$(PRODUCT_PRODUCT_BASE_FS_PATH)" >> $(1))
Yifan Hong56a6c3b2018-07-20 15:19:34 -07001351 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001352 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001353 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001354)
Justin Yun6151e3f2019-06-25 15:58:13 +09001355$(if $(filter $(2),system_ext),\
1356 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1357 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1358 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1359 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1360 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1361 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1362 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1363 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1364 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1365 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1366 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001367 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001368)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001369$(if $(filter $(2),odm),\
1370 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1371 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1372 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1373 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1374 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1375 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1376 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1377 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1378 $(if $(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_squashfs_disable_4k_align=$(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001379 $(if $(PRODUCT_ODM_BASE_FS_PATH),$(hide) echo "odm_base_fs_file=$(PRODUCT_ODM_BASE_FS_PATH)" >> $(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001380 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001381 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001382 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001383)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001384$(if $(filter $(2),vendor_dlkm),\
1385 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1386 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1387 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1388 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1389 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1390 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1391 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1392 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1393 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1394 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1395 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1396 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1397)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001398$(if $(filter $(2),odm_dlkm),\
1399 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1400 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1401 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1402 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1403 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1404 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1405 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1406 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1407 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1408 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1409 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1410 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1411)
Yifan Hong760d3c02018-05-30 11:16:46 -07001412$(if $(filter $(2),oem),\
1413 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1414 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1415 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1416 $(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001417 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001418)
Tao Bao3602eca2018-07-10 10:53:55 -07001419$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001420
Tao Bao3602eca2018-07-10 10:53:55 -07001421$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001422$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001423$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001424$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001425$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1426$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1427$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001428$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1429$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1430$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1431$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1432$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001433$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001434$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1435$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1436$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001437$(if $(PRODUCT_SYSTEM_EXT_VERITY_PARTITION),$(hide) echo "system_ext_verity_block_device=$(PRODUCT_SYSTEM_EXT_VERITY_PARTITION)" >> $(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001438$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001439$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001440$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1441$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1442$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1443$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1444$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001445$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001446$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1447$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1448$(if $(BOARD_AVB_ENABLE),\
1449 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1450 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1451 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1452 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001453$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1454$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1455$(if $(BOARD_AVB_ENABLE),\
1456 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1457 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001458 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001459$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1460$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1461$(if $(BOARD_AVB_ENABLE),\
1462 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1463 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1464 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1465 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001466$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1467$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1468$(if $(BOARD_AVB_ENABLE),\
1469 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1470 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1471 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1472 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001473$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001474$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001475 $(hide) echo "avb_system_ext_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001476$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001477 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1478 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1479 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1480 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001481$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1482$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1483$(if $(BOARD_AVB_ENABLE),\
1484 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1485 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1486 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1487 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001488$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1489$(if $(BOARD_AVB_ENABLE),\
1490 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1491$(if $(BOARD_AVB_ENABLE),\
1492 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1493 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1494 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1495 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001496$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1497$(if $(BOARD_AVB_ENABLE),\
1498 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1499$(if $(BOARD_AVB_ENABLE),\
1500 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1501 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1502 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1503 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001504$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1505 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001506$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001507 $(hide) echo "system_root_image=true" >> $(1))
1508$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001509$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1510 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001511$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1512endef
1513
1514# $(1): the path of the output dictionary file
1515# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001516PROP_DICTIONARY_IMAGES := oem
1517ifdef BUILDING_CACHE_IMAGE
1518 PROP_DICTIONARY_IMAGES += cache
1519endif
1520ifdef BUILDING_SYSTEM_IMAGE
1521 PROP_DICTIONARY_IMAGES += system
1522endif
Chris Gross203191b2020-05-30 02:39:12 +00001523ifdef BUILDING_SYSTEM_OTHER_IMAGE
1524 PROP_DICTIONARY_IMAGES += system_other
1525endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001526ifdef BUILDING_USERDATA_IMAGE
1527 PROP_DICTIONARY_IMAGES += userdata
1528endif
1529ifdef BUILDING_VENDOR_IMAGE
1530 PROP_DICTIONARY_IMAGES += vendor
1531endif
1532ifdef BUILDING_PRODUCT_IMAGE
1533 PROP_DICTIONARY_IMAGES += product
1534endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001535ifdef BUILDING_SYSTEM_EXT_IMAGE
1536 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001537endif
1538ifdef BUILDING_ODM_IMAGE
1539 PROP_DICTIONARY_IMAGES += odm
1540endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001541ifdef BUILDING_VENDOR_DLKM_IMAGE
1542 PROP_DICTIONARY_IMAGES += vendor_dlkm
1543endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001544ifdef BUILDING_ODM_DLKM_IMAGE
1545 PROP_DICTIONARY_IMAGES += odm_dlkm
1546endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001547define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001548 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001549endef
1550
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001551# $(1): the path of the input dictionary file, where each line has the format key=value
1552# $(2): the key to look up
1553define read-image-prop-dictionary
1554$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1555endef
1556
The Android Open Source Project88b60792009-03-03 19:28:42 -08001557# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001558# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001559
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001560# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001561ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001562
Ying Wang37526142015-03-10 12:02:57 -07001563INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1564 $(ALL_DEFAULT_INSTALLED_MODULES))
1565
Tao Bao10fc9492018-08-14 12:17:48 -07001566INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1567INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1568
1569# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1570# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1571# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1572# the call to FILELIST.
1573ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001574INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001575$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1576else
1577$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1578endif
1579
1580$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001581$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001582 @echo Installed file list: $@
1583 @mkdir -p $(dir $@)
1584 @rm -f $@
1585 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001586 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001587
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001588recovery_sepolicy := \
1589 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001590 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001591 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001592 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1593 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1594 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001595 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001596 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001597 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1598 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1599 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001600
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001601# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1602# SELinux files
1603IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1604
Steve Muckle04b6f052020-08-09 14:36:56 -07001605# if building multiple boot images from multiple kernels, use the first kernel listed
1606# for the recovery image
1607recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001608recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001609recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001610
Anton Hansson45a40da2019-01-18 14:06:34 +00001611# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1612# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1613# which get remapped to a bucket.
1614recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001615ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1616recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001617# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001618# ------160------240------320----------480------------640------
1619# mdpi hdpi xhdpi xxhdpi xxxhdpi
1620recovery_density := $(strip \
1621 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1622 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1623 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1624 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001625endif
1626
1627ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1628recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1629else
Doug Zongker25d55f82014-04-04 13:51:15 -07001630recovery_resources_common := $(recovery_resources_common)-xhdpi
1631endif
1632
Tao Baoe1e829e2018-08-29 20:36:00 -07001633# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1634# Note that the font selected here can be overridden for a particular device by putting a font.png
1635# in its private recovery resources.
1636ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001637recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001638else
Dan Willemsen97672232020-05-27 00:09:16 -07001639recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001640endif
1641
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001642
1643# We will only generate the recovery background text images if the variable
1644# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1645# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1646# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1647# BoardConfig in order to use this feature.
1648ifeq ($(recovery_density),xxxhdpi)
1649TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1650else ifeq ($(recovery_density),xxhdpi)
1651TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1652endif
1653
1654ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1655# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1656ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1657 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1658else
1659 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1660endif
1661
1662
Dan Willemsen97672232020-05-27 00:09:16 -07001663RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001664RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1665RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1666RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1667RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1668
xunchangcc57d312018-12-07 12:12:17 -08001669RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1670RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1671RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1672RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1673RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1674
1675generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001676 $(RECOVERY_INSTALLING_TEXT_FILE) \
1677 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1678 $(RECOVERY_ERASING_TEXT_FILE) \
1679 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001680 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1681 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1682 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1683 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1684 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1685 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001686
Dan Willemsen97672232020-05-27 00:09:16 -07001687resource_dir := bootable/recovery/tools/recovery_l10n/res/
1688resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001689image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001690zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001691$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001692$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001693$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1694$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001695$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001696$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001697$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001698 recovery_installing \
1699 recovery_installing_security \
1700 recovery_erasing \
1701 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001702 recovery_no_command
1703$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001704 recovery_cancel_wipe_data \
1705 recovery_factory_data_reset \
1706 recovery_try_again \
1707 recovery_wipe_data_menu_header \
1708 recovery_wipe_data_confirmation
1709$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001710$(RECOVERY_INSTALLING_TEXT_FILE): $(image_generator_jar) $(resource_dir_deps) $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep) $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001711 # Prepares the font directory.
1712 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1713 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001714 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001715 @rm -rf $(dir $@)
1716 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001717 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001718 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001719 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001720 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1721 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1722 --text_name $(text_name) \
1723 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1724 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001725 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001726 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001727else
1728RECOVERY_INSTALLING_TEXT_FILE :=
1729RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1730RECOVERY_ERASING_TEXT_FILE :=
1731RECOVERY_ERROR_TEXT_FILE :=
1732RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001733RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1734RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1735RECOVERY_TRY_AGAIN_TEXT_FILE :=
1736RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1737RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001738endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1739
Ying Wang9a175682015-08-06 11:47:47 -07001740ifndef TARGET_PRIVATE_RES_DIRS
1741TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1742endif
Doug Zongker4647f122009-07-02 09:00:54 -07001743recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001744 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001745recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001746
1747
Andrew Boiefa61ff02012-09-28 09:33:45 -07001748ifdef TARGET_RECOVERY_FSTAB
1749recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1750else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001751recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001752endif
Tao Baoc3c17532016-06-10 10:11:54 -07001753ifdef TARGET_RECOVERY_WIPE
1754recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001755else
Tao Baoc3c17532016-06-10 10:11:54 -07001756recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001757endif
Tao Bao8beab692015-07-22 12:33:18 -07001758
Tao Bao6d5d6232018-03-09 17:04:42 -08001759# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001760# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001761# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1762# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001763#
1764# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001765# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001766# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001767# b) We build a single image that contains boot and recovery both - no recovery image to install
1768# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001769# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001770# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001771# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1772# do bsdiff because boot and recovery will contain different number of entries
1773# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001774# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1775# do bsdiff because boot and recovery will contain different number of entries
1776# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001777
Tom Cherry2929cad2018-09-20 11:04:37 -07001778ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001779 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001780# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001781RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1782ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001783else
Tao Bao8beab692015-07-22 12:33:18 -07001784RECOVERY_RESOURCE_ZIP :=
1785endif
Doug Zongker4647f122009-07-02 09:00:54 -07001786
Tao Bao139c7272018-07-31 13:26:54 -07001787INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1788
1789$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001790 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1791 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1792 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1793 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1794 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1795 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1796 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1797 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1798
1799# Parses the given list of build variables and writes their values as build properties if defined.
1800# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1801# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1802# $(1): Map from the build variable names to property names
1803# $(2): Output file
1804define append-recovery-ui-properties
1805echo "#" >> $(2)
1806echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1807echo "#" >> $(2)
1808$(foreach prop,$(1), \
1809 $(eval _varname := $(call word-colon,1,$(prop))) \
1810 $(eval _propname := $(call word-colon,2,$(prop))) \
1811 $(eval _value := $($(_varname))) \
1812 $(if $(_value), \
1813 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1814endef
1815
1816$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001817 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001818 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1819 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1820 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001821 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001822 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001823 $(hide) mkdir -p $(dir $@)
1824 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001825 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001826 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001827 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001828 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001829 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001830 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1831
Yifan Hong33fd5d42020-09-24 18:18:26 -07001832# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
1833# On device with dedicated recovery partition, the file should come from the boot
1834# ramdisk.
1835ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
1836INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
1837$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
1838 $(copy-file-to-target)
1839endif
1840
Steve Mucklef84668e2020-03-16 19:13:46 -07001841ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001842 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001843ifdef GENERIC_KERNEL_CMDLINE
1844 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1845endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001846else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001847 INTERNAL_RECOVERYIMAGE_ARGS := \
1848 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001849 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001850# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001851ifdef INTERNAL_KERNEL_CMDLINE
1852 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001853endif
1854ifdef BOARD_KERNEL_BASE
1855 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1856endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001857ifdef BOARD_KERNEL_PAGESIZE
1858 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1859endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001860ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001861ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1862 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1863else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001864 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1865endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001866endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001867ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1868 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1869endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001870ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1871 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1872endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001873endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001874ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1875 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1876endif
Doug Zongker4647f122009-07-02 09:00:54 -07001877
J. Avila3f6560e2020-05-11 20:20:03 +00001878$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001879 $(INTERNAL_ROOT_FILES) \
1880 $(INSTALLED_RAMDISK_TARGET) \
1881 $(INTERNAL_RECOVERYIMAGE_FILES) \
1882 $(recovery_sepolicy) \
1883 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1884 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07001885 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001886 $(recovery_resource_deps) \
1887 $(recovery_fstab)
1888 # Making recovery image
1889 mkdir -p $(TARGET_RECOVERY_OUT)
1890 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1891 # Copying baseline ramdisk...
1892 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1893 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1894 # Modifying ramdisk contents...
1895 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1896 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1897 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1898 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1899 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1900 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1901 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1902 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1903 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1904 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1905 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1906 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1907 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1908 $(foreach item,$(recovery_fstab), \
1909 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1910 $(if $(strip $(recovery_wipe)), \
1911 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1912 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1913 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001914 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001915
Ying Wang747b9f12015-01-30 14:05:22 -08001916# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001917# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001918define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001919 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001920 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001921 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001922 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001923 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001924 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001925 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001926 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001927 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001928 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1929 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001930 )\
1931 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001932 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1933 $(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 +08001934 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001935 $(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 -07001936 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001937 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1938 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001939 $(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 -07001940 $(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 -08001941endef
1942
Dan Willemsend120ac62020-06-12 02:39:34 +00001943recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001944ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001945 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001946endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001947ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001948 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001949endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001950ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001951 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001952endif
Tao Baof4866c72018-08-22 14:35:09 -07001953ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001954 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1955 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1956 else
1957 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1958 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001959endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001960ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001961 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001962endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001963ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001964 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001965endif
Tao Baof4866c72018-08-22 14:35:09 -07001966
Dan Willemsend120ac62020-06-12 02:39:34 +00001967ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1968$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001969 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001970 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001971endif # BOARD_USES_RECOVERY_AS_BOOT
1972
Dan Willemsend120ac62020-06-12 02:39:34 +00001973$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001974 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001975
Tao Bao4594d0e2015-12-22 09:47:46 -08001976ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001977$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001978 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001979 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1980 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001981endif
Doug Zongker56588872012-08-20 15:38:58 -07001982
Ying Wang747b9f12015-01-30 14:05:22 -08001983.PHONY: recoveryimage-nodeps
1984recoveryimage-nodeps:
1985 @echo "make $@: ignoring dependencies"
Steve Mucklea21b44a2020-08-09 14:54:42 -07001986 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), $(recovery_kernel))
Ying Wang747b9f12015-01-30 14:05:22 -08001987
Chris Grossa784ef12019-04-22 11:09:57 -07001988else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001989RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001990endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001991
1992.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001993recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001994
Jiyong Park03eb0612017-10-04 21:22:41 +09001995ifneq ($(BOARD_NAND_PAGE_SIZE),)
1996$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001997endif
1998
Jiyong Park03eb0612017-10-04 21:22:41 +09001999ifneq ($(BOARD_NAND_SPARE_SIZE),)
2000$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002001endif
2002
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002003ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002004# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002005# the debug ramdisk, which is the original ramdisk plus additional
2006# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2007# When /force_debuggable is present, /init will load userdebug sepolicy
2008# and property files to allow adb root, if the device is unlocked.
2009
2010ifdef BUILDING_RAMDISK_IMAGE
2011BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2012INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2013
2014INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2015 $(ALL_GENERATED_SOURCES) \
2016 $(ALL_DEFAULT_INSTALLED_MODULES))
2017
2018# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2019# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2020# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2021my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2022
2023INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2024INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2025$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2026$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2027
2028# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2029# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2030# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2031$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002032$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002033 echo Installed file list: $@
2034 mkdir -p $(dir $@)
2035 rm -f $@
2036 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002037 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002038
2039# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2040# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2041ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2042my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2043else
2044my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2045endif # BOARD_USES_RECOVERY_AS_BOOT
2046
2047$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2048$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002049
2050ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2051# 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 +08002052$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002053else
2054# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2055$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2056endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002057$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002058 $(call pretty,"Target debug ram disk: $@")
2059 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2060 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002061 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002062 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002063
2064.PHONY: ramdisk_debug-nodeps
2065ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2066ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002067ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002068 echo "make $@: ignoring dependencies"
2069 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2070 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002071 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002072 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002073
2074my_debug_ramdisk_sync_dir :=
2075my_debug_ramdisk_root_dir :=
2076
2077endif # BUILDING_RAMDISK_IMAGE
2078
2079# -----------------------------------------------------------------
2080# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2081#
2082# Note: it's intentional to skip signing for boot-debug.img, because it
2083# can only be used if the device is unlocked with verification error.
2084ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002085ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2086 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2087 $(PRODUCT_OUT)/$(k).img)
2088else
2089 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2090endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002091
2092# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2093ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2094INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2095else
2096INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2097endif
2098
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002099# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2100# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2101# Using a test key to sign boot-debug.img to continue booting with the mismatched
2102# public key, if the device is unlocked.
2103ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002104$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002105endif
2106
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002107BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2108INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2109# $(1): the bootimage to sign
2110define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002111$(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 +08002112$(AVBTOOL) add_hash_footer \
2113 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002114 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002115 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2116 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002117$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002118endef
2119
Steve Muckleb3dda772020-03-11 16:03:07 -07002120# $(1): output file
2121define build-debug-bootimage-target
2122 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2123 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2124 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2125endef
2126
Bowgo Tsai0013f552019-03-20 17:59:52 +08002127# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2128$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2129 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002130 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002131
2132.PHONY: bootimage_debug-nodeps
2133bootimage_debug-nodeps: $(MKBOOTIMG)
2134 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002135 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002136
2137endif # TARGET_NO_KERNEL
2138
Bowgo Tsai6a683672020-02-14 19:00:15 +08002139ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2140ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2141# -----------------------------------------------------------------
2142# vendor debug ramdisk
2143# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002144INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002145$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2146$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2147
2148INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2149 $(ALL_GENERATED_SOURCES) \
2150 $(ALL_DEFAULT_INSTALLED_MODULES))
2151
2152# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2153# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2154# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2155# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2156$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2157$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002158$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002159 $(call pretty,"Target vendor debug ram disk: $@")
2160 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2161 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2162 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2163 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2164 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002165 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002166
2167INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2168INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2169$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2170$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2171
2172# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2173# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2174$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2175$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2176 echo Installed file list: $@
2177 mkdir -p $(dir $@)
2178 rm -f $@
2179 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2180 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2181
2182# -----------------------------------------------------------------
2183# vendor_boot-debug.img.
2184INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2185
2186# The util to sign vendor_boot-debug.img with a test key.
2187BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2188INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2189# $(1): the vendor bootimage to sign
2190define test-key-sign-vendor-bootimage
2191$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2192$(AVBTOOL) add_hash_footer \
2193 --image $(1) \
2194 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2195 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2196 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2197$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2198endef
2199
2200ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2201$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2202endif
2203
2204# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2205$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2206 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002207 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002208 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2209 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2210
2211endif # BUILDING_RAMDISK_IMAGE
2212endif # BUILDING_VENDOR_BOOT_IMAGE
2213
Bowgo Tsai0013f552019-03-20 17:59:52 +08002214# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002215# The test harness ramdisk, which is based off debug_ramdisk, plus a
2216# few additional test-harness-specific properties in adb_debug.prop.
2217
2218ifdef BUILDING_RAMDISK_IMAGE
2219BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2220INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2221
2222# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2223# appends a few test harness specific properties into the adb_debug.prop.
2224TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2225TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2226
2227# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2228# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2229TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2230ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2231ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2232
2233# $(1): a list of key=value pairs for additional property assignments
2234# $(2): the target .prop file to append the properties from $(1)
2235define append-test-harness-props
2236 echo "#" >> $(2); \
2237 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2238 echo "#" >> $(2);
2239 $(foreach line,$(1), echo "$(line)" >> $(2);)
2240endef
2241
2242$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002243$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002244 $(call pretty,"Target test harness ram disk: $@")
2245 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2246 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002247 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002248
2249.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002250ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002251 echo "make $@: ignoring dependencies"
2252 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2253 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002254 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002255
2256endif # BUILDING_RAMDISK_IMAGE
2257
2258# -----------------------------------------------------------------
2259# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2260#
2261# Note: it's intentional to skip signing for boot-test-harness.img, because it
2262# can only be used if the device is unlocked with verification error.
2263ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2264
Steve Muckle4866bd62020-04-02 11:31:08 -07002265ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2266 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2267 $(PRODUCT_OUT)/$(k).img)
2268else
2269 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2270endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002271
2272# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2273INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2274
2275# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2276# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2277# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2278# public key, if the device is unlocked.
2279ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2280$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2281endif
2282
Steve Muckle4866bd62020-04-02 11:31:08 -07002283# $(1): output file
2284define build-boot-test-harness-target
2285 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2286 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2287 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2288endef
2289
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002290# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2291$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2292 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002293 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002294
2295.PHONY: bootimage_test_harness-nodeps
2296bootimage_test_harness-nodeps: $(MKBOOTIMG)
2297 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002298 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002299
2300endif # TARGET_NO_KERNEL
2301endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2302
Colin Crossbd382142020-08-26 15:08:57 -07002303# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2304# $1: from location (e.g $(TARGET_OUT)/vendor)
2305# $2: destination location (e.g. /vendor)
2306# $3: partition image name (e.g. vendor.img)
2307define create-partition-compat-symlink
2308$(eval \
2309$1:
2310 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2311 mkdir -p $(dir $1)
2312 if [ -d $1 ] && [ ! -h $1 ]; then \
2313 echo 'Non-symlink $1 detected!' 1>&2; \
2314 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2315 exit 1; \
2316 fi
2317 ln -sfn $2 $1
2318)
2319$1
2320endef
2321
2322
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002323# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002324# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002325
Dan Willemsen37a19862018-10-31 16:31:46 -07002326INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002327 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002328 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002329
Colin Crossbd382142020-08-26 15:08:57 -07002330# Create symlink /system/vendor to /vendor if necessary.
2331ifdef BOARD_USES_VENDORIMAGE
2332 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2333endif
2334
2335# Create symlink /system/product to /product if necessary.
2336ifdef BOARD_USES_PRODUCTIMAGE
2337 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2338endif
2339
2340# Create symlink /system/system_ext to /system_ext if necessary.
2341ifdef BOARD_USES_SYSTEM_EXTIMAGE
2342 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2343endif
2344
Ying Wang82cceba2012-08-13 15:03:00 -07002345FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002346
2347# ASAN libraries in the system image - add dependency.
2348ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002349ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002350 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2351 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2352 endif
2353endif
2354
Tom Cherryd14b8952018-08-09 14:26:00 -07002355FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002356
Ying Wange5e8c5f2011-09-09 16:35:53 -07002357# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002358ifdef BUILDING_SYSTEM_IMAGE
2359
Ying Wange5e8c5f2011-09-09 16:35:53 -07002360# installed file list
2361# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2362# We put installed-files.txt ahead of image itself in the dependency graph
2363# so that we can get the size stat even if the build fails due to too large
2364# system image.
2365INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002366INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2367$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002368$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002369 @echo Installed file list: $@
2370 @mkdir -p $(dir $@)
2371 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002372 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002373 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002374
2375.PHONY: installed-file-list
2376installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002377
2378$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002379
2380systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002381 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002382BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2383
The Android Open Source Project88b60792009-03-03 19:28:42 -08002384# $(1): output file
2385define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002386 @echo "Target system fs image: $(1)"
2387 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002388 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002389 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002390 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002391 $(BUILD_IMAGE) \
2392 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2393 || ( mkdir -p $${DIST_DIR}; \
2394 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2395 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002396endef
2397
Dan Willemsen6b72c732019-06-12 21:33:38 +00002398ifeq ($(BOARD_AVB_ENABLE),true)
2399$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2400endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002401$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002402 $(call build-systemimage-target,$@)
2403
Tao Baoe9d61b02018-08-20 21:09:07 -07002404INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002405SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002406
Tao Baoe9d61b02018-08-20 21:09:07 -07002407# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2408# compatibility, in case device-specific Makefiles still refer to the old name.
2409INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2410
Doug Zongker73ef8252009-07-23 15:12:53 -07002411# The system partition needs room for the recovery image as well. We
2412# now store the recovery image as a binary patch using the boot image
2413# as the source (since they are very similar). Generate the patch so
2414# we can see how big it's going to be, and include that in the system
2415# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002416ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002417ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002418ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002419ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002420diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2421else
2422diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2423endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002424intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2425RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002426$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2427$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002428 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002429 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002430 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002431 @echo "Construct recovery from boot"
2432 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002433 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002434else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2435RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002436endif # BOARD_USES_FULL_RECOVERY_IMAGE
2437endif # INSTALLED_RECOVERYIMAGE_TARGET
2438endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002439
Yifan Hong9a3cad92020-04-27 19:06:59 -07002440$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002441 @echo "Install system fs image: $@"
2442 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002443 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002444
Tao Baoe9d61b02018-08-20 21:09:07 -07002445systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002446
2447.PHONY: systemimage-nodeps snod
2448systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002449 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002450 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002451 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002452 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002453ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002454 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002455endif
2456
Dan Willemsen67495202019-01-16 12:42:05 -08002457endif # BUILDING_SYSTEM_IMAGE
2458
Anton Hansson30e061b2018-11-12 13:36:46 +00002459.PHONY: sync syncsys
2460sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002461
Ying Wang3a61eeb2016-03-11 10:32:01 -08002462# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002463# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002464.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002465platform:
2466 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002467
2468.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002469platform-java:
2470 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002471
Ying Wang3a61eeb2016-03-11 10:32:01 -08002472# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002473# data partition image
2474INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002475 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002476
Dan Willemsen67495202019-01-16 12:42:05 -08002477ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002478userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002479 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002480BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2481
Ying Wangbd93d422011-10-28 17:02:30 -07002482define build-userdataimage-target
2483 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2484 @mkdir -p $(TARGET_OUT_DATA)
2485 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002486 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002487 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002488 $(BUILD_IMAGE) \
2489 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2490 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2491 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002492endef
2493
Joe Onorato64d85d02009-04-09 19:31:12 -07002494# We just build this directly to the install location.
2495INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002496INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2497 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002498 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002499$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002500 $(build-userdataimage-target)
2501
2502.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002503userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002504 $(build-userdataimage-target)
2505
Dan Willemsen67495202019-01-16 12:42:05 -08002506endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002507
Andreas Gampe039b5c72017-03-24 16:06:31 -07002508# ASAN libraries in the system image - build rule.
2509ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2510 $(TARGET_OUT_SHARED_LIBRARIES) \
2511 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2512 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2513 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002514# Extra options: Enforce the system user for the files to avoid having to change ownership.
2515ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002516# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2517# enough space.
2518$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002519 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 -07002520
The Android Open Source Project88b60792009-03-03 19:28:42 -08002521# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002522# partition table image
2523ifdef BOARD_BPT_INPUT_FILES
2524
2525BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002526BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002527
2528INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2529 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002530 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002531 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2532
2533ifdef BOARD_BPT_DISK_SIZE
2534INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2535endif
2536
2537define build-bptimage-target
2538 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2539 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2540endef
2541
2542INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002543$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2544 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2545
David Zeuthen25328622016-04-08 15:08:03 -04002546$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2547 $(build-bptimage-target)
2548
2549.PHONY: bptimage-nodeps
2550bptimage-nodeps:
2551 $(build-bptimage-target)
2552
2553endif # BOARD_BPT_INPUT_FILES
2554
2555# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002556# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002557ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002558INTERNAL_CACHEIMAGE_FILES := \
2559 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2560
2561cacheimage_intermediates := \
2562 $(call intermediates-dir-for,PACKAGING,cache)
2563BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2564
2565define build-cacheimage-target
2566 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2567 @mkdir -p $(TARGET_OUT_CACHE)
2568 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002569 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002570 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002571 $(BUILD_IMAGE) \
2572 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2573 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2574 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002575endef
2576
2577# We just build this directly to the install location.
2578INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002579$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002580 $(build-cacheimage-target)
2581
2582.PHONY: cacheimage-nodeps
2583cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2584 $(build-cacheimage-target)
2585
Dan Willemsen67495202019-01-16 12:42:05 -08002586else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002587# we need to ignore the broken cache link when doing the rsync
2588IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002589endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002590
David Zeuthen0eb10972016-09-28 17:55:27 -04002591# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002592# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002593ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002594ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002595# Marker file to identify that odex files are installed
2596INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2597ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2598$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2599 $(hide) touch $@
2600endif
2601
Alex Light4e358ab2016-06-16 14:47:10 -07002602INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2603 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002604 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002605
Colin Cross6db5b0e2018-11-16 21:26:33 -08002606# system_other dex files are installed as a side-effect of installing system image files
2607INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2608
Alex Light4e358ab2016-06-16 14:47:10 -07002609INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002610INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2611$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002612$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002613 @echo Installed file list: $@
2614 @mkdir -p $(dir $@)
2615 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002616 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002617 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002618
Bowgo Tsai867ab662019-01-29 13:30:18 +08002619# Determines partition size for system_other.img.
2620ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2621ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2622INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2623endif
2624endif
2625
2626ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2627INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2628endif
2629
Alex Light4e358ab2016-06-16 14:47:10 -07002630systemotherimage_intermediates := \
2631 $(call intermediates-dir-for,PACKAGING,system_other)
2632BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2633
2634# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2635define build-systemotherimage-target
2636 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2637 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2638 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002639 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002640 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002641 $(BUILD_IMAGE) \
2642 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2643 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2644 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002645endef
2646
2647# We just build this directly to the install location.
2648INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002649ifneq (true,$(SANITIZE_LITE))
2650# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002651$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2652 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002653endif
Alex Light4e358ab2016-06-16 14:47:10 -07002654
2655.PHONY: systemotherimage-nodeps
2656systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2657 $(build-systemotherimage-target)
2658
Dan Willemsen67495202019-01-16 12:42:05 -08002659endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002660
2661
2662# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002663# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002664ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002665INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002666 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002667 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002668
Ying Wang8da19e32015-09-15 14:22:12 -07002669
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002670# Create symlink /vendor/odm to /odm if necessary.
2671ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002672 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002673endif
2674
Yifan Honge51dff22020-06-23 17:26:57 -07002675# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2676# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2677#
2678# On devices with a vendor_dlkm partition,
2679# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2680# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2681# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2682# are hidden.
2683# On devices without a vendor_dlkm partition,
2684# - /vendor/lib/modules stores vendor DLKMs directly.
2685# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2686# See system/core/rootdir/Android.mk for a list of created symlinks.
2687# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2688# are not guaranteed to exist on all devices.
2689ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002690 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 -07002691endif
2692
Colin Crossbd382142020-08-26 15:08:57 -07002693INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2694INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2695$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2696$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2697 @echo Installed file list: $@
2698 @mkdir -p $(dir $@)
2699 @rm -f $@
2700 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2701 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002702
Ying Wanga0febe52013-03-20 11:02:05 -07002703vendorimage_intermediates := \
2704 $(call intermediates-dir-for,PACKAGING,vendor)
2705BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002706define build-vendorimage-target
2707 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2708 @mkdir -p $(TARGET_OUT_VENDOR)
2709 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002710 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002711 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002712 $(BUILD_IMAGE) \
2713 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2714 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002715 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002716endef
2717
2718# We just build this directly to the install location.
2719INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002720$(INSTALLED_VENDORIMAGE_TARGET): \
2721 $(INTERNAL_USERIMAGES_DEPS) \
2722 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002723 $(INSTALLED_FILES_FILE_VENDOR) \
2724 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002725 $(build-vendorimage-target)
2726
Steven Morelanda2e734d2017-03-07 12:10:09 -08002727.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002728vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002729 $(build-vendorimage-target)
2730
Colin Cross91a52272017-06-20 16:57:52 -07002731sync: $(INTERNAL_VENDORIMAGE_FILES)
2732
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002733else ifdef BOARD_PREBUILT_VENDORIMAGE
2734INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2735$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2736endif
Ying Wanga0febe52013-03-20 11:02:05 -07002737
Ying Wang9f8e8db2011-11-04 11:37:01 -07002738# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002739# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002740ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002741INTERNAL_PRODUCTIMAGE_FILES := \
2742 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002743 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002744
2745INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002746INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2747$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002748$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002749 @echo Installed file list: $@
2750 @mkdir -p $(dir $@)
2751 @rm -f $@
2752 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002753 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002754
2755productimage_intermediates := \
2756 $(call intermediates-dir-for,PACKAGING,product)
2757BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2758define build-productimage-target
2759 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2760 @mkdir -p $(TARGET_OUT_PRODUCT)
2761 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002762 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002763 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002764 $(BUILD_IMAGE) \
2765 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2766 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2767 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002768endef
2769
2770# We just build this directly to the install location.
2771INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002772$(INSTALLED_PRODUCTIMAGE_TARGET): \
2773 $(INTERNAL_USERIMAGES_DEPS) \
2774 $(INTERNAL_PRODUCTIMAGE_FILES) \
2775 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002776 $(build-productimage-target)
2777
2778.PHONY: productimage-nodeps pnod
2779productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2780 $(build-productimage-target)
2781
2782sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2783
2784else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2785INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2786$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2787endif
2788
2789# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002790# system_ext partition image
2791ifdef BUILDING_SYSTEM_EXT_IMAGE
2792INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2793 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002794 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002795
Justin Yun6151e3f2019-06-25 15:58:13 +09002796INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2797INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2798$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2799$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002800 @echo Installed file list: $@
2801 @mkdir -p $(dir $@)
2802 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002803 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002804 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002805
Justin Yun6151e3f2019-06-25 15:58:13 +09002806system_extimage_intermediates := \
2807 $(call intermediates-dir-for,PACKAGING,system_ext)
2808BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2809define build-system_extimage-target
2810 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2811 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2812 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2813 $(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 -07002814 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002815 $(BUILD_IMAGE) \
2816 $(TARGET_OUT_SYSTEM_EXT) \
2817 $(system_extimage_intermediates)/system_ext_image_info.txt \
2818 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2819 $(TARGET_OUT)
2820 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002821endef
2822
2823# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002824INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002825$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2826 $(INTERNAL_USERIMAGES_DEPS) \
2827 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2828 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002829 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002830
Justin Yun6151e3f2019-06-25 15:58:13 +09002831.PHONY: systemextimage-nodeps senod
2832systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2833 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002834
Justin Yun6151e3f2019-06-25 15:58:13 +09002835sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002836
Justin Yun6151e3f2019-06-25 15:58:13 +09002837else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2838INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2839$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002840endif
2841
2842# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002843# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002844ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002845INTERNAL_ODMIMAGE_FILES := \
2846 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002847 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002848
Colin Crossbd382142020-08-26 15:08:57 -07002849# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2850# /odm/lib/modules -> /odm_dlkm/lib/modules
2851#
2852# On devices with a odm_dlkm partition,
2853# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2854# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2855# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2856# are hidden.
2857# On devices without a odm_dlkm partition,
2858# - /odm/lib/modules stores odm DLKMs directly.
2859# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2860# See system/core/rootdir/Android.mk for a list of created symlinks.
2861# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2862# are not guaranteed to exist on all devices.
2863ifdef BOARD_USES_ODM_DLKMIMAGE
2864 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
2865endif
2866
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002867INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2868INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2869$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002870$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002871 @echo Installed file list: $@
2872 @mkdir -p $(dir $@)
2873 @rm -f $@
2874 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002875 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002876
2877odmimage_intermediates := \
2878 $(call intermediates-dir-for,PACKAGING,odm)
2879BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2880define build-odmimage-target
2881 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2882 @mkdir -p $(TARGET_OUT_ODM)
2883 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2884 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002885 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002886 $(BUILD_IMAGE) \
2887 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2888 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2889 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002890endef
2891
2892# We just build this directly to the install location.
2893INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002894$(INSTALLED_ODMIMAGE_TARGET): \
2895 $(INTERNAL_USERIMAGES_DEPS) \
2896 $(INTERNAL_ODMIMAGE_FILES) \
2897 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002898 $(build-odmimage-target)
2899
2900.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002901odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002902 $(build-odmimage-target)
2903
2904sync: $(INTERNAL_ODMIMAGE_FILES)
2905
2906else ifdef BOARD_PREBUILT_ODMIMAGE
2907INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2908$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2909endif
2910
2911# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002912# vendor_dlkm partition image
2913ifdef BUILDING_VENDOR_DLKM_IMAGE
2914INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2915 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002916 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002917
2918INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2919INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2920$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2921$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2922 @echo Installed file list: $@
2923 @mkdir -p $(dir $@)
2924 @rm -f $@
2925 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2926 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2927
2928vendor_dlkmimage_intermediates := \
2929 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2930BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2931define build-vendor_dlkmimage-target
2932 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2933 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2934 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2935 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2936 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2937 $(BUILD_IMAGE) \
2938 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2939 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2940 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2941endef
2942
2943# We just build this directly to the install location.
2944INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2945$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2946 $(INTERNAL_USERIMAGES_DEPS) \
2947 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2948 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2949 $(build-vendor_dlkmimage-target)
2950
2951.PHONY: vendor_dlkmimage-nodeps vdnod
2952vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2953 $(build-vendor_dlkmimage-target)
2954
2955sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2956
2957else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2958INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2959$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2960endif
2961
2962# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07002963# odm_dlkm partition image
2964ifdef BUILDING_ODM_DLKM_IMAGE
2965INTERNAL_ODM_DLKMIMAGE_FILES := \
2966 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002967 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002968
2969INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
2970INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
2971$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
2972$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2973 @echo Installed file list: $@
2974 @mkdir -p $(dir $@)
2975 @rm -f $@
2976 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
2977 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2978
2979odm_dlkmimage_intermediates := \
2980 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
2981BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
2982define build-odm_dlkmimage-target
2983 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
2984 @mkdir -p $(TARGET_OUT_ODM_DLKM)
2985 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
2986 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
2987 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2988 $(BUILD_IMAGE) \
2989 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
2990 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
2991 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
2992endef
2993
2994# We just build this directly to the install location.
2995INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
2996$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
2997 $(INTERNAL_USERIMAGES_DEPS) \
2998 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
2999 $(INSTALLED_FILES_FILE_ODM_DLKM)
3000 $(build-odm_dlkmimage-target)
3001
3002.PHONY: odm_dlkmimage-nodeps odnod
3003odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3004 $(build-odm_dlkmimage-target)
3005
3006sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3007
3008else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3009INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3010$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3011endif
3012
3013
3014# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003015# dtbo image
3016ifdef BOARD_PREBUILT_DTBOIMAGE
3017INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3018
3019ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003020$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003021 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3022 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003023 --image $@ \
3024 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3025 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3026 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003027else
3028$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3029 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3030endif
3031
Tao Bao0da43472018-08-22 22:53:41 -07003032endif # BOARD_PREBUILT_DTBOIMAGE
3033
3034# Returns a list of image targets corresponding to the given list of partitions. For example, it
3035# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3036# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003037# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003038define images-for-partitions
3039$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3040endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003041
3042# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003043# custom images
3044INSTALLED_CUSTOMIMAGES_TARGET :=
3045
3046ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3047INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3048
3049# Sign custom image.
3050# $(1): the prebuilt custom image.
3051# $(2): the mount point of the prebuilt custom image.
3052# $(3): the signed custom image target.
3053define sign_custom_image
3054$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3055 @echo Target custom image: $(3)
3056 mkdir -p $(dir $(3))
3057 cp $(1) $(3)
3058ifeq ($(BOARD_AVB_ENABLE),true)
3059 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3060 $(AVBTOOL) add_hashtree_footer \
3061 --image $(3) \
3062 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3063 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3064 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3065 --partition_name $(2) \
3066 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3067 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3068endif
3069INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3070endef
3071
3072$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3073 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3074 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3075endif
3076
3077# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003078# vbmeta image
3079ifeq ($(BOARD_AVB_ENABLE),true)
3080
3081BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003082AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003083
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003084ifdef BOARD_AVB_KEY_PATH
3085$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3086else
3087# If key path isn't specified, use the 4096-bit test key.
3088BOARD_AVB_ALGORITHM := SHA256_RSA4096
3089BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3090endif
3091
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003092# AVB signing for system_other.img.
3093ifdef BUILDING_SYSTEM_OTHER_IMAGE
3094ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3095$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3096else
3097# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3098BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3099BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3100endif
3101
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003102$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3103 @echo Extracting system_other avb key: $@
3104 @rm -f $@
3105 @mkdir -p $(dir $@)
3106 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003107
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003108ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3109BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3110endif
3111
3112BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3113endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3114
Tao Bao744c4c72018-08-20 21:09:07 -07003115INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003116 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003117 $(BOARD_AVB_VBMETA_VENDOR)
3118
3119# Not allowing the same partition to appear in multiple groups.
3120ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003121 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003122endif
3123
cfig1aeef722019-09-20 22:45:06 +08003124# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3125# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3126# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003127ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003128ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3129$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003130 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003131 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3132endif
3133endif
3134
Bowgo Tsai9b548012019-05-14 16:57:03 +08003135# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003136
3137BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003138 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003139 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003140 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3141
3142BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003143 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003144 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003145 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3146
Justin Yun6151e3f2019-06-25 15:58:13 +09003147BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003148 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003149 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3150 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003151
Bowgo Tsai9b548012019-05-14 16:57:03 +08003152BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003153 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003154 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3155
Tao Bao19b02fe2019-10-09 00:04:28 -07003156BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3157 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3158
3159BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3160 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3161
Bowgo Tsai9b548012019-05-14 16:57:03 +08003162BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003163 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003164 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3165
3166BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003167 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003168 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3169
Yifan Hongcfb917a2020-05-07 14:58:20 -07003170BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3171 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3172 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3173
Yifan Hongf496f1b2020-07-15 16:52:59 -07003174BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3175 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3176 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3177
Tao Bao19b02fe2019-10-09 00:04:28 -07003178BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3179 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3180
Bowgo Tsai9b548012019-05-14 16:57:03 +08003181# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003182ifdef BOOT_SECURITY_PATCH
3183BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3184 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3185endif
3186
3187ifdef VENDOR_SECURITY_PATCH
3188BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3189 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3190endif
3191
3192ifdef ODM_SECURITY_PATCH
3193BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3194 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3195endif
3196
Yifan Hongcfb917a2020-05-07 14:58:20 -07003197ifdef VENDOR_DLKM_SECURITY_PATCH
3198BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3199 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3200endif
3201
Yifan Hongf496f1b2020-07-15 16:52:59 -07003202ifdef ODM_DLKM_SECURITY_PATCH
3203BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3204 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3205endif
3206
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003207BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003208VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003209DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3210SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3211VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003212RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003213PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003214SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003215ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003216VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003217ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003218
Tao Bao0da43472018-08-22 22:53:41 -07003219# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003220# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003221define _check-and-set-avb-chain-args
3222$(eval part := $(1))
3223$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003224
3225$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3226$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3227$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3228$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3229$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3230$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3231$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3232$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3233
3234# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3235$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3236$(eval $(_signing_args) := \
3237 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3238
cfig1aeef722019-09-20 22:45:06 +08003239# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3240# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003241$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003242 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3243 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003244
Tao Bao744c4c72018-08-20 21:09:07 -07003245# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003246# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003247$(if $(filter $(part),$(part:vbmeta_%=%)),\
3248 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3249 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003250endef
3251
Tao Bao0da43472018-08-22 22:53:41 -07003252# Checks and sets the required build variables for an AVB partition. The partition will be
3253# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003254# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3255# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003256# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3257# but vbmeta would capture the image descriptor of only the first boot
3258# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003259# $(1): Partition name, e.g. boot or system.
3260define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003261$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003262$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003263 $(if $(_in_chained_vbmeta),\
3264 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003265 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003266 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003267 $(if $(filter boot,$(1)),\
3268 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3269 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3270 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3271 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003272endef
3273
Hongguang Chenf23364d2020-04-27 18:36:36 -07003274# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3275# $(1): the custom partition to enable AVB chain.
3276define check-and-set-custom-avb-chain-args
3277$(eval part := $(1))
3278$(eval PART=$(call to-upper,$(part)))
3279$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3280$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3281
3282INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3283 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3284endef
3285
Tao Baob1a2e352018-08-14 16:17:12 -07003286ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003287$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003288endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003289
Steve Mucklee1b10862019-07-10 10:49:37 -07003290ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3291$(eval $(call check-and-set-avb-args,vendor_boot))
3292endif
3293
Tao Bao0da43472018-08-22 22:53:41 -07003294$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003295
3296ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003297$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003298endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003299
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003300ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003301$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003302endif
3303
Justin Yun6151e3f2019-06-25 15:58:13 +09003304ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3305$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003306endif
3307
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003308ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003309$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003310endif
3311
Yifan Hongcfb917a2020-05-07 14:58:20 -07003312ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3313$(eval $(call check-and-set-avb-args,vendor_dlkm))
3314endif
3315
Yifan Hongf496f1b2020-07-15 16:52:59 -07003316ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3317$(eval $(call check-and-set-avb-args,odm_dlkm))
3318endif
3319
Yueyao Zhu211c9012017-04-27 00:34:50 -07003320ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003321$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003322endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003323
David Zeuthen8fecb282017-12-01 16:24:01 -05003324ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003325$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003326endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003327
David Anderson7709ab22018-10-15 14:41:34 -07003328# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3329ifdef BOARD_AVB_VBMETA_SYSTEM
3330$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003331endif
3332
3333ifdef BOARD_AVB_VBMETA_VENDOR
3334$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3335endif
3336
Hongguang Chenf23364d2020-04-27 18:36:36 -07003337ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3338$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3339 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3340endif
3341
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003342# Add kernel cmdline descriptor for kernel to mount system.img as root with
3343# dm-verity. This works when system.img is either chained or not-chained:
3344# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3345# cmdline descriptor to system.img
3346# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3347# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003348ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003349ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003350BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003351endif
David Anderson8916a2a2018-09-18 15:46:59 -07003352endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003353
Tao Bao0da43472018-08-22 22:53:41 -07003354BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003355BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003356BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3357
3358ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003359# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003360BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003361endif
Tao Bao0da43472018-08-22 22:53:41 -07003362
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003363ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003364BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003365endif
3366
David Anderson7709ab22018-10-15 14:41:34 -07003367ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3368BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3369 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003370endif
3371
3372ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3373BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3374 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003375endif
3376
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003377# $(1): the directory to extract public keys to
3378define extract-avb-chain-public-keys
3379 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3380 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3381 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003382 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3383 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3384 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003385 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3386 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3387 --output $(1)/system.avbpubkey)
3388 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3389 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3390 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003391 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3392 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3393 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003394 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3395 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3396 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003397 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3398 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3399 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003400 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3401 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3402 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003403 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3404 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3405 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003406 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3407 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3408 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003409 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3410 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3411 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003412 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3413 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3414 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003415 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3416 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3417 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003418 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3419 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3420 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3421 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003422endef
3423
Tao Bao744c4c72018-08-20 21:09:07 -07003424# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3425# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003426# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003427# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3428# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003429# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003430# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003431# $(2): Output filename.
3432define build-chained-vbmeta-image
3433 $(call pretty,"Target chained vbmeta image: $@")
3434 $(hide) $(AVBTOOL) make_vbmeta_image \
3435 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3436 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3437 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3438 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3439 --output $@
3440endef
3441
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003442ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003443ifdef BOARD_AVB_VBMETA_SYSTEM
3444INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3445$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003446 $(AVBTOOL) \
3447 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3448 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003449 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003450endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003451endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003452
3453ifdef BOARD_AVB_VBMETA_VENDOR
3454INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3455$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003456 $(AVBTOOL) \
3457 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3458 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003459 $(call build-chained-vbmeta-image,vbmeta_vendor)
3460endif
3461
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003462define build-vbmetaimage-target
3463 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003464 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3465 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003466 $(hide) $(AVBTOOL) make_vbmeta_image \
3467 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003468 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003469 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3470 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003471 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003472endef
3473
Paul Trautrim4e143232019-08-13 16:30:57 +09003474ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003475INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003476$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3477 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3478
David Zeuthen8fecb282017-12-01 16:24:01 -05003479$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003480 $(AVBTOOL) \
3481 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003482 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003483 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3484 $(INSTALLED_VENDORIMAGE_TARGET) \
3485 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003486 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003487 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003488 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003489 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003490 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003491 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003492 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3493 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3494 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3495 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3496 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3497 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003498 $(build-vbmetaimage-target)
3499
3500.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003501vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3502 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003503vbmetaimage-nodeps:
3504 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003505endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003506
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003507endif # BOARD_AVB_ENABLE
3508
3509# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003510# Check VINTF of build
3511
Yifan Hongf496f1b2020-07-15 16:52:59 -07003512# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003513ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003514
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003515intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3516check_vintf_all_deps :=
3517
Yifan Hongaf9b0702020-01-21 12:46:57 -08003518# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3519# because they are only used for prebuilt images.
3520check_vintf_common_srcs_patterns := \
3521 $(TARGET_OUT)/etc/vintf/% \
3522 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3523 $(TARGET_OUT_ODM)/etc/vintf/% \
3524 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3525 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3526
3527check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3528 $(INTERNAL_SYSTEMIMAGE_FILES) \
3529 $(INTERNAL_VENDORIMAGE_FILES) \
3530 $(INTERNAL_ODMIMAGE_FILES) \
3531 $(INTERNAL_PRODUCTIMAGE_FILES) \
3532 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3533))
3534check_vintf_common_srcs_patterns :=
3535
3536check_vintf_has_system :=
3537check_vintf_has_vendor :=
3538
Yifan Hong28ffd732020-03-13 13:11:10 -07003539ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3540$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3541endif
3542ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3543$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3544endif
3545
Yifan Hong605ea042020-01-14 21:36:00 +00003546# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003547check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3548ifneq ($(check_vintf_system_deps),)
3549check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003550check_vintf_system_log := $(intermediates)/check_vintf_system_log
3551check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003552$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003553 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3554check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003555endif # check_vintf_system_deps
3556check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003557
3558# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003559check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3560ifneq ($(check_vintf_vendor_deps),)
3561check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003562check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3563check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003564# Check vendor SKU=(empty) case when:
3565# - DEVICE_MANIFEST_FILE is not empty; OR
3566# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003567$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003568 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3569 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003570 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003571$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003572 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3573 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3574 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3575 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003576check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003577endif # check_vintf_vendor_deps
3578check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003579
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003580# -- Check VINTF compatibility of build.
3581# Skip partial builds; only check full builds. Only check if:
3582# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003583# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003584# - Building product / system_ext / odm images if board has product / system_ext / odm images
3585ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003586ifeq ($(check_vintf_has_system),true)
3587ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003588ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3589ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3590ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3591
3592check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3593check_vintf_all_deps += $(check_vintf_compatible_log)
3594
3595check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003596check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003597
3598# -- Kernel version and configurations.
3599ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3600
Yifan Hong605ea042020-01-14 21:36:00 +00003601BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3602BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3603
3604my_board_extracted_kernel :=
3605
3606# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3607# from INSTALLED_KERNEL_TARGET.
3608ifdef BOARD_KERNEL_CONFIG_FILE
3609ifdef BOARD_KERNEL_VERSION
3610$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3611 cp $< $@
3612$(BUILT_KERNEL_VERSION_FILE):
3613 echo $(BOARD_KERNEL_VERSION) > $@
3614
3615my_board_extracted_kernel := true
3616endif # BOARD_KERNEL_VERSION
3617endif # BOARD_KERNEL_CONFIG_FILE
3618
3619ifneq ($(my_board_extracted_kernel),true)
3620ifndef INSTALLED_KERNEL_TARGET
3621$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3622 is true. Information about the updated kernel cannot be built into OTA update package. \
3623 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3624 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3625 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3626 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3627 manually.)
3628else
3629
3630# Tools for decompression that is not in PATH.
3631# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3632# Algorithms that are in the script but not in this list will be found in PATH.
3633my_decompress_tools := \
3634 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3635
3636$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3637$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3638$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003639$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3640 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003641 --output-configs $@ \
3642 --output-version $(BUILT_KERNEL_VERSION_FILE)
3643
3644my_decompress_tools :=
3645
3646endif # my_board_extracted_kernel
3647my_board_extracted_kernel :=
3648
3649endif # INSTALLED_KERNEL_TARGET
3650
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003651check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3652check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3653
3654endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3655
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003656check_vintf_compatible_args += \
3657 --dirmap /system:$(TARGET_OUT) \
3658 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3659 --dirmap /odm:$(TARGET_OUT_ODM) \
3660 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3661 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3662
3663ifdef PRODUCT_SHIPPING_API_LEVEL
3664check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3665endif # PRODUCT_SHIPPING_API_LEVEL
3666
3667$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3668$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003669# Check ODM SKU=(empty) case when:
3670# - ODM_MANIFEST_FILES is not empty; OR
3671# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003672$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003673 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3674 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003675 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003676# Check vendor SKU=(empty) case when:
3677# - DEVICE_MANIFEST_FILE is not empty; OR
3678# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003679$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003680 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3681 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003682 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003683$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3684 @echo -n -e 'Deps: \n ' > $@
3685 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3686 @echo -n -e 'Args: \n ' >> $@
3687 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003688 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3689 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003690 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003691 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3692 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3693 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003694
3695check_vintf_compatible_log :=
3696check_vintf_compatible_args :=
3697check_vintf_compatible_deps :=
3698
3699endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3700endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3701endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003702endif # check_vintf_has_vendor
3703endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003704endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3705
3706# Add all logs of VINTF checks to dist builds
3707droid_targets: $(check_vintf_all_deps)
3708$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3709
3710# Helper alias to check all VINTF of current build.
3711.PHONY: check-vintf-all
3712check-vintf-all: $(check_vintf_all_deps)
3713 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3714
Yifan Hongaf9b0702020-01-21 12:46:57 -08003715check_vintf_has_vendor :=
3716check_vintf_has_system :=
3717check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003718check_vintf_all_deps :=
3719intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003720endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003721
3722# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003723# Check image sizes <= size of super partition
3724
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003725ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003726
3727ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003728
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003729# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003730# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003731define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003732 mkdir -p $(dir $(1))
3733 rm -f $(1)
3734 $(call dump-super-image-info, $(1))
3735 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3736 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003737 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003738endef
3739
Yifan Hong30910932019-10-25 20:36:55 -07003740check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3741droid_targets: $(check_all_partition_sizes_log)
3742$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003743
Yifan Hong30910932019-10-25 20:36:55 -07003744$(check_all_partition_sizes_log): \
3745 $(CHECK_PARTITION_SIZES) \
3746 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3747 $(call check-all-partition-sizes-target, \
3748 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3749 $@)
3750
3751.PHONY: check-all-partition-sizes
3752check-all-partition-sizes: $(check_all_partition_sizes_log)
3753
3754.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003755check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003756 $(call check-all-partition-sizes-target, \
3757 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003758
Yifan Hong2dae5722018-07-31 12:47:27 -07003759endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003760
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003761endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003762
3763# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003764# bring in the installer image generation defines if necessary
3765ifeq ($(TARGET_USE_DISKINSTALLER),true)
3766include bootable/diskinstaller/config.mk
3767endif
3768
3769# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003770# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003771
Ying Wangbd2d0242015-09-22 11:17:52 -07003772ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003773 build_ota_package := false
3774 build_otatools_package := false
3775else
Tao Bao9be20c72019-04-08 21:11:59 -07003776 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003777 build_ota_package := true
3778 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3779 build_ota_package := false
3780 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003781 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003782 build_ota_package := false
3783 endif
3784 ifeq ($(TARGET_PRODUCT),sdk)
3785 build_ota_package := false
3786 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003787 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3788 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3789 build_ota_package := false
3790 endif
3791 ifeq ($(TARGET_NO_KERNEL),true)
3792 build_ota_package := false
3793 endif
3794 ifeq ($(recovery_fstab),)
3795 build_ota_package := false
3796 endif
3797 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003798
Tao Bao9be20c72019-04-08 21:11:59 -07003799 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003800 build_otatools_package := true
3801 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3802 build_otatools_package := false
3803 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003804endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003805
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003806ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003807
3808INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003809 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003810 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003811 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003812 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003813 append2simg \
3814 avbtool \
3815 blk_alloc_to_base_fs \
3816 boot_signer \
3817 brillo_update_payload \
3818 brotli \
3819 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003820 build_image \
3821 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003822 build_verity_metadata \
3823 build_verity_tree \
3824 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003825 check_ota_package_signature \
3826 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003827 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003828 checkvintf \
3829 delta_generator \
3830 e2fsck \
3831 e2fsdroid \
3832 fc_sort \
3833 fec \
3834 fs_config \
3835 generate_verity_key \
3836 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003837 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003838 imgdiff \
3839 libconscrypt_openjdk_jni \
3840 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003841 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003842 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003843 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003844 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003845 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003846 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003847 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003848 mkbootfs \
3849 mkbootimg \
3850 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003851 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003852 mkf2fsuserimg.sh \
3853 mksquashfs \
3854 mksquashfsimage.sh \
3855 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003856 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003857 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003858 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003859 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003860 sign_apex \
3861 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003862 signapk \
3863 simg2img \
3864 sload_f2fs \
3865 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003866 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003867 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003868 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003869 verity_signer \
3870 verity_verifier \
3871 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003872
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003873# Additional tools to unpack and repack the apex file.
3874INTERNAL_OTATOOLS_MODULES += \
3875 apexer \
3876 deapexer \
3877 debugfs_static \
3878 merge_zips \
3879 resize2fs \
3880 soong_zip \
3881
Anton Hansson8dab0a62019-03-28 15:45:40 +00003882ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003883INTERNAL_OTATOOLS_MODULES += \
3884 futility \
3885 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003886endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003887
Tao Bao96daeeb2019-05-01 21:17:13 -07003888INTERNAL_OTATOOLS_FILES := \
3889 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003890
Ying Wang06898662010-06-17 17:52:18 -07003891.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003892otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003893
Tao Bao96daeeb2019-05-01 21:17:13 -07003894# For each module, recursively resolve its host shared library dependencies. Then we have a full
3895# list of modules whose installed files need to be packed.
3896INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3897 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3898 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003899
Tao Bao96daeeb2019-05-01 21:17:13 -07003900INTERNAL_OTATOOLS_PACKAGE_FILES := \
3901 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3902
3903INTERNAL_OTATOOLS_PACKAGE_FILES += \
3904 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3905 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003906
3907ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003908INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003909 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003910 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003911endif
3912ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003913INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003914 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3915 -name "atx_metadata.bin"))
3916endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003917ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003918INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003919 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003920endif
3921
Tao Bao96daeeb2019-05-01 21:17:13 -07003922INTERNAL_OTATOOLS_RELEASETOOLS := \
3923 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3924 \( -type f -o -type l \) -print))
3925
3926BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3927$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3928$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3929$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3930$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003931$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003932 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003933 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3934 mkdir -p $(dir $@)
3935 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3936 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003937 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003938 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003939
3940.PHONY: otatools-package
3941otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3942
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003943endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003944
The Android Open Source Project88b60792009-03-03 19:28:42 -08003945# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003946# misc_info.txt
3947
3948INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3949
3950ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3951# default to common dir for device vendor
3952tool_extensions := $(TARGET_DEVICE_DIR)/../common
3953else
3954tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3955endif
3956.KATI_READONLY := tool_extensions
3957
Steve Muckle903a1ca2020-05-07 17:32:10 -07003958# $1: boot image file name
3959define misc_boot_size
3960$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3961endef
3962
Daniel Normane1e48082019-06-27 13:55:23 -07003963$(INSTALLED_MISC_INFO_TARGET):
3964 rm -f $@
3965 $(call pretty,"Target misc_info.txt: $@")
3966 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3967 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3968ifdef BOARD_FLASH_BLOCK_SIZE
3969 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3970endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07003971ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
3972 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
3973 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07003974endif
3975ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3976 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07003977else
3978 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003979endif
J. Avila98cd4cc2020-06-10 20:09:10 +00003980ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
3981 echo "lz4_ramdisks=true" >> $@
3982endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003983ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3984 echo "vendor_boot=true" >> $@
3985 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3986endif
Daniel Normane1e48082019-06-27 13:55:23 -07003987ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3988 $(hide) echo "no_recovery=true" >> $@
3989endif
3990ifdef BOARD_INCLUDE_RECOVERY_DTBO
3991 $(hide) echo "include_recovery_dtbo=true" >> $@
3992endif
3993ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3994 $(hide) echo "include_recovery_acpio=true" >> $@
3995endif
3996ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3997 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3998endif
3999ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4000 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4001 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4002else
4003 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4004endif
4005 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4006 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4007ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4008 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4009endif
4010 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004011 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004012 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4013 $(hide) echo "multistage_support=1" >> $@
4014 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4015ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4016 $(hide) echo "build_generic_ota_package=true" >> $@
4017endif
4018ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4019 # OTA scripts are only interested in fingerprint related properties
4020 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4021endif
4022ifneq (,$(filter address, $(SANITIZE_TARGET)))
4023 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4024 $(hide) echo "userdata_img_with_data=true" >> $@
4025endif
4026ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4027 $(hide) echo "full_recovery_image=true" >> $@
4028endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004029ifdef BOARD_USES_VENDORIMAGE
4030 $(hide) echo "board_uses_vendorimage=true" >> $@
4031endif
Daniel Normane1e48082019-06-27 13:55:23 -07004032ifeq ($(BOARD_AVB_ENABLE),true)
4033 $(hide) echo "avb_enable=true" >> $@
4034 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4035 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4036 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4037 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4038ifdef BOARD_AVB_BOOT_KEY_PATH
4039 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4040 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4041 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4042endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004043 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4044ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4045 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4046 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4047 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4048endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004049 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4050ifdef BOARD_AVB_RECOVERY_KEY_PATH
4051 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4052 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4053 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4054endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004055ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4056 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4057 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4058 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4059 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4060 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4061 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4062 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4063 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4064endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004065ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4066 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4067 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4068 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4069 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4070 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4071endif # BOARD_AVB_VBMETA_SYSTEM
4072ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4073 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4074 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4075 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4076 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4077 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4078endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4079endif # BOARD_AVB_ENABLE
4080ifdef BOARD_BPT_INPUT_FILES
4081 $(hide) echo "board_bpt_enable=true" >> $@
4082 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4083 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4084endif
4085ifdef BOARD_BPT_DISK_SIZE
4086 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4087endif
4088 $(call generate-userimage-prop-dictionary, $@)
4089ifeq ($(AB_OTA_UPDATER),true)
4090 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4091 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4092 $(hide) echo "ab_update=true" >> $@
4093endif
Yifan Hong65afc072020-04-17 10:08:10 -07004094ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4095 $(hide) echo "allow_non_ab=true" >> $@
4096endif
Daniel Normane1e48082019-06-27 13:55:23 -07004097ifdef BOARD_PREBUILT_DTBOIMAGE
4098 $(hide) echo "has_dtbo=true" >> $@
4099ifeq ($(BOARD_AVB_ENABLE),true)
4100 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4101 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4102ifdef BOARD_AVB_DTBO_KEY_PATH
4103 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4104 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4105 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4106endif # BOARD_AVB_DTBO_KEY_PATH
4107endif # BOARD_AVB_ENABLE
4108endif # BOARD_PREBUILT_DTBOIMAGE
4109 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004110 @# VINTF checks
4111ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4112 $(hide) echo "vintf_enforce=true" >> $@
4113endif
4114ifdef ODM_MANIFEST_SKUS
4115 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4116endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004117ifdef ODM_MANIFEST_FILES
4118 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4119endif
4120ifdef DEVICE_MANIFEST_SKUS
4121 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4122endif
4123ifdef DEVICE_MANIFEST_FILE
4124 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4125endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004126ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4127 $(hide) echo "bootloader_in_update_package=true" >> $@
4128endif
Daniel Normane1e48082019-06-27 13:55:23 -07004129
4130.PHONY: misc_info
4131misc_info: $(INSTALLED_MISC_INFO_TARGET)
4132
4133droidcore: $(INSTALLED_MISC_INFO_TARGET)
4134
4135# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004136# A zip of the directories that map to the target filesystem.
4137# This zip can be used to create an OTA package or filesystem image
4138# as a post-build step.
4139#
4140name := $(TARGET_PRODUCT)
4141ifeq ($(TARGET_BUILD_TYPE),debug)
4142 name := $(name)_debug
4143endif
4144name := $(name)-target_files-$(FILE_NAME_TAG)
4145
4146intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4147BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4148$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4149$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004150 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004151
4152# $(1): Directory to copy
4153# $(2): Location to copy it to
4154# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4155define package_files-copy-root
4156 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4157 mkdir -p $(2) && \
4158 $(ACP) -rd $(strip $(1))/* $(2); \
4159 fi
4160endef
4161
Tao Baoa04fca32015-11-30 12:22:24 -08004162built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004163
4164# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004165ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004166built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004167 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004168endif
4169
The Android Open Source Project88b60792009-03-03 19:28:42 -08004170$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4171
Dan Willemsen653bea92017-03-21 15:47:37 -07004172tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004173$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004174
Sen Jiang4438fd92016-03-07 16:51:01 -08004175ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004176updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004177endif
4178
4179# Build OTA tools if non-A/B is allowed
4180ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004181updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004182endif
Yifan Hong65afc072020-04-17 10:08:10 -07004183
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004184$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004185
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004186# If we are using recovery as boot, output recovery files to BOOT/.
4187ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4188$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4189else
4190$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4191endif
4192
Dan Willemsen653bea92017-03-21 15:47:37 -07004193ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004194 ifdef OSRELEASED_DIRECTORY
4195 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4196 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4197 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4198 endif
Tao Baoa835f382019-07-18 15:55:30 -07004199
4200 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4201 # additionally include radio or bootloader partitions).
4202 ifeq ($(AB_OTA_PARTITIONS),)
4203 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4204 endif
4205endif
4206
4207ifneq ($(AB_OTA_PARTITIONS),)
4208 ifneq ($(AB_OTA_UPDATER),true)
4209 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4210 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004211endif
4212
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004213# Run fs_config while creating the target files package
4214# $1: root directory
4215# $2: add prefix
4216define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004217(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 -08004218endef
4219
Yifan Hong60bfcc42019-11-01 11:39:45 -07004220# Filter out vendor from the list for AOSP targets.
4221# $(1): list
4222define filter-out-missing-vendor
4223$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4224endef
4225
4226# Information related to dynamic partitions and virtual A/B. This information
4227# is needed for building the super image (see dump-super-image-info) and
4228# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004229# $(1): file
4230define dump-dynamic-partitions-info
4231 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4232 echo "use_dynamic_partitions=true" >> $(1))
4233 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4234 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004235 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4236 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4237 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004238 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4239 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004240 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4241 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4242 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4243 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4244 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4245 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004246 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004247 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4248 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4249 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4250 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4251 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004252 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 -07004253 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4254 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004255 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4256 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004257 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4258 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004259 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4260 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4261 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4262 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4263 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4264 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4265 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4266 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004267 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4268 echo "virtual_ab=true" >> $(1))
4269 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4270 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004271endef
4272
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004273# By conditionally including the dependency of the target files package on the
4274# full system image deps, we speed up builds that do not build the system
4275# image.
4276ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004277 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4278endif
4279
4280ifdef BUILDING_USERDATA_IMAGE
4281 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4282endif
4283
4284ifdef BUILDING_SYSTEM_OTHER_IMAGE
4285 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4286endif
4287
4288ifdef BUILDING_VENDOR_BOOT_IMAGE
4289 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
4290endif
4291
4292ifdef BUILDING_RECOVERY_IMAGE
4293 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
4294 # BUILD_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
4295 # commands in build-recoveryimage-target, which would touch the files under
4296 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4297 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4298 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4299 else
4300 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4301 endif
4302 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4303endif
4304
4305# Conditionally depend on the image files if the image is being built so the
4306# target-files.zip rule doesn't wait on the image creation rule, or the image
4307# if it is coming from a prebuilt.
4308
4309ifdef BUILDING_VENDOR_IMAGE
4310 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4311else ifdef BOARD_PREBUILT_VENDORIMAGE
4312 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4313endif
4314
4315ifdef BUILDING_PRODUCT_IMAGE
4316 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4317else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4318 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4319endif
4320
4321ifdef BUILDING_SYSTEM_EXT_IMAGE
4322 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4323else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4324 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4325endif
4326
4327ifdef BUILDING_BOOT_IMAGE
4328 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
4329else ifdef BOARD_PREBUILT_BOOTIMAGE
4330 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4331endif
4332
4333ifdef BUILDING_ODM_IMAGE
4334 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4335else ifdef BOARD_PREBUILT_ODMIMAGE
4336 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4337endif
4338
4339ifdef BUILDING_VENDOR_DLKM_IMAGE
4340 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4341else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4342 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4343endif
4344
4345ifdef BUILDING_ODM_DLKM_IMAGE
4346 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4347else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4348 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004349endif
4350
Isaac Chen9e09d472019-07-05 17:30:41 +08004351ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004352 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4353 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004354endif
4355
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004356ifdef BOARD_PREBUILT_BOOTLOADER
4357$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004358droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004359endif
4360
The Android Open Source Project88b60792009-03-03 19:28:42 -08004361# Depending on the various images guarantees that the underlying
4362# directories are up-to-date.
4363$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004364 $(INSTALLED_RADIOIMAGE_TARGET) \
4365 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004366 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004367 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004368 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004369 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4370 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004371 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004372 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4373 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004374 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004375 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004376 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4377 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4378 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004379 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004380 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004381 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004382 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004383 $(LPMAKE) \
4384 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004385 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004386 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004387 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004388 $(SOONG_ZIP) \
4389 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004390 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004391 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004392 $(BUILT_KERNEL_CONFIGS_FILE) \
4393 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004394 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004395 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004396 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004397 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004398ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004399 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004400 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004401 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004402 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004403ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004404ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004405 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Steve Muckle04b6f052020-08-09 14:36:56 -07004406else # BOARD_USES_RECOVERY_AS_BOOT not true
4407 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4408endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004409endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004410ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004411 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004412else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004413ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004414 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004415endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004416ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004417ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004418 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004419else
Steve Mucklee1b10862019-07-10 10:49:37 -07004420 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004421endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004422endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004423ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004424 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004425endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004426ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004427 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004428endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004429ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004430 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004431endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004432ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004433 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004434endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004435ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004436 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004437endif
Colin Crossa6de2ad2020-08-26 18:40:19 -07004438endif # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004439endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004440 @# Components of the boot image
4441 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004442 $(hide) mkdir -p $(zip_root)/ROOT
4443 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004444 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004445 @# If we are using recovery as boot, this is already done when processing recovery.
4446ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004447ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004448 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004449 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004450endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004451ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004452 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004453endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004454ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004455ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004456 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004457endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004458ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004459 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004460endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004461 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004462ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004463 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004464endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004465ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004466 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004467endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004468else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4469 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4470endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4471endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004472 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4473 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004474 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004475ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4476 mkdir -p $(zip_root)/VENDOR_BOOT
4477 $(call package_files-copy-root, \
4478 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4479ifdef INSTALLED_DTBIMAGE_TARGET
4480 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4481endif
4482ifdef BOARD_KERNEL_BASE
4483 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4484endif
4485ifdef BOARD_KERNEL_PAGESIZE
4486 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4487endif
4488 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4489endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004490ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004491 @# Contents of the system image
4492 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004493 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004494endif
4495ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004496 @# Contents of the data image
4497 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004498 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004499endif
4500ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004501 @# Contents of the vendor image
4502 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004503 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004504endif
Dan Willemsen67495202019-01-16 12:42:05 -08004505ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004506 @# Contents of the product image
4507 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004508 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004509endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004510ifdef BUILDING_SYSTEM_EXT_IMAGE
4511 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004512 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004513 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004514endif
Dan Willemsen67495202019-01-16 12:42:05 -08004515ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004516 @# Contents of the odm image
4517 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004518 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004519endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004520ifdef BUILDING_VENDOR_DLKM_IMAGE
4521 @# Contents of the vendor_dlkm image
4522 $(hide) $(call package_files-copy-root, \
4523 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4524endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004525ifdef BUILDING_ODM_DLKM_IMAGE
4526 @# Contents of the odm_dlkm image
4527 $(hide) $(call package_files-copy-root, \
4528 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4529endif
Dan Willemsen67495202019-01-16 12:42:05 -08004530ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004531 @# Contents of the system_other image
4532 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004533 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004534endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004535 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004536 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004537 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004538ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004539ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004540 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004541 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004542endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004543endif
Doug Zongker8678df42009-06-15 14:30:14 -07004544 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004545 @# build them.
4546 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004547 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004548 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004549ifneq ($(tool_extension),)
4550 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4551endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004552 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004553 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004554 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004555ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4556 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4557 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004558endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004559ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4560 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4561 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004562endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004563ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4564 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4565 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004566endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004567ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4568 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4569 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004570endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004571ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4572 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4573 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004574endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004575ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4576 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4577 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4578endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004579ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4580 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4581 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4582endif
Yifan Hong65afc072020-04-17 10:08:10 -07004583ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004584ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004585 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004586 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004587endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004588endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004589ifeq ($(AB_OTA_UPDATER),true)
4590 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004591 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004592 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004593 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4594 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004595 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4596 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4597 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004598ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004599 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4600 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4601 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004602endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004603endif
Steve Fungdfbab492015-09-24 18:12:33 -07004604ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004605 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004606 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004607endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004608ifdef BOARD_PREBUILT_VENDORIMAGE
4609 $(hide) mkdir -p $(zip_root)/IMAGES
4610 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4611endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004612ifdef BOARD_PREBUILT_PRODUCTIMAGE
4613 $(hide) mkdir -p $(zip_root)/IMAGES
4614 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4615endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004616ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004617 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004618 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004619endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004620ifdef BOARD_PREBUILT_BOOTIMAGE
4621 $(hide) mkdir -p $(zip_root)/IMAGES
4622 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4623endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004624ifdef BOARD_PREBUILT_ODMIMAGE
4625 $(hide) mkdir -p $(zip_root)/IMAGES
4626 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4627endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004628ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004629 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004630 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4631endif
4632ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4633 $(hide) mkdir -p $(zip_root)/IMAGES
4634 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004635endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004636ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004637 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4638 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004639endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004640ifdef BOARD_PREBUILT_BOOTLOADER
4641 $(hide) mkdir -p $(zip_root)/IMAGES
4642 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4643endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004644ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4645 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4646 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4647 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4648endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004649 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4650 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4651 @# INSTALLED_RADIOIMAGE_TARGET.
4652 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4653 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004654 @# Run fs_config on all the system, vendor, boot ramdisk,
4655 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004656ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004657 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004658endif
4659ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004660 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4661endif
Dan Willemsen67495202019-01-16 12:42:05 -08004662ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004663 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4664endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004665ifdef BUILDING_SYSTEM_EXT_IMAGE
4666 $(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 +01004667endif
Dan Willemsen67495202019-01-16 12:42:05 -08004668ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004669 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4670endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004671ifdef BUILDING_VENDOR_DLKM_IMAGE
4672 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4673endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004674ifdef BUILDING_ODM_DLKM_IMAGE
4675 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4676endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004677 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004678 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004679ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004680 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004681 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004682endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004683ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4684 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4685endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004686ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4687 @# 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 -08004688 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4689endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004690ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4691 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4692endif
Dan Willemsen67495202019-01-16 12:42:05 -08004693ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004694 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4695endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004696 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004697ifdef BUILT_KERNEL_CONFIGS_FILE
4698 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4699endif
4700ifdef BUILT_KERNEL_VERSION_FILE
4701 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4702endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004703 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4704ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4705 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4706endif
Tao Baocbd6d492019-10-07 22:46:02 -07004707 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4708 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004709ifeq ($(BUILD_QEMU_IMAGES),true)
4710 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4711 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4712endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004713 @# Zip everything up, preserving symlinks and placing META/ files first to
4714 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004715 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004716 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004717 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004718
Ying Wanga0febe52013-03-20 11:02:05 -07004719.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004720target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4721
Ying Wang4709d7c2014-04-14 17:25:43 -07004722$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07004723
Dan Albert4d323332016-10-14 13:23:06 -07004724# -----------------------------------------------------------------
4725# NDK Sysroot Package
4726NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004727$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004728 @echo Package NDK sysroot...
4729 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4730
4731$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4732
Ying Wang09c4b682015-08-11 11:24:19 -07004733ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004734# -----------------------------------------------------------------
4735# OTA update package
4736
Yifan Hong50e79542018-11-08 17:44:12 -08004737# $(1): output file
4738# $(2): additional args
4739define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004740PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004741 $(OTA_FROM_TARGET_FILES) \
4742 --verbose \
4743 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4744 --path $(HOST_OUT) \
4745 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4746 $(2) \
4747 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004748endef
4749
Doug Zongker8678df42009-06-15 14:30:14 -07004750name := $(TARGET_PRODUCT)
4751ifeq ($(TARGET_BUILD_TYPE),debug)
4752 name := $(name)_debug
4753endif
4754name := $(name)-ota-$(FILE_NAME_TAG)
4755
4756INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004757INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4758
Doug Zongker8678df42009-06-15 14:30:14 -07004759$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004760$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004761$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004762 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004763 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004764
4765.PHONY: otapackage
4766otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4767
Tao Bao519d1822018-12-27 12:47:23 -08004768ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004769name := $(TARGET_PRODUCT)
4770ifeq ($(TARGET_BUILD_TYPE),debug)
4771 name := $(name)_debug
4772endif
4773name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4774
4775INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004776$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004777$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4778 $(BUILT_TARGET_FILES_PACKAGE) \
4779 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004780 @echo "Package OTA (retrofit dynamic partitions): $@"
4781 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4782
4783.PHONY: otardppackage
4784
4785otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4786
Tao Bao519d1822018-12-27 12:47:23 -08004787endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004788
Ying Wang09c4b682015-08-11 11:24:19 -07004789endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004790
Ying Wang09a00a62010-10-20 14:01:09 -07004791# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004792# A zip of the appcompat directory containing logs
4793APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4794# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004795ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004796$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4797 $(INTERNAL_RAMDISK_FILES) \
4798 $(INTERNAL_USERDATAIMAGE_FILES) \
4799 $(INTERNAL_VENDORIMAGE_FILES) \
4800 $(INTERNAL_PRODUCTIMAGE_FILES) \
4801 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01004802endif
4803$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4804$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4805 @echo "appcompat logs: $@"
4806 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4807 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4808 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4809 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4810
Dario Frenid1011272018-07-23 20:20:15 +01004811# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004812# A zip of the symbols directory. Keep the full paths to make it
4813# more obvious where these files came from.
4814#
4815name := $(TARGET_PRODUCT)
4816ifeq ($(TARGET_BUILD_TYPE),debug)
4817 name := $(name)_debug
4818endif
4819name := $(name)-symbols-$(FILE_NAME_TAG)
4820
4821SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004822# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004823ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004824$(SYMBOLS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4825 $(INTERNAL_RAMDISK_FILES) \
4826 $(INTERNAL_USERDATAIMAGE_FILES) \
4827 $(INTERNAL_VENDORIMAGE_FILES) \
4828 $(INTERNAL_PRODUCTIMAGE_FILES) \
4829 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4830 $(INTERNAL_ODMIMAGE_FILES) \
4831 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4832 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Anton Hansson6d814982018-11-26 18:12:05 +00004833 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004834endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004835$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4836$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004837 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004838 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4839 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004840 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004841 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004842# -----------------------------------------------------------------
4843# A zip of the coverage directory.
4844#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004845name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004846ifeq ($(TARGET_BUILD_TYPE),debug)
4847name := $(name)_debug
4848endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004849COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004850ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004851$(COVERAGE_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4852 $(INTERNAL_RAMDISK_FILES) \
4853 $(INTERNAL_USERDATAIMAGE_FILES) \
4854 $(INTERNAL_VENDORIMAGE_FILES) \
4855 $(INTERNAL_PRODUCTIMAGE_FILES) \
4856 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4857 $(INTERNAL_ODMIMAGE_FILES) \
4858 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4859 $(INTERNAL_ODM_DLKMIMAGE_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004860endif
4861$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4862$(COVERAGE_ZIP): $(SOONG_ZIP)
4863 @echo "Package coverage: $@"
4864 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4865 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4866 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4867 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004868
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004869#------------------------------------------------------------------
4870# Export the LLVM profile data tool and dependencies for Clang coverage processing
4871#
4872ifeq (true,$(CLANG_COVERAGE))
4873 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4874 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4875 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4876 $(PROFDATA_ZIP): $(SOONG_ZIP)
4877 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4878
4879 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4880endif
4881
The Android Open Source Project88b60792009-03-03 19:28:42 -08004882# -----------------------------------------------------------------
4883# A zip of the Android Apps. Not keeping full path so that we don't
4884# include product names when distributing
4885#
4886name := $(TARGET_PRODUCT)
4887ifeq ($(TARGET_BUILD_TYPE),debug)
4888 name := $(name)_debug
4889endif
4890name := $(name)-apps-$(FILE_NAME_TAG)
4891
4892APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07004893$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004894 @echo "Package apps: $@"
4895 $(hide) rm -rf $@
4896 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004897 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4898 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004899 echo "No apps to zip up. Generating empty apps archive." ; \
4900 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004901 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004902 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004903 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004904
Ying Wangbc415dd2012-08-15 12:22:44 -07004905ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004906#------------------------------------------------------------------
4907# An archive of classes for use in generating code-coverage reports
4908# These are the uninstrumented versions of any classes that were
4909# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004910# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004911
Colin Crossa6bc3a82017-09-27 14:28:41 -07004912JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004913$(JACOCO_REPORT_CLASSES_ALL) :
4914 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004915 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4916 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004917
Ying Wangbc415dd2012-08-15 12:22:44 -07004918endif # EMMA_INSTRUMENT=true
4919
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004920
Ying Wangae9115a2013-08-22 20:52:47 -07004921#------------------------------------------------------------------
4922# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004923#
Ying Wangc62c92c2013-08-28 18:38:25 -07004924PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004925# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004926ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004927$(PROGUARD_DICT_ZIP): \
Colin Crosscda30c72020-08-26 18:43:21 -07004928 $(FULL_SYSTEMIMAGE_DEPS) \
4929 $(INTERNAL_RAMDISK_FILES) \
4930 $(INTERNAL_USERDATAIMAGE_FILES) \
4931 $(INTERNAL_VENDORIMAGE_FILES) \
4932 $(INTERNAL_PRODUCTIMAGE_FILES) \
4933 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4934 $(INTERNAL_ODMIMAGE_FILES) \
4935 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4936 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Colin Cross114e8df2019-09-05 17:19:35 -07004937 $(updater_dep)
4938endif
4939$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4940$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004941 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004942 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4943 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4944 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4945 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004946
Colin Crossa9b9e6e2020-08-14 17:43:35 -07004947#------------------------------------------------------------------
4948# A zip of Proguard usage files.
4949#
4950PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
4951# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4952ifeq (,$(TARGET_BUILD_UNBUNDLED))
4953$(PROGUARD_USAGE_ZIP): \
4954 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4955 $(INSTALLED_RAMDISK_TARGET) \
4956 $(INSTALLED_BOOTIMAGE_TARGET) \
4957 $(INSTALLED_USERDATAIMAGE_TARGET) \
4958 $(INSTALLED_VENDORIMAGE_TARGET) \
4959 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4960 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4961 $(INSTALLED_ODMIMAGE_TARGET) \
4962 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
4963 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
4964 $(updater_dep)
4965endif
4966$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
4967$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
4968 @echo "Packaging Proguard usage files."
4969 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4970 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
4971 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07004972
4973ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4974
4975# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4976# $(1): output file
4977define dump-super-image-info
4978 $(call dump-dynamic-partitions-info,$(1))
4979 $(if $(filter true,$(AB_OTA_UPDATER)), \
4980 echo "ab_update=true" >> $(1))
4981endef
4982
4983endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4984
The Android Open Source Project88b60792009-03-03 19:28:42 -08004985# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004986# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004987
4988ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4989
4990# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4991ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4992
4993ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004994
4995# For real devices and for dist builds, build super image from target files to an intermediate directory.
4996INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4997$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4998$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4999 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005000 PATH=$(dir $(LPMAKE)):$$PATH \
5001 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005002
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005003# Skip packing it in dist package because it is in update package.
5004ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005005$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005006endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005007
5008.PHONY: superimage_dist
5009superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005010
5011endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005012endif # BOARD_SUPER_PARTITION_SIZE != ""
5013endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005014
Yifan Hongacd862a2019-04-16 15:44:30 -07005015# -----------------------------------------------------------------
5016# super partition image for development
5017
5018ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5019ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5020ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5021
5022# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5023# $(1): built image path
5024# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5025define build-superimage-target
5026 mkdir -p $(dir $(2))
5027 rm -rf $(2)
5028 $(call dump-super-image-info,$(2))
5029 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5030 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005031 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5032 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005033 mkdir -p $(dir $(1))
5034 PATH=$(dir $(LPMAKE)):$$PATH \
5035 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5036endef
5037
5038INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5039INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5040 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5041
changho.shina8f9f112019-10-15 13:26:19 +09005042ifdef BUILDING_SYSTEM_OTHER_IMAGE
5043ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5044INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5045endif
5046endif
5047
Yifan Hongacd862a2019-04-16 15:44:30 -07005048# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5049# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5050# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5051# virtual devices.
5052ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5053$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5054 $(call pretty,"Target super fs image for debug: $@")
5055 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005056 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005057
5058droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5059
5060# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5061.PHONY: superimage
5062superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005063
5064$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005065endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5066
5067# Build $(PRODUCT_OUT)/super.img without dependencies.
5068.PHONY: superimage-nodeps supernod
5069superimage-nodeps supernod: intermediates :=
5070superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5071 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5072 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5073 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5074
5075endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5076endif # BOARD_SUPER_PARTITION_SIZE != ""
5077endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5078
5079# -----------------------------------------------------------------
5080# super empty image
5081
Tao Bao48a2feb2019-06-28 11:00:05 -07005082ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005083ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005084
Yifan Hong8b79d162018-11-29 12:32:00 -08005085INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5086$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5087$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5088 $(call pretty,"Target empty super fs image: $@")
5089 mkdir -p $(intermediates)
5090 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005091 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005092 PATH=$(dir $(LPMAKE)):$$PATH \
5093 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005094
5095$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5096
Yifan Hong2b891ac2018-11-29 12:06:31 -08005097endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005098endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005099
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005100
5101# -----------------------------------------------------------------
5102# The update package
5103
5104name := $(TARGET_PRODUCT)
5105ifeq ($(TARGET_BUILD_TYPE),debug)
5106 name := $(name)_debug
5107endif
5108name := $(name)-img-$(FILE_NAME_TAG)
5109
5110INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5111
Tao Bao57f8ed62019-08-14 23:08:18 -07005112$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5113 $(call pretty,"Package: $@")
5114 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5115 $(IMG_FROM_TARGET_FILES) \
5116 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5117 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005118
5119.PHONY: updatepackage
5120updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005121$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005122
5123
Yifan Hong2b891ac2018-11-29 12:06:31 -08005124# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005125# dalvik something
5126.PHONY: dalvikfiles
5127dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5128
Bo Huf0d50bb2017-08-01 19:02:09 +00005129ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005130MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005131MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005132SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005133
5134ifdef INSTALLED_SYSTEMIMAGE_TARGET
5135INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005136INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5137$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5138 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5139 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005140$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005141 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5142 @echo Create system-qemu.img now
5143 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005144 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005145
5146systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5147droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005148endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005149ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005150INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005151$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005152 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005153 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005154
5155vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5156droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5157endif
bohu8fd437c2020-03-30 20:16:13 -07005158
5159ifdef INSTALLED_RAMDISK_TARGET
5160ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5161ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5162INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5163$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5164 @echo Create ramdisk-qemu.img
5165 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5166
5167droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5168endif
5169endif
5170endif
5171
Anton Hansson32c76fe2018-12-13 14:34:18 +00005172ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005173INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005174$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005175 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005176 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005177
5178productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5179droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5180endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005181ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5182INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5183$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5184 @echo Create system_ext-qemu.img
5185 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005186
Justin Yun6151e3f2019-06-25 15:58:13 +09005187systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5188droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005189endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005190ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005191INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5192$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5193 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005194 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005195
5196odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5197droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5198endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005199
Yifan Hongcfb917a2020-05-07 14:58:20 -07005200ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5201INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5202$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5203 @echo Create vendor_dlkm-qemu.img
5204 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5205
5206vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5207droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5208endif
5209
Yifan Hongf496f1b2020-07-15 16:52:59 -07005210ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5211INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5212$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5213 @echo Create odm_dlkm-qemu.img
5214 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5215
5216odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5217droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5218endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005219
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005220QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005221$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5222 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005223 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005224 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5225 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005226
5227systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5228droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005229
Bo Huf0d50bb2017-08-01 19:02:09 +00005230endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005231# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005232# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005233ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005234INTERNAL_EMULATOR_PACKAGE_FILES += \
5235 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005236 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005237 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005238 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5239 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005240
5241name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5242
5243INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5244
Ying Wang5d887702015-11-04 10:06:25 -08005245$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005246 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005247 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005248
Ying Wang7d8c5352012-07-26 10:15:21 -07005249endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005250
The Android Open Source Project88b60792009-03-03 19:28:42 -08005251
5252# -----------------------------------------------------------------
5253# The SDK
5254
The Android Open Source Project88b60792009-03-03 19:28:42 -08005255# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005256sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005257
5258# Build a name that looks like:
5259#
5260# linux-x86 --> android-sdk_12345_linux-x86
5261# darwin-x86 --> android-sdk_12345_mac-x86
5262# windows-x86 --> android-sdk_12345_windows
5263#
5264sdk_name := android-sdk_$(FILE_NAME_TAG)
5265ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005266 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005267else
Joe Onorato03fbe402009-04-13 08:31:16 -07005268 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005269endif
5270ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005271 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005272endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005273sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005274
5275sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5276
5277ATREE_FILES :=
5278-include $(sdk_dep_file)
5279
5280# if we don't have a real list, then use "everything"
5281ifeq ($(strip $(ATREE_FILES)),)
5282ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005283 $(ALL_DEFAULT_INSTALLED_MODULES) \
5284 $(INSTALLED_RAMDISK_TARGET) \
5285 $(ALL_DOCS) \
5286 $(ALL_SDK_FILES)
5287endif
5288
5289atree_dir := development/build
5290
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005291
The Android Open Source Project88b60792009-03-03 19:28:42 -08005292sdk_atree_files := \
5293 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005294 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005295
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005296# development/build/sdk-android-<abi>.atree is used to differentiate
5297# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5298# files like the kernel image. We use TARGET_CPU_ABI because we don't
5299# have a better way to distinguish between CPU models.
5300ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5301 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5302endif
5303
Anton Hansson8dab0a62019-03-28 15:45:40 +00005304ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5305sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005306else
5307sdk_atree_files += $(atree_dir)/sdk.atree
5308endif
5309
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005310include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005311
The Android Open Source Project88b60792009-03-03 19:28:42 -08005312deps := \
5313 $(target_notice_file_txt) \
5314 $(tools_notice_file_txt) \
5315 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005316 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005317 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005318 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005319 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005320 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005321 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005322 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005323 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005324 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005325 $(INSTALLED_USERDATAIMAGE_TARGET) \
5326 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005327 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005328 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005329 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005330 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005331 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005332 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005333 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005334
5335INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5336$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5337$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5338$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5339$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5340
5341# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5342#
5343#SDK_GNU_ERROR := true
5344
Ying Wang5d887702015-11-04 10:06:25 -08005345$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005346 @echo "Package SDK: $@"
5347 $(hide) rm -rf $(PRIVATE_DIR) $@
5348 $(hide) for f in $(target_gnu_MODULES); do \
5349 if [ -f $$f ]; then \
5350 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5351 including GNU target $$f >&2; \
5352 FAIL=$(SDK_GNU_ERROR); \
5353 fi; \
5354 done; \
5355 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005356 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005357 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005358 ATREE_STRIP="$(HOST_STRIP) -x" \
5359 $(HOST_OUT_EXECUTABLES)/atree \
5360 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5361 -m $(PRIVATE_DEP_FILE) \
5362 -I . \
5363 -I $(PRODUCT_OUT) \
5364 -I $(HOST_OUT) \
5365 -I $(TARGET_COMMON_OUT_ROOT) \
5366 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5367 -v "OUT_DIR=$(OUT_DIR)" \
5368 -v "HOST_OUT=$(HOST_OUT)" \
5369 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5370 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5371 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5372 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5373 -o $(PRIVATE_DIR) && \
5374 cp -f $(target_notice_file_txt) \
5375 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5376 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5377 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5378 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5379 chmod -R ug+rwX $(PRIVATE_DIR) && \
5380 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005381 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5382
Raphael3d224a02010-04-16 17:50:09 -07005383
5384# Is a Windows SDK requested? If so, we need some definitions from here
5385# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005386MAIN_SDK_NAME := $(sdk_name)
5387MAIN_SDK_DIR := $(sdk_dir)
5388MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005389ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005390include $(TOPDIR)development/build/tools/windows_sdk.mk
5391endif
5392
The Android Open Source Project88b60792009-03-03 19:28:42 -08005393# -----------------------------------------------------------------
5394# Findbugs
5395INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5396INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5397$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5398 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005399 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005400 > $@
5401$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5402 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005403 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005404 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005405
5406# -----------------------------------------------------------------
5407# Findbugs
5408
5409# -----------------------------------------------------------------
5410# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005411ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005412include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005413-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005414-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005415-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005416# Also the project-specific tasks
5417-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5418-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005419-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005420# Also add test specifc tasks
5421include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005422include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005423endif
Raphaelc4d47312011-02-15 16:09:36 -08005424
Ying Wang67132ba2015-10-28 16:42:39 -07005425include $(BUILD_SYSTEM)/product-graph.mk
5426
Raphaelc4d47312011-02-15 16:09:36 -08005427# -----------------------------------------------------------------
5428# Create SDK repository packages. Must be done after tasks/* since
5429# we need the addon rules defined.
5430ifneq ($(sdk_repo_goal),)
5431include $(TOPDIR)development/build/tools/sdk_repo.mk
5432endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005433
5434# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005435# Soong generates the list of all shared libraries that are depended on by fuzz
5436# targets. It saves this list as a source:destination pair to
5437# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5438# build of the unstripped shared library, and the destination is the
5439# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5440# where fuzz target shared libraries are to be "reinstalled". The
5441# copy-many-files below generates the rules to copy the unstripped shared
5442# libraries to the device or host "reinstallation" directory. These rules are
5443# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5444# a dependency on each shared library that it needs to be "reinstalled".
5445FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5446
5447# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005448# The rule to build all fuzz targets, and package them.
5449# Note: The packages are created in Soong, and in a perfect world,
5450# we'd be able to create the phony rule there. But, if we want to
5451# have dist goals for the fuzz target, we need to have the PHONY
5452# target defined in make. MakeVarsContext.DistForGoal doesn't take
5453# into account that a PHONY rule create by Soong won't be available
5454# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005455# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005456# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005457.PHONY: haiku
5458haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5459$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005460
5461# -----------------------------------------------------------------
5462# The makefile for haiku line coverage.
5463include $(BUILD_SYSTEM)/line_coverage.mk