blob: add62b4398590e22c8113c9659c2a66b63dc93ec [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 :=
Yifan Hong881df392020-10-09 14:29:39 -0700165# Build recovery image if
166# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
167# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
168# with recovery resources.
169# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
170# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700171ifdef BUILDING_RECOVERY_IMAGE
172ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700173ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700174INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
175endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700176endif
Yifan Hong881df392020-10-09 14:29:39 -0700177endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700178
Jiyong Parke1346862020-05-18 14:31:30 +0900179include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100180
181# ----------------------------------------------------------------
182
183# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800184# sdk-build.prop
185#
186# There are certain things in build.prop that we don't want to
187# ship with the sdk; remove them.
188
189# This must be a list of entire property keys followed by
190# "=" characters, without any internal spaces.
191sdk_build_prop_remove := \
192 ro.build.user= \
193 ro.build.host= \
194 ro.product.brand= \
195 ro.product.manufacturer= \
196 ro.product.device=
197# TODO: Remove this soon-to-be obsolete property
198sdk_build_prop_remove += ro.build.product=
199INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
200$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
201 @echo SDK buildinfo: $@
202 @mkdir -p $(dir $@)
203 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000204 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800205 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000206 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800207 $(hide) mv $@.tmp $@
208
209# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700210# kernel modules
211
212# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
213DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
214
J. Avilaa2ceec62020-05-12 23:40:02 +0000215define copy-and-strip-kernel-module
216$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000217 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000218endef
219
Colin Cross4f60e362019-06-05 11:53:43 -0700220# $(1): modules list
221# $(2): output dir
222# $(3): mount point
223# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700224# $(5): module load list
225# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800226# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000227# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700228# $(9): module directory name
Colin Cross4f60e362019-06-05 11:53:43 -0700229# Returns the a list of src:dest pairs to install the modules using copy-many-files.
230define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700231 $(if $(9), \
232 $(eval _dir := $(9)/), \
233 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000234 $(foreach module,$(1), \
235 $(eval _src := $(module)) \
236 $(if $(8), \
237 $(eval _src := $(8)/$(notdir $(module))) \
238 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700239 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700240 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700241 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
242 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
243 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
244 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700245endef
246
247# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700248# $(2): mount point
249# $(3): staging dir
250# $(4): module load list
251# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800252# $(6): module archive
253# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700254# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800255# TODO(b/144844424): If a module archive is being used, this step (which
256# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
257# the output directory. This should be moved to a module with a
258# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
259# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700260define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700261$(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 -0700262$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
263$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
264$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700265$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700266$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
267$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
268$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800269$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
270$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
271$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700272 @echo depmod $$(PRIVATE_STAGING_DIR)
273 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700274 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800275 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700276 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800277 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700278 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800279 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
280 )
281 $(if $(1),\
282 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
283 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
284 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
285 done; \
286 )
Colin Cross4f60e362019-06-05 11:53:43 -0700287 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
288 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700289 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
290 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700291endef
292
Steve Muckle474e4d02019-06-19 12:56:48 -0700293# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700294# $(2): modules list
295# $(3): module load list
296# $(4): module load list filename
297# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700298define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700299 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
300 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700301endef
302
303# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700304# $(2): modules list
305# $(3): module load list
306# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700307define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700308$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
309$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
310 @echo load-list $$(@)
311 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700312endef
313
Steve Muckle2335d762020-05-28 18:39:38 -0700314# $(1): image name
315# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
316# $(3): mount point
317# $(4): module load filename
318# $(5): stripped staging directory
319# $(6): kernel module directory name (top is an out of band value for no directory)
320define build-image-kernel-modules-dir
321$(if $(filter top,$(6)),\
322 $(eval _kver :=)$(eval _sep :=),\
323 $(eval _kver := $(6))$(eval _sep :=_))\
324$(if $(5),\
325 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
326 $(eval _stripped_staging_dir :=))\
327$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
328 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
329 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
330 $(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))))
331endef
332
333# $(1): kernel module directory name (top is an out of band value for no directory)
334define build-recovery-as-boot-load
335$(if $(filter top,$(1)),\
336 $(eval _kver :=)$(eval _sep :=),\
337 $(eval _kver := $(1))$(eval _sep :=_))\
338 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
339 $(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))))
340endef
341
342# $(1): kernel module directory name (top is an out of band value for no directory)
343define build-vendor-ramdisk-recovery-load
344$(if $(filter top,$(1)),\
345 $(eval _kver :=)$(eval _sep :=),\
346 $(eval _kver := $(1))$(eval _sep :=_))\
347 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
348 $(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))))
349endef
350
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700351# $(1): kernel module directory name (top is an out of band value for no directory)
352define build-vendor-charger-load
353$(if $(filter top,$(1)),\
354 $(eval _kver :=)$(eval _sep :=),\
355 $(eval _kver := $(1))$(eval _sep :=_))\
356 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
357 $(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))))
358endef
359
Steve Mucklee1b10862019-07-10 10:49:37 -0700360ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
361 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
362 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700363 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700364 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
365endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700366
Steve Muckle69280d22019-07-11 12:23:38 -0700367ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
368 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700369endif
370
Steve Mucklee1b10862019-07-10 10:49:37 -0700371ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700372 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700373 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700374 endif
375endif
376
J. Avilaa2ceec62020-05-12 23:40:02 +0000377ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
378 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
379else
380 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
381endif
Colin Cross4f60e362019-06-05 11:53:43 -0700382
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700383ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
384 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
385else
386 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
387endif
388
Steve Muckle2335d762020-05-28 18:39:38 -0700389BOARD_KERNEL_MODULE_DIRS += top
390$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
391 $(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 -0700392 $(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 -0700393 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
Yifan Honge51dff22020-06-23 17:26:57 -0700394 $(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 -0700395 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Yifan Hong3d5e2c22020-07-15 17:01:14 -0700396 $(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 -0700397 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
398 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
399 $(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 -0700400
401# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800402# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700403# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900404# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700405# $2 certificate
406# $3 private key
407# $4 compressed
408# $5 partition tag
409# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100410define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700411$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
412$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
413$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
414$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700415
416endef
417
Jaewoong Jung704b4542020-06-29 19:37:53 -0700418# -----------------------------------------------------------------
419# Merge an individual apkcerts output into the final apkcerts.txt output.
420# Use a macro to make it compatible with _apkcerts_write_line
421# $1 apkcerts file to be merged
422# $2 output file
423define _apkcerts_merge
424$(hide) cat $1 >> $2
425
426endef
427
The Android Open Source Project88b60792009-03-03 19:28:42 -0800428name := $(TARGET_PRODUCT)
429ifeq ($(TARGET_BUILD_TYPE),debug)
430 name := $(name)_debug
431endif
432name := $(name)-apkcerts-$(FILE_NAME_TAG)
433intermediates := \
434 $(call intermediates-dir-for,PACKAGING,apkcerts)
435APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700436all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
437$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800438# We don't need to really build all the modules.
439# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700440$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800441 @echo APK certs list: $@
442 @mkdir -p $(dir $@)
443 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700444 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700445 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
446 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
447 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700448 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700449 $(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 -0700450 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700451 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800452
453.PHONY: apkcerts-list
454apkcerts-list: $(APKCERTS_FILE)
455
Ying Wang15e487a2011-02-15 10:56:18 -0800456ifneq (,$(TARGET_BUILD_APPS))
457 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900458 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800459endif
Ying Wangefb21682010-07-23 16:42:13 -0700460
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900461
The Android Open Source Project88b60792009-03-03 19:28:42 -0800462# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# build system stats
464BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
465$(BUILD_SYSTEM_STATS):
466 @rm -f $@
467 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
468 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
469$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700470
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700471# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800472# build /product/etc/security/avb/system_other.avbpubkey if needed
473ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800474ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800475INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
476ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800477endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800478endif # BUILDING_SYSTEM_OTHER_IMAGE
479
480# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700481# Modules ready to be converted to Soong, ordered by how many
482# modules depend on them.
483SOONG_CONV := $(sort $(SOONG_CONV))
484SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
485$(SOONG_CONV_DATA):
486 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700487 @$(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 -0700488
Colin Crossfdea8932017-12-06 14:38:40 -0800489SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700490SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
491$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
492 @rm -f $@
493 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
494$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
495
Joe Onorato02fb89a2020-06-27 00:10:23 -0700496MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
497MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
498$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
499$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
500 @rm -f $@
501 $(hide) $(MK2BP_CATALOG_SCRIPT) \
502 --device=$(TARGET_DEVICE) \
503 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
504 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
505 --out_dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700506 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700507 > $@
508$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
509
Joe Onorato31986072020-08-10 09:58:49 -0700510MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
511$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
512 @rm -f $@
513 $(hide) $(MK2BP_CATALOG_SCRIPT) \
514 --device=$(TARGET_DEVICE) \
515 --out_dir="$(OUT_DIR)" \
516 --mode=csv \
517 > $@
518$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_CSV))
519
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700520# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800521# Modules use -Wno-error, or added default -Wall -Werror
522WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
523$(WALL_WERROR):
524 @rm -f $@
525 echo "# Modules using -Wno-error" >> $@
526 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 -0800527 echo "# Modules added default -Wall" >> $@
528 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
529
530$(call dist-for-goals,droidcore,$(WALL_WERROR))
531
532# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700533# C/C++ flag information for modules
534$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
535
536# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800537# Modules missing profile files
538PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
539$(PGO_PROFILE_MISSING):
540 @rm -f $@
541 echo "# Modules missing PGO profile files" >> $@
542 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
543
544$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
545
546# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700547# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700548# for future OTA packages installed by this system. Actual product
549# deliverables will be re-signed by hand. We expect this file to
550# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700551DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700552
553
Jeff Browne33ba4c2011-07-11 22:11:46 -0700554# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800555# if they don't do anything.
556.PHONY: systemimage
557systemimage:
558
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800559# -----------------------------------------------------------------
560
561.PHONY: event-log-tags
562
Joe Onoratob7510532010-07-14 10:22:54 -0700563# Produce an event logs tag file for everything we know about, in order
564# to properly allocate numbers. Then produce a file that's filtered
565# for what's going to be installed.
566
567all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
568
Colin Crossdc8f8e42012-04-12 13:25:54 -0700569event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
570
Joe Onoratob7510532010-07-14 10:22:54 -0700571# Include tags from all packages that we know about
572all_event_log_tags_src := \
573 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
574
Dan Willemsena3f66322020-05-28 15:46:33 -0700575$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
576$(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 -0700577 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900578 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700579
Doug Zongkera34fa952011-02-23 12:17:29 -0800580# Include tags from all packages included in this product, plus all
581# tags that are part of the system (ie, not in a vendor/ or device/
582# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800583event_log_tags_src := \
584 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800585 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800586 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800587 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
588 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800589
Dan Willemsena3f66322020-05-28 15:46:33 -0700590$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700591$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700592$(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 -0800593 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900594 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800595
596event-log-tags: $(event_log_tags_file)
597
598ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
599
Joe Onoratob7510532010-07-14 10:22:54 -0700600
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601# #################################################################
602# Targets for boot/OS images
603# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800604ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
605 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000606 ifdef BOARD_PREBUILT_BOOTLOADER
607 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
608 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
609 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800610 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
611 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
612 else
613 INSTALLED_2NDBOOTLOADER_TARGET :=
614 endif
615else
616 INSTALLED_BOOTLOADER_MODULE :=
617 INSTALLED_2NDBOOTLOADER_TARGET :=
618endif # TARGET_NO_BOOTLOADER
619ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700620 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
621 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
622 $(PRODUCT_OUT)/$(k))
623 else
624 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
625 endif
Ying Wangc6349742014-01-13 16:14:20 -0800626else
627 INSTALLED_KERNEL_TARGET :=
628endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629
630# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700631# the root dir
632INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800633 $(ALL_GENERATED_SOURCES) \
634 $(ALL_DEFAULT_INSTALLED_MODULES))
635
Luis Hector Chavezff489932018-07-03 15:41:40 -0700636INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
637INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
638$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700639$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700640 @echo Installed file list: $@
641 @mkdir -p $(dir $@)
642 @rm -f $@
643 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700644 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700645
646$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
647
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800648#------------------------------------------------------------------
649# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700650ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800651INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700652ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800653$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800654 cat $^ > $@
655endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700656endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800657
Tom Cherryd14b8952018-08-09 14:26:00 -0700658# -----------------------------------------------------------------
659# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800660ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700661INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
662 $(ALL_GENERATED_SOURCES) \
663 $(ALL_DEFAULT_INSTALLED_MODULES))
664
665INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
666INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
667$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700668$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700669 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800670 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700671 @mkdir -p $(dir $@)
672 @rm -f $@
673 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700674 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700675
676$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700677BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
678
J. Avila3f6560e2020-05-11 20:20:03 +0000679ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
680# -l enables the legacy format used by the Linux kernel
681COMPRESSION_COMMAND_DEPS := $(LZ4)
682COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
683RAMDISK_EXT := .lz4
684else
685COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
686COMPRESSION_COMMAND := $(MINIGZIP)
687RAMDISK_EXT := .gz
688endif
689
Joe Onorato64d85d02009-04-09 19:31:12 -0700690# We just build this directly to the install location.
691INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000692$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800693 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000694 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800695
Ying Wangad7fd292013-08-08 16:34:29 -0700696.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000697ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700698 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000699 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800700
Dan Willemsen67495202019-01-16 12:42:05 -0800701endif # BUILDING_RAMDISK_IMAGE
702
The Android Open Source Project88b60792009-03-03 19:28:42 -0800703# -----------------------------------------------------------------
704# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700705
706# This is defined here since we may be building recovery as boot
707# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700708ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
709 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
710else
711 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
712endif
713
Yifan Hong78b55b22020-10-28 14:19:05 -0700714# kernel cmdline for GKI
715GENERIC_KERNEL_CMDLINE := rw
716.KATI_READONLY := GENERIC_KERNEL_CMDLINE
717
Yifan Hong0674a6e2020-10-22 14:37:01 -0700718INTERNAL_PREBUILT_BOOTIMAGE :=
719
720my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
721ifdef my_installed_prebuilt_gki_apex
722 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
723 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
724 endif # len(my_installed_prebuilt_gki_apex) > 1
725
726 ifdef BOARD_PREBUILT_BOOTIMAGE
727 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
728 endif # BOARD_PREBUILT_BOOTIMAGE defined
729
730 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
731 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
732 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
733
734 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
735
736else # my_installed_prebuilt_gki_apex not defined
737
Steve Muckle04b6f052020-08-09 14:36:56 -0700738# $1: boot image target
739# returns the kernel used to make the bootimage
740define bootimage-to-kernel
741 $(if $(BOARD_KERNEL_BINARIES),\
742 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
743 $(INSTALLED_KERNEL_TARGET))
744endef
745
Steve Muckle903a1ca2020-05-07 17:32:10 -0700746ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
747 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
748endif
749
750# $1: boot image file name
751# $2: boot image variant (boot, boot-debug)
752define get-bootimage-partition-size
753 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
754endef
Chris Grossa784ef12019-04-22 11:09:57 -0700755
756ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800757INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700758 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700759
760ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
761INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
762endif
763
Steve Mucklee1b10862019-07-10 10:49:37 -0700764ifndef BUILDING_VENDOR_BOOT_IMAGE
765ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
766 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
767endif
768endif
769
The Android Open Source Project88b60792009-03-03 19:28:42 -0800770INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
771
Anton Hansson8dab0a62019-03-28 15:45:40 +0000772ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700773ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000774VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700775 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
776endif
777endif
778
Anton Hansson72e36f02019-02-26 17:36:30 +0000779INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700780
Yifan Hong46aff092020-10-28 13:50:47 -0700781# kernel cmdline/base/pagesize in boot.
782# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
783# device-specific.
784# - If not using GKI:
785# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
786# - Otherwise, put them in boot.
787ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -0700788 ifdef GENERIC_KERNEL_CMDLINE
789 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
790 endif
Yifan Hong46aff092020-10-28 13:50:47 -0700791else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
792 ifdef INTERNAL_KERNEL_CMDLINE
793 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
794 endif
795 ifdef BOARD_KERNEL_BASE
796 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
797 endif
798 ifdef BOARD_KERNEL_PAGESIZE
799 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
800 endif
801endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700802
Sami Tolvanen3303d902016-03-15 16:49:30 +0000803INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700804 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000805 --os_patch_level $(PLATFORM_SECURITY_PATCH)
806
Chris Grossa784ef12019-04-22 11:09:57 -0700807# Define these only if we are building boot
808ifdef BUILDING_BOOT_IMAGE
809INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
810
The Android Open Source Project88b60792009-03-03 19:28:42 -0800811ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800812$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700813endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400814
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700815$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
816
817ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400818
Steve Muckle04b6f052020-08-09 14:36:56 -0700819# $1: boot image target
820define build_boot_board_avb_enabled
821 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700822 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot)))
Steve Muckle04b6f052020-08-09 14:36:56 -0700823 $(AVBTOOL) add_hash_footer \
824 --image $(1) \
Yifan Hongebe65f82020-10-15 14:48:07 -0700825 --partition_size $(call get-bootimage-partition-size,$(1),boot) \
Steve Muckle04b6f052020-08-09 14:36:56 -0700826 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
827 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
828endef
829
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700830$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400831 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700832 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400833
834.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800835bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400836 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700837 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400838
Anton Hansson8dab0a62019-03-28 15:45:40 +0000839else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700840
Steve Muckle04b6f052020-08-09 14:36:56 -0700841# $1: boot image target
842define build_boot_supports_boot_signer
843 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
844 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700845 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700846endef
847
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700848$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -0700849 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700850 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700851
852.PHONY: bootimage-nodeps
853bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
854 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700855 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700856
Anton Hansson8dab0a62019-03-28 15:45:40 +0000857else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800858
Steve Muckle04b6f052020-08-09 14:36:56 -0700859# $1: boot image target
860define build_boot_supports_vboot
861 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
862 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700863 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700864endef
865
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700866$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800867 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700868 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800869
870.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800871bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800872 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700873 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800874
875else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800876
Steve Muckle04b6f052020-08-09 14:36:56 -0700877# $1: boot image target
878define build_boot_novboot
879 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700880 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700881endef
882
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700883$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800884 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700885 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700886
887.PHONY: bootimage-nodeps
888bootimage-nodeps: $(MKBOOTIMG)
889 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700890 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700891
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700892endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -0700893endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800894
Tao Baob1a2e352018-08-14 16:17:12 -0700895else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700896ifdef BOARD_PREBUILT_BOOTIMAGE
897ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
898# Remove when b/63676296 is resolved.
899$(error Prebuilt bootimage is only supported for AB targets)
900endif
Yifan Hong0674a6e2020-10-22 14:37:01 -0700901INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +0900902INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Yifan Hong0674a6e2020-10-22 14:37:01 -0700903$(eval $(call copy-one-file,$(INTERNAL_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700904else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700905INSTALLED_BOOTIMAGE_TARGET :=
906endif # BOARD_PREBUILT_BOOTIMAGE
907endif # TARGET_NO_KERNEL
Yifan Hong0674a6e2020-10-22 14:37:01 -0700908endif # my_installed_prebuilt_gki_apex not defined
909
910my_apex_extracted_boot_image :=
911my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800912
913# -----------------------------------------------------------------
Yifan Hong881df392020-10-09 14:29:39 -0700914# declare recovery ramdisk files
915ifeq ($(BUILDING_RECOVERY_IMAGE),true)
916INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
917endif
918
919# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700920# vendor boot image
921ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
922
923ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
924 $(error vboot 1.0 does not support vendor_boot partition)
925endif
926
927INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
928 $(ALL_GENERATED_SOURCES) \
929 $(ALL_DEFAULT_INSTALLED_MODULES))
930
Steve Muckle414dbe12020-06-18 21:38:35 -0700931INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -0700932
933ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
934$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
935$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
936endif
937
J. Avila3f6560e2020-05-11 20:20:03 +0000938$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -0700939 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700940
941ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
942 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
943endif
944ifdef BOARD_KERNEL_BASE
945 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
946endif
947ifdef BOARD_KERNEL_PAGESIZE
948 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
949endif
950ifdef INTERNAL_KERNEL_CMDLINE
951 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
952endif
953
954INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
955$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
956ifeq ($(BOARD_AVB_ENABLE),true)
957$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
958 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800959 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700960 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
961 $(AVBTOOL) add_hash_footer \
962 --image $@ \
963 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
964 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
965 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
966else
967$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
968 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800969 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700970 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
971endif
972endif # BUILDING_VENDOR_BOOT_IMAGE
973
974# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800975# NOTICE files
976#
Steve Blockd14d3b42012-03-01 11:34:41 +0000977# We are required to publish the licenses for all code under BSD, GPL and
978# Apache licenses (and possibly other more exotic ones as well). We err on the
979# side of caution, so the licenses for other third-party code are included here
980# too.
981#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800982# This needs to be before the systemimage rules, because it adds to
983# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
984# go into the systemimage.
985
Steve Block495e5852012-02-29 19:18:08 +0000986.PHONY: notice_files
987
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900988# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700989# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
990# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
991# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
992# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900993# $(2) - Plain text output file
994# $(3) - HTML/XML output file
995# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700996# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800997# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900998# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800999# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -08001000#
1001# The algorithm here is that we go collect a hash for each of the notice
1002# files and write the names of the files that match that hash. Then
1003# to generate the real files, we go print out all of the files and their
1004# hashes.
1005#
1006# These rules are fairly complex, so they depend on this makefile so if
1007# it changes, they'll run again.
1008#
1009# TODO: We could clean this up so that we just record the locations of the
1010# original notice files instead of making rules to copy them somwehere.
1011# Then we could traverse that without quite as much bash drama.
1012define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -07001013$(2): PRIVATE_MESSAGE := $(4)
1014$(2): PRIVATE_DIR := $(5)
1015$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
1016$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -08001017 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -07001018 $(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, \
1019 $(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 +00001020 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001021 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001022 $(if $(filter $(1),xml_system),-i system --xml-output, \
1023 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001024 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001025 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
1026 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -07001027 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001028notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001029endef
1030
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001031# Notice file logic isn't relevant for TARGET_BUILD_APPS
1032ifndef TARGET_BUILD_APPS
1033
The Android Open Source Project88b60792009-03-03 19:28:42 -08001034# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1035# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1036# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001037target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001038tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001039tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001040kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1041winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001042
Bob Badour4b25c902020-01-28 13:23:39 -08001043# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1044# reasons--not to be flashed onto any device. Targets under these directories
1045# need no associated notice file on the device UI.
1046exclude_target_dirs := apex
1047
Steven Morelandae69e572017-12-15 14:49:55 -08001048# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001049ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1050target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1051target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1052installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1053$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001054 $(target_notice_file_txt), \
1055 $(target_notice_file_html), \
1056 "Notices for files contained in the filesystem images in this directory:", \
1057 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -07001058 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -08001059 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001060$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1061 $(hide) $(MINIGZIP) -9 < $< > $@
1062$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1063 $(copy-file-to-target)
1064else
1065target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1066target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001067installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1068
1069target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1070target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1071target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1072installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001073
1074target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1075target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1076target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1077installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001078
Justin Yun6151e3f2019-06-25 15:58:13 +09001079target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1080target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1081target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1082installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001083
Chris Gross15d96552019-07-16 14:38:43 -07001084target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1085target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1086target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1087installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1088
Yifan Hong3d3f0302020-05-11 18:35:11 -07001089target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1090target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1091target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1092installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1093
Yifan Hongc83f9e92020-07-15 16:57:47 -07001094target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1095target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1096target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1097installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1098
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001099# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1100# being built. A notice xml file must depend on all modules that could potentially
1101# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001102license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001103# Only files copied to a system image need system image notices.
1104license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001105# Phonys/fakes don't have notice files (though their deps might)
1106license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001107# testcases are not relevant to the system image.
1108license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001109# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001110license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001111# system_other is relevant to system partition.
1112license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001113license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1114license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001115license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001116license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001117license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001118license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001119license_modules_agg := $(license_modules_system) \
1120 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001121 $(license_modules_product) \
1122 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001123 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001124 $(license_modules_vendor_dlkm) \
1125 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001126# targets used for debug symbols only and do not get copied to the device
1127license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1128
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001129license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001130license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1131
1132# Identify the other targets we expect to have notices for:
1133# targets copied to the device but are not readable by the UI (e.g. must boot
1134# into a different partition to read or don't have an associated /etc
1135# directory) must have their notices built somewhere readable.
1136license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1137license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1138license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1139license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1140license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1141license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1142license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1143license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1144license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1145license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1146license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1147license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1148license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1149
1150# after removing targets in system images, targets reported in system images, and
1151# targets used for debug symbols that do not need notices, nothing must remain.
1152license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1153$(call maybe-print-list-and-error, $(license_modules_rest), \
1154 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001155
Chris Grossaad39b32019-06-13 09:43:26 -07001156# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1157# update its notice file, so include those notices in the system partition instead
1158ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001159license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001160system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1161system_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 -07001162else
Bob Badour4b25c902020-01-28 13:23:39 -08001163license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001164system_xml_directories := xml_system
1165system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001166endif
1167
1168$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001169 $(target_notice_file_txt), \
1170 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001171 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001172 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001173 $(license_modules_system), \
1174 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001175$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001176 $(target_vendor_notice_file_txt), \
1177 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001178 "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 +00001179 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001180 $(license_modules_vendor), \
1181 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001182$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001183 $(target_product_notice_file_txt), \
1184 $(target_product_notice_file_xml), \
1185 "Notices for files contained in the product filesystem image in this directory:", \
1186 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001187 $(license_modules_product), \
1188 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001189$(eval $(call combine-notice-files, xml_system_ext, \
1190 $(target_system_ext_notice_file_txt), \
1191 $(target_system_ext_notice_file_xml), \
1192 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001193 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001194 $(license_modules_system_ext), \
1195 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001196$(eval $(call combine-notice-files, xml_odm, \
1197 $(target_odm_notice_file_txt), \
1198 $(target_odm_notice_file_xml), \
1199 "Notices for files contained in the odm filesystem image in this directory:", \
1200 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001201 $(license_modules_odm), \
1202 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001203$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1204 $(target_vendor_dlkm_notice_file_txt), \
1205 $(target_vendor_dlkm_notice_file_xml), \
1206 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1207 $(TARGET_OUT_NOTICE_FILES), \
1208 $(license_modules_vendor_dlkm), \
1209 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001210$(eval $(call combine-notice-files, xml_odm_dlkm, \
1211 $(target_odm_dlkm_notice_file_txt), \
1212 $(target_odm_dlkm_notice_file_xml), \
1213 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1214 $(TARGET_OUT_NOTICE_FILES), \
1215 $(license_modules_odm_dlkm), \
1216 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001217
1218$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1219 $(hide) $(MINIGZIP) -9 < $< > $@
1220$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1221 $(hide) $(MINIGZIP) -9 < $< > $@
1222$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1223 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001224$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001225 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001226$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1227 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001228$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1229 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001230$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1231 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001232$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1233 $(copy-file-to-target)
1234$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1235 $(copy-file-to-target)
1236$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1237 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001238$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001239 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001240$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1241 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001242$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1243 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001244$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1245 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001246
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001247ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1248ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1249ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1250ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1251ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001252ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001253ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001254endif # PRODUCT_NOTICE_SPLIT
1255
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001256ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001257
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001258$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001259 $(tools_notice_file_txt), \
1260 $(tools_notice_file_html), \
1261 "Notices for files contained in the tools directory:", \
1262 $(HOST_OUT_NOTICE_FILES), \
1263 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001264 $(winpthreads_notice_file), \
1265 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001266
Ying Wang62c81f82013-08-22 20:02:03 -07001267endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001268
1269# The kernel isn't really a module, so to get its module file in there, we
1270# make the target NOTICE files depend on this particular file too, which will
1271# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001272$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001273
Dan Willemsen288bedf2019-05-28 15:36:47 -07001274$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001275
Doug Zongker8678df42009-06-15 14:30:14 -07001276
The Android Open Source Project88b60792009-03-03 19:28:42 -08001277# #################################################################
1278# Targets for user images
1279# #################################################################
1280
Ying Wang933abf12010-06-16 14:31:34 -07001281INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001282ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001283INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1284else
1285ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001286INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1287else
1288ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001289INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1290endif
1291endif
1292endif
1293
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001294# These options tell the recovery updater/installer how to mount the partitions writebale.
1295# <fstype>=<fstype_opts>[|<fstype_opts>]...
1296# fstype_opts := <opt>[,<opt>]...
1297# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001298# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1299DEFAULT_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 -07001300
Ying Wang542903a2010-11-17 15:40:38 -08001301ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1302 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1303endif
Gao Xiang961041a2020-06-17 13:59:16 +08001304ifneq (true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED))
1305 INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG := -s
1306endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001307ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1308 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1309endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001310ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1311 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1312endif
Tao Baodba635a2019-06-24 10:39:54 -07001313
1314INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001315 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001316 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001317 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001318
1319ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1320INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001321endif
1322
Yifan Hongcfb917a2020-05-07 14:58:20 -07001323ifneq ($(filter \
1324 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1325 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1326 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1327 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1328 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1329 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001330 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001331 ,erofs),)
1332INTERNAL_USERIMAGES_DEPS += $(MKEROFSUSERIMG)
1333endif
1334
1335ifneq ($(filter \
1336 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1337 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1338 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1339 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1340 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1341 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1342 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001343 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001344INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1345endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001346
Anton Hansson8dab0a62019-03-28 15:45:40 +00001347ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001348INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001349ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001350INTERNAL_USERIMAGES_DEPS += $(FEC)
1351endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001352endif
1353
Tao Baodba635a2019-06-24 10:39:54 -07001354ifeq ($(BOARD_AVB_ENABLE),true)
1355INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1356endif
1357
1358# Get a colon-separated list of search paths.
1359INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1360
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001361# Collects file_contexts files from modules to be installed
1362$(call merge-fc-files, \
1363 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1364 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1365
Alex Klyubin092c9022017-03-13 13:28:34 -07001366SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001367
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001368INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1369
Yifan Hongc5c01242018-11-09 10:27:23 -08001370ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001371
Anton Hansson8dab0a62019-03-28 15:45:40 +00001372ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001373 $(error vboot 1.0 doesn't support logical partition)
1374endif
1375
Yifan Hongc5c01242018-11-09 10:27:23 -08001376endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001377
Ying Wangbd93d422011-10-28 17:02:30 -07001378# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001379# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001380# $(3): additional "key=value" pairs to append to the dictionary file.
1381define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001382$(if $(filter $(2),system),\
1383 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001384 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001385 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1386 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1387 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1388 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1389 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1390 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1391 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1392 $(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 +00001393 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1394 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001395 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001396 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001397 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1398)
1399$(if $(filter $(2),system_other),\
1400 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001401)
Yifan Hong760d3c02018-05-30 11:16:46 -07001402$(if $(filter $(2),userdata),\
1403 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1404 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001405 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1406 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kimed754fb2020-10-12 19:50:05 -07001407 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001408 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001409 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001410)
Yifan Hong760d3c02018-05-30 11:16:46 -07001411$(if $(filter $(2),cache),\
1412 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1413 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001414 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001415 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001416)
1417$(if $(filter $(2),vendor),\
1418 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1419 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1420 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1421 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1422 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1423 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1424 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1425 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1426 $(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 +00001427 $(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 -07001428 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001429 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001430 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001431)
1432$(if $(filter $(2),product),\
1433 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1434 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1435 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1436 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1437 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1438 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1439 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1440 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1441 $(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 +00001442 $(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 -07001443 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001444 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001445 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001446)
Justin Yun6151e3f2019-06-25 15:58:13 +09001447$(if $(filter $(2),system_ext),\
1448 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1449 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1450 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1451 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1452 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1453 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1454 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1455 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1456 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1457 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1458 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001459 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001460)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001461$(if $(filter $(2),odm),\
1462 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1463 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1464 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1465 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1466 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1467 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1468 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1469 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1470 $(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 +00001471 $(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 +08001472 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001473 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001474 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001475)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001476$(if $(filter $(2),vendor_dlkm),\
1477 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1478 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1479 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1480 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1481 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1482 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1483 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1484 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1485 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1486 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1487 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1488 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1489)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001490$(if $(filter $(2),odm_dlkm),\
1491 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1492 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1493 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1494 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1495 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1496 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1497 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1498 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1499 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1500 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1501 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1502 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1503)
Yifan Hong760d3c02018-05-30 11:16:46 -07001504$(if $(filter $(2),oem),\
1505 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1506 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1507 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1508 $(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 -07001509 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001510)
Tao Bao3602eca2018-07-10 10:53:55 -07001511$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001512
Tao Bao3602eca2018-07-10 10:53:55 -07001513$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001514$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Gao Xiang961041a2020-06-17 13:59:16 +08001515$(if $(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG),$(hide) echo "erofs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001516$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001517$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001518$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1519$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1520$(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 +00001521$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1522$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1523$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1524$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1525$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001526$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001527$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1528$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1529$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001530$(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 -07001531$(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 -07001532$(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 +00001533$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1534$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1535$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1536$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1537$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001538$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001539$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1540$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1541$(if $(BOARD_AVB_ENABLE),\
1542 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1543 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1544 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1545 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001546$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1547$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1548$(if $(BOARD_AVB_ENABLE),\
1549 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1550 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001551 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001552$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1553$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1554$(if $(BOARD_AVB_ENABLE),\
1555 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1556 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1557 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1558 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001559$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1560$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1561$(if $(BOARD_AVB_ENABLE),\
1562 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1563 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1564 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1565 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001566$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001567$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001568 $(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 +01001569$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001570 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1571 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1572 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1573 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001574$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1575$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1576$(if $(BOARD_AVB_ENABLE),\
1577 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1578 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1579 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1580 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001581$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1582$(if $(BOARD_AVB_ENABLE),\
1583 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1584$(if $(BOARD_AVB_ENABLE),\
1585 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1586 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1587 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1588 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001589$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1590$(if $(BOARD_AVB_ENABLE),\
1591 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1592$(if $(BOARD_AVB_ENABLE),\
1593 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1594 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1595 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1596 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001597$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1598 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001599$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001600 $(hide) echo "system_root_image=true" >> $(1))
1601$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001602$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1603 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001604$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1605endef
1606
1607# $(1): the path of the output dictionary file
1608# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001609PROP_DICTIONARY_IMAGES := oem
1610ifdef BUILDING_CACHE_IMAGE
1611 PROP_DICTIONARY_IMAGES += cache
1612endif
1613ifdef BUILDING_SYSTEM_IMAGE
1614 PROP_DICTIONARY_IMAGES += system
1615endif
Chris Gross203191b2020-05-30 02:39:12 +00001616ifdef BUILDING_SYSTEM_OTHER_IMAGE
1617 PROP_DICTIONARY_IMAGES += system_other
1618endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001619ifdef BUILDING_USERDATA_IMAGE
1620 PROP_DICTIONARY_IMAGES += userdata
1621endif
1622ifdef BUILDING_VENDOR_IMAGE
1623 PROP_DICTIONARY_IMAGES += vendor
1624endif
1625ifdef BUILDING_PRODUCT_IMAGE
1626 PROP_DICTIONARY_IMAGES += product
1627endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001628ifdef BUILDING_SYSTEM_EXT_IMAGE
1629 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001630endif
1631ifdef BUILDING_ODM_IMAGE
1632 PROP_DICTIONARY_IMAGES += odm
1633endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001634ifdef BUILDING_VENDOR_DLKM_IMAGE
1635 PROP_DICTIONARY_IMAGES += vendor_dlkm
1636endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001637ifdef BUILDING_ODM_DLKM_IMAGE
1638 PROP_DICTIONARY_IMAGES += odm_dlkm
1639endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001640define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001641 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001642endef
1643
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001644# $(1): the path of the input dictionary file, where each line has the format key=value
1645# $(2): the key to look up
1646define read-image-prop-dictionary
1647$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1648endef
1649
The Android Open Source Project88b60792009-03-03 19:28:42 -08001650# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001651# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001652
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001653# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001654ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001655
Ying Wang37526142015-03-10 12:02:57 -07001656INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1657 $(ALL_DEFAULT_INSTALLED_MODULES))
1658
Tao Bao10fc9492018-08-14 12:17:48 -07001659INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1660INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1661
1662# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1663# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1664# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1665# the call to FILELIST.
1666ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001667INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001668$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1669else
1670$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1671endif
1672
1673$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001674$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001675 @echo Installed file list: $@
1676 @mkdir -p $(dir $@)
1677 @rm -f $@
1678 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001679 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001680
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001681recovery_sepolicy := \
1682 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001683 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001684 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001685 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1686 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1687 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001688 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001689 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001690 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1691 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1692 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001693
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001694# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1695# SELinux files
1696IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1697
Steve Muckle04b6f052020-08-09 14:36:56 -07001698# if building multiple boot images from multiple kernels, use the first kernel listed
1699# for the recovery image
1700recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001701recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001702recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001703
Anton Hansson45a40da2019-01-18 14:06:34 +00001704# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1705# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1706# which get remapped to a bucket.
1707recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001708ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1709recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001710# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001711# ------160------240------320----------480------------640------
1712# mdpi hdpi xhdpi xxhdpi xxxhdpi
1713recovery_density := $(strip \
1714 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1715 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1716 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1717 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001718endif
1719
1720ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1721recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1722else
Doug Zongker25d55f82014-04-04 13:51:15 -07001723recovery_resources_common := $(recovery_resources_common)-xhdpi
1724endif
1725
Tao Baoe1e829e2018-08-29 20:36:00 -07001726# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1727# Note that the font selected here can be overridden for a particular device by putting a font.png
1728# in its private recovery resources.
1729ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001730recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001731else
Dan Willemsen97672232020-05-27 00:09:16 -07001732recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001733endif
1734
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001735
1736# We will only generate the recovery background text images if the variable
1737# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1738# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1739# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1740# BoardConfig in order to use this feature.
1741ifeq ($(recovery_density),xxxhdpi)
1742TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1743else ifeq ($(recovery_density),xxhdpi)
1744TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1745endif
1746
1747ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1748# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1749ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1750 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1751else
1752 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1753endif
1754
1755
Dan Willemsen97672232020-05-27 00:09:16 -07001756RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001757RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1758RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1759RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1760RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1761
xunchangcc57d312018-12-07 12:12:17 -08001762RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1763RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1764RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1765RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1766RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1767
1768generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001769 $(RECOVERY_INSTALLING_TEXT_FILE) \
1770 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1771 $(RECOVERY_ERASING_TEXT_FILE) \
1772 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001773 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1774 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1775 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1776 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1777 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1778 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001779
Dan Willemsen97672232020-05-27 00:09:16 -07001780resource_dir := bootable/recovery/tools/recovery_l10n/res/
1781resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001782image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001783zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001784$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001785$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001786$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1787$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001788$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001789$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001790$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001791 recovery_installing \
1792 recovery_installing_security \
1793 recovery_erasing \
1794 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001795 recovery_no_command
1796$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001797 recovery_cancel_wipe_data \
1798 recovery_factory_data_reset \
1799 recovery_try_again \
1800 recovery_wipe_data_menu_header \
1801 recovery_wipe_data_confirmation
1802$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001803$(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 -08001804 # Prepares the font directory.
1805 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1806 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001807 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001808 @rm -rf $(dir $@)
1809 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001810 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001811 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001812 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001813 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1814 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1815 --text_name $(text_name) \
1816 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1817 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001818 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001819 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001820else
1821RECOVERY_INSTALLING_TEXT_FILE :=
1822RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1823RECOVERY_ERASING_TEXT_FILE :=
1824RECOVERY_ERROR_TEXT_FILE :=
1825RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001826RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1827RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1828RECOVERY_TRY_AGAIN_TEXT_FILE :=
1829RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1830RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001831endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1832
Ying Wang9a175682015-08-06 11:47:47 -07001833ifndef TARGET_PRIVATE_RES_DIRS
1834TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1835endif
Doug Zongker4647f122009-07-02 09:00:54 -07001836recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001837 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001838recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001839
1840
Andrew Boiefa61ff02012-09-28 09:33:45 -07001841ifdef TARGET_RECOVERY_FSTAB
1842recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1843else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001844recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001845endif
Tao Baoc3c17532016-06-10 10:11:54 -07001846ifdef TARGET_RECOVERY_WIPE
1847recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001848else
Tao Baoc3c17532016-06-10 10:11:54 -07001849recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001850endif
Tao Bao8beab692015-07-22 12:33:18 -07001851
Tao Bao6d5d6232018-03-09 17:04:42 -08001852# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001853# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001854# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1855# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001856#
1857# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001858# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001859# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001860# b) We build a single image that contains boot and recovery both - no recovery image to install
1861# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001862# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001863# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001864# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1865# do bsdiff because boot and recovery will contain different number of entries
1866# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001867# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1868# do bsdiff because boot and recovery will contain different number of entries
1869# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yifan Hongef7a9712020-10-20 13:17:42 -07001870# f) We build a single image that contains vendor_boot and recovery both - no recovery image to
1871# install
1872# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001873
Tom Cherry2929cad2018-09-20 11:04:37 -07001874ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yifan Hongef7a9712020-10-20 13:17:42 -07001875 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
1876 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07001877# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001878RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1879ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001880else
Tao Bao8beab692015-07-22 12:33:18 -07001881RECOVERY_RESOURCE_ZIP :=
1882endif
Doug Zongker4647f122009-07-02 09:00:54 -07001883
Tao Bao139c7272018-07-31 13:26:54 -07001884INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1885
1886$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001887 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1888 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1889 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1890 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1891 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1892 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1893 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1894 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1895
1896# Parses the given list of build variables and writes their values as build properties if defined.
1897# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1898# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1899# $(1): Map from the build variable names to property names
1900# $(2): Output file
1901define append-recovery-ui-properties
1902echo "#" >> $(2)
1903echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1904echo "#" >> $(2)
1905$(foreach prop,$(1), \
1906 $(eval _varname := $(call word-colon,1,$(prop))) \
1907 $(eval _propname := $(call word-colon,2,$(prop))) \
1908 $(eval _value := $($(_varname))) \
1909 $(if $(_value), \
1910 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1911endef
1912
1913$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001914 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001915 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1916 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1917 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001918 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001919 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001920 $(hide) mkdir -p $(dir $@)
1921 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001922 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001923 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001924 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001925 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001926 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001927 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1928
Yifan Hong33fd5d42020-09-24 18:18:26 -07001929# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
1930# On device with dedicated recovery partition, the file should come from the boot
1931# ramdisk.
1932ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
1933INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
1934$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
1935 $(copy-file-to-target)
1936endif
1937
Yifan Hongc56931c2020-10-28 16:35:19 -07001938INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07001939
Yifan Hong78860162020-10-28 14:15:21 -07001940ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07001941INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001942# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07001943ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001944ifdef INTERNAL_KERNEL_CMDLINE
1945 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07001946endif # INTERNAL_KERNEL_CMDLINE != ""
1947endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07001948ifdef BOARD_KERNEL_BASE
1949 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1950endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001951ifdef BOARD_KERNEL_PAGESIZE
1952 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1953endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001954ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001955ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1956 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1957else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001958 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1959endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001960endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001961ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1962 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1963endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001964ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1965 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1966endif
Yifan Hong3941a872020-10-28 16:33:06 -07001967endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07001968ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1969 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1970endif
Doug Zongker4647f122009-07-02 09:00:54 -07001971
Yifan Hong881df392020-10-09 14:29:39 -07001972$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001973 $(INTERNAL_ROOT_FILES) \
1974 $(INSTALLED_RAMDISK_TARGET) \
1975 $(INTERNAL_RECOVERYIMAGE_FILES) \
1976 $(recovery_sepolicy) \
1977 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1978 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07001979 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001980 $(recovery_resource_deps) \
1981 $(recovery_fstab)
1982 # Making recovery image
1983 mkdir -p $(TARGET_RECOVERY_OUT)
1984 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1985 # Copying baseline ramdisk...
1986 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1987 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1988 # Modifying ramdisk contents...
1989 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1990 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1991 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1992 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1993 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1994 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1995 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1996 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1997 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1998 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1999 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2000 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2001 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2002 $(foreach item,$(recovery_fstab), \
2003 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2004 $(if $(strip $(recovery_wipe)), \
2005 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2006 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2007 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002008 $(hide) touch $@
2009
2010$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002011 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002012
Ying Wang747b9f12015-01-30 14:05:22 -08002013# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002014# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002015define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002016 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002017 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002018 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002019 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002020 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002021 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002022 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002023 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002024 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002025 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2026 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002027 )\
2028 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002029 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2030 $(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 +08002031 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002032 $(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 -07002033 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002034 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2035 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002036 $(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 -07002037 $(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 -08002038endef
2039
Dan Willemsend120ac62020-06-12 02:39:34 +00002040recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002041ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00002042 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002043endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002044ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002045 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002046endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002047ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002048 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002049endif
Tao Baof4866c72018-08-22 14:35:09 -07002050ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002051 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2052 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2053 else
2054 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2055 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002056endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002057ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002058 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002059endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002060ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002061 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002062endif
Tao Baof4866c72018-08-22 14:35:09 -07002063
Dan Willemsend120ac62020-06-12 02:39:34 +00002064ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002065$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002066$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002067 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002068 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07002069endif # BOARD_USES_RECOVERY_AS_BOOT
2070
Dan Willemsend120ac62020-06-12 02:39:34 +00002071$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002072 $(call build-recoveryimage-target, $@, \
2073 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002074
Tao Bao4594d0e2015-12-22 09:47:46 -08002075ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002076$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002077 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002078 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2079 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002080endif
Doug Zongker56588872012-08-20 15:38:58 -07002081
Ying Wang747b9f12015-01-30 14:05:22 -08002082.PHONY: recoveryimage-nodeps
2083recoveryimage-nodeps:
2084 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002085 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2086 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002087
Chris Grossa784ef12019-04-22 11:09:57 -07002088else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002089RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002090endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002091
2092.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002093recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002094
Jiyong Park03eb0612017-10-04 21:22:41 +09002095ifneq ($(BOARD_NAND_PAGE_SIZE),)
2096$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002097endif
2098
Jiyong Park03eb0612017-10-04 21:22:41 +09002099ifneq ($(BOARD_NAND_SPARE_SIZE),)
2100$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002101endif
2102
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002103ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002104# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002105# the debug ramdisk, which is the original ramdisk plus additional
2106# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2107# When /force_debuggable is present, /init will load userdebug sepolicy
2108# and property files to allow adb root, if the device is unlocked.
2109
2110ifdef BUILDING_RAMDISK_IMAGE
2111BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2112INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2113
2114INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2115 $(ALL_GENERATED_SOURCES) \
2116 $(ALL_DEFAULT_INSTALLED_MODULES))
2117
2118# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2119# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2120# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2121my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2122
2123INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2124INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2125$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2126$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2127
2128# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2129# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2130# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2131$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002132$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002133 echo Installed file list: $@
2134 mkdir -p $(dir $@)
2135 rm -f $@
2136 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002137 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002138
2139# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2140# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2141ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2142my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2143else
2144my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2145endif # BOARD_USES_RECOVERY_AS_BOOT
2146
2147$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2148$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002149
2150ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2151# 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 +08002152$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002153else
2154# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2155$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2156endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002157$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002158 $(call pretty,"Target debug ram disk: $@")
2159 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2160 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002161 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002162 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002163
2164.PHONY: ramdisk_debug-nodeps
2165ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2166ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002167ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002168 echo "make $@: ignoring dependencies"
2169 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2170 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002171 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002172 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002173
2174my_debug_ramdisk_sync_dir :=
2175my_debug_ramdisk_root_dir :=
2176
2177endif # BUILDING_RAMDISK_IMAGE
2178
2179# -----------------------------------------------------------------
2180# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2181#
2182# Note: it's intentional to skip signing for boot-debug.img, because it
2183# can only be used if the device is unlocked with verification error.
Daniel Normanaf670812020-10-12 11:31:35 -07002184ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002185ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002186ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2187 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2188 $(PRODUCT_OUT)/$(k).img)
2189else
2190 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2191endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002192
2193# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2194ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2195INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2196else
2197INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2198endif
2199
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002200# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2201# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2202# Using a test key to sign boot-debug.img to continue booting with the mismatched
2203# public key, if the device is unlocked.
2204ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002205$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002206endif
2207
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002208BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2209INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2210# $(1): the bootimage to sign
2211define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002212$(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 +08002213$(AVBTOOL) add_hash_footer \
2214 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002215 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002216 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2217 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002218$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002219endef
2220
Steve Muckleb3dda772020-03-11 16:03:07 -07002221# $(1): output file
2222define build-debug-bootimage-target
2223 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2224 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2225 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2226endef
2227
Bowgo Tsai0013f552019-03-20 17:59:52 +08002228# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2229$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2230 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002231 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002232
2233.PHONY: bootimage_debug-nodeps
2234bootimage_debug-nodeps: $(MKBOOTIMG)
2235 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002236 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002237
2238endif # TARGET_NO_KERNEL
Daniel Normanaf670812020-10-12 11:31:35 -07002239endif # INSTALLED_BOOTIMAGE_TARGET
Bowgo Tsai0013f552019-03-20 17:59:52 +08002240
Bowgo Tsai6a683672020-02-14 19:00:15 +08002241ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2242ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2243# -----------------------------------------------------------------
2244# vendor debug ramdisk
2245# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002246INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002247$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2248$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2249
2250INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2251 $(ALL_GENERATED_SOURCES) \
2252 $(ALL_DEFAULT_INSTALLED_MODULES))
2253
2254# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2255# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2256# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2257# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2258$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2259$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002260$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002261 $(call pretty,"Target vendor debug ram disk: $@")
2262 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2263 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2264 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2265 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2266 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002267 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002268
2269INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2270INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2271$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2272$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2273
2274# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2275# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2276$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2277$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2278 echo Installed file list: $@
2279 mkdir -p $(dir $@)
2280 rm -f $@
2281 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2282 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2283
2284# -----------------------------------------------------------------
2285# vendor_boot-debug.img.
2286INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2287
2288# The util to sign vendor_boot-debug.img with a test key.
2289BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2290INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2291# $(1): the vendor bootimage to sign
2292define test-key-sign-vendor-bootimage
2293$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2294$(AVBTOOL) add_hash_footer \
2295 --image $(1) \
2296 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2297 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2298 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2299$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2300endef
2301
2302ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2303$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2304endif
2305
2306# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2307$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2308 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002309 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002310 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2311 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2312
2313endif # BUILDING_RAMDISK_IMAGE
2314endif # BUILDING_VENDOR_BOOT_IMAGE
2315
Bowgo Tsai0013f552019-03-20 17:59:52 +08002316# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002317# The test harness ramdisk, which is based off debug_ramdisk, plus a
2318# few additional test-harness-specific properties in adb_debug.prop.
2319
2320ifdef BUILDING_RAMDISK_IMAGE
2321BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2322INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2323
2324# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2325# appends a few test harness specific properties into the adb_debug.prop.
2326TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2327TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2328
2329# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2330# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2331TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2332ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2333ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2334
2335# $(1): a list of key=value pairs for additional property assignments
2336# $(2): the target .prop file to append the properties from $(1)
2337define append-test-harness-props
2338 echo "#" >> $(2); \
2339 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2340 echo "#" >> $(2);
2341 $(foreach line,$(1), echo "$(line)" >> $(2);)
2342endef
2343
2344$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002345$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002346 $(call pretty,"Target test harness ram disk: $@")
2347 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2348 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002349 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002350
2351.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002352ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002353 echo "make $@: ignoring dependencies"
2354 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2355 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002356 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002357
2358endif # BUILDING_RAMDISK_IMAGE
2359
2360# -----------------------------------------------------------------
2361# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2362#
2363# Note: it's intentional to skip signing for boot-test-harness.img, because it
2364# can only be used if the device is unlocked with verification error.
2365ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2366
Steve Muckle4866bd62020-04-02 11:31:08 -07002367ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2368 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2369 $(PRODUCT_OUT)/$(k).img)
2370else
2371 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2372endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002373
2374# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2375INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2376
2377# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2378# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2379# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2380# public key, if the device is unlocked.
2381ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2382$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2383endif
2384
Steve Muckle4866bd62020-04-02 11:31:08 -07002385# $(1): output file
2386define build-boot-test-harness-target
2387 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2388 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2389 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2390endef
2391
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002392# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2393$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2394 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002395 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002396
2397.PHONY: bootimage_test_harness-nodeps
2398bootimage_test_harness-nodeps: $(MKBOOTIMG)
2399 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002400 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002401
2402endif # TARGET_NO_KERNEL
2403endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2404
Colin Crossbd382142020-08-26 15:08:57 -07002405# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2406# $1: from location (e.g $(TARGET_OUT)/vendor)
2407# $2: destination location (e.g. /vendor)
2408# $3: partition image name (e.g. vendor.img)
2409define create-partition-compat-symlink
2410$(eval \
2411$1:
2412 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2413 mkdir -p $(dir $1)
2414 if [ -d $1 ] && [ ! -h $1 ]; then \
2415 echo 'Non-symlink $1 detected!' 1>&2; \
2416 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2417 exit 1; \
2418 fi
2419 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002420$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002421)
2422$1
2423endef
2424
2425
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002426# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002427# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002428
Dan Willemsen37a19862018-10-31 16:31:46 -07002429INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002430 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002431 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002432
Colin Crossbd382142020-08-26 15:08:57 -07002433# Create symlink /system/vendor to /vendor if necessary.
2434ifdef BOARD_USES_VENDORIMAGE
2435 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2436endif
2437
2438# Create symlink /system/product to /product if necessary.
2439ifdef BOARD_USES_PRODUCTIMAGE
2440 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2441endif
2442
2443# Create symlink /system/system_ext to /system_ext if necessary.
2444ifdef BOARD_USES_SYSTEM_EXTIMAGE
2445 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2446endif
2447
Ying Wang82cceba2012-08-13 15:03:00 -07002448FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002449
2450# ASAN libraries in the system image - add dependency.
2451ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002452ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002453 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2454 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2455 endif
2456endif
2457
Tom Cherryd14b8952018-08-09 14:26:00 -07002458FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002459
Ying Wange5e8c5f2011-09-09 16:35:53 -07002460# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002461ifdef BUILDING_SYSTEM_IMAGE
2462
Ying Wange5e8c5f2011-09-09 16:35:53 -07002463# installed file list
2464# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2465# We put installed-files.txt ahead of image itself in the dependency graph
2466# so that we can get the size stat even if the build fails due to too large
2467# system image.
2468INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002469INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2470$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002471$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002472 @echo Installed file list: $@
2473 @mkdir -p $(dir $@)
2474 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002475 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002476 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002477
2478.PHONY: installed-file-list
2479installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002480
2481$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002482
2483systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002484 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002485BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2486
The Android Open Source Project88b60792009-03-03 19:28:42 -08002487# $(1): output file
2488define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002489 @echo "Target system fs image: $(1)"
2490 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002491 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002492 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002493 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002494 $(BUILD_IMAGE) \
2495 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2496 || ( mkdir -p $${DIST_DIR}; \
2497 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2498 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002499endef
2500
Dan Willemsen6b72c732019-06-12 21:33:38 +00002501ifeq ($(BOARD_AVB_ENABLE),true)
2502$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2503endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002504$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002505 $(call build-systemimage-target,$@)
2506
Tao Baoe9d61b02018-08-20 21:09:07 -07002507INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002508SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002509
Tao Baoe9d61b02018-08-20 21:09:07 -07002510# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2511# compatibility, in case device-specific Makefiles still refer to the old name.
2512INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2513
Doug Zongker73ef8252009-07-23 15:12:53 -07002514# The system partition needs room for the recovery image as well. We
2515# now store the recovery image as a binary patch using the boot image
2516# as the source (since they are very similar). Generate the patch so
2517# we can see how big it's going to be, and include that in the system
2518# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002519ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002520ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002521ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002522ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002523diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2524else
2525diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2526endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002527intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2528RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002529$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2530$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002531 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002532 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002533 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002534 @echo "Construct recovery from boot"
2535 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002536 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002537else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2538RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002539endif # BOARD_USES_FULL_RECOVERY_IMAGE
2540endif # INSTALLED_RECOVERYIMAGE_TARGET
2541endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002542
Yifan Hong9a3cad92020-04-27 19:06:59 -07002543$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002544 @echo "Install system fs image: $@"
2545 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002546 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002547
Tao Baoe9d61b02018-08-20 21:09:07 -07002548systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002549
2550.PHONY: systemimage-nodeps snod
2551systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002552 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002553 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002554 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002555 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002556ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002557 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002558endif
2559
Dan Willemsen67495202019-01-16 12:42:05 -08002560endif # BUILDING_SYSTEM_IMAGE
2561
Anton Hansson30e061b2018-11-12 13:36:46 +00002562.PHONY: sync syncsys
2563sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002564
Ying Wang3a61eeb2016-03-11 10:32:01 -08002565# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002566# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002567.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002568platform:
2569 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002570
2571.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002572platform-java:
2573 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002574
Ying Wang3a61eeb2016-03-11 10:32:01 -08002575# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002576# data partition image
2577INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002578 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002579
Dan Willemsen67495202019-01-16 12:42:05 -08002580ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002581userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002582 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002583BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2584
Ying Wangbd93d422011-10-28 17:02:30 -07002585define build-userdataimage-target
2586 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2587 @mkdir -p $(TARGET_OUT_DATA)
2588 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002589 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002590 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002591 $(BUILD_IMAGE) \
2592 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2593 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2594 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002595endef
2596
Joe Onorato64d85d02009-04-09 19:31:12 -07002597# We just build this directly to the install location.
2598INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002599INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2600 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002601 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002602$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002603 $(build-userdataimage-target)
2604
2605.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002606userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002607 $(build-userdataimage-target)
2608
Dan Willemsen67495202019-01-16 12:42:05 -08002609endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002610
Andreas Gampe039b5c72017-03-24 16:06:31 -07002611# ASAN libraries in the system image - build rule.
2612ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2613 $(TARGET_OUT_SHARED_LIBRARIES) \
2614 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2615 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2616 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002617# Extra options: Enforce the system user for the files to avoid having to change ownership.
2618ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002619# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2620# enough space.
2621$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002622 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 -07002623
The Android Open Source Project88b60792009-03-03 19:28:42 -08002624# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002625# partition table image
2626ifdef BOARD_BPT_INPUT_FILES
2627
2628BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002629BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002630
2631INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2632 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002633 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002634 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2635
2636ifdef BOARD_BPT_DISK_SIZE
2637INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2638endif
2639
2640define build-bptimage-target
2641 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2642 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2643endef
2644
2645INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002646$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2647 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2648
David Zeuthen25328622016-04-08 15:08:03 -04002649$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2650 $(build-bptimage-target)
2651
2652.PHONY: bptimage-nodeps
2653bptimage-nodeps:
2654 $(build-bptimage-target)
2655
2656endif # BOARD_BPT_INPUT_FILES
2657
2658# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002659# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002660ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002661INTERNAL_CACHEIMAGE_FILES := \
2662 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2663
2664cacheimage_intermediates := \
2665 $(call intermediates-dir-for,PACKAGING,cache)
2666BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2667
2668define build-cacheimage-target
2669 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2670 @mkdir -p $(TARGET_OUT_CACHE)
2671 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002672 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002673 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002674 $(BUILD_IMAGE) \
2675 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2676 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2677 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002678endef
2679
2680# We just build this directly to the install location.
2681INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002682$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002683 $(build-cacheimage-target)
2684
2685.PHONY: cacheimage-nodeps
2686cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2687 $(build-cacheimage-target)
2688
Dan Willemsen67495202019-01-16 12:42:05 -08002689else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002690# we need to ignore the broken cache link when doing the rsync
2691IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002692endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002693
David Zeuthen0eb10972016-09-28 17:55:27 -04002694# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002695# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002696ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002697ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002698# Marker file to identify that odex files are installed
2699INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2700ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2701$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2702 $(hide) touch $@
2703endif
2704
Alex Light4e358ab2016-06-16 14:47:10 -07002705INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2706 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002707 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002708
Colin Cross6db5b0e2018-11-16 21:26:33 -08002709# system_other dex files are installed as a side-effect of installing system image files
2710INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2711
Alex Light4e358ab2016-06-16 14:47:10 -07002712INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002713INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2714$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002715$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002716 @echo Installed file list: $@
2717 @mkdir -p $(dir $@)
2718 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002719 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002720 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002721
Bowgo Tsai867ab662019-01-29 13:30:18 +08002722# Determines partition size for system_other.img.
2723ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2724ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2725INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2726endif
2727endif
2728
2729ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2730INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2731endif
2732
Alex Light4e358ab2016-06-16 14:47:10 -07002733systemotherimage_intermediates := \
2734 $(call intermediates-dir-for,PACKAGING,system_other)
2735BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2736
2737# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2738define build-systemotherimage-target
2739 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2740 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2741 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002742 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002743 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002744 $(BUILD_IMAGE) \
2745 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2746 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2747 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002748endef
2749
2750# We just build this directly to the install location.
2751INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002752ifneq (true,$(SANITIZE_LITE))
2753# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002754$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2755 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002756endif
Alex Light4e358ab2016-06-16 14:47:10 -07002757
2758.PHONY: systemotherimage-nodeps
2759systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2760 $(build-systemotherimage-target)
2761
Dan Willemsen67495202019-01-16 12:42:05 -08002762endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002763
2764
2765# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002766# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002767ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002768INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002769 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002770 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002771
Ying Wang8da19e32015-09-15 14:22:12 -07002772
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002773# Create symlink /vendor/odm to /odm if necessary.
2774ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002775 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002776endif
2777
Yifan Honge51dff22020-06-23 17:26:57 -07002778# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2779# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2780#
2781# On devices with a vendor_dlkm partition,
2782# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2783# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2784# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2785# are hidden.
2786# On devices without a vendor_dlkm partition,
2787# - /vendor/lib/modules stores vendor DLKMs directly.
2788# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2789# See system/core/rootdir/Android.mk for a list of created symlinks.
2790# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2791# are not guaranteed to exist on all devices.
2792ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002793 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 -07002794endif
2795
Colin Crossbd382142020-08-26 15:08:57 -07002796INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2797INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2798$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2799$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2800 @echo Installed file list: $@
2801 @mkdir -p $(dir $@)
2802 @rm -f $@
2803 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2804 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002805
Ying Wanga0febe52013-03-20 11:02:05 -07002806vendorimage_intermediates := \
2807 $(call intermediates-dir-for,PACKAGING,vendor)
2808BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002809define build-vendorimage-target
2810 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2811 @mkdir -p $(TARGET_OUT_VENDOR)
2812 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002813 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,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_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2817 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002818 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002819endef
2820
2821# We just build this directly to the install location.
2822INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002823$(INSTALLED_VENDORIMAGE_TARGET): \
2824 $(INTERNAL_USERIMAGES_DEPS) \
2825 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002826 $(INSTALLED_FILES_FILE_VENDOR) \
2827 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002828 $(build-vendorimage-target)
2829
Steven Morelanda2e734d2017-03-07 12:10:09 -08002830.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002831vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002832 $(build-vendorimage-target)
2833
Colin Cross91a52272017-06-20 16:57:52 -07002834sync: $(INTERNAL_VENDORIMAGE_FILES)
2835
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002836else ifdef BOARD_PREBUILT_VENDORIMAGE
2837INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2838$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2839endif
Ying Wanga0febe52013-03-20 11:02:05 -07002840
Ying Wang9f8e8db2011-11-04 11:37:01 -07002841# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002842# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002843ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002844INTERNAL_PRODUCTIMAGE_FILES := \
2845 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002846 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002847
2848INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002849INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2850$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002851$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002852 @echo Installed file list: $@
2853 @mkdir -p $(dir $@)
2854 @rm -f $@
2855 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002856 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002857
2858productimage_intermediates := \
2859 $(call intermediates-dir-for,PACKAGING,product)
2860BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2861define build-productimage-target
2862 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2863 @mkdir -p $(TARGET_OUT_PRODUCT)
2864 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002865 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002866 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002867 $(BUILD_IMAGE) \
2868 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2869 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2870 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002871endef
2872
2873# We just build this directly to the install location.
2874INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002875$(INSTALLED_PRODUCTIMAGE_TARGET): \
2876 $(INTERNAL_USERIMAGES_DEPS) \
2877 $(INTERNAL_PRODUCTIMAGE_FILES) \
2878 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002879 $(build-productimage-target)
2880
2881.PHONY: productimage-nodeps pnod
2882productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2883 $(build-productimage-target)
2884
2885sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2886
2887else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2888INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2889$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2890endif
2891
2892# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002893# system_ext partition image
2894ifdef BUILDING_SYSTEM_EXT_IMAGE
2895INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2896 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002897 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002898
Justin Yun6151e3f2019-06-25 15:58:13 +09002899INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2900INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2901$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2902$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002903 @echo Installed file list: $@
2904 @mkdir -p $(dir $@)
2905 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002906 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002907 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002908
Justin Yun6151e3f2019-06-25 15:58:13 +09002909system_extimage_intermediates := \
2910 $(call intermediates-dir-for,PACKAGING,system_ext)
2911BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2912define build-system_extimage-target
2913 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2914 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2915 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2916 $(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 -07002917 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002918 $(BUILD_IMAGE) \
2919 $(TARGET_OUT_SYSTEM_EXT) \
2920 $(system_extimage_intermediates)/system_ext_image_info.txt \
2921 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2922 $(TARGET_OUT)
2923 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002924endef
2925
2926# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002927INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002928$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2929 $(INTERNAL_USERIMAGES_DEPS) \
2930 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2931 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002932 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002933
Justin Yun6151e3f2019-06-25 15:58:13 +09002934.PHONY: systemextimage-nodeps senod
2935systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2936 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002937
Justin Yun6151e3f2019-06-25 15:58:13 +09002938sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002939
Justin Yun6151e3f2019-06-25 15:58:13 +09002940else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2941INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2942$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002943endif
2944
2945# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002946# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002947ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002948INTERNAL_ODMIMAGE_FILES := \
2949 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002950 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002951
Colin Crossbd382142020-08-26 15:08:57 -07002952# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2953# /odm/lib/modules -> /odm_dlkm/lib/modules
2954#
2955# On devices with a odm_dlkm partition,
2956# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2957# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2958# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2959# are hidden.
2960# On devices without a odm_dlkm partition,
2961# - /odm/lib/modules stores odm DLKMs directly.
2962# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2963# See system/core/rootdir/Android.mk for a list of created symlinks.
2964# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2965# are not guaranteed to exist on all devices.
2966ifdef BOARD_USES_ODM_DLKMIMAGE
2967 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
2968endif
2969
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002970INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2971INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2972$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002973$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002974 @echo Installed file list: $@
2975 @mkdir -p $(dir $@)
2976 @rm -f $@
2977 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002978 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002979
2980odmimage_intermediates := \
2981 $(call intermediates-dir-for,PACKAGING,odm)
2982BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2983define build-odmimage-target
2984 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2985 @mkdir -p $(TARGET_OUT_ODM)
2986 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2987 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002988 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002989 $(BUILD_IMAGE) \
2990 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2991 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2992 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002993endef
2994
2995# We just build this directly to the install location.
2996INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002997$(INSTALLED_ODMIMAGE_TARGET): \
2998 $(INTERNAL_USERIMAGES_DEPS) \
2999 $(INTERNAL_ODMIMAGE_FILES) \
3000 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003001 $(build-odmimage-target)
3002
3003.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003004odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003005 $(build-odmimage-target)
3006
3007sync: $(INTERNAL_ODMIMAGE_FILES)
3008
3009else ifdef BOARD_PREBUILT_ODMIMAGE
3010INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3011$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3012endif
3013
3014# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003015# vendor_dlkm partition image
3016ifdef BUILDING_VENDOR_DLKM_IMAGE
3017INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3018 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003019 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003020
3021INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3022INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3023$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3024$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3025 @echo Installed file list: $@
3026 @mkdir -p $(dir $@)
3027 @rm -f $@
3028 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3029 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3030
3031vendor_dlkmimage_intermediates := \
3032 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3033BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3034define build-vendor_dlkmimage-target
3035 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3036 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3037 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
3038 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
3039 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3040 $(BUILD_IMAGE) \
3041 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3042 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3043 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3044endef
3045
3046# We just build this directly to the install location.
3047INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3048$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3049 $(INTERNAL_USERIMAGES_DEPS) \
3050 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3051 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3052 $(build-vendor_dlkmimage-target)
3053
3054.PHONY: vendor_dlkmimage-nodeps vdnod
3055vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3056 $(build-vendor_dlkmimage-target)
3057
3058sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3059
3060else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3061INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3062$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3063endif
3064
3065# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003066# odm_dlkm partition image
3067ifdef BUILDING_ODM_DLKM_IMAGE
3068INTERNAL_ODM_DLKMIMAGE_FILES := \
3069 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003070 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003071
3072INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3073INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3074$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3075$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3076 @echo Installed file list: $@
3077 @mkdir -p $(dir $@)
3078 @rm -f $@
3079 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3080 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3081
3082odm_dlkmimage_intermediates := \
3083 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3084BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3085define build-odm_dlkmimage-target
3086 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3087 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3088 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3089 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3090 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3091 $(BUILD_IMAGE) \
3092 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3093 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3094 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3095endef
3096
3097# We just build this directly to the install location.
3098INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3099$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3100 $(INTERNAL_USERIMAGES_DEPS) \
3101 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3102 $(INSTALLED_FILES_FILE_ODM_DLKM)
3103 $(build-odm_dlkmimage-target)
3104
3105.PHONY: odm_dlkmimage-nodeps odnod
3106odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3107 $(build-odm_dlkmimage-target)
3108
3109sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3110
3111else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3112INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3113$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3114endif
3115
3116
3117# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003118# dtbo image
3119ifdef BOARD_PREBUILT_DTBOIMAGE
3120INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3121
3122ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003123$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003124 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3125 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003126 --image $@ \
3127 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3128 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3129 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003130else
3131$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3132 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3133endif
3134
Tao Bao0da43472018-08-22 22:53:41 -07003135endif # BOARD_PREBUILT_DTBOIMAGE
3136
3137# Returns a list of image targets corresponding to the given list of partitions. For example, it
3138# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3139# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003140# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003141define images-for-partitions
3142$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3143endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003144
3145# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003146# custom images
3147INSTALLED_CUSTOMIMAGES_TARGET :=
3148
3149ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3150INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3151
3152# Sign custom image.
3153# $(1): the prebuilt custom image.
3154# $(2): the mount point of the prebuilt custom image.
3155# $(3): the signed custom image target.
3156define sign_custom_image
3157$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3158 @echo Target custom image: $(3)
3159 mkdir -p $(dir $(3))
3160 cp $(1) $(3)
3161ifeq ($(BOARD_AVB_ENABLE),true)
3162 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3163 $(AVBTOOL) add_hashtree_footer \
3164 --image $(3) \
3165 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3166 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3167 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3168 --partition_name $(2) \
3169 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3170 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3171endif
3172INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3173endef
3174
3175$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3176 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3177 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3178endif
3179
3180# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003181# vbmeta image
3182ifeq ($(BOARD_AVB_ENABLE),true)
3183
3184BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003185AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003186
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003187ifdef BOARD_AVB_KEY_PATH
3188$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3189else
3190# If key path isn't specified, use the 4096-bit test key.
3191BOARD_AVB_ALGORITHM := SHA256_RSA4096
3192BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3193endif
3194
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003195# AVB signing for system_other.img.
3196ifdef BUILDING_SYSTEM_OTHER_IMAGE
3197ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3198$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3199else
3200# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3201BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3202BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3203endif
3204
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003205$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3206 @echo Extracting system_other avb key: $@
3207 @rm -f $@
3208 @mkdir -p $(dir $@)
3209 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003210
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003211ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3212BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3213endif
3214
3215BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3216endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3217
Tao Bao744c4c72018-08-20 21:09:07 -07003218INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003219 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003220 $(BOARD_AVB_VBMETA_VENDOR)
3221
3222# Not allowing the same partition to appear in multiple groups.
3223ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003224 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003225endif
3226
cfig1aeef722019-09-20 22:45:06 +08003227# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3228# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3229# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003230ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003231ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3232$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003233 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003234 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3235endif
3236endif
3237
Bowgo Tsai9b548012019-05-14 16:57:03 +08003238# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003239
3240BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003241 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003242 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003243 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3244
3245BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003246 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003247 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003248 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3249
Justin Yun6151e3f2019-06-25 15:58:13 +09003250BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003251 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003252 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003253 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003254
Bowgo Tsai9b548012019-05-14 16:57:03 +08003255BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003256 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003257 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003258
Tao Bao19b02fe2019-10-09 00:04:28 -07003259BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3260 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3261
3262BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3263 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3264
Bowgo Tsai9b548012019-05-14 16:57:03 +08003265BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003266 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003267 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003268
3269BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003270 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003271 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003272
Yifan Hongcfb917a2020-05-07 14:58:20 -07003273BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3274 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3275 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3276
Yifan Hongf496f1b2020-07-15 16:52:59 -07003277BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3278 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3279 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3280
Tao Bao19b02fe2019-10-09 00:04:28 -07003281BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3282 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3283
Bowgo Tsai9b548012019-05-14 16:57:03 +08003284# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003285ifdef BOOT_SECURITY_PATCH
3286BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3287 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3288endif
3289
3290ifdef VENDOR_SECURITY_PATCH
3291BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3292 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3293endif
3294
3295ifdef ODM_SECURITY_PATCH
3296BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3297 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3298endif
3299
Yifan Hongcfb917a2020-05-07 14:58:20 -07003300ifdef VENDOR_DLKM_SECURITY_PATCH
3301BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3302 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3303endif
3304
Yifan Hongf496f1b2020-07-15 16:52:59 -07003305ifdef ODM_DLKM_SECURITY_PATCH
3306BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3307 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3308endif
3309
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003310BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003311VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003312DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3313SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3314VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003315RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003316PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003317SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003318ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003319VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003320ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003321
Tao Bao0da43472018-08-22 22:53:41 -07003322# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003323# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003324define _check-and-set-avb-chain-args
3325$(eval part := $(1))
3326$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003327
3328$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3329$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3330$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3331$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3332$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3333$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3334$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3335$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3336
3337# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3338$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3339$(eval $(_signing_args) := \
3340 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3341
cfig1aeef722019-09-20 22:45:06 +08003342# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3343# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003344$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003345 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3346 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003347
Tao Bao744c4c72018-08-20 21:09:07 -07003348# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003349# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003350$(if $(filter $(part),$(part:vbmeta_%=%)),\
3351 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3352 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003353endef
3354
Tao Bao0da43472018-08-22 22:53:41 -07003355# Checks and sets the required build variables for an AVB partition. The partition will be
3356# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003357# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3358# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003359# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3360# but vbmeta would capture the image descriptor of only the first boot
3361# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003362# $(1): Partition name, e.g. boot or system.
3363define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003364$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003365$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003366 $(if $(_in_chained_vbmeta),\
3367 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003368 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003369 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003370 $(if $(filter boot,$(1)),\
3371 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3372 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3373 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3374 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003375endef
3376
Hongguang Chenf23364d2020-04-27 18:36:36 -07003377# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3378# $(1): the custom partition to enable AVB chain.
3379define check-and-set-custom-avb-chain-args
3380$(eval part := $(1))
3381$(eval PART=$(call to-upper,$(part)))
3382$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3383$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3384
3385INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3386 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3387endef
3388
Tao Baob1a2e352018-08-14 16:17:12 -07003389ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003390$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003391endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003392
Steve Mucklee1b10862019-07-10 10:49:37 -07003393ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3394$(eval $(call check-and-set-avb-args,vendor_boot))
3395endif
3396
Tao Bao0da43472018-08-22 22:53:41 -07003397$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003398
3399ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003400$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003401endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003402
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003403ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003404$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003405endif
3406
Justin Yun6151e3f2019-06-25 15:58:13 +09003407ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3408$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003409endif
3410
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003411ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003412$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003413endif
3414
Yifan Hongcfb917a2020-05-07 14:58:20 -07003415ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3416$(eval $(call check-and-set-avb-args,vendor_dlkm))
3417endif
3418
Yifan Hongf496f1b2020-07-15 16:52:59 -07003419ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3420$(eval $(call check-and-set-avb-args,odm_dlkm))
3421endif
3422
Yueyao Zhu211c9012017-04-27 00:34:50 -07003423ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003424$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003425endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003426
David Zeuthen8fecb282017-12-01 16:24:01 -05003427ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003428$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003429endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003430
David Anderson7709ab22018-10-15 14:41:34 -07003431# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3432ifdef BOARD_AVB_VBMETA_SYSTEM
3433$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003434endif
3435
3436ifdef BOARD_AVB_VBMETA_VENDOR
3437$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3438endif
3439
Hongguang Chenf23364d2020-04-27 18:36:36 -07003440ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3441$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3442 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3443endif
3444
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003445# Add kernel cmdline descriptor for kernel to mount system.img as root with
3446# dm-verity. This works when system.img is either chained or not-chained:
3447# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3448# cmdline descriptor to system.img
3449# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3450# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003451ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003452ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003453BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003454endif
David Anderson8916a2a2018-09-18 15:46:59 -07003455endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003456
Tao Bao0da43472018-08-22 22:53:41 -07003457BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003458BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003459BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3460
3461ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003462# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003463BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003464endif
Tao Bao0da43472018-08-22 22:53:41 -07003465
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003466ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003467BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003468endif
3469
David Anderson7709ab22018-10-15 14:41:34 -07003470ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3471BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3472 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003473endif
3474
3475ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3476BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3477 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003478endif
3479
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003480# $(1): the directory to extract public keys to
3481define extract-avb-chain-public-keys
3482 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3483 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3484 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003485 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3486 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3487 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003488 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3489 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3490 --output $(1)/system.avbpubkey)
3491 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3492 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3493 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003494 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3495 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3496 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003497 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3498 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3499 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003500 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3501 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3502 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003503 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3504 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3505 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003506 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3507 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3508 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003509 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3510 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3511 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003512 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3513 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3514 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003515 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3516 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3517 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003518 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3519 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3520 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003521 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3522 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3523 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3524 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003525endef
3526
Tao Bao744c4c72018-08-20 21:09:07 -07003527# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3528# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003529# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003530# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3531# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003532# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003533# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003534# $(2): Output filename.
3535define build-chained-vbmeta-image
3536 $(call pretty,"Target chained vbmeta image: $@")
3537 $(hide) $(AVBTOOL) make_vbmeta_image \
3538 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3539 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3540 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3541 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3542 --output $@
3543endef
3544
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003545ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003546ifdef BOARD_AVB_VBMETA_SYSTEM
3547INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3548$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003549 $(AVBTOOL) \
3550 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3551 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003552 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003553endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003554endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003555
3556ifdef BOARD_AVB_VBMETA_VENDOR
3557INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3558$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003559 $(AVBTOOL) \
3560 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3561 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003562 $(call build-chained-vbmeta-image,vbmeta_vendor)
3563endif
3564
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003565define build-vbmetaimage-target
3566 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003567 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3568 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003569 $(hide) $(AVBTOOL) make_vbmeta_image \
3570 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003571 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003572 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3573 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003574 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003575endef
3576
Paul Trautrim4e143232019-08-13 16:30:57 +09003577ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003578INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003579$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3580 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3581
David Zeuthen8fecb282017-12-01 16:24:01 -05003582$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003583 $(AVBTOOL) \
3584 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003585 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003586 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3587 $(INSTALLED_VENDORIMAGE_TARGET) \
3588 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003589 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003590 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003591 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003592 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003593 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003594 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003595 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3596 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3597 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3598 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3599 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3600 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003601 $(build-vbmetaimage-target)
3602
3603.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003604vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3605 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003606vbmetaimage-nodeps:
3607 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003608endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003609
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003610endif # BOARD_AVB_ENABLE
3611
3612# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003613# Check VINTF of build
3614
Yifan Hongc08cbf02020-09-15 19:07:39 +00003615# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003616ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003617
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003618intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3619check_vintf_all_deps :=
3620
Yifan Hongaf9b0702020-01-21 12:46:57 -08003621# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3622# because they are only used for prebuilt images.
3623check_vintf_common_srcs_patterns := \
3624 $(TARGET_OUT)/etc/vintf/% \
3625 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3626 $(TARGET_OUT_ODM)/etc/vintf/% \
3627 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3628 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3629
3630check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3631 $(INTERNAL_SYSTEMIMAGE_FILES) \
3632 $(INTERNAL_VENDORIMAGE_FILES) \
3633 $(INTERNAL_ODMIMAGE_FILES) \
3634 $(INTERNAL_PRODUCTIMAGE_FILES) \
3635 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3636))
3637check_vintf_common_srcs_patterns :=
3638
3639check_vintf_has_system :=
3640check_vintf_has_vendor :=
3641
Yifan Hong28ffd732020-03-13 13:11:10 -07003642ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3643$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3644endif
3645ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3646$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3647endif
3648
Yifan Hong605ea042020-01-14 21:36:00 +00003649# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003650check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3651ifneq ($(check_vintf_system_deps),)
3652check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00003653
Yifan Hong605ea042020-01-14 21:36:00 +00003654check_vintf_system_log := $(intermediates)/check_vintf_system_log
3655check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003656$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003657 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3658check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00003659
3660vintffm_log := $(intermediates)/vintffm_log
3661check_vintf_all_deps += $(vintffm_log)
3662$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
3663 @( $< --check --dirmap /system:$(TARGET_OUT) \
3664 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3665
Yifan Hongaf9b0702020-01-21 12:46:57 -08003666endif # check_vintf_system_deps
3667check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003668
3669# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003670check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3671ifneq ($(check_vintf_vendor_deps),)
3672check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003673check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3674check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003675# Check vendor SKU=(empty) case when:
3676# - DEVICE_MANIFEST_FILE is not empty; OR
3677# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003678$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003679 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3680 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003681 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003682$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003683 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3684 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3685 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3686 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003687check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003688endif # check_vintf_vendor_deps
3689check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003690
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003691# -- Check VINTF compatibility of build.
3692# Skip partial builds; only check full builds. Only check if:
3693# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003694# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003695# - Building product / system_ext / odm images if board has product / system_ext / odm images
3696ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003697ifeq ($(check_vintf_has_system),true)
3698ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003699ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3700ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3701ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3702
3703check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3704check_vintf_all_deps += $(check_vintf_compatible_log)
3705
3706check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003707check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003708
3709# -- Kernel version and configurations.
3710ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3711
Yifan Hong605ea042020-01-14 21:36:00 +00003712BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3713BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3714
3715my_board_extracted_kernel :=
3716
3717# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3718# from INSTALLED_KERNEL_TARGET.
3719ifdef BOARD_KERNEL_CONFIG_FILE
3720ifdef BOARD_KERNEL_VERSION
3721$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3722 cp $< $@
3723$(BUILT_KERNEL_VERSION_FILE):
3724 echo $(BOARD_KERNEL_VERSION) > $@
3725
3726my_board_extracted_kernel := true
3727endif # BOARD_KERNEL_VERSION
3728endif # BOARD_KERNEL_CONFIG_FILE
3729
3730ifneq ($(my_board_extracted_kernel),true)
3731ifndef INSTALLED_KERNEL_TARGET
3732$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3733 is true. Information about the updated kernel cannot be built into OTA update package. \
3734 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3735 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3736 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3737 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3738 manually.)
3739else
3740
3741# Tools for decompression that is not in PATH.
3742# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3743# Algorithms that are in the script but not in this list will be found in PATH.
3744my_decompress_tools := \
3745 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3746
3747$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3748$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3749$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003750$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3751 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003752 --output-configs $@ \
3753 --output-version $(BUILT_KERNEL_VERSION_FILE)
3754
3755my_decompress_tools :=
3756
3757endif # my_board_extracted_kernel
3758my_board_extracted_kernel :=
3759
3760endif # INSTALLED_KERNEL_TARGET
3761
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003762check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3763check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3764
3765endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3766
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003767check_vintf_compatible_args += \
3768 --dirmap /system:$(TARGET_OUT) \
3769 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3770 --dirmap /odm:$(TARGET_OUT_ODM) \
3771 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3772 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3773
3774ifdef PRODUCT_SHIPPING_API_LEVEL
3775check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3776endif # PRODUCT_SHIPPING_API_LEVEL
3777
3778$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3779$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003780# Check ODM SKU=(empty) case when:
3781# - ODM_MANIFEST_FILES is not empty; OR
3782# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003783$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003784 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3785 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003786 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003787# Check vendor SKU=(empty) case when:
3788# - DEVICE_MANIFEST_FILE is not empty; OR
3789# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003790$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003791 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3792 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003793 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003794$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3795 @echo -n -e 'Deps: \n ' > $@
3796 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3797 @echo -n -e 'Args: \n ' >> $@
3798 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003799 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3800 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003801 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003802 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3803 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3804 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003805
3806check_vintf_compatible_log :=
3807check_vintf_compatible_args :=
3808check_vintf_compatible_deps :=
3809
3810endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3811endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3812endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003813endif # check_vintf_has_vendor
3814endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003815endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3816
3817# Add all logs of VINTF checks to dist builds
3818droid_targets: $(check_vintf_all_deps)
3819$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3820
3821# Helper alias to check all VINTF of current build.
3822.PHONY: check-vintf-all
3823check-vintf-all: $(check_vintf_all_deps)
3824 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3825
Yifan Hongaf9b0702020-01-21 12:46:57 -08003826check_vintf_has_vendor :=
3827check_vintf_has_system :=
3828check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003829check_vintf_all_deps :=
3830intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003831endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003832
3833# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003834# Check image sizes <= size of super partition
3835
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003836ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003837
3838ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003839
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003840# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003841# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003842define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003843 mkdir -p $(dir $(1))
3844 rm -f $(1)
3845 $(call dump-super-image-info, $(1))
3846 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3847 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003848 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003849endef
3850
Yifan Hong30910932019-10-25 20:36:55 -07003851check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3852droid_targets: $(check_all_partition_sizes_log)
3853$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003854
Yifan Hong30910932019-10-25 20:36:55 -07003855$(check_all_partition_sizes_log): \
3856 $(CHECK_PARTITION_SIZES) \
3857 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3858 $(call check-all-partition-sizes-target, \
3859 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3860 $@)
3861
3862.PHONY: check-all-partition-sizes
3863check-all-partition-sizes: $(check_all_partition_sizes_log)
3864
3865.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003866check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003867 $(call check-all-partition-sizes-target, \
3868 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003869
Yifan Hong2dae5722018-07-31 12:47:27 -07003870endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003871
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003872endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003873
3874# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003875# bring in the installer image generation defines if necessary
3876ifeq ($(TARGET_USE_DISKINSTALLER),true)
3877include bootable/diskinstaller/config.mk
3878endif
3879
3880# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003881# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003882
Ying Wangbd2d0242015-09-22 11:17:52 -07003883ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003884 build_ota_package := false
3885 build_otatools_package := false
3886else
Tao Bao9be20c72019-04-08 21:11:59 -07003887 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003888 build_ota_package := true
3889 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3890 build_ota_package := false
3891 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003892 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003893 build_ota_package := false
3894 endif
3895 ifeq ($(TARGET_PRODUCT),sdk)
3896 build_ota_package := false
3897 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003898 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3899 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3900 build_ota_package := false
3901 endif
3902 ifeq ($(TARGET_NO_KERNEL),true)
3903 build_ota_package := false
3904 endif
3905 ifeq ($(recovery_fstab),)
3906 build_ota_package := false
3907 endif
3908 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003909
Tao Bao9be20c72019-04-08 21:11:59 -07003910 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003911 build_otatools_package := true
3912 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3913 build_otatools_package := false
3914 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003915endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003916
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003917ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003918
3919INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003920 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003921 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003922 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003923 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003924 append2simg \
3925 avbtool \
3926 blk_alloc_to_base_fs \
3927 boot_signer \
3928 brillo_update_payload \
3929 brotli \
3930 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003931 build_image \
3932 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003933 build_verity_metadata \
3934 build_verity_tree \
3935 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003936 check_ota_package_signature \
3937 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003938 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003939 checkvintf \
3940 delta_generator \
3941 e2fsck \
3942 e2fsdroid \
3943 fc_sort \
3944 fec \
3945 fs_config \
3946 generate_verity_key \
3947 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003948 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003949 imgdiff \
3950 libconscrypt_openjdk_jni \
3951 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003952 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003953 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003954 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003955 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003956 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003957 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003958 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003959 mkbootfs \
3960 mkbootimg \
3961 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003962 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08003963 mkfs.erofs \
3964 mkerofsimage.sh \
Tao Bao96daeeb2019-05-01 21:17:13 -07003965 mkf2fsuserimg.sh \
3966 mksquashfs \
3967 mksquashfsimage.sh \
3968 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003969 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003970 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003971 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003972 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003973 sign_apex \
3974 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003975 signapk \
3976 simg2img \
3977 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07003978 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07003979 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003980 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003981 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003982 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003983 verity_signer \
3984 verity_verifier \
3985 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003986
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003987# Additional tools to unpack and repack the apex file.
3988INTERNAL_OTATOOLS_MODULES += \
3989 apexer \
3990 deapexer \
3991 debugfs_static \
3992 merge_zips \
3993 resize2fs \
3994 soong_zip \
3995
Anton Hansson8dab0a62019-03-28 15:45:40 +00003996ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003997INTERNAL_OTATOOLS_MODULES += \
3998 futility \
3999 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004000endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004001
Tao Bao96daeeb2019-05-01 21:17:13 -07004002INTERNAL_OTATOOLS_FILES := \
4003 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004004
Ying Wang06898662010-06-17 17:52:18 -07004005.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004006otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004007
Tao Bao96daeeb2019-05-01 21:17:13 -07004008# For each module, recursively resolve its host shared library dependencies. Then we have a full
4009# list of modules whose installed files need to be packed.
4010INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4011 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4012 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004013
Tao Bao96daeeb2019-05-01 21:17:13 -07004014INTERNAL_OTATOOLS_PACKAGE_FILES := \
4015 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4016
4017INTERNAL_OTATOOLS_PACKAGE_FILES += \
4018 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4019 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004020
4021ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004022INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004023 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004024 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004025endif
4026ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004027INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004028 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4029 -name "atx_metadata.bin"))
4030endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004031ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004032INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004033 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004034endif
4035
Tao Bao96daeeb2019-05-01 21:17:13 -07004036INTERNAL_OTATOOLS_RELEASETOOLS := \
4037 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4038 \( -type f -o -type l \) -print))
4039
4040BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4041$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4042$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4043$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4044$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004045$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004046 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004047 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4048 mkdir -p $(dir $@)
4049 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4050 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004051 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004052 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004053
4054.PHONY: otatools-package
4055otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4056
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004057endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004058
The Android Open Source Project88b60792009-03-03 19:28:42 -08004059# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004060# misc_info.txt
4061
4062INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4063
4064ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4065# default to common dir for device vendor
4066tool_extensions := $(TARGET_DEVICE_DIR)/../common
4067else
4068tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4069endif
4070.KATI_READONLY := tool_extensions
4071
Steve Muckle903a1ca2020-05-07 17:32:10 -07004072# $1: boot image file name
4073define misc_boot_size
4074$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4075endef
4076
Daniel Normane1e48082019-06-27 13:55:23 -07004077$(INSTALLED_MISC_INFO_TARGET):
4078 rm -f $@
4079 $(call pretty,"Target misc_info.txt: $@")
4080 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4081 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4082ifdef BOARD_FLASH_BLOCK_SIZE
4083 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4084endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004085ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4086 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4087 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004088endif
4089ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4090 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004091else
4092 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004093endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004094ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4095 echo "lz4_ramdisks=true" >> $@
4096endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004097ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4098 echo "vendor_boot=true" >> $@
4099 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4100endif
Daniel Normane1e48082019-06-27 13:55:23 -07004101ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4102 $(hide) echo "no_recovery=true" >> $@
4103endif
4104ifdef BOARD_INCLUDE_RECOVERY_DTBO
4105 $(hide) echo "include_recovery_dtbo=true" >> $@
4106endif
4107ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4108 $(hide) echo "include_recovery_acpio=true" >> $@
4109endif
4110ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4111 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4112endif
4113ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4114 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4115 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4116else
4117 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4118endif
4119 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4120 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4121ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4122 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4123endif
4124 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004125 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004126 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4127 $(hide) echo "multistage_support=1" >> $@
4128 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4129ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4130 $(hide) echo "build_generic_ota_package=true" >> $@
4131endif
4132ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4133 # OTA scripts are only interested in fingerprint related properties
4134 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4135endif
4136ifneq (,$(filter address, $(SANITIZE_TARGET)))
4137 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4138 $(hide) echo "userdata_img_with_data=true" >> $@
4139endif
4140ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4141 $(hide) echo "full_recovery_image=true" >> $@
4142endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004143ifdef BOARD_USES_VENDORIMAGE
4144 $(hide) echo "board_uses_vendorimage=true" >> $@
4145endif
Daniel Normane1e48082019-06-27 13:55:23 -07004146ifeq ($(BOARD_AVB_ENABLE),true)
4147 $(hide) echo "avb_enable=true" >> $@
4148 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4149 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4150 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4151 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4152ifdef BOARD_AVB_BOOT_KEY_PATH
4153 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4154 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4155 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4156endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004157 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4158ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4159 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4160 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4161 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4162endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004163 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4164ifdef BOARD_AVB_RECOVERY_KEY_PATH
4165 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4166 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4167 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4168endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004169ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4170 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4171 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4172 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4173 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4174 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4175 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4176 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4177 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4178endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004179ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4180 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4181 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4182 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4183 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4184 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4185endif # BOARD_AVB_VBMETA_SYSTEM
4186ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4187 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4188 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4189 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4190 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4191 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4192endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4193endif # BOARD_AVB_ENABLE
4194ifdef BOARD_BPT_INPUT_FILES
4195 $(hide) echo "board_bpt_enable=true" >> $@
4196 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4197 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4198endif
4199ifdef BOARD_BPT_DISK_SIZE
4200 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4201endif
4202 $(call generate-userimage-prop-dictionary, $@)
4203ifeq ($(AB_OTA_UPDATER),true)
4204 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4205 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4206 $(hide) echo "ab_update=true" >> $@
4207endif
Yifan Hong65afc072020-04-17 10:08:10 -07004208ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4209 $(hide) echo "allow_non_ab=true" >> $@
4210endif
Daniel Normane1e48082019-06-27 13:55:23 -07004211ifdef BOARD_PREBUILT_DTBOIMAGE
4212 $(hide) echo "has_dtbo=true" >> $@
4213ifeq ($(BOARD_AVB_ENABLE),true)
4214 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4215 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4216ifdef BOARD_AVB_DTBO_KEY_PATH
4217 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4218 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4219 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4220endif # BOARD_AVB_DTBO_KEY_PATH
4221endif # BOARD_AVB_ENABLE
4222endif # BOARD_PREBUILT_DTBOIMAGE
4223 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004224 @# VINTF checks
4225ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4226 $(hide) echo "vintf_enforce=true" >> $@
4227endif
4228ifdef ODM_MANIFEST_SKUS
4229 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4230endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004231ifdef ODM_MANIFEST_FILES
4232 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4233endif
4234ifdef DEVICE_MANIFEST_SKUS
4235 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4236endif
4237ifdef DEVICE_MANIFEST_FILE
4238 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4239endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004240ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4241 $(hide) echo "bootloader_in_update_package=true" >> $@
4242endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07004243ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
4244 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
4245endif
Daniel Normane1e48082019-06-27 13:55:23 -07004246
4247.PHONY: misc_info
4248misc_info: $(INSTALLED_MISC_INFO_TARGET)
4249
4250droidcore: $(INSTALLED_MISC_INFO_TARGET)
4251
4252# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004253# A zip of the directories that map to the target filesystem.
4254# This zip can be used to create an OTA package or filesystem image
4255# as a post-build step.
4256#
4257name := $(TARGET_PRODUCT)
4258ifeq ($(TARGET_BUILD_TYPE),debug)
4259 name := $(name)_debug
4260endif
4261name := $(name)-target_files-$(FILE_NAME_TAG)
4262
4263intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4264BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4265$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4266$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004267 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004268
4269# $(1): Directory to copy
4270# $(2): Location to copy it to
4271# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4272define package_files-copy-root
4273 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4274 mkdir -p $(2) && \
4275 $(ACP) -rd $(strip $(1))/* $(2); \
4276 fi
4277endef
4278
Tao Baoa04fca32015-11-30 12:22:24 -08004279built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004280
4281# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004282ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004283built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004284 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004285endif
4286
The Android Open Source Project88b60792009-03-03 19:28:42 -08004287$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4288
Dan Willemsen653bea92017-03-21 15:47:37 -07004289tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004290$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004291
Sen Jiang4438fd92016-03-07 16:51:01 -08004292ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004293updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004294endif
4295
4296# Build OTA tools if non-A/B is allowed
4297ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004298updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004299endif
Yifan Hong65afc072020-04-17 10:08:10 -07004300
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004301$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004302
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004303# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07004304# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004305ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4306$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07004307else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
4308$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004309else
4310$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4311endif
4312
Dan Willemsen653bea92017-03-21 15:47:37 -07004313ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004314 ifdef OSRELEASED_DIRECTORY
4315 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4316 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4317 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4318 endif
Tao Baoa835f382019-07-18 15:55:30 -07004319
4320 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4321 # additionally include radio or bootloader partitions).
4322 ifeq ($(AB_OTA_PARTITIONS),)
4323 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4324 endif
4325endif
4326
4327ifneq ($(AB_OTA_PARTITIONS),)
4328 ifneq ($(AB_OTA_UPDATER),true)
4329 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4330 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004331endif
4332
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004333# Run fs_config while creating the target files package
4334# $1: root directory
4335# $2: add prefix
4336define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004337(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 -08004338endef
4339
Yifan Hong60bfcc42019-11-01 11:39:45 -07004340# Filter out vendor from the list for AOSP targets.
4341# $(1): list
4342define filter-out-missing-vendor
4343$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4344endef
4345
4346# Information related to dynamic partitions and virtual A/B. This information
4347# is needed for building the super image (see dump-super-image-info) and
4348# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004349# $(1): file
4350define dump-dynamic-partitions-info
4351 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4352 echo "use_dynamic_partitions=true" >> $(1))
4353 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4354 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004355 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4356 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4357 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004358 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4359 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004360 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4361 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4362 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4363 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4364 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4365 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004366 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004367 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4368 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4369 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4370 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4371 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004372 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 -07004373 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4374 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004375 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4376 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004377 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4378 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004379 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4380 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4381 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4382 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4383 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4384 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4385 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4386 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004387 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4388 echo "virtual_ab=true" >> $(1))
4389 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4390 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004391endef
4392
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004393# By conditionally including the dependency of the target files package on the
4394# full system image deps, we speed up builds that do not build the system
4395# image.
4396ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004397 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4398endif
4399
4400ifdef BUILDING_USERDATA_IMAGE
4401 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4402endif
4403
4404ifdef BUILDING_SYSTEM_OTHER_IMAGE
4405 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4406endif
4407
4408ifdef BUILDING_VENDOR_BOOT_IMAGE
4409 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
4410endif
4411
4412ifdef BUILDING_RECOVERY_IMAGE
4413 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
4414 # BUILD_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
4415 # commands in build-recoveryimage-target, which would touch the files under
4416 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4417 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4418 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4419 else
4420 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4421 endif
4422 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4423endif
4424
4425# Conditionally depend on the image files if the image is being built so the
4426# target-files.zip rule doesn't wait on the image creation rule, or the image
4427# if it is coming from a prebuilt.
4428
4429ifdef BUILDING_VENDOR_IMAGE
4430 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4431else ifdef BOARD_PREBUILT_VENDORIMAGE
4432 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4433endif
4434
4435ifdef BUILDING_PRODUCT_IMAGE
4436 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4437else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4438 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4439endif
4440
4441ifdef BUILDING_SYSTEM_EXT_IMAGE
4442 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4443else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4444 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4445endif
4446
4447ifdef BUILDING_BOOT_IMAGE
4448 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Yifan Hong0674a6e2020-10-22 14:37:01 -07004449else ifdef INTERNAL_PREBUILT_BOOTIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004450 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4451endif
4452
4453ifdef BUILDING_ODM_IMAGE
4454 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4455else ifdef BOARD_PREBUILT_ODMIMAGE
4456 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4457endif
4458
4459ifdef BUILDING_VENDOR_DLKM_IMAGE
4460 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4461else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4462 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4463endif
4464
4465ifdef BUILDING_ODM_DLKM_IMAGE
4466 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4467else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4468 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004469endif
4470
Isaac Chen9e09d472019-07-05 17:30:41 +08004471ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004472 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4473 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004474endif
4475
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004476ifdef BOARD_PREBUILT_BOOTLOADER
4477$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004478droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004479endif
4480
The Android Open Source Project88b60792009-03-03 19:28:42 -08004481# Depending on the various images guarantees that the underlying
4482# directories are up-to-date.
4483$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004484 $(INSTALLED_RADIOIMAGE_TARGET) \
4485 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004486 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004487 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004488 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004489 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4490 $(INSTALLED_KERNEL_TARGET) \
Enrico Granata16059382020-10-14 15:17:20 -06004491 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004492 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004493 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4494 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004495 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004496 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004497 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4498 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4499 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004500 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004501 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004502 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004503 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004504 $(LPMAKE) \
4505 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004506 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004507 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004508 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004509 $(SOONG_ZIP) \
4510 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004511 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004512 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004513 $(BUILT_KERNEL_CONFIGS_FILE) \
4514 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004515 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004516 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004517 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004518 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07004519ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))$(filter true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004520 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004521 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004522 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004523 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004524ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004525ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004526 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07004527else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07004528 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4529endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004530endif
Yifan Hong78860162020-10-28 14:15:21 -07004531ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004532ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004533 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004534endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004535ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004536ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004537 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004538else
Steve Mucklee1b10862019-07-10 10:49:37 -07004539 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004540endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004541endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004542ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004543 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004544endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004545ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004546 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004547endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004548ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004549ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004550 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07004551endif # INTERNAL_KERNEL_CMDLINE != ""
4552endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07004553ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004554 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004555endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004556ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004557 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004558endif
Yifan Hong3941a872020-10-28 16:33:06 -07004559endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004560endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004561 @# Components of the boot image
4562 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004563 $(hide) mkdir -p $(zip_root)/ROOT
4564 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004565 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004566 @# If we are using recovery as boot, this is already done when processing recovery.
4567ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004568ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004569 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004570 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004571endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004572ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004573 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004574endif
Yifan Hong46aff092020-10-28 13:50:47 -07004575ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07004576 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07004577else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07004578 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004579ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004580 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004581endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004582ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004583 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004584endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004585ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004586 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004587endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004588ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004589 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004590endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004591endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07004592endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004593 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4594 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004595 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004596ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4597 mkdir -p $(zip_root)/VENDOR_BOOT
4598 $(call package_files-copy-root, \
4599 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4600ifdef INSTALLED_DTBIMAGE_TARGET
4601 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4602endif
4603ifdef BOARD_KERNEL_BASE
4604 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4605endif
4606ifdef BOARD_KERNEL_PAGESIZE
4607 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4608endif
4609 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4610endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004611ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004612 @# Contents of the system image
4613 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004614 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004615endif
4616ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004617 @# Contents of the data image
4618 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004619 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004620endif
4621ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004622 @# Contents of the vendor image
4623 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004624 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004625endif
Dan Willemsen67495202019-01-16 12:42:05 -08004626ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004627 @# Contents of the product image
4628 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004629 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004630endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004631ifdef BUILDING_SYSTEM_EXT_IMAGE
4632 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004633 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004634 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004635endif
Dan Willemsen67495202019-01-16 12:42:05 -08004636ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004637 @# Contents of the odm image
4638 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004639 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004640endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004641ifdef BUILDING_VENDOR_DLKM_IMAGE
4642 @# Contents of the vendor_dlkm image
4643 $(hide) $(call package_files-copy-root, \
4644 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4645endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004646ifdef BUILDING_ODM_DLKM_IMAGE
4647 @# Contents of the odm_dlkm image
4648 $(hide) $(call package_files-copy-root, \
4649 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4650endif
Dan Willemsen67495202019-01-16 12:42:05 -08004651ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004652 @# Contents of the system_other image
4653 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004654 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004655endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004656 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004657 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004658 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granata16059382020-10-14 15:17:20 -06004659ifdef BUILDING_RAMDISK_IMAGE
4660ifeq (true,$(BOARD_IMG_USE_RAMDISK))
4661 @# Contents of the ramdisk image
4662 $(hide) mkdir -p $(zip_root)/IMAGES
4663 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
4664endif
4665endif
Yifan Hong65afc072020-04-17 10:08:10 -07004666ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004667ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004668 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004669 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004670endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004671endif
Doug Zongker8678df42009-06-15 14:30:14 -07004672 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004673 @# build them.
4674 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004675 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004676 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004677ifneq ($(tool_extension),)
4678 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4679endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004680 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004681 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004682 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004683ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4684 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4685 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004686endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004687ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4688 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4689 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004690endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004691ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4692 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4693 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004694endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004695ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4696 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4697 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004698endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004699ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4700 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4701 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004702endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004703ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4704 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4705 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4706endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004707ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4708 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4709 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4710endif
Yifan Hong65afc072020-04-17 10:08:10 -07004711ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004712ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004713 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004714 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004715endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004716endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004717ifeq ($(AB_OTA_UPDATER),true)
4718 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004719 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004720 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004721 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4722 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004723 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4724 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4725 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004726ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004727 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4728 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4729 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004730endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004731endif
Steve Fungdfbab492015-09-24 18:12:33 -07004732ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004733 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004734 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004735endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004736ifdef BOARD_PREBUILT_VENDORIMAGE
4737 $(hide) mkdir -p $(zip_root)/IMAGES
4738 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4739endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004740ifdef BOARD_PREBUILT_PRODUCTIMAGE
4741 $(hide) mkdir -p $(zip_root)/IMAGES
4742 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4743endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004744ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004745 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004746 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004747endif
Yifan Hong0674a6e2020-10-22 14:37:01 -07004748ifdef INTERNAL_PREBUILT_BOOTIMAGE
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004749 $(hide) mkdir -p $(zip_root)/IMAGES
4750 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4751endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004752ifdef BOARD_PREBUILT_ODMIMAGE
4753 $(hide) mkdir -p $(zip_root)/IMAGES
4754 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4755endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004756ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004757 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004758 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4759endif
4760ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4761 $(hide) mkdir -p $(zip_root)/IMAGES
4762 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004763endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004764ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004765 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4766 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004767endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004768ifdef BOARD_PREBUILT_BOOTLOADER
4769 $(hide) mkdir -p $(zip_root)/IMAGES
4770 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4771endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004772ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4773 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4774 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4775 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4776endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004777 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4778 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4779 @# INSTALLED_RADIOIMAGE_TARGET.
4780 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4781 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004782 @# Run fs_config on all the system, vendor, boot ramdisk,
4783 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004784ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004785 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004786endif
4787ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004788 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4789endif
Dan Willemsen67495202019-01-16 12:42:05 -08004790ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004791 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4792endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004793ifdef BUILDING_SYSTEM_EXT_IMAGE
4794 $(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 +01004795endif
Dan Willemsen67495202019-01-16 12:42:05 -08004796ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004797 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4798endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004799ifdef BUILDING_VENDOR_DLKM_IMAGE
4800 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4801endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004802ifdef BUILDING_ODM_DLKM_IMAGE
4803 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4804endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004805 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004806 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004807ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004808 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004809 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004810endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004811ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4812 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4813endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004814ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4815 @# 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 -08004816 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4817endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004818ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4819 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4820endif
Dan Willemsen67495202019-01-16 12:42:05 -08004821ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004822 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4823endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004824 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004825ifdef BUILT_KERNEL_CONFIGS_FILE
4826 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4827endif
4828ifdef BUILT_KERNEL_VERSION_FILE
4829 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4830endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004831 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4832ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4833 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4834endif
Tao Baocbd6d492019-10-07 22:46:02 -07004835 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4836 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004837ifeq ($(BUILD_QEMU_IMAGES),true)
4838 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4839 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4840endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004841 @# Zip everything up, preserving symlinks and placing META/ files first to
4842 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004843 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004844 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004845 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004846
Ying Wanga0febe52013-03-20 11:02:05 -07004847.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004848target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4849
Ying Wang4709d7c2014-04-14 17:25:43 -07004850$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07004851
Dan Albert4d323332016-10-14 13:23:06 -07004852# -----------------------------------------------------------------
4853# NDK Sysroot Package
4854NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004855$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004856 @echo Package NDK sysroot...
4857 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4858
4859$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4860
Ying Wang09c4b682015-08-11 11:24:19 -07004861ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004862# -----------------------------------------------------------------
4863# OTA update package
4864
Yifan Hong50e79542018-11-08 17:44:12 -08004865# $(1): output file
4866# $(2): additional args
4867define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07004868PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004869 $(OTA_FROM_TARGET_FILES) \
4870 --verbose \
4871 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4872 --path $(HOST_OUT) \
4873 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4874 $(2) \
4875 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004876endef
4877
Tianjie6bd3b1a2020-10-16 18:53:47 -07004878product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07004879ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07004880 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07004881endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07004882name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07004883
4884INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004885INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4886
Doug Zongker8678df42009-06-15 14:30:14 -07004887$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004888$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07004889$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004890 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004891 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004892
4893.PHONY: otapackage
4894otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4895
Tao Bao519d1822018-12-27 12:47:23 -08004896ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07004897name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08004898
4899INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004900$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004901$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4902 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07004903 $(OTA_FROM_TARGET_FILES) \
4904 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004905 @echo "Package OTA (retrofit dynamic partitions): $@"
4906 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4907
4908.PHONY: otardppackage
4909
4910otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4911
Tao Bao519d1822018-12-27 12:47:23 -08004912endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004913
Tianjie6bd3b1a2020-10-16 18:53:47 -07004914ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
4915name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
4916
4917INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
4918$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
4919$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
4920 @echo "Package partial OTA: $@"
4921 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
4922
4923.PHONY: partialotapackage
4924partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
4925
4926endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
4927
Ying Wang09c4b682015-08-11 11:24:19 -07004928endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004929
Ying Wang09a00a62010-10-20 14:01:09 -07004930# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004931# A zip of the appcompat directory containing logs
4932APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4933# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004934ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004935$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4936 $(INTERNAL_RAMDISK_FILES) \
4937 $(INTERNAL_USERDATAIMAGE_FILES) \
4938 $(INTERNAL_VENDORIMAGE_FILES) \
4939 $(INTERNAL_PRODUCTIMAGE_FILES) \
4940 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01004941endif
4942$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4943$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4944 @echo "appcompat logs: $@"
4945 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4946 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4947 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4948 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4949
Dario Frenid1011272018-07-23 20:20:15 +01004950# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004951# A zip of the symbols directory. Keep the full paths to make it
4952# more obvious where these files came from.
4953#
4954name := $(TARGET_PRODUCT)
4955ifeq ($(TARGET_BUILD_TYPE),debug)
4956 name := $(name)_debug
4957endif
4958name := $(name)-symbols-$(FILE_NAME_TAG)
4959
4960SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004961# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004962ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004963$(SYMBOLS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4964 $(INTERNAL_RAMDISK_FILES) \
4965 $(INTERNAL_USERDATAIMAGE_FILES) \
4966 $(INTERNAL_VENDORIMAGE_FILES) \
4967 $(INTERNAL_PRODUCTIMAGE_FILES) \
4968 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4969 $(INTERNAL_ODMIMAGE_FILES) \
4970 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4971 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Anton Hansson6d814982018-11-26 18:12:05 +00004972 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004973endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004974$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4975$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004976 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004977 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4978 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004979 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004980 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004981# -----------------------------------------------------------------
4982# A zip of the coverage directory.
4983#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004984name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004985ifeq ($(TARGET_BUILD_TYPE),debug)
4986name := $(name)_debug
4987endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004988COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004989ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004990$(COVERAGE_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4991 $(INTERNAL_RAMDISK_FILES) \
4992 $(INTERNAL_USERDATAIMAGE_FILES) \
4993 $(INTERNAL_VENDORIMAGE_FILES) \
4994 $(INTERNAL_PRODUCTIMAGE_FILES) \
4995 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4996 $(INTERNAL_ODMIMAGE_FILES) \
4997 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4998 $(INTERNAL_ODM_DLKMIMAGE_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004999endif
5000$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
5001$(COVERAGE_ZIP): $(SOONG_ZIP)
5002 @echo "Package coverage: $@"
5003 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5004 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
5005 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
5006 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005007
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005008#------------------------------------------------------------------
5009# Export the LLVM profile data tool and dependencies for Clang coverage processing
5010#
5011ifeq (true,$(CLANG_COVERAGE))
5012 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
5013 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
5014 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
5015 $(PROFDATA_ZIP): $(SOONG_ZIP)
5016 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
5017
Kun Niud322d8d2020-05-14 16:32:29 -07005018 $(call dist-for-goals,droidcore apps_only,$(PROFDATA_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005019endif
5020
The Android Open Source Project88b60792009-03-03 19:28:42 -08005021# -----------------------------------------------------------------
5022# A zip of the Android Apps. Not keeping full path so that we don't
5023# include product names when distributing
5024#
5025name := $(TARGET_PRODUCT)
5026ifeq ($(TARGET_BUILD_TYPE),debug)
5027 name := $(name)_debug
5028endif
5029name := $(name)-apps-$(FILE_NAME_TAG)
5030
5031APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07005032$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005033 @echo "Package apps: $@"
5034 $(hide) rm -rf $@
5035 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005036 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
5037 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00005038 echo "No apps to zip up. Generating empty apps archive." ; \
5039 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005040 else \
Anton Hansson6d814982018-11-26 18:12:05 +00005041 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005042 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07005043
Ying Wangbc415dd2012-08-15 12:22:44 -07005044ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07005045#------------------------------------------------------------------
5046# An archive of classes for use in generating code-coverage reports
5047# These are the uninstrumented versions of any classes that were
5048# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07005049# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005050
Colin Crossa6bc3a82017-09-27 14:28:41 -07005051JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005052$(JACOCO_REPORT_CLASSES_ALL) :
5053 @echo "Collecting uninstrumented classes"
Colin Crosse8ac9952020-10-09 18:41:58 -07005054 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" -o -name "proguard_usage.zip" 2>/dev/null | sort > $@.list
Colin Crossd81f4b32020-02-12 14:14:27 -08005055 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005056
Ying Wangbc415dd2012-08-15 12:22:44 -07005057endif # EMMA_INSTRUMENT=true
5058
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005059
Ying Wangae9115a2013-08-22 20:52:47 -07005060#------------------------------------------------------------------
5061# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07005062#
Ying Wangc62c92c2013-08-28 18:38:25 -07005063PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07005064# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005065ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07005066$(PROGUARD_DICT_ZIP): \
Colin Crosscda30c72020-08-26 18:43:21 -07005067 $(FULL_SYSTEMIMAGE_DEPS) \
5068 $(INTERNAL_RAMDISK_FILES) \
5069 $(INTERNAL_USERDATAIMAGE_FILES) \
5070 $(INTERNAL_VENDORIMAGE_FILES) \
5071 $(INTERNAL_PRODUCTIMAGE_FILES) \
5072 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
5073 $(INTERNAL_ODMIMAGE_FILES) \
5074 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
5075 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Colin Cross114e8df2019-09-05 17:19:35 -07005076 $(updater_dep)
5077endif
5078$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
5079$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07005080 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07005081 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5082 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
5083 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
5084 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07005085
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005086#------------------------------------------------------------------
5087# A zip of Proguard usage files.
5088#
5089PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
5090# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5091ifeq (,$(TARGET_BUILD_UNBUNDLED))
5092$(PROGUARD_USAGE_ZIP): \
5093 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5094 $(INSTALLED_RAMDISK_TARGET) \
5095 $(INSTALLED_BOOTIMAGE_TARGET) \
5096 $(INSTALLED_USERDATAIMAGE_TARGET) \
5097 $(INSTALLED_VENDORIMAGE_TARGET) \
5098 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5099 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5100 $(INSTALLED_ODMIMAGE_TARGET) \
5101 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
5102 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
5103 $(updater_dep)
5104endif
5105$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
5106$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
5107 @echo "Packaging Proguard usage files."
5108 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5109 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
5110 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07005111
5112ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5113
5114# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5115# $(1): output file
5116define dump-super-image-info
5117 $(call dump-dynamic-partitions-info,$(1))
5118 $(if $(filter true,$(AB_OTA_UPDATER)), \
5119 echo "ab_update=true" >> $(1))
5120endef
5121
5122endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5123
The Android Open Source Project88b60792009-03-03 19:28:42 -08005124# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005125# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005126
5127ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5128
5129# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5130ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5131
5132ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005133
5134# For real devices and for dist builds, build super image from target files to an intermediate directory.
5135INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5136$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5137$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5138 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005139 PATH=$(dir $(LPMAKE)):$$PATH \
5140 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005141
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005142# Skip packing it in dist package because it is in update package.
5143ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005144$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005145endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005146
5147.PHONY: superimage_dist
5148superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005149
5150endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005151endif # BOARD_SUPER_PARTITION_SIZE != ""
5152endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005153
Yifan Hongacd862a2019-04-16 15:44:30 -07005154# -----------------------------------------------------------------
5155# super partition image for development
5156
5157ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5158ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5159ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5160
5161# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5162# $(1): built image path
5163# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5164define build-superimage-target
5165 mkdir -p $(dir $(2))
5166 rm -rf $(2)
5167 $(call dump-super-image-info,$(2))
5168 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5169 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005170 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5171 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005172 mkdir -p $(dir $(1))
5173 PATH=$(dir $(LPMAKE)):$$PATH \
5174 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5175endef
5176
5177INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5178INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5179 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5180
changho.shina8f9f112019-10-15 13:26:19 +09005181ifdef BUILDING_SYSTEM_OTHER_IMAGE
5182ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5183INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5184endif
5185endif
5186
Yifan Hongacd862a2019-04-16 15:44:30 -07005187# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5188# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5189# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5190# virtual devices.
5191ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5192$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5193 $(call pretty,"Target super fs image for debug: $@")
5194 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005195 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005196
5197droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5198
5199# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5200.PHONY: superimage
5201superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005202
5203$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005204endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5205
5206# Build $(PRODUCT_OUT)/super.img without dependencies.
5207.PHONY: superimage-nodeps supernod
5208superimage-nodeps supernod: intermediates :=
5209superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5210 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5211 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5212 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5213
5214endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5215endif # BOARD_SUPER_PARTITION_SIZE != ""
5216endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5217
5218# -----------------------------------------------------------------
5219# super empty image
5220
Tao Bao48a2feb2019-06-28 11:00:05 -07005221ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005222ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005223
Yifan Hong8b79d162018-11-29 12:32:00 -08005224INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5225$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5226$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5227 $(call pretty,"Target empty super fs image: $@")
5228 mkdir -p $(intermediates)
5229 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005230 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005231 PATH=$(dir $(LPMAKE)):$$PATH \
5232 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005233
5234$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5235
Yifan Hong2b891ac2018-11-29 12:06:31 -08005236endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005237endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005238
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005239
5240# -----------------------------------------------------------------
5241# The update package
5242
5243name := $(TARGET_PRODUCT)
5244ifeq ($(TARGET_BUILD_TYPE),debug)
5245 name := $(name)_debug
5246endif
5247name := $(name)-img-$(FILE_NAME_TAG)
5248
5249INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5250
Tao Bao57f8ed62019-08-14 23:08:18 -07005251$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5252 $(call pretty,"Package: $@")
5253 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5254 $(IMG_FROM_TARGET_FILES) \
5255 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5256 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005257
5258.PHONY: updatepackage
5259updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005260$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005261
5262
Yifan Hong2b891ac2018-11-29 12:06:31 -08005263# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005264# dalvik something
5265.PHONY: dalvikfiles
5266dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5267
Bo Huf0d50bb2017-08-01 19:02:09 +00005268ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005269MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005270MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005271SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005272
5273ifdef INSTALLED_SYSTEMIMAGE_TARGET
5274INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005275INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5276$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5277 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5278 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005279$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005280 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5281 @echo Create system-qemu.img now
5282 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005283 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005284
5285systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5286droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005287endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005288ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005289INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005290$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005291 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005292 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005293
5294vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5295droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5296endif
bohu8fd437c2020-03-30 20:16:13 -07005297
5298ifdef INSTALLED_RAMDISK_TARGET
5299ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5300ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5301INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5302$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5303 @echo Create ramdisk-qemu.img
5304 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5305
5306droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5307endif
5308endif
5309endif
5310
Anton Hansson32c76fe2018-12-13 14:34:18 +00005311ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005312INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005313$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005314 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005315 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005316
5317productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5318droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5319endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005320ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5321INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5322$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5323 @echo Create system_ext-qemu.img
5324 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005325
Justin Yun6151e3f2019-06-25 15:58:13 +09005326systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5327droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005328endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005329ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005330INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5331$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5332 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005333 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005334
5335odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5336droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5337endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005338
Yifan Hongcfb917a2020-05-07 14:58:20 -07005339ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5340INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5341$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5342 @echo Create vendor_dlkm-qemu.img
5343 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5344
5345vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5346droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5347endif
5348
Yifan Hongf496f1b2020-07-15 16:52:59 -07005349ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5350INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5351$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5352 @echo Create odm_dlkm-qemu.img
5353 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5354
5355odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5356droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5357endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005358
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005359QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005360$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5361 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005362 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005363 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5364 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005365
5366systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5367droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005368
Bo Huf0d50bb2017-08-01 19:02:09 +00005369endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005370# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005371# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005372ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005373INTERNAL_EMULATOR_PACKAGE_FILES += \
5374 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005375 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005376 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005377 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5378 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005379
5380name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5381
5382INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5383
Ying Wang5d887702015-11-04 10:06:25 -08005384$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005385 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005386 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005387
Ying Wang7d8c5352012-07-26 10:15:21 -07005388endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005389
The Android Open Source Project88b60792009-03-03 19:28:42 -08005390
5391# -----------------------------------------------------------------
5392# The SDK
5393
The Android Open Source Project88b60792009-03-03 19:28:42 -08005394# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005395sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005396
5397# Build a name that looks like:
5398#
5399# linux-x86 --> android-sdk_12345_linux-x86
5400# darwin-x86 --> android-sdk_12345_mac-x86
5401# windows-x86 --> android-sdk_12345_windows
5402#
5403sdk_name := android-sdk_$(FILE_NAME_TAG)
5404ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005405 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005406else
Joe Onorato03fbe402009-04-13 08:31:16 -07005407 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005408endif
5409ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005410 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005411endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005412sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005413
5414sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5415
5416ATREE_FILES :=
5417-include $(sdk_dep_file)
5418
5419# if we don't have a real list, then use "everything"
5420ifeq ($(strip $(ATREE_FILES)),)
5421ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005422 $(ALL_DEFAULT_INSTALLED_MODULES) \
5423 $(INSTALLED_RAMDISK_TARGET) \
5424 $(ALL_DOCS) \
5425 $(ALL_SDK_FILES)
5426endif
5427
5428atree_dir := development/build
5429
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005430
The Android Open Source Project88b60792009-03-03 19:28:42 -08005431sdk_atree_files := \
5432 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005433 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005434
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005435# development/build/sdk-android-<abi>.atree is used to differentiate
5436# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5437# files like the kernel image. We use TARGET_CPU_ABI because we don't
5438# have a better way to distinguish between CPU models.
5439ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5440 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5441endif
5442
Anton Hansson8dab0a62019-03-28 15:45:40 +00005443ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5444sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005445else
5446sdk_atree_files += $(atree_dir)/sdk.atree
5447endif
5448
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005449include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005450
The Android Open Source Project88b60792009-03-03 19:28:42 -08005451deps := \
5452 $(target_notice_file_txt) \
5453 $(tools_notice_file_txt) \
5454 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005455 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005456 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005457 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005458 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005459 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005460 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005461 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005462 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005463 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005464 $(INSTALLED_USERDATAIMAGE_TARGET) \
5465 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005466 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005467 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005468 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005469 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005470 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005471 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005472 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005473
5474INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5475$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5476$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5477$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5478$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5479
5480# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5481#
5482#SDK_GNU_ERROR := true
5483
Ying Wang5d887702015-11-04 10:06:25 -08005484$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005485 @echo "Package SDK: $@"
5486 $(hide) rm -rf $(PRIVATE_DIR) $@
5487 $(hide) for f in $(target_gnu_MODULES); do \
5488 if [ -f $$f ]; then \
5489 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5490 including GNU target $$f >&2; \
5491 FAIL=$(SDK_GNU_ERROR); \
5492 fi; \
5493 done; \
5494 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005495 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005496 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005497 ATREE_STRIP="$(HOST_STRIP) -x" \
5498 $(HOST_OUT_EXECUTABLES)/atree \
5499 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5500 -m $(PRIVATE_DEP_FILE) \
5501 -I . \
5502 -I $(PRODUCT_OUT) \
5503 -I $(HOST_OUT) \
5504 -I $(TARGET_COMMON_OUT_ROOT) \
5505 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5506 -v "OUT_DIR=$(OUT_DIR)" \
5507 -v "HOST_OUT=$(HOST_OUT)" \
5508 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5509 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5510 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5511 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5512 -o $(PRIVATE_DIR) && \
5513 cp -f $(target_notice_file_txt) \
5514 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5515 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5516 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5517 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5518 chmod -R ug+rwX $(PRIVATE_DIR) && \
5519 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005520 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5521
Raphael3d224a02010-04-16 17:50:09 -07005522
5523# Is a Windows SDK requested? If so, we need some definitions from here
5524# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005525MAIN_SDK_NAME := $(sdk_name)
5526MAIN_SDK_DIR := $(sdk_dir)
5527MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005528ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005529include $(TOPDIR)development/build/tools/windows_sdk.mk
5530endif
5531
The Android Open Source Project88b60792009-03-03 19:28:42 -08005532# -----------------------------------------------------------------
5533# Findbugs
5534INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5535INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5536$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5537 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005538 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005539 > $@
5540$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5541 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005542 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005543 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005544
5545# -----------------------------------------------------------------
5546# Findbugs
5547
5548# -----------------------------------------------------------------
5549# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005550ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005551include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005552-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005553-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005554-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005555# Also the project-specific tasks
5556-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5557-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005558-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005559# Also add test specifc tasks
5560include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005561include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005562endif
Raphaelc4d47312011-02-15 16:09:36 -08005563
Ying Wang67132ba2015-10-28 16:42:39 -07005564include $(BUILD_SYSTEM)/product-graph.mk
5565
Raphaelc4d47312011-02-15 16:09:36 -08005566# -----------------------------------------------------------------
5567# Create SDK repository packages. Must be done after tasks/* since
5568# we need the addon rules defined.
5569ifneq ($(sdk_repo_goal),)
5570include $(TOPDIR)development/build/tools/sdk_repo.mk
5571endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005572
5573# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005574# Soong generates the list of all shared libraries that are depended on by fuzz
5575# targets. It saves this list as a source:destination pair to
5576# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5577# build of the unstripped shared library, and the destination is the
5578# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5579# where fuzz target shared libraries are to be "reinstalled". The
5580# copy-many-files below generates the rules to copy the unstripped shared
5581# libraries to the device or host "reinstallation" directory. These rules are
5582# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5583# a dependency on each shared library that it needs to be "reinstalled".
5584FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5585
5586# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005587# The rule to build all fuzz targets, and package them.
5588# Note: The packages are created in Soong, and in a perfect world,
5589# we'd be able to create the phony rule there. But, if we want to
5590# have dist goals for the fuzz target, we need to have the PHONY
5591# target defined in make. MakeVarsContext.DistForGoal doesn't take
5592# into account that a PHONY rule create by Soong won't be available
5593# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005594# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005595# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005596.PHONY: haiku
5597haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5598$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))