blob: 1cf0a0c388fd98264211a117dd8861e6d03fc2da [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),\
448 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
449 $(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
Steve Muckle04b6f052020-08-09 14:36:56 -0700714# $1: boot image target
715# returns the kernel used to make the bootimage
716define bootimage-to-kernel
717 $(if $(BOARD_KERNEL_BINARIES),\
718 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
719 $(INSTALLED_KERNEL_TARGET))
720endef
721
Steve Muckle903a1ca2020-05-07 17:32:10 -0700722ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
723 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
724endif
725
726# $1: boot image file name
727# $2: boot image variant (boot, boot-debug)
728define get-bootimage-partition-size
729 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
730endef
Chris Grossa784ef12019-04-22 11:09:57 -0700731
732ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700734 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700735
736ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
737INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
738endif
739
Steve Mucklee1b10862019-07-10 10:49:37 -0700740ifndef BUILDING_VENDOR_BOOT_IMAGE
741ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
742 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
743endif
744endif
745
The Android Open Source Project88b60792009-03-03 19:28:42 -0800746INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
747
Anton Hansson8dab0a62019-03-28 15:45:40 +0000748ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700749ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000750VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700751 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
752endif
753endif
754
Anton Hansson72e36f02019-02-26 17:36:30 +0000755INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700756
757ifndef BUILDING_VENDOR_BOOT_IMAGE
758ifdef BOARD_KERNEL_BASE
759 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
760endif
761ifdef BOARD_KERNEL_PAGESIZE
762 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
763endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700764ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700765 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
766endif
767else
768# building vendor boot image, dtb/base/pagesize go there
769ifdef GENERIC_KERNEL_CMDLINE
770 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
771endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700772endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700773
Sami Tolvanen3303d902016-03-15 16:49:30 +0000774INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700775 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000776 --os_patch_level $(PLATFORM_SECURITY_PATCH)
777
Chris Grossa784ef12019-04-22 11:09:57 -0700778# Define these only if we are building boot
779ifdef BUILDING_BOOT_IMAGE
780INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
781
The Android Open Source Project88b60792009-03-03 19:28:42 -0800782ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800783$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700784endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400785
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700786$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
787
788ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400789
Steve Muckle04b6f052020-08-09 14:36:56 -0700790# $1: boot image target
791define build_boot_board_avb_enabled
792 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
793 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
794 $(AVBTOOL) add_hash_footer \
795 --image $(1) \
796 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
797 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
798 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
799endef
800
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700801$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400802 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700803 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400804
805.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800806bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400807 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700808 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400809
Anton Hansson8dab0a62019-03-28 15:45:40 +0000810else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700811
Steve Muckle04b6f052020-08-09 14:36:56 -0700812# $1: boot image target
813define build_boot_supports_boot_signer
814 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
815 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
816 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
817endef
818
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700819$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -0700820 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700821 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700822
823.PHONY: bootimage-nodeps
824bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
825 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700826 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700827
Anton Hansson8dab0a62019-03-28 15:45:40 +0000828else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800829
Steve Muckle04b6f052020-08-09 14:36:56 -0700830# $1: boot image target
831define build_boot_supports_vboot
832 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
833 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
834 $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
835endef
836
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700837$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800838 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700839 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800840
841.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800842bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800843 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700844 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800845
846else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800847
Steve Muckle04b6f052020-08-09 14:36:56 -0700848# $1: boot image target
849define build_boot_novboot
850 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
851 $(call assert-max-image-size,$1,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
852endef
853
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700854$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800855 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700856 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700857
858.PHONY: bootimage-nodeps
859bootimage-nodeps: $(MKBOOTIMG)
860 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700861 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700862
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700863endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -0700864endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800865
Tao Baob1a2e352018-08-14 16:17:12 -0700866else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700867ifdef BOARD_PREBUILT_BOOTIMAGE
868ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
869# Remove when b/63676296 is resolved.
870$(error Prebuilt bootimage is only supported for AB targets)
871endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900872INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700873$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700874else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700875INSTALLED_BOOTIMAGE_TARGET :=
876endif # BOARD_PREBUILT_BOOTIMAGE
877endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800878
879# -----------------------------------------------------------------
Yifan Hong881df392020-10-09 14:29:39 -0700880# declare recovery ramdisk files
881ifeq ($(BUILDING_RECOVERY_IMAGE),true)
882INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
883endif
884
885# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700886# vendor boot image
887ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
888
889ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
890 $(error vboot 1.0 does not support vendor_boot partition)
891endif
892
893INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
894 $(ALL_GENERATED_SOURCES) \
895 $(ALL_DEFAULT_INSTALLED_MODULES))
896
Steve Muckle414dbe12020-06-18 21:38:35 -0700897INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -0700898
899ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
900$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
901$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
902endif
903
J. Avila3f6560e2020-05-11 20:20:03 +0000904$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -0700905 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700906
907ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
908 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
909endif
910ifdef BOARD_KERNEL_BASE
911 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
912endif
913ifdef BOARD_KERNEL_PAGESIZE
914 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
915endif
916ifdef INTERNAL_KERNEL_CMDLINE
917 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
918endif
919
920INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
921$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
922ifeq ($(BOARD_AVB_ENABLE),true)
923$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
924 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800925 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700926 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
927 $(AVBTOOL) add_hash_footer \
928 --image $@ \
929 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
930 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
931 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
932else
933$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
934 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800935 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700936 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
937endif
938endif # BUILDING_VENDOR_BOOT_IMAGE
939
940# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800941# NOTICE files
942#
Steve Blockd14d3b42012-03-01 11:34:41 +0000943# We are required to publish the licenses for all code under BSD, GPL and
944# Apache licenses (and possibly other more exotic ones as well). We err on the
945# side of caution, so the licenses for other third-party code are included here
946# too.
947#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800948# This needs to be before the systemimage rules, because it adds to
949# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
950# go into the systemimage.
951
Steve Block495e5852012-02-29 19:18:08 +0000952.PHONY: notice_files
953
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900954# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -0700955# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
956# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
957# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
958# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900959# $(2) - Plain text output file
960# $(3) - HTML/XML output file
961# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700962# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800963# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900964# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800965# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800966#
967# The algorithm here is that we go collect a hash for each of the notice
968# files and write the names of the files that match that hash. Then
969# to generate the real files, we go print out all of the files and their
970# hashes.
971#
972# These rules are fairly complex, so they depend on this makefile so if
973# it changes, they'll run again.
974#
975# TODO: We could clean this up so that we just record the locations of the
976# original notice files instead of making rules to copy them somwehere.
977# Then we could traverse that without quite as much bash drama.
978define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700979$(2): PRIVATE_MESSAGE := $(4)
980$(2): PRIVATE_DIR := $(5)
981$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
982$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800983 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -0700984 $(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, \
985 $(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 +0000986 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900987 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700988 $(if $(filter $(1),xml_system),-i system --xml-output, \
989 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700990 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -0700991 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
992 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -0700993 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900994notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800995endef
996
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000997# Notice file logic isn't relevant for TARGET_BUILD_APPS
998ifndef TARGET_BUILD_APPS
999
The Android Open Source Project88b60792009-03-03 19:28:42 -08001000# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1001# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1002# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001003target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001004tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001005tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001006kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1007winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001008
Bob Badour4b25c902020-01-28 13:23:39 -08001009# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1010# reasons--not to be flashed onto any device. Targets under these directories
1011# need no associated notice file on the device UI.
1012exclude_target_dirs := apex
1013
Steven Morelandae69e572017-12-15 14:49:55 -08001014# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001015ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1016target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1017target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1018installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1019$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001020 $(target_notice_file_txt), \
1021 $(target_notice_file_html), \
1022 "Notices for files contained in the filesystem images in this directory:", \
1023 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -07001024 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -08001025 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001026$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1027 $(hide) $(MINIGZIP) -9 < $< > $@
1028$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1029 $(copy-file-to-target)
1030else
1031target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1032target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001033installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1034
1035target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1036target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1037target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1038installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001039
1040target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1041target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1042target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1043installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001044
Justin Yun6151e3f2019-06-25 15:58:13 +09001045target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1046target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1047target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1048installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001049
Chris Gross15d96552019-07-16 14:38:43 -07001050target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1051target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1052target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1053installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1054
Yifan Hong3d3f0302020-05-11 18:35:11 -07001055target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1056target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1057target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1058installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1059
Yifan Hongc83f9e92020-07-15 16:57:47 -07001060target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1061target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1062target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1063installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1064
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001065# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1066# being built. A notice xml file must depend on all modules that could potentially
1067# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001068license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001069# Only files copied to a system image need system image notices.
1070license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001071# Phonys/fakes don't have notice files (though their deps might)
1072license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001073# testcases are not relevant to the system image.
1074license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001075# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001076license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001077# system_other is relevant to system partition.
1078license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001079license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1080license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001081license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001082license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001083license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001084license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001085license_modules_agg := $(license_modules_system) \
1086 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001087 $(license_modules_product) \
1088 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001089 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001090 $(license_modules_vendor_dlkm) \
1091 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001092# targets used for debug symbols only and do not get copied to the device
1093license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1094
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001095license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001096license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1097
1098# Identify the other targets we expect to have notices for:
1099# targets copied to the device but are not readable by the UI (e.g. must boot
1100# into a different partition to read or don't have an associated /etc
1101# directory) must have their notices built somewhere readable.
1102license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1103license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1104license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1105license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1106license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1107license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1108license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1109license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1110license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1111license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1112license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1113license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1114license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1115
1116# after removing targets in system images, targets reported in system images, and
1117# targets used for debug symbols that do not need notices, nothing must remain.
1118license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1119$(call maybe-print-list-and-error, $(license_modules_rest), \
1120 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001121
Chris Grossaad39b32019-06-13 09:43:26 -07001122# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1123# update its notice file, so include those notices in the system partition instead
1124ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001125license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001126system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1127system_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 -07001128else
Bob Badour4b25c902020-01-28 13:23:39 -08001129license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001130system_xml_directories := xml_system
1131system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001132endif
1133
1134$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001135 $(target_notice_file_txt), \
1136 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001137 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001138 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001139 $(license_modules_system), \
1140 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001141$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001142 $(target_vendor_notice_file_txt), \
1143 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001144 "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 +00001145 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001146 $(license_modules_vendor), \
1147 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001148$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001149 $(target_product_notice_file_txt), \
1150 $(target_product_notice_file_xml), \
1151 "Notices for files contained in the product filesystem image in this directory:", \
1152 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001153 $(license_modules_product), \
1154 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001155$(eval $(call combine-notice-files, xml_system_ext, \
1156 $(target_system_ext_notice_file_txt), \
1157 $(target_system_ext_notice_file_xml), \
1158 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001159 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001160 $(license_modules_system_ext), \
1161 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001162$(eval $(call combine-notice-files, xml_odm, \
1163 $(target_odm_notice_file_txt), \
1164 $(target_odm_notice_file_xml), \
1165 "Notices for files contained in the odm filesystem image in this directory:", \
1166 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001167 $(license_modules_odm), \
1168 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001169$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1170 $(target_vendor_dlkm_notice_file_txt), \
1171 $(target_vendor_dlkm_notice_file_xml), \
1172 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1173 $(TARGET_OUT_NOTICE_FILES), \
1174 $(license_modules_vendor_dlkm), \
1175 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001176$(eval $(call combine-notice-files, xml_odm_dlkm, \
1177 $(target_odm_dlkm_notice_file_txt), \
1178 $(target_odm_dlkm_notice_file_xml), \
1179 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1180 $(TARGET_OUT_NOTICE_FILES), \
1181 $(license_modules_odm_dlkm), \
1182 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001183
1184$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1185 $(hide) $(MINIGZIP) -9 < $< > $@
1186$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1187 $(hide) $(MINIGZIP) -9 < $< > $@
1188$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1189 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001190$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001191 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001192$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1193 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001194$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1195 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001196$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1197 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001198$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1199 $(copy-file-to-target)
1200$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1201 $(copy-file-to-target)
1202$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1203 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001204$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001205 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001206$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1207 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001208$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1209 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001210$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1211 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001212
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001213ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1214ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1215ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1216ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1217ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001218ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001219ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001220endif # PRODUCT_NOTICE_SPLIT
1221
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001222ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001223
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001224$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001225 $(tools_notice_file_txt), \
1226 $(tools_notice_file_html), \
1227 "Notices for files contained in the tools directory:", \
1228 $(HOST_OUT_NOTICE_FILES), \
1229 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001230 $(winpthreads_notice_file), \
1231 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001232
Ying Wang62c81f82013-08-22 20:02:03 -07001233endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001234
1235# The kernel isn't really a module, so to get its module file in there, we
1236# make the target NOTICE files depend on this particular file too, which will
1237# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001238$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001239
Dan Willemsen288bedf2019-05-28 15:36:47 -07001240$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001241
Doug Zongker8678df42009-06-15 14:30:14 -07001242
The Android Open Source Project88b60792009-03-03 19:28:42 -08001243# #################################################################
1244# Targets for user images
1245# #################################################################
1246
Ying Wang933abf12010-06-16 14:31:34 -07001247INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001248ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001249INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1250else
1251ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001252INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1253else
1254ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001255INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1256endif
1257endif
1258endif
1259
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001260# These options tell the recovery updater/installer how to mount the partitions writebale.
1261# <fstype>=<fstype_opts>[|<fstype_opts>]...
1262# fstype_opts := <opt>[,<opt>]...
1263# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001264# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1265DEFAULT_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 -07001266
Ying Wang542903a2010-11-17 15:40:38 -08001267ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1268 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1269endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001270ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1271 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1272endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001273ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1274 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1275endif
Tao Baodba635a2019-06-24 10:39:54 -07001276
1277INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001278 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001279 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001280 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001281
1282ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1283INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001284endif
1285
Yifan Hongcfb917a2020-05-07 14:58:20 -07001286ifneq ($(filter \
1287 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1288 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1289 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1290 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1291 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1292 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001293 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001294 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001295INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1296endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001297
Anton Hansson8dab0a62019-03-28 15:45:40 +00001298ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001299INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001300ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001301INTERNAL_USERIMAGES_DEPS += $(FEC)
1302endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001303endif
1304
Tao Baodba635a2019-06-24 10:39:54 -07001305ifeq ($(BOARD_AVB_ENABLE),true)
1306INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1307endif
1308
1309# Get a colon-separated list of search paths.
1310INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1311
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001312# Collects file_contexts files from modules to be installed
1313$(call merge-fc-files, \
1314 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1315 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1316
Alex Klyubin092c9022017-03-13 13:28:34 -07001317SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001318
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001319INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1320
Yifan Hongc5c01242018-11-09 10:27:23 -08001321ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001322
Anton Hansson8dab0a62019-03-28 15:45:40 +00001323ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001324 $(error vboot 1.0 doesn't support logical partition)
1325endif
1326
Yifan Hongc5c01242018-11-09 10:27:23 -08001327endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001328
Ying Wangbd93d422011-10-28 17:02:30 -07001329# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001330# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001331# $(3): additional "key=value" pairs to append to the dictionary file.
1332define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001333$(if $(filter $(2),system),\
1334 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001335 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001336 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1337 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1338 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1339 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1340 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1341 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1342 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1343 $(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 +00001344 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1345 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001346 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001347 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001348 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1349)
1350$(if $(filter $(2),system_other),\
1351 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001352)
Yifan Hong760d3c02018-05-30 11:16:46 -07001353$(if $(filter $(2),userdata),\
1354 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1355 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001356 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1357 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001358 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001359 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001360)
Yifan Hong760d3c02018-05-30 11:16:46 -07001361$(if $(filter $(2),cache),\
1362 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1363 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001364 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001365 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001366)
1367$(if $(filter $(2),vendor),\
1368 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1369 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1370 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1371 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1372 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1373 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1374 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1375 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1376 $(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 +00001377 $(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 -07001378 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001379 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001380 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001381)
1382$(if $(filter $(2),product),\
1383 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1384 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1385 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1386 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1387 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1388 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1389 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1390 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1391 $(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 +00001392 $(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 -07001393 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001394 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001395 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001396)
Justin Yun6151e3f2019-06-25 15:58:13 +09001397$(if $(filter $(2),system_ext),\
1398 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1399 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1400 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1401 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1402 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1403 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1404 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1405 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1406 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1407 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1408 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001409 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001410)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001411$(if $(filter $(2),odm),\
1412 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1413 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1414 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1415 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1416 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1417 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1418 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1419 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1420 $(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 +00001421 $(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 +08001422 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001423 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001424 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001425)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001426$(if $(filter $(2),vendor_dlkm),\
1427 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1428 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1429 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1430 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1431 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1432 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1433 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1434 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1435 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1436 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1437 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1438 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1439)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001440$(if $(filter $(2),odm_dlkm),\
1441 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1442 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1443 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1444 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1445 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1446 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1447 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1448 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1449 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1450 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1451 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1452 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1453)
Yifan Hong760d3c02018-05-30 11:16:46 -07001454$(if $(filter $(2),oem),\
1455 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1456 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1457 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1458 $(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 -07001459 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001460)
Tao Bao3602eca2018-07-10 10:53:55 -07001461$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001462
Tao Bao3602eca2018-07-10 10:53:55 -07001463$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001464$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001465$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001466$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001467$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1468$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1469$(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 +00001470$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1471$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1472$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1473$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1474$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001475$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001476$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1477$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1478$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001479$(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 -07001480$(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 -07001481$(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 +00001482$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1483$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1484$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1485$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1486$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001487$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001488$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1489$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1490$(if $(BOARD_AVB_ENABLE),\
1491 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1492 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1493 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1494 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001495$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1496$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1497$(if $(BOARD_AVB_ENABLE),\
1498 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1499 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001500 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001501$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1502$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1503$(if $(BOARD_AVB_ENABLE),\
1504 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1505 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1506 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1507 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001508$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1509$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1510$(if $(BOARD_AVB_ENABLE),\
1511 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1512 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1513 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1514 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001515$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001516$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001517 $(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 +01001518$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001519 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1520 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1521 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1522 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001523$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1524$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1525$(if $(BOARD_AVB_ENABLE),\
1526 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1527 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1528 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1529 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001530$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1531$(if $(BOARD_AVB_ENABLE),\
1532 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1533$(if $(BOARD_AVB_ENABLE),\
1534 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1535 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1536 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1537 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001538$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1539$(if $(BOARD_AVB_ENABLE),\
1540 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1541$(if $(BOARD_AVB_ENABLE),\
1542 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1543 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1544 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1545 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001546$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1547 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001548$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001549 $(hide) echo "system_root_image=true" >> $(1))
1550$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001551$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1552 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001553$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1554endef
1555
1556# $(1): the path of the output dictionary file
1557# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001558PROP_DICTIONARY_IMAGES := oem
1559ifdef BUILDING_CACHE_IMAGE
1560 PROP_DICTIONARY_IMAGES += cache
1561endif
1562ifdef BUILDING_SYSTEM_IMAGE
1563 PROP_DICTIONARY_IMAGES += system
1564endif
Chris Gross203191b2020-05-30 02:39:12 +00001565ifdef BUILDING_SYSTEM_OTHER_IMAGE
1566 PROP_DICTIONARY_IMAGES += system_other
1567endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001568ifdef BUILDING_USERDATA_IMAGE
1569 PROP_DICTIONARY_IMAGES += userdata
1570endif
1571ifdef BUILDING_VENDOR_IMAGE
1572 PROP_DICTIONARY_IMAGES += vendor
1573endif
1574ifdef BUILDING_PRODUCT_IMAGE
1575 PROP_DICTIONARY_IMAGES += product
1576endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001577ifdef BUILDING_SYSTEM_EXT_IMAGE
1578 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001579endif
1580ifdef BUILDING_ODM_IMAGE
1581 PROP_DICTIONARY_IMAGES += odm
1582endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001583ifdef BUILDING_VENDOR_DLKM_IMAGE
1584 PROP_DICTIONARY_IMAGES += vendor_dlkm
1585endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001586ifdef BUILDING_ODM_DLKM_IMAGE
1587 PROP_DICTIONARY_IMAGES += odm_dlkm
1588endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001589define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001590 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001591endef
1592
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001593# $(1): the path of the input dictionary file, where each line has the format key=value
1594# $(2): the key to look up
1595define read-image-prop-dictionary
1596$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1597endef
1598
The Android Open Source Project88b60792009-03-03 19:28:42 -08001599# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001600# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001601
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001602# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001603ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001604
Ying Wang37526142015-03-10 12:02:57 -07001605INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1606 $(ALL_DEFAULT_INSTALLED_MODULES))
1607
Tao Bao10fc9492018-08-14 12:17:48 -07001608INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1609INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1610
1611# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1612# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1613# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1614# the call to FILELIST.
1615ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001616INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001617$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1618else
1619$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1620endif
1621
1622$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001623$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001624 @echo Installed file list: $@
1625 @mkdir -p $(dir $@)
1626 @rm -f $@
1627 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001628 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001629
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001630recovery_sepolicy := \
1631 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001632 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001633 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001634 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1635 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1636 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001637 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001638 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001639 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1640 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1641 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001642
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001643# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1644# SELinux files
1645IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1646
Steve Muckle04b6f052020-08-09 14:36:56 -07001647# if building multiple boot images from multiple kernels, use the first kernel listed
1648# for the recovery image
1649recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001650recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001651recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001652
Anton Hansson45a40da2019-01-18 14:06:34 +00001653# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1654# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1655# which get remapped to a bucket.
1656recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001657ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1658recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001659# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001660# ------160------240------320----------480------------640------
1661# mdpi hdpi xhdpi xxhdpi xxxhdpi
1662recovery_density := $(strip \
1663 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1664 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1665 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1666 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001667endif
1668
1669ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1670recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1671else
Doug Zongker25d55f82014-04-04 13:51:15 -07001672recovery_resources_common := $(recovery_resources_common)-xhdpi
1673endif
1674
Tao Baoe1e829e2018-08-29 20:36:00 -07001675# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1676# Note that the font selected here can be overridden for a particular device by putting a font.png
1677# in its private recovery resources.
1678ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001679recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001680else
Dan Willemsen97672232020-05-27 00:09:16 -07001681recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001682endif
1683
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001684
1685# We will only generate the recovery background text images if the variable
1686# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1687# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1688# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1689# BoardConfig in order to use this feature.
1690ifeq ($(recovery_density),xxxhdpi)
1691TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1692else ifeq ($(recovery_density),xxhdpi)
1693TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1694endif
1695
1696ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1697# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1698ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1699 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1700else
1701 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1702endif
1703
1704
Dan Willemsen97672232020-05-27 00:09:16 -07001705RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001706RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1707RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1708RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1709RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1710
xunchangcc57d312018-12-07 12:12:17 -08001711RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1712RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1713RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1714RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1715RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1716
1717generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001718 $(RECOVERY_INSTALLING_TEXT_FILE) \
1719 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1720 $(RECOVERY_ERASING_TEXT_FILE) \
1721 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001722 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1723 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1724 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1725 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1726 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1727 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001728
Dan Willemsen97672232020-05-27 00:09:16 -07001729resource_dir := bootable/recovery/tools/recovery_l10n/res/
1730resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001731image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001732zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001733$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001734$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001735$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1736$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001737$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001738$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001739$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001740 recovery_installing \
1741 recovery_installing_security \
1742 recovery_erasing \
1743 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001744 recovery_no_command
1745$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001746 recovery_cancel_wipe_data \
1747 recovery_factory_data_reset \
1748 recovery_try_again \
1749 recovery_wipe_data_menu_header \
1750 recovery_wipe_data_confirmation
1751$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001752$(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 -08001753 # Prepares the font directory.
1754 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1755 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001756 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001757 @rm -rf $(dir $@)
1758 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001759 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001760 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001761 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001762 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1763 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1764 --text_name $(text_name) \
1765 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1766 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001767 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001768 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001769else
1770RECOVERY_INSTALLING_TEXT_FILE :=
1771RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1772RECOVERY_ERASING_TEXT_FILE :=
1773RECOVERY_ERROR_TEXT_FILE :=
1774RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001775RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1776RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1777RECOVERY_TRY_AGAIN_TEXT_FILE :=
1778RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1779RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001780endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1781
Ying Wang9a175682015-08-06 11:47:47 -07001782ifndef TARGET_PRIVATE_RES_DIRS
1783TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1784endif
Doug Zongker4647f122009-07-02 09:00:54 -07001785recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001786 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001787recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001788
1789
Andrew Boiefa61ff02012-09-28 09:33:45 -07001790ifdef TARGET_RECOVERY_FSTAB
1791recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1792else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001793recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001794endif
Tao Baoc3c17532016-06-10 10:11:54 -07001795ifdef TARGET_RECOVERY_WIPE
1796recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001797else
Tao Baoc3c17532016-06-10 10:11:54 -07001798recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001799endif
Tao Bao8beab692015-07-22 12:33:18 -07001800
Tao Bao6d5d6232018-03-09 17:04:42 -08001801# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001802# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001803# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1804# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001805#
1806# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001807# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001808# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001809# b) We build a single image that contains boot and recovery both - no recovery image to install
1810# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001811# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001812# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001813# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1814# do bsdiff because boot and recovery will contain different number of entries
1815# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001816# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1817# do bsdiff because boot and recovery will contain different number of entries
1818# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001819
Tom Cherry2929cad2018-09-20 11:04:37 -07001820ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001821 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001822# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001823RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1824ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001825else
Tao Bao8beab692015-07-22 12:33:18 -07001826RECOVERY_RESOURCE_ZIP :=
1827endif
Doug Zongker4647f122009-07-02 09:00:54 -07001828
Tao Bao139c7272018-07-31 13:26:54 -07001829INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1830
1831$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001832 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1833 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1834 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1835 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1836 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1837 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1838 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1839 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1840
1841# Parses the given list of build variables and writes their values as build properties if defined.
1842# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1843# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1844# $(1): Map from the build variable names to property names
1845# $(2): Output file
1846define append-recovery-ui-properties
1847echo "#" >> $(2)
1848echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1849echo "#" >> $(2)
1850$(foreach prop,$(1), \
1851 $(eval _varname := $(call word-colon,1,$(prop))) \
1852 $(eval _propname := $(call word-colon,2,$(prop))) \
1853 $(eval _value := $($(_varname))) \
1854 $(if $(_value), \
1855 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1856endef
1857
1858$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001859 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001860 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1861 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1862 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001863 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001864 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001865 $(hide) mkdir -p $(dir $@)
1866 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001867 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001868 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001869 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001870 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001871 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001872 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1873
Yifan Hong33fd5d42020-09-24 18:18:26 -07001874# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
1875# On device with dedicated recovery partition, the file should come from the boot
1876# ramdisk.
1877ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
1878INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
1879$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
1880 $(copy-file-to-target)
1881endif
1882
Steve Mucklef84668e2020-03-16 19:13:46 -07001883ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001884 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001885ifdef GENERIC_KERNEL_CMDLINE
1886 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1887endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001888else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001889 INTERNAL_RECOVERYIMAGE_ARGS := \
1890 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001891 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001892# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001893ifdef INTERNAL_KERNEL_CMDLINE
1894 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001895endif
1896ifdef BOARD_KERNEL_BASE
1897 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1898endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001899ifdef BOARD_KERNEL_PAGESIZE
1900 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1901endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001902ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001903ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1904 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1905else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001906 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1907endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001908endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001909ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1910 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1911endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001912ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1913 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1914endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001915endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001916ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1917 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1918endif
Doug Zongker4647f122009-07-02 09:00:54 -07001919
Yifan Hong881df392020-10-09 14:29:39 -07001920$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001921 $(INTERNAL_ROOT_FILES) \
1922 $(INSTALLED_RAMDISK_TARGET) \
1923 $(INTERNAL_RECOVERYIMAGE_FILES) \
1924 $(recovery_sepolicy) \
1925 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1926 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07001927 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001928 $(recovery_resource_deps) \
1929 $(recovery_fstab)
1930 # Making recovery image
1931 mkdir -p $(TARGET_RECOVERY_OUT)
1932 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1933 # Copying baseline ramdisk...
1934 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1935 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1936 # Modifying ramdisk contents...
1937 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1938 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1939 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1940 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1941 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1942 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1943 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1944 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1945 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1946 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1947 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1948 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1949 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1950 $(foreach item,$(recovery_fstab), \
1951 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1952 $(if $(strip $(recovery_wipe)), \
1953 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1954 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1955 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07001956 $(hide) touch $@
1957
1958$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00001959 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001960
Ying Wang747b9f12015-01-30 14:05:22 -08001961# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07001962# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001963define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001964 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07001965 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001966 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001967 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07001968 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001969 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001970 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001971 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001972 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001973 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1974 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001975 )\
1976 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001977 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1978 $(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 +08001979 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001980 $(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 -07001981 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001982 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1983 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001984 $(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 -07001985 $(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 -08001986endef
1987
Dan Willemsend120ac62020-06-12 02:39:34 +00001988recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001989ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001990 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001991endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001992ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001993 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001994endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001995ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001996 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001997endif
Tao Baof4866c72018-08-22 14:35:09 -07001998ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001999 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2000 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2001 else
2002 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2003 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002004endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002005ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002006 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002007endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002008ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002009 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002010endif
Tao Baof4866c72018-08-22 14:35:09 -07002011
Dan Willemsend120ac62020-06-12 02:39:34 +00002012ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002013$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002014$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002015 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002016 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07002017endif # BOARD_USES_RECOVERY_AS_BOOT
2018
Dan Willemsend120ac62020-06-12 02:39:34 +00002019$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002020 $(call build-recoveryimage-target, $@, \
2021 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002022
Tao Bao4594d0e2015-12-22 09:47:46 -08002023ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002024$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002025 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002026 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2027 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002028endif
Doug Zongker56588872012-08-20 15:38:58 -07002029
Ying Wang747b9f12015-01-30 14:05:22 -08002030.PHONY: recoveryimage-nodeps
2031recoveryimage-nodeps:
2032 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002033 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2034 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002035
Chris Grossa784ef12019-04-22 11:09:57 -07002036else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002037RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002038endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002039
2040.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002041recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002042
Jiyong Park03eb0612017-10-04 21:22:41 +09002043ifneq ($(BOARD_NAND_PAGE_SIZE),)
2044$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002045endif
2046
Jiyong Park03eb0612017-10-04 21:22:41 +09002047ifneq ($(BOARD_NAND_SPARE_SIZE),)
2048$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002049endif
2050
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002051ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002052# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002053# the debug ramdisk, which is the original ramdisk plus additional
2054# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2055# When /force_debuggable is present, /init will load userdebug sepolicy
2056# and property files to allow adb root, if the device is unlocked.
2057
2058ifdef BUILDING_RAMDISK_IMAGE
2059BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2060INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2061
2062INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2063 $(ALL_GENERATED_SOURCES) \
2064 $(ALL_DEFAULT_INSTALLED_MODULES))
2065
2066# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2067# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2068# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2069my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2070
2071INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2072INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2073$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2074$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2075
2076# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2077# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2078# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2079$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002080$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002081 echo Installed file list: $@
2082 mkdir -p $(dir $@)
2083 rm -f $@
2084 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002085 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002086
2087# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2088# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2089ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2090my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2091else
2092my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2093endif # BOARD_USES_RECOVERY_AS_BOOT
2094
2095$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2096$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002097
2098ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2099# 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 +08002100$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002101else
2102# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2103$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2104endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002105$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002106 $(call pretty,"Target debug ram disk: $@")
2107 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2108 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002109 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002110 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002111
2112.PHONY: ramdisk_debug-nodeps
2113ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2114ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002115ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002116 echo "make $@: ignoring dependencies"
2117 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2118 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002119 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002120 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002121
2122my_debug_ramdisk_sync_dir :=
2123my_debug_ramdisk_root_dir :=
2124
2125endif # BUILDING_RAMDISK_IMAGE
2126
2127# -----------------------------------------------------------------
2128# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2129#
2130# Note: it's intentional to skip signing for boot-debug.img, because it
2131# can only be used if the device is unlocked with verification error.
Daniel Norman42879ff2020-10-06 11:09:56 -07002132ifdef BUILDING_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002133ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002134ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2135 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2136 $(PRODUCT_OUT)/$(k).img)
2137else
2138 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2139endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002140
2141# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2142ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2143INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2144else
2145INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2146endif
2147
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002148# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2149# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2150# Using a test key to sign boot-debug.img to continue booting with the mismatched
2151# public key, if the device is unlocked.
2152ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002153$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002154endif
2155
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002156BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2157INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2158# $(1): the bootimage to sign
2159define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002160$(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 +08002161$(AVBTOOL) add_hash_footer \
2162 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002163 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002164 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2165 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002166$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002167endef
2168
Steve Muckleb3dda772020-03-11 16:03:07 -07002169# $(1): output file
2170define build-debug-bootimage-target
2171 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2172 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2173 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2174endef
2175
Bowgo Tsai0013f552019-03-20 17:59:52 +08002176# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2177$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2178 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002179 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002180
2181.PHONY: bootimage_debug-nodeps
2182bootimage_debug-nodeps: $(MKBOOTIMG)
2183 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002184 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002185
2186endif # TARGET_NO_KERNEL
Daniel Norman42879ff2020-10-06 11:09:56 -07002187endif # BUILDING_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002188
Bowgo Tsai6a683672020-02-14 19:00:15 +08002189ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2190ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2191# -----------------------------------------------------------------
2192# vendor debug ramdisk
2193# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002194INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002195$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2196$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2197
2198INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2199 $(ALL_GENERATED_SOURCES) \
2200 $(ALL_DEFAULT_INSTALLED_MODULES))
2201
2202# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2203# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2204# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2205# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2206$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2207$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002208$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002209 $(call pretty,"Target vendor debug ram disk: $@")
2210 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2211 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2212 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2213 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2214 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002215 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002216
2217INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2218INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2219$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2220$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2221
2222# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2223# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2224$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2225$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2226 echo Installed file list: $@
2227 mkdir -p $(dir $@)
2228 rm -f $@
2229 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2230 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2231
2232# -----------------------------------------------------------------
2233# vendor_boot-debug.img.
2234INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2235
2236# The util to sign vendor_boot-debug.img with a test key.
2237BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2238INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2239# $(1): the vendor bootimage to sign
2240define test-key-sign-vendor-bootimage
2241$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2242$(AVBTOOL) add_hash_footer \
2243 --image $(1) \
2244 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2245 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2246 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2247$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2248endef
2249
2250ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2251$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2252endif
2253
2254# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2255$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2256 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002257 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002258 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2259 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2260
2261endif # BUILDING_RAMDISK_IMAGE
2262endif # BUILDING_VENDOR_BOOT_IMAGE
2263
Bowgo Tsai0013f552019-03-20 17:59:52 +08002264# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002265# The test harness ramdisk, which is based off debug_ramdisk, plus a
2266# few additional test-harness-specific properties in adb_debug.prop.
2267
2268ifdef BUILDING_RAMDISK_IMAGE
2269BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2270INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2271
2272# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2273# appends a few test harness specific properties into the adb_debug.prop.
2274TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2275TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2276
2277# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2278# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2279TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2280ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2281ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2282
2283# $(1): a list of key=value pairs for additional property assignments
2284# $(2): the target .prop file to append the properties from $(1)
2285define append-test-harness-props
2286 echo "#" >> $(2); \
2287 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2288 echo "#" >> $(2);
2289 $(foreach line,$(1), echo "$(line)" >> $(2);)
2290endef
2291
2292$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002293$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002294 $(call pretty,"Target test harness ram disk: $@")
2295 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2296 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002297 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002298
2299.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002300ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002301 echo "make $@: ignoring dependencies"
2302 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2303 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002304 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002305
2306endif # BUILDING_RAMDISK_IMAGE
2307
2308# -----------------------------------------------------------------
2309# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2310#
2311# Note: it's intentional to skip signing for boot-test-harness.img, because it
2312# can only be used if the device is unlocked with verification error.
2313ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2314
Steve Muckle4866bd62020-04-02 11:31:08 -07002315ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2316 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2317 $(PRODUCT_OUT)/$(k).img)
2318else
2319 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2320endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002321
2322# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2323INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2324
2325# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2326# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2327# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2328# public key, if the device is unlocked.
2329ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2330$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2331endif
2332
Steve Muckle4866bd62020-04-02 11:31:08 -07002333# $(1): output file
2334define build-boot-test-harness-target
2335 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2336 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2337 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2338endef
2339
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002340# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2341$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2342 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002343 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002344
2345.PHONY: bootimage_test_harness-nodeps
2346bootimage_test_harness-nodeps: $(MKBOOTIMG)
2347 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002348 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002349
2350endif # TARGET_NO_KERNEL
2351endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2352
Colin Crossbd382142020-08-26 15:08:57 -07002353# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2354# $1: from location (e.g $(TARGET_OUT)/vendor)
2355# $2: destination location (e.g. /vendor)
2356# $3: partition image name (e.g. vendor.img)
2357define create-partition-compat-symlink
2358$(eval \
2359$1:
2360 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2361 mkdir -p $(dir $1)
2362 if [ -d $1 ] && [ ! -h $1 ]; then \
2363 echo 'Non-symlink $1 detected!' 1>&2; \
2364 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2365 exit 1; \
2366 fi
2367 ln -sfn $2 $1
2368)
2369$1
2370endef
2371
2372
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002373# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002374# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002375
Dan Willemsen37a19862018-10-31 16:31:46 -07002376INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002377 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002378 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002379
Colin Crossbd382142020-08-26 15:08:57 -07002380# Create symlink /system/vendor to /vendor if necessary.
2381ifdef BOARD_USES_VENDORIMAGE
2382 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2383endif
2384
2385# Create symlink /system/product to /product if necessary.
2386ifdef BOARD_USES_PRODUCTIMAGE
2387 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2388endif
2389
2390# Create symlink /system/system_ext to /system_ext if necessary.
2391ifdef BOARD_USES_SYSTEM_EXTIMAGE
2392 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2393endif
2394
Ying Wang82cceba2012-08-13 15:03:00 -07002395FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002396
2397# ASAN libraries in the system image - add dependency.
2398ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002399ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002400 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2401 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2402 endif
2403endif
2404
Tom Cherryd14b8952018-08-09 14:26:00 -07002405FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002406
Ying Wange5e8c5f2011-09-09 16:35:53 -07002407# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002408ifdef BUILDING_SYSTEM_IMAGE
2409
Ying Wange5e8c5f2011-09-09 16:35:53 -07002410# installed file list
2411# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2412# We put installed-files.txt ahead of image itself in the dependency graph
2413# so that we can get the size stat even if the build fails due to too large
2414# system image.
2415INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002416INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2417$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002418$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002419 @echo Installed file list: $@
2420 @mkdir -p $(dir $@)
2421 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002422 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002423 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002424
2425.PHONY: installed-file-list
2426installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002427
2428$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002429
2430systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002431 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002432BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2433
The Android Open Source Project88b60792009-03-03 19:28:42 -08002434# $(1): output file
2435define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002436 @echo "Target system fs image: $(1)"
2437 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002438 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002439 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002440 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002441 $(BUILD_IMAGE) \
2442 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2443 || ( mkdir -p $${DIST_DIR}; \
2444 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2445 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002446endef
2447
Dan Willemsen6b72c732019-06-12 21:33:38 +00002448ifeq ($(BOARD_AVB_ENABLE),true)
2449$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2450endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002451$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002452 $(call build-systemimage-target,$@)
2453
Tao Baoe9d61b02018-08-20 21:09:07 -07002454INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002455SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002456
Tao Baoe9d61b02018-08-20 21:09:07 -07002457# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2458# compatibility, in case device-specific Makefiles still refer to the old name.
2459INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2460
Doug Zongker73ef8252009-07-23 15:12:53 -07002461# The system partition needs room for the recovery image as well. We
2462# now store the recovery image as a binary patch using the boot image
2463# as the source (since they are very similar). Generate the patch so
2464# we can see how big it's going to be, and include that in the system
2465# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002466ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002467ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002468ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002469ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002470diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2471else
2472diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2473endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002474intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2475RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002476$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2477$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002478 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002479 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002480 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002481 @echo "Construct recovery from boot"
2482 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002483 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002484else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2485RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002486endif # BOARD_USES_FULL_RECOVERY_IMAGE
2487endif # INSTALLED_RECOVERYIMAGE_TARGET
2488endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002489
Yifan Hong9a3cad92020-04-27 19:06:59 -07002490$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002491 @echo "Install system fs image: $@"
2492 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002493 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002494
Tao Baoe9d61b02018-08-20 21:09:07 -07002495systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002496
2497.PHONY: systemimage-nodeps snod
2498systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002499 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002500 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002501 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002502 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002503ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002504 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002505endif
2506
Dan Willemsen67495202019-01-16 12:42:05 -08002507endif # BUILDING_SYSTEM_IMAGE
2508
Anton Hansson30e061b2018-11-12 13:36:46 +00002509.PHONY: sync syncsys
2510sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002511
Ying Wang3a61eeb2016-03-11 10:32:01 -08002512# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002513# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002514.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002515platform:
2516 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002517
2518.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002519platform-java:
2520 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002521
Ying Wang3a61eeb2016-03-11 10:32:01 -08002522# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002523# data partition image
2524INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002525 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002526
Dan Willemsen67495202019-01-16 12:42:05 -08002527ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002528userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002529 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002530BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2531
Ying Wangbd93d422011-10-28 17:02:30 -07002532define build-userdataimage-target
2533 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2534 @mkdir -p $(TARGET_OUT_DATA)
2535 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002536 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002537 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002538 $(BUILD_IMAGE) \
2539 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2540 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2541 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002542endef
2543
Joe Onorato64d85d02009-04-09 19:31:12 -07002544# We just build this directly to the install location.
2545INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002546INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2547 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002548 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002549$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002550 $(build-userdataimage-target)
2551
2552.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002553userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002554 $(build-userdataimage-target)
2555
Dan Willemsen67495202019-01-16 12:42:05 -08002556endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002557
Andreas Gampe039b5c72017-03-24 16:06:31 -07002558# ASAN libraries in the system image - build rule.
2559ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2560 $(TARGET_OUT_SHARED_LIBRARIES) \
2561 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2562 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2563 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002564# Extra options: Enforce the system user for the files to avoid having to change ownership.
2565ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002566# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2567# enough space.
2568$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002569 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 -07002570
The Android Open Source Project88b60792009-03-03 19:28:42 -08002571# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002572# partition table image
2573ifdef BOARD_BPT_INPUT_FILES
2574
2575BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002576BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002577
2578INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2579 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002580 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002581 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2582
2583ifdef BOARD_BPT_DISK_SIZE
2584INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2585endif
2586
2587define build-bptimage-target
2588 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2589 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2590endef
2591
2592INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002593$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2594 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2595
David Zeuthen25328622016-04-08 15:08:03 -04002596$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2597 $(build-bptimage-target)
2598
2599.PHONY: bptimage-nodeps
2600bptimage-nodeps:
2601 $(build-bptimage-target)
2602
2603endif # BOARD_BPT_INPUT_FILES
2604
2605# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002606# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002607ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002608INTERNAL_CACHEIMAGE_FILES := \
2609 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2610
2611cacheimage_intermediates := \
2612 $(call intermediates-dir-for,PACKAGING,cache)
2613BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2614
2615define build-cacheimage-target
2616 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2617 @mkdir -p $(TARGET_OUT_CACHE)
2618 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002619 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002620 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002621 $(BUILD_IMAGE) \
2622 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2623 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2624 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002625endef
2626
2627# We just build this directly to the install location.
2628INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002629$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002630 $(build-cacheimage-target)
2631
2632.PHONY: cacheimage-nodeps
2633cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2634 $(build-cacheimage-target)
2635
Dan Willemsen67495202019-01-16 12:42:05 -08002636else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002637# we need to ignore the broken cache link when doing the rsync
2638IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002639endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002640
David Zeuthen0eb10972016-09-28 17:55:27 -04002641# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002642# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002643ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002644ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002645# Marker file to identify that odex files are installed
2646INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2647ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2648$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2649 $(hide) touch $@
2650endif
2651
Alex Light4e358ab2016-06-16 14:47:10 -07002652INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2653 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002654 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002655
Colin Cross6db5b0e2018-11-16 21:26:33 -08002656# system_other dex files are installed as a side-effect of installing system image files
2657INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2658
Alex Light4e358ab2016-06-16 14:47:10 -07002659INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002660INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2661$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002662$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002663 @echo Installed file list: $@
2664 @mkdir -p $(dir $@)
2665 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002666 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002667 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002668
Bowgo Tsai867ab662019-01-29 13:30:18 +08002669# Determines partition size for system_other.img.
2670ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2671ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2672INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2673endif
2674endif
2675
2676ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2677INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2678endif
2679
Alex Light4e358ab2016-06-16 14:47:10 -07002680systemotherimage_intermediates := \
2681 $(call intermediates-dir-for,PACKAGING,system_other)
2682BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2683
2684# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2685define build-systemotherimage-target
2686 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2687 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2688 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002689 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002690 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002691 $(BUILD_IMAGE) \
2692 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2693 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2694 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002695endef
2696
2697# We just build this directly to the install location.
2698INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002699ifneq (true,$(SANITIZE_LITE))
2700# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002701$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2702 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002703endif
Alex Light4e358ab2016-06-16 14:47:10 -07002704
2705.PHONY: systemotherimage-nodeps
2706systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2707 $(build-systemotherimage-target)
2708
Dan Willemsen67495202019-01-16 12:42:05 -08002709endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002710
2711
2712# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002713# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002714ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002715INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002716 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002717 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002718
Ying Wang8da19e32015-09-15 14:22:12 -07002719
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002720# Create symlink /vendor/odm to /odm if necessary.
2721ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002722 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002723endif
2724
Yifan Honge51dff22020-06-23 17:26:57 -07002725# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2726# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2727#
2728# On devices with a vendor_dlkm partition,
2729# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2730# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2731# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2732# are hidden.
2733# On devices without a vendor_dlkm partition,
2734# - /vendor/lib/modules stores vendor DLKMs directly.
2735# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2736# See system/core/rootdir/Android.mk for a list of created symlinks.
2737# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2738# are not guaranteed to exist on all devices.
2739ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002740 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 -07002741endif
2742
Colin Crossbd382142020-08-26 15:08:57 -07002743INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2744INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2745$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2746$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2747 @echo Installed file list: $@
2748 @mkdir -p $(dir $@)
2749 @rm -f $@
2750 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2751 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002752
Ying Wanga0febe52013-03-20 11:02:05 -07002753vendorimage_intermediates := \
2754 $(call intermediates-dir-for,PACKAGING,vendor)
2755BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002756define build-vendorimage-target
2757 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2758 @mkdir -p $(TARGET_OUT_VENDOR)
2759 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002760 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002761 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002762 $(BUILD_IMAGE) \
2763 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2764 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002765 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002766endef
2767
2768# We just build this directly to the install location.
2769INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002770$(INSTALLED_VENDORIMAGE_TARGET): \
2771 $(INTERNAL_USERIMAGES_DEPS) \
2772 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002773 $(INSTALLED_FILES_FILE_VENDOR) \
2774 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002775 $(build-vendorimage-target)
2776
Steven Morelanda2e734d2017-03-07 12:10:09 -08002777.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002778vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002779 $(build-vendorimage-target)
2780
Colin Cross91a52272017-06-20 16:57:52 -07002781sync: $(INTERNAL_VENDORIMAGE_FILES)
2782
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002783else ifdef BOARD_PREBUILT_VENDORIMAGE
2784INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2785$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2786endif
Ying Wanga0febe52013-03-20 11:02:05 -07002787
Ying Wang9f8e8db2011-11-04 11:37:01 -07002788# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002789# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002790ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002791INTERNAL_PRODUCTIMAGE_FILES := \
2792 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002793 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002794
2795INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002796INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2797$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002798$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002799 @echo Installed file list: $@
2800 @mkdir -p $(dir $@)
2801 @rm -f $@
2802 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002803 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002804
2805productimage_intermediates := \
2806 $(call intermediates-dir-for,PACKAGING,product)
2807BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2808define build-productimage-target
2809 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2810 @mkdir -p $(TARGET_OUT_PRODUCT)
2811 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002812 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002813 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002814 $(BUILD_IMAGE) \
2815 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2816 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2817 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002818endef
2819
2820# We just build this directly to the install location.
2821INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002822$(INSTALLED_PRODUCTIMAGE_TARGET): \
2823 $(INTERNAL_USERIMAGES_DEPS) \
2824 $(INTERNAL_PRODUCTIMAGE_FILES) \
2825 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002826 $(build-productimage-target)
2827
2828.PHONY: productimage-nodeps pnod
2829productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2830 $(build-productimage-target)
2831
2832sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2833
2834else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2835INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2836$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2837endif
2838
2839# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002840# system_ext partition image
2841ifdef BUILDING_SYSTEM_EXT_IMAGE
2842INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2843 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002844 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01002845
Justin Yun6151e3f2019-06-25 15:58:13 +09002846INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2847INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2848$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2849$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002850 @echo Installed file list: $@
2851 @mkdir -p $(dir $@)
2852 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002853 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002854 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002855
Justin Yun6151e3f2019-06-25 15:58:13 +09002856system_extimage_intermediates := \
2857 $(call intermediates-dir-for,PACKAGING,system_ext)
2858BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2859define build-system_extimage-target
2860 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2861 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2862 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2863 $(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 -07002864 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002865 $(BUILD_IMAGE) \
2866 $(TARGET_OUT_SYSTEM_EXT) \
2867 $(system_extimage_intermediates)/system_ext_image_info.txt \
2868 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2869 $(TARGET_OUT)
2870 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002871endef
2872
2873# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002874INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002875$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2876 $(INTERNAL_USERIMAGES_DEPS) \
2877 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2878 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002879 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002880
Justin Yun6151e3f2019-06-25 15:58:13 +09002881.PHONY: systemextimage-nodeps senod
2882systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2883 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002884
Justin Yun6151e3f2019-06-25 15:58:13 +09002885sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002886
Justin Yun6151e3f2019-06-25 15:58:13 +09002887else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2888INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2889$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002890endif
2891
2892# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002893# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002894ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002895INTERNAL_ODMIMAGE_FILES := \
2896 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002897 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002898
Colin Crossbd382142020-08-26 15:08:57 -07002899# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
2900# /odm/lib/modules -> /odm_dlkm/lib/modules
2901#
2902# On devices with a odm_dlkm partition,
2903# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
2904# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
2905# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2906# are hidden.
2907# On devices without a odm_dlkm partition,
2908# - /odm/lib/modules stores odm DLKMs directly.
2909# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
2910# See system/core/rootdir/Android.mk for a list of created symlinks.
2911# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
2912# are not guaranteed to exist on all devices.
2913ifdef BOARD_USES_ODM_DLKMIMAGE
2914 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
2915endif
2916
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002917INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2918INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2919$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002920$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002921 @echo Installed file list: $@
2922 @mkdir -p $(dir $@)
2923 @rm -f $@
2924 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002925 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002926
2927odmimage_intermediates := \
2928 $(call intermediates-dir-for,PACKAGING,odm)
2929BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2930define build-odmimage-target
2931 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2932 @mkdir -p $(TARGET_OUT_ODM)
2933 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2934 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002935 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002936 $(BUILD_IMAGE) \
2937 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2938 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2939 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002940endef
2941
2942# We just build this directly to the install location.
2943INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002944$(INSTALLED_ODMIMAGE_TARGET): \
2945 $(INTERNAL_USERIMAGES_DEPS) \
2946 $(INTERNAL_ODMIMAGE_FILES) \
2947 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002948 $(build-odmimage-target)
2949
2950.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002951odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002952 $(build-odmimage-target)
2953
2954sync: $(INTERNAL_ODMIMAGE_FILES)
2955
2956else ifdef BOARD_PREBUILT_ODMIMAGE
2957INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2958$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2959endif
2960
2961# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002962# vendor_dlkm partition image
2963ifdef BUILDING_VENDOR_DLKM_IMAGE
2964INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2965 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002966 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002967
2968INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2969INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2970$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2971$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2972 @echo Installed file list: $@
2973 @mkdir -p $(dir $@)
2974 @rm -f $@
2975 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2976 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2977
2978vendor_dlkmimage_intermediates := \
2979 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2980BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2981define build-vendor_dlkmimage-target
2982 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2983 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2984 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2985 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2986 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2987 $(BUILD_IMAGE) \
2988 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2989 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2990 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2991endef
2992
2993# We just build this directly to the install location.
2994INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2995$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2996 $(INTERNAL_USERIMAGES_DEPS) \
2997 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2998 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2999 $(build-vendor_dlkmimage-target)
3000
3001.PHONY: vendor_dlkmimage-nodeps vdnod
3002vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3003 $(build-vendor_dlkmimage-target)
3004
3005sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3006
3007else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3008INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3009$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3010endif
3011
3012# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003013# odm_dlkm partition image
3014ifdef BUILDING_ODM_DLKM_IMAGE
3015INTERNAL_ODM_DLKMIMAGE_FILES := \
3016 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003017 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003018
3019INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3020INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3021$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3022$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3023 @echo Installed file list: $@
3024 @mkdir -p $(dir $@)
3025 @rm -f $@
3026 $(hide) $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3027 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3028
3029odm_dlkmimage_intermediates := \
3030 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3031BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3032define build-odm_dlkmimage-target
3033 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3034 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3035 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3036 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3037 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3038 $(BUILD_IMAGE) \
3039 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3040 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3041 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3042endef
3043
3044# We just build this directly to the install location.
3045INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3046$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3047 $(INTERNAL_USERIMAGES_DEPS) \
3048 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3049 $(INSTALLED_FILES_FILE_ODM_DLKM)
3050 $(build-odm_dlkmimage-target)
3051
3052.PHONY: odm_dlkmimage-nodeps odnod
3053odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3054 $(build-odm_dlkmimage-target)
3055
3056sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3057
3058else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3059INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3060$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3061endif
3062
3063
3064# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003065# dtbo image
3066ifdef BOARD_PREBUILT_DTBOIMAGE
3067INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3068
3069ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003070$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003071 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3072 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003073 --image $@ \
3074 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3075 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3076 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003077else
3078$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3079 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3080endif
3081
Tao Bao0da43472018-08-22 22:53:41 -07003082endif # BOARD_PREBUILT_DTBOIMAGE
3083
3084# Returns a list of image targets corresponding to the given list of partitions. For example, it
3085# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3086# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003087# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003088define images-for-partitions
3089$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3090endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003091
3092# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003093# custom images
3094INSTALLED_CUSTOMIMAGES_TARGET :=
3095
3096ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3097INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3098
3099# Sign custom image.
3100# $(1): the prebuilt custom image.
3101# $(2): the mount point of the prebuilt custom image.
3102# $(3): the signed custom image target.
3103define sign_custom_image
3104$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3105 @echo Target custom image: $(3)
3106 mkdir -p $(dir $(3))
3107 cp $(1) $(3)
3108ifeq ($(BOARD_AVB_ENABLE),true)
3109 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3110 $(AVBTOOL) add_hashtree_footer \
3111 --image $(3) \
3112 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3113 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3114 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3115 --partition_name $(2) \
3116 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3117 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3118endif
3119INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3120endef
3121
3122$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3123 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3124 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3125endif
3126
3127# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003128# vbmeta image
3129ifeq ($(BOARD_AVB_ENABLE),true)
3130
3131BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003132AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003133
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003134ifdef BOARD_AVB_KEY_PATH
3135$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3136else
3137# If key path isn't specified, use the 4096-bit test key.
3138BOARD_AVB_ALGORITHM := SHA256_RSA4096
3139BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3140endif
3141
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003142# AVB signing for system_other.img.
3143ifdef BUILDING_SYSTEM_OTHER_IMAGE
3144ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3145$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3146else
3147# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3148BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3149BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3150endif
3151
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003152$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3153 @echo Extracting system_other avb key: $@
3154 @rm -f $@
3155 @mkdir -p $(dir $@)
3156 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003157
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003158ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3159BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3160endif
3161
3162BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3163endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3164
Tao Bao744c4c72018-08-20 21:09:07 -07003165INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003166 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003167 $(BOARD_AVB_VBMETA_VENDOR)
3168
3169# Not allowing the same partition to appear in multiple groups.
3170ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003171 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003172endif
3173
cfig1aeef722019-09-20 22:45:06 +08003174# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3175# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3176# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003177ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003178ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3179$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003180 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003181 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3182endif
3183endif
3184
Bowgo Tsai9b548012019-05-14 16:57:03 +08003185# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003186
3187BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003188 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003189 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003190 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3191
3192BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003193 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003194 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003195 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3196
Justin Yun6151e3f2019-06-25 15:58:13 +09003197BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003198 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003199 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003200 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003201
Bowgo Tsai9b548012019-05-14 16:57:03 +08003202BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003203 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003204 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003205
Tao Bao19b02fe2019-10-09 00:04:28 -07003206BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3207 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3208
3209BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3210 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3211
Bowgo Tsai9b548012019-05-14 16:57:03 +08003212BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003213 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003214 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003215
3216BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003217 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003218 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003219
Yifan Hongcfb917a2020-05-07 14:58:20 -07003220BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3221 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3222 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3223
Yifan Hongf496f1b2020-07-15 16:52:59 -07003224BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3225 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3226 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3227
Tao Bao19b02fe2019-10-09 00:04:28 -07003228BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3229 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3230
Bowgo Tsai9b548012019-05-14 16:57:03 +08003231# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003232ifdef BOOT_SECURITY_PATCH
3233BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3234 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3235endif
3236
3237ifdef VENDOR_SECURITY_PATCH
3238BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3239 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3240endif
3241
3242ifdef ODM_SECURITY_PATCH
3243BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3244 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3245endif
3246
Yifan Hongcfb917a2020-05-07 14:58:20 -07003247ifdef VENDOR_DLKM_SECURITY_PATCH
3248BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3249 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3250endif
3251
Yifan Hongf496f1b2020-07-15 16:52:59 -07003252ifdef ODM_DLKM_SECURITY_PATCH
3253BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3254 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3255endif
3256
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003257BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003258VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003259DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3260SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3261VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003262RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003263PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003264SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003265ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003266VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003267ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003268
Tao Bao0da43472018-08-22 22:53:41 -07003269# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003270# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003271define _check-and-set-avb-chain-args
3272$(eval part := $(1))
3273$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003274
3275$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3276$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3277$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3278$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3279$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3280$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3281$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3282$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3283
3284# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3285$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3286$(eval $(_signing_args) := \
3287 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3288
cfig1aeef722019-09-20 22:45:06 +08003289# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3290# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003291$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003292 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3293 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003294
Tao Bao744c4c72018-08-20 21:09:07 -07003295# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003296# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003297$(if $(filter $(part),$(part:vbmeta_%=%)),\
3298 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3299 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003300endef
3301
Tao Bao0da43472018-08-22 22:53:41 -07003302# Checks and sets the required build variables for an AVB partition. The partition will be
3303# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003304# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3305# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003306# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3307# but vbmeta would capture the image descriptor of only the first boot
3308# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003309# $(1): Partition name, e.g. boot or system.
3310define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003311$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003312$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003313 $(if $(_in_chained_vbmeta),\
3314 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003315 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003316 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003317 $(if $(filter boot,$(1)),\
3318 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3319 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3320 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3321 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003322endef
3323
Hongguang Chenf23364d2020-04-27 18:36:36 -07003324# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3325# $(1): the custom partition to enable AVB chain.
3326define check-and-set-custom-avb-chain-args
3327$(eval part := $(1))
3328$(eval PART=$(call to-upper,$(part)))
3329$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3330$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3331
3332INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3333 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3334endef
3335
Tao Baob1a2e352018-08-14 16:17:12 -07003336ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003337$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003338endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003339
Steve Mucklee1b10862019-07-10 10:49:37 -07003340ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3341$(eval $(call check-and-set-avb-args,vendor_boot))
3342endif
3343
Tao Bao0da43472018-08-22 22:53:41 -07003344$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003345
3346ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003347$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003348endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003349
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003350ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003351$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003352endif
3353
Justin Yun6151e3f2019-06-25 15:58:13 +09003354ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3355$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003356endif
3357
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003358ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003359$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003360endif
3361
Yifan Hongcfb917a2020-05-07 14:58:20 -07003362ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3363$(eval $(call check-and-set-avb-args,vendor_dlkm))
3364endif
3365
Yifan Hongf496f1b2020-07-15 16:52:59 -07003366ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3367$(eval $(call check-and-set-avb-args,odm_dlkm))
3368endif
3369
Yueyao Zhu211c9012017-04-27 00:34:50 -07003370ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003371$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003372endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003373
David Zeuthen8fecb282017-12-01 16:24:01 -05003374ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003375$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003376endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003377
David Anderson7709ab22018-10-15 14:41:34 -07003378# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3379ifdef BOARD_AVB_VBMETA_SYSTEM
3380$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003381endif
3382
3383ifdef BOARD_AVB_VBMETA_VENDOR
3384$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3385endif
3386
Hongguang Chenf23364d2020-04-27 18:36:36 -07003387ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3388$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3389 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3390endif
3391
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003392# Add kernel cmdline descriptor for kernel to mount system.img as root with
3393# dm-verity. This works when system.img is either chained or not-chained:
3394# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3395# cmdline descriptor to system.img
3396# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3397# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003398ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003399ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003400BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003401endif
David Anderson8916a2a2018-09-18 15:46:59 -07003402endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003403
Tao Bao0da43472018-08-22 22:53:41 -07003404BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003405BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003406BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3407
3408ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003409# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003410BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003411endif
Tao Bao0da43472018-08-22 22:53:41 -07003412
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003413ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003414BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003415endif
3416
David Anderson7709ab22018-10-15 14:41:34 -07003417ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3418BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3419 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003420endif
3421
3422ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3423BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3424 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003425endif
3426
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003427# $(1): the directory to extract public keys to
3428define extract-avb-chain-public-keys
3429 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3430 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3431 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003432 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3433 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3434 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003435 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3436 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3437 --output $(1)/system.avbpubkey)
3438 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3439 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3440 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003441 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3442 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3443 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003444 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3445 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3446 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003447 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3448 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3449 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003450 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3451 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3452 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003453 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3454 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3455 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003456 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3457 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3458 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003459 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3460 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3461 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003462 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3463 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3464 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003465 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3466 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3467 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003468 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3469 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3470 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3471 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003472endef
3473
Tao Bao744c4c72018-08-20 21:09:07 -07003474# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3475# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003476# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003477# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3478# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003479# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003480# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003481# $(2): Output filename.
3482define build-chained-vbmeta-image
3483 $(call pretty,"Target chained vbmeta image: $@")
3484 $(hide) $(AVBTOOL) make_vbmeta_image \
3485 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3486 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3487 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3488 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3489 --output $@
3490endef
3491
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003492ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003493ifdef BOARD_AVB_VBMETA_SYSTEM
3494INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3495$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003496 $(AVBTOOL) \
3497 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3498 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003499 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003500endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003501endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003502
3503ifdef BOARD_AVB_VBMETA_VENDOR
3504INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3505$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003506 $(AVBTOOL) \
3507 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3508 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003509 $(call build-chained-vbmeta-image,vbmeta_vendor)
3510endif
3511
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003512define build-vbmetaimage-target
3513 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003514 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3515 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003516 $(hide) $(AVBTOOL) make_vbmeta_image \
3517 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003518 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003519 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3520 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003521 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003522endef
3523
Paul Trautrim4e143232019-08-13 16:30:57 +09003524ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003525INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003526$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3527 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3528
David Zeuthen8fecb282017-12-01 16:24:01 -05003529$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003530 $(AVBTOOL) \
3531 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003532 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003533 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3534 $(INSTALLED_VENDORIMAGE_TARGET) \
3535 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003536 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003537 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003538 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003539 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003540 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003541 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003542 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3543 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3544 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3545 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3546 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3547 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003548 $(build-vbmetaimage-target)
3549
3550.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003551vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3552 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003553vbmetaimage-nodeps:
3554 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003555endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003556
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003557endif # BOARD_AVB_ENABLE
3558
3559# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003560# Check VINTF of build
3561
Yifan Hongc08cbf02020-09-15 19:07:39 +00003562# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003563ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003564
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003565intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3566check_vintf_all_deps :=
3567
Yifan Hongaf9b0702020-01-21 12:46:57 -08003568# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3569# because they are only used for prebuilt images.
3570check_vintf_common_srcs_patterns := \
3571 $(TARGET_OUT)/etc/vintf/% \
3572 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3573 $(TARGET_OUT_ODM)/etc/vintf/% \
3574 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3575 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3576
3577check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3578 $(INTERNAL_SYSTEMIMAGE_FILES) \
3579 $(INTERNAL_VENDORIMAGE_FILES) \
3580 $(INTERNAL_ODMIMAGE_FILES) \
3581 $(INTERNAL_PRODUCTIMAGE_FILES) \
3582 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3583))
3584check_vintf_common_srcs_patterns :=
3585
3586check_vintf_has_system :=
3587check_vintf_has_vendor :=
3588
Yifan Hong28ffd732020-03-13 13:11:10 -07003589ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3590$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3591endif
3592ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3593$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3594endif
3595
Yifan Hong605ea042020-01-14 21:36:00 +00003596# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003597check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3598ifneq ($(check_vintf_system_deps),)
3599check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003600check_vintf_system_log := $(intermediates)/check_vintf_system_log
3601check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003602$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003603 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3604check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003605endif # check_vintf_system_deps
3606check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003607
3608# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003609check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3610ifneq ($(check_vintf_vendor_deps),)
3611check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003612check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3613check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003614# Check vendor SKU=(empty) case when:
3615# - DEVICE_MANIFEST_FILE is not empty; OR
3616# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003617$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003618 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3619 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003620 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003621$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003622 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3623 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3624 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3625 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003626check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003627endif # check_vintf_vendor_deps
3628check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003629
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003630# -- Check VINTF compatibility of build.
3631# Skip partial builds; only check full builds. Only check if:
3632# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003633# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003634# - Building product / system_ext / odm images if board has product / system_ext / odm images
3635ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003636ifeq ($(check_vintf_has_system),true)
3637ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003638ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3639ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3640ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3641
3642check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3643check_vintf_all_deps += $(check_vintf_compatible_log)
3644
3645check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003646check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003647
3648# -- Kernel version and configurations.
3649ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3650
Yifan Hong605ea042020-01-14 21:36:00 +00003651BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3652BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3653
3654my_board_extracted_kernel :=
3655
3656# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3657# from INSTALLED_KERNEL_TARGET.
3658ifdef BOARD_KERNEL_CONFIG_FILE
3659ifdef BOARD_KERNEL_VERSION
3660$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3661 cp $< $@
3662$(BUILT_KERNEL_VERSION_FILE):
3663 echo $(BOARD_KERNEL_VERSION) > $@
3664
3665my_board_extracted_kernel := true
3666endif # BOARD_KERNEL_VERSION
3667endif # BOARD_KERNEL_CONFIG_FILE
3668
3669ifneq ($(my_board_extracted_kernel),true)
3670ifndef INSTALLED_KERNEL_TARGET
3671$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3672 is true. Information about the updated kernel cannot be built into OTA update package. \
3673 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3674 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3675 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3676 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3677 manually.)
3678else
3679
3680# Tools for decompression that is not in PATH.
3681# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3682# Algorithms that are in the script but not in this list will be found in PATH.
3683my_decompress_tools := \
3684 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3685
3686$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3687$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3688$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003689$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3690 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003691 --output-configs $@ \
3692 --output-version $(BUILT_KERNEL_VERSION_FILE)
3693
3694my_decompress_tools :=
3695
3696endif # my_board_extracted_kernel
3697my_board_extracted_kernel :=
3698
3699endif # INSTALLED_KERNEL_TARGET
3700
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003701check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3702check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3703
3704endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3705
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003706check_vintf_compatible_args += \
3707 --dirmap /system:$(TARGET_OUT) \
3708 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3709 --dirmap /odm:$(TARGET_OUT_ODM) \
3710 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3711 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3712
3713ifdef PRODUCT_SHIPPING_API_LEVEL
3714check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3715endif # PRODUCT_SHIPPING_API_LEVEL
3716
3717$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3718$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003719# Check ODM SKU=(empty) case when:
3720# - ODM_MANIFEST_FILES is not empty; OR
3721# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003722$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003723 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3724 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003725 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003726# Check vendor SKU=(empty) case when:
3727# - DEVICE_MANIFEST_FILE is not empty; OR
3728# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003729$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003730 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3731 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003732 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003733$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3734 @echo -n -e 'Deps: \n ' > $@
3735 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3736 @echo -n -e 'Args: \n ' >> $@
3737 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003738 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3739 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003740 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003741 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3742 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3743 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003744
3745check_vintf_compatible_log :=
3746check_vintf_compatible_args :=
3747check_vintf_compatible_deps :=
3748
3749endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3750endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3751endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003752endif # check_vintf_has_vendor
3753endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003754endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3755
3756# Add all logs of VINTF checks to dist builds
3757droid_targets: $(check_vintf_all_deps)
3758$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3759
3760# Helper alias to check all VINTF of current build.
3761.PHONY: check-vintf-all
3762check-vintf-all: $(check_vintf_all_deps)
3763 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3764
Yifan Hongaf9b0702020-01-21 12:46:57 -08003765check_vintf_has_vendor :=
3766check_vintf_has_system :=
3767check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003768check_vintf_all_deps :=
3769intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003770endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003771
3772# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003773# Check image sizes <= size of super partition
3774
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003775ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003776
3777ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003778
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003779# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003780# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003781define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003782 mkdir -p $(dir $(1))
3783 rm -f $(1)
3784 $(call dump-super-image-info, $(1))
3785 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3786 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003787 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003788endef
3789
Yifan Hong30910932019-10-25 20:36:55 -07003790check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3791droid_targets: $(check_all_partition_sizes_log)
3792$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003793
Yifan Hong30910932019-10-25 20:36:55 -07003794$(check_all_partition_sizes_log): \
3795 $(CHECK_PARTITION_SIZES) \
3796 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3797 $(call check-all-partition-sizes-target, \
3798 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3799 $@)
3800
3801.PHONY: check-all-partition-sizes
3802check-all-partition-sizes: $(check_all_partition_sizes_log)
3803
3804.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003805check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003806 $(call check-all-partition-sizes-target, \
3807 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003808
Yifan Hong2dae5722018-07-31 12:47:27 -07003809endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003810
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003811endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003812
3813# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003814# bring in the installer image generation defines if necessary
3815ifeq ($(TARGET_USE_DISKINSTALLER),true)
3816include bootable/diskinstaller/config.mk
3817endif
3818
3819# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003820# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003821
Ying Wangbd2d0242015-09-22 11:17:52 -07003822ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003823 build_ota_package := false
3824 build_otatools_package := false
3825else
Tao Bao9be20c72019-04-08 21:11:59 -07003826 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003827 build_ota_package := true
3828 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3829 build_ota_package := false
3830 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003831 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003832 build_ota_package := false
3833 endif
3834 ifeq ($(TARGET_PRODUCT),sdk)
3835 build_ota_package := false
3836 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003837 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3838 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3839 build_ota_package := false
3840 endif
3841 ifeq ($(TARGET_NO_KERNEL),true)
3842 build_ota_package := false
3843 endif
3844 ifeq ($(recovery_fstab),)
3845 build_ota_package := false
3846 endif
3847 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003848
Tao Bao9be20c72019-04-08 21:11:59 -07003849 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003850 build_otatools_package := true
3851 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3852 build_otatools_package := false
3853 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003854endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003855
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003856ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003857
3858INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003859 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003860 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003861 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003862 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003863 append2simg \
3864 avbtool \
3865 blk_alloc_to_base_fs \
3866 boot_signer \
3867 brillo_update_payload \
3868 brotli \
3869 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003870 build_image \
3871 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003872 build_verity_metadata \
3873 build_verity_tree \
3874 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003875 check_ota_package_signature \
3876 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003877 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003878 checkvintf \
3879 delta_generator \
3880 e2fsck \
3881 e2fsdroid \
3882 fc_sort \
3883 fec \
3884 fs_config \
3885 generate_verity_key \
3886 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003887 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003888 imgdiff \
3889 libconscrypt_openjdk_jni \
3890 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003891 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003892 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003893 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07003894 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07003895 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003896 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003897 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003898 mkbootfs \
3899 mkbootimg \
3900 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003901 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003902 mkf2fsuserimg.sh \
3903 mksquashfs \
3904 mksquashfsimage.sh \
3905 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003906 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003907 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003908 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003909 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003910 sign_apex \
3911 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003912 signapk \
3913 simg2img \
3914 sload_f2fs \
3915 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003916 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003917 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003918 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003919 verity_signer \
3920 verity_verifier \
3921 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003922
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003923# Additional tools to unpack and repack the apex file.
3924INTERNAL_OTATOOLS_MODULES += \
3925 apexer \
3926 deapexer \
3927 debugfs_static \
3928 merge_zips \
3929 resize2fs \
3930 soong_zip \
3931
Anton Hansson8dab0a62019-03-28 15:45:40 +00003932ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003933INTERNAL_OTATOOLS_MODULES += \
3934 futility \
3935 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003936endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003937
Tao Bao96daeeb2019-05-01 21:17:13 -07003938INTERNAL_OTATOOLS_FILES := \
3939 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003940
Ying Wang06898662010-06-17 17:52:18 -07003941.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003942otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003943
Tao Bao96daeeb2019-05-01 21:17:13 -07003944# For each module, recursively resolve its host shared library dependencies. Then we have a full
3945# list of modules whose installed files need to be packed.
3946INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3947 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3948 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003949
Tao Bao96daeeb2019-05-01 21:17:13 -07003950INTERNAL_OTATOOLS_PACKAGE_FILES := \
3951 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3952
3953INTERNAL_OTATOOLS_PACKAGE_FILES += \
3954 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3955 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003956
3957ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003958INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003959 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003960 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003961endif
3962ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003963INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003964 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3965 -name "atx_metadata.bin"))
3966endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003967ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003968INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003969 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003970endif
3971
Tao Bao96daeeb2019-05-01 21:17:13 -07003972INTERNAL_OTATOOLS_RELEASETOOLS := \
3973 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3974 \( -type f -o -type l \) -print))
3975
3976BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3977$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3978$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3979$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3980$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003981$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003982 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003983 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3984 mkdir -p $(dir $@)
3985 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3986 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003987 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003988 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003989
3990.PHONY: otatools-package
3991otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3992
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003993endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003994
The Android Open Source Project88b60792009-03-03 19:28:42 -08003995# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003996# misc_info.txt
3997
3998INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3999
4000ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4001# default to common dir for device vendor
4002tool_extensions := $(TARGET_DEVICE_DIR)/../common
4003else
4004tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4005endif
4006.KATI_READONLY := tool_extensions
4007
Steve Muckle903a1ca2020-05-07 17:32:10 -07004008# $1: boot image file name
4009define misc_boot_size
4010$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4011endef
4012
Daniel Normane1e48082019-06-27 13:55:23 -07004013$(INSTALLED_MISC_INFO_TARGET):
4014 rm -f $@
4015 $(call pretty,"Target misc_info.txt: $@")
4016 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4017 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4018ifdef BOARD_FLASH_BLOCK_SIZE
4019 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4020endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004021ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4022 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4023 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004024endif
4025ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4026 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004027else
4028 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004029endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004030ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4031 echo "lz4_ramdisks=true" >> $@
4032endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004033ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4034 echo "vendor_boot=true" >> $@
4035 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4036endif
Daniel Normane1e48082019-06-27 13:55:23 -07004037ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4038 $(hide) echo "no_recovery=true" >> $@
4039endif
4040ifdef BOARD_INCLUDE_RECOVERY_DTBO
4041 $(hide) echo "include_recovery_dtbo=true" >> $@
4042endif
4043ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4044 $(hide) echo "include_recovery_acpio=true" >> $@
4045endif
4046ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4047 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4048endif
4049ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4050 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4051 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4052else
4053 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4054endif
4055 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4056 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4057ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4058 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4059endif
4060 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004061 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004062 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4063 $(hide) echo "multistage_support=1" >> $@
4064 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4065ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4066 $(hide) echo "build_generic_ota_package=true" >> $@
4067endif
4068ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4069 # OTA scripts are only interested in fingerprint related properties
4070 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4071endif
4072ifneq (,$(filter address, $(SANITIZE_TARGET)))
4073 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4074 $(hide) echo "userdata_img_with_data=true" >> $@
4075endif
4076ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4077 $(hide) echo "full_recovery_image=true" >> $@
4078endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004079ifdef BOARD_USES_VENDORIMAGE
4080 $(hide) echo "board_uses_vendorimage=true" >> $@
4081endif
Daniel Normane1e48082019-06-27 13:55:23 -07004082ifeq ($(BOARD_AVB_ENABLE),true)
4083 $(hide) echo "avb_enable=true" >> $@
4084 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4085 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4086 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4087 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4088ifdef BOARD_AVB_BOOT_KEY_PATH
4089 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4090 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4091 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4092endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004093 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4094ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4095 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4096 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4097 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4098endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004099 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4100ifdef BOARD_AVB_RECOVERY_KEY_PATH
4101 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4102 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4103 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4104endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004105ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4106 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4107 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4108 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4109 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4110 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4111 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4112 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4113 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4114endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004115ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4116 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4117 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4118 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4119 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4120 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4121endif # BOARD_AVB_VBMETA_SYSTEM
4122ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4123 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4124 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4125 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4126 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4127 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4128endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4129endif # BOARD_AVB_ENABLE
4130ifdef BOARD_BPT_INPUT_FILES
4131 $(hide) echo "board_bpt_enable=true" >> $@
4132 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4133 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4134endif
4135ifdef BOARD_BPT_DISK_SIZE
4136 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4137endif
4138 $(call generate-userimage-prop-dictionary, $@)
4139ifeq ($(AB_OTA_UPDATER),true)
4140 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4141 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4142 $(hide) echo "ab_update=true" >> $@
4143endif
Yifan Hong65afc072020-04-17 10:08:10 -07004144ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4145 $(hide) echo "allow_non_ab=true" >> $@
4146endif
Daniel Normane1e48082019-06-27 13:55:23 -07004147ifdef BOARD_PREBUILT_DTBOIMAGE
4148 $(hide) echo "has_dtbo=true" >> $@
4149ifeq ($(BOARD_AVB_ENABLE),true)
4150 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4151 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4152ifdef BOARD_AVB_DTBO_KEY_PATH
4153 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4154 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4155 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4156endif # BOARD_AVB_DTBO_KEY_PATH
4157endif # BOARD_AVB_ENABLE
4158endif # BOARD_PREBUILT_DTBOIMAGE
4159 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004160 @# VINTF checks
4161ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4162 $(hide) echo "vintf_enforce=true" >> $@
4163endif
4164ifdef ODM_MANIFEST_SKUS
4165 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4166endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004167ifdef ODM_MANIFEST_FILES
4168 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4169endif
4170ifdef DEVICE_MANIFEST_SKUS
4171 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4172endif
4173ifdef DEVICE_MANIFEST_FILE
4174 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4175endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004176ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4177 $(hide) echo "bootloader_in_update_package=true" >> $@
4178endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07004179ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
4180 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
4181endif
Daniel Normane1e48082019-06-27 13:55:23 -07004182
4183.PHONY: misc_info
4184misc_info: $(INSTALLED_MISC_INFO_TARGET)
4185
4186droidcore: $(INSTALLED_MISC_INFO_TARGET)
4187
4188# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004189# A zip of the directories that map to the target filesystem.
4190# This zip can be used to create an OTA package or filesystem image
4191# as a post-build step.
4192#
4193name := $(TARGET_PRODUCT)
4194ifeq ($(TARGET_BUILD_TYPE),debug)
4195 name := $(name)_debug
4196endif
4197name := $(name)-target_files-$(FILE_NAME_TAG)
4198
4199intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4200BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4201$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4202$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004203 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004204
4205# $(1): Directory to copy
4206# $(2): Location to copy it to
4207# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4208define package_files-copy-root
4209 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4210 mkdir -p $(2) && \
4211 $(ACP) -rd $(strip $(1))/* $(2); \
4212 fi
4213endef
4214
Tao Baoa04fca32015-11-30 12:22:24 -08004215built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004216
4217# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004218ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004219built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004220 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004221endif
4222
The Android Open Source Project88b60792009-03-03 19:28:42 -08004223$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4224
Dan Willemsen653bea92017-03-21 15:47:37 -07004225tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004226$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004227
Sen Jiang4438fd92016-03-07 16:51:01 -08004228ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004229updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004230endif
4231
4232# Build OTA tools if non-A/B is allowed
4233ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004234updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004235endif
Yifan Hong65afc072020-04-17 10:08:10 -07004236
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004237$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004238
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004239# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07004240# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004241ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4242$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07004243else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
4244$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004245else
4246$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4247endif
4248
Dan Willemsen653bea92017-03-21 15:47:37 -07004249ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004250 ifdef OSRELEASED_DIRECTORY
4251 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4252 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4253 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4254 endif
Tao Baoa835f382019-07-18 15:55:30 -07004255
4256 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4257 # additionally include radio or bootloader partitions).
4258 ifeq ($(AB_OTA_PARTITIONS),)
4259 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4260 endif
4261endif
4262
4263ifneq ($(AB_OTA_PARTITIONS),)
4264 ifneq ($(AB_OTA_UPDATER),true)
4265 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4266 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004267endif
4268
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004269# Run fs_config while creating the target files package
4270# $1: root directory
4271# $2: add prefix
4272define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004273(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 -08004274endef
4275
Yifan Hong60bfcc42019-11-01 11:39:45 -07004276# Filter out vendor from the list for AOSP targets.
4277# $(1): list
4278define filter-out-missing-vendor
4279$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4280endef
4281
4282# Information related to dynamic partitions and virtual A/B. This information
4283# is needed for building the super image (see dump-super-image-info) and
4284# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004285# $(1): file
4286define dump-dynamic-partitions-info
4287 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4288 echo "use_dynamic_partitions=true" >> $(1))
4289 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4290 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004291 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4292 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4293 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004294 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4295 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004296 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4297 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4298 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4299 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4300 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4301 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004302 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004303 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4304 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4305 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4306 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4307 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004308 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 -07004309 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4310 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004311 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4312 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004313 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4314 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004315 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4316 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4317 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4318 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4319 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4320 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4321 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4322 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004323 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4324 echo "virtual_ab=true" >> $(1))
4325 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4326 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004327endef
4328
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004329# By conditionally including the dependency of the target files package on the
4330# full system image deps, we speed up builds that do not build the system
4331# image.
4332ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004333 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4334endif
4335
4336ifdef BUILDING_USERDATA_IMAGE
4337 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4338endif
4339
4340ifdef BUILDING_SYSTEM_OTHER_IMAGE
4341 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4342endif
4343
4344ifdef BUILDING_VENDOR_BOOT_IMAGE
4345 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
4346endif
4347
4348ifdef BUILDING_RECOVERY_IMAGE
4349 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
4350 # BUILD_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
4351 # commands in build-recoveryimage-target, which would touch the files under
4352 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4353 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4354 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4355 else
4356 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4357 endif
4358 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4359endif
4360
4361# Conditionally depend on the image files if the image is being built so the
4362# target-files.zip rule doesn't wait on the image creation rule, or the image
4363# if it is coming from a prebuilt.
4364
4365ifdef BUILDING_VENDOR_IMAGE
4366 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4367else ifdef BOARD_PREBUILT_VENDORIMAGE
4368 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4369endif
4370
4371ifdef BUILDING_PRODUCT_IMAGE
4372 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4373else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4374 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4375endif
4376
4377ifdef BUILDING_SYSTEM_EXT_IMAGE
4378 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4379else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4380 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4381endif
4382
4383ifdef BUILDING_BOOT_IMAGE
4384 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
4385else ifdef BOARD_PREBUILT_BOOTIMAGE
4386 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4387endif
4388
4389ifdef BUILDING_ODM_IMAGE
4390 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4391else ifdef BOARD_PREBUILT_ODMIMAGE
4392 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4393endif
4394
4395ifdef BUILDING_VENDOR_DLKM_IMAGE
4396 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4397else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4398 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4399endif
4400
4401ifdef BUILDING_ODM_DLKM_IMAGE
4402 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4403else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4404 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004405endif
4406
Isaac Chen9e09d472019-07-05 17:30:41 +08004407ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004408 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4409 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004410endif
4411
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004412ifdef BOARD_PREBUILT_BOOTLOADER
4413$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004414droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004415endif
4416
The Android Open Source Project88b60792009-03-03 19:28:42 -08004417# Depending on the various images guarantees that the underlying
4418# directories are up-to-date.
4419$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004420 $(INSTALLED_RADIOIMAGE_TARGET) \
4421 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004422 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004423 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004424 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004425 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4426 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004427 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004428 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4429 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004430 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004431 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004432 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4433 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4434 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004435 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004436 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004437 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004438 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004439 $(LPMAKE) \
4440 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004441 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004442 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004443 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004444 $(SOONG_ZIP) \
4445 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004446 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004447 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004448 $(BUILT_KERNEL_CONFIGS_FILE) \
4449 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004450 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004451 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004452 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004453 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07004454ifneq (,$(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 -08004455 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004456 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004457 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004458 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004459ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004460ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004461 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07004462else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07004463 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4464endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004465endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004466ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004467 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004468else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004469ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004470 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004471endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004472ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004473ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004474 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004475else
Steve Mucklee1b10862019-07-10 10:49:37 -07004476 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004477endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004478endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004479ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004480 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004481endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004482ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004483 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004484endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004485ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004486 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004487endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004488ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004489 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004490endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004491ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004492 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004493endif
Colin Crossa6de2ad2020-08-26 18:40:19 -07004494endif # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004495endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004496 @# Components of the boot image
4497 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004498 $(hide) mkdir -p $(zip_root)/ROOT
4499 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004500 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004501 @# If we are using recovery as boot, this is already done when processing recovery.
4502ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004503ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004504 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004505 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004506endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004507ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004508 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004509endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004510ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004511ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004512 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004513endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004514ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004515 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004516endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004517 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004518ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004519 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004520endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004521ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004522 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004523endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004524else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4525 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4526endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4527endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004528 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4529 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004530 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004531ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4532 mkdir -p $(zip_root)/VENDOR_BOOT
4533 $(call package_files-copy-root, \
4534 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4535ifdef INSTALLED_DTBIMAGE_TARGET
4536 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4537endif
4538ifdef BOARD_KERNEL_BASE
4539 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4540endif
4541ifdef BOARD_KERNEL_PAGESIZE
4542 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4543endif
4544 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4545endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004546ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004547 @# Contents of the system image
4548 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004549 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004550endif
4551ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004552 @# Contents of the data image
4553 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004554 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004555endif
4556ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004557 @# Contents of the vendor image
4558 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004559 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004560endif
Dan Willemsen67495202019-01-16 12:42:05 -08004561ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004562 @# Contents of the product image
4563 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004564 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004565endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004566ifdef BUILDING_SYSTEM_EXT_IMAGE
4567 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004568 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004569 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004570endif
Dan Willemsen67495202019-01-16 12:42:05 -08004571ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004572 @# Contents of the odm image
4573 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004574 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004575endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004576ifdef BUILDING_VENDOR_DLKM_IMAGE
4577 @# Contents of the vendor_dlkm image
4578 $(hide) $(call package_files-copy-root, \
4579 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4580endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004581ifdef BUILDING_ODM_DLKM_IMAGE
4582 @# Contents of the odm_dlkm image
4583 $(hide) $(call package_files-copy-root, \
4584 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4585endif
Dan Willemsen67495202019-01-16 12:42:05 -08004586ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004587 @# Contents of the system_other image
4588 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004589 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004590endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004591 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004592 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004593 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004594ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004595ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004596 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004597 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004598endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004599endif
Doug Zongker8678df42009-06-15 14:30:14 -07004600 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004601 @# build them.
4602 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004603 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004604 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004605ifneq ($(tool_extension),)
4606 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4607endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004608 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004609 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004610 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004611ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4612 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4613 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004614endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004615ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4616 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4617 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004618endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004619ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4620 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4621 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004622endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004623ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4624 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4625 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004626endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004627ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4628 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4629 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004630endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004631ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4632 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4633 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4634endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004635ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4636 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4637 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4638endif
Yifan Hong65afc072020-04-17 10:08:10 -07004639ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004640ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004641 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004642 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004643endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004644endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004645ifeq ($(AB_OTA_UPDATER),true)
4646 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004647 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004648 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004649 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4650 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004651 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4652 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4653 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004654ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004655 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4656 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4657 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004658endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004659endif
Steve Fungdfbab492015-09-24 18:12:33 -07004660ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004661 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004662 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004663endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004664ifdef BOARD_PREBUILT_VENDORIMAGE
4665 $(hide) mkdir -p $(zip_root)/IMAGES
4666 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4667endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004668ifdef BOARD_PREBUILT_PRODUCTIMAGE
4669 $(hide) mkdir -p $(zip_root)/IMAGES
4670 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4671endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004672ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004673 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004674 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004675endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004676ifdef BOARD_PREBUILT_BOOTIMAGE
4677 $(hide) mkdir -p $(zip_root)/IMAGES
4678 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4679endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004680ifdef BOARD_PREBUILT_ODMIMAGE
4681 $(hide) mkdir -p $(zip_root)/IMAGES
4682 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4683endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004684ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004685 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004686 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4687endif
4688ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4689 $(hide) mkdir -p $(zip_root)/IMAGES
4690 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004691endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004692ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004693 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4694 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004695endif # BOARD_PREBUILT_DTBOIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004696ifdef BOARD_PREBUILT_BOOTLOADER
4697 $(hide) mkdir -p $(zip_root)/IMAGES
4698 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
4699endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07004700ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4701 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4702 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4703 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4704endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004705 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4706 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4707 @# INSTALLED_RADIOIMAGE_TARGET.
4708 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4709 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004710 @# Run fs_config on all the system, vendor, boot ramdisk,
4711 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004712ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004713 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004714endif
4715ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004716 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4717endif
Dan Willemsen67495202019-01-16 12:42:05 -08004718ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004719 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4720endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004721ifdef BUILDING_SYSTEM_EXT_IMAGE
4722 $(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 +01004723endif
Dan Willemsen67495202019-01-16 12:42:05 -08004724ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004725 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4726endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004727ifdef BUILDING_VENDOR_DLKM_IMAGE
4728 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4729endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004730ifdef BUILDING_ODM_DLKM_IMAGE
4731 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
4732endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004733 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004734 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004735ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004736 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004737 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004738endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004739ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4740 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4741endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004742ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4743 @# 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 -08004744 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4745endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004746ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4747 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4748endif
Dan Willemsen67495202019-01-16 12:42:05 -08004749ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004750 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4751endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004752 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004753ifdef BUILT_KERNEL_CONFIGS_FILE
4754 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4755endif
4756ifdef BUILT_KERNEL_VERSION_FILE
4757 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4758endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004759 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4760ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4761 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4762endif
Tao Baocbd6d492019-10-07 22:46:02 -07004763 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4764 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004765ifeq ($(BUILD_QEMU_IMAGES),true)
4766 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4767 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4768endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004769 @# Zip everything up, preserving symlinks and placing META/ files first to
4770 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004771 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004772 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004773 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004774
Ying Wanga0febe52013-03-20 11:02:05 -07004775.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004776target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4777
Ying Wang4709d7c2014-04-14 17:25:43 -07004778$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07004779
Dan Albert4d323332016-10-14 13:23:06 -07004780# -----------------------------------------------------------------
4781# NDK Sysroot Package
4782NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004783$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004784 @echo Package NDK sysroot...
4785 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4786
4787$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4788
Ying Wang09c4b682015-08-11 11:24:19 -07004789ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004790# -----------------------------------------------------------------
4791# OTA update package
4792
Yifan Hong50e79542018-11-08 17:44:12 -08004793# $(1): output file
4794# $(2): additional args
4795define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004796PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004797 $(OTA_FROM_TARGET_FILES) \
4798 --verbose \
4799 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4800 --path $(HOST_OUT) \
4801 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4802 $(2) \
4803 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004804endef
4805
Doug Zongker8678df42009-06-15 14:30:14 -07004806name := $(TARGET_PRODUCT)
4807ifeq ($(TARGET_BUILD_TYPE),debug)
4808 name := $(name)_debug
4809endif
4810name := $(name)-ota-$(FILE_NAME_TAG)
4811
4812INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004813INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4814
Doug Zongker8678df42009-06-15 14:30:14 -07004815$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004816$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07004817$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004818 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004819 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004820
4821.PHONY: otapackage
4822otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4823
Tao Bao519d1822018-12-27 12:47:23 -08004824ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004825name := $(TARGET_PRODUCT)
4826ifeq ($(TARGET_BUILD_TYPE),debug)
4827 name := $(name)_debug
4828endif
4829name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4830
4831INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004832$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004833$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4834 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07004835 $(OTA_FROM_TARGET_FILES) \
4836 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004837 @echo "Package OTA (retrofit dynamic partitions): $@"
4838 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4839
4840.PHONY: otardppackage
4841
4842otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4843
Tao Bao519d1822018-12-27 12:47:23 -08004844endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004845
Ying Wang09c4b682015-08-11 11:24:19 -07004846endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004847
Ying Wang09a00a62010-10-20 14:01:09 -07004848# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004849# A zip of the appcompat directory containing logs
4850APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4851# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004852ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004853$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4854 $(INTERNAL_RAMDISK_FILES) \
4855 $(INTERNAL_USERDATAIMAGE_FILES) \
4856 $(INTERNAL_VENDORIMAGE_FILES) \
4857 $(INTERNAL_PRODUCTIMAGE_FILES) \
4858 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01004859endif
4860$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4861$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4862 @echo "appcompat logs: $@"
4863 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4864 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4865 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4866 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4867
Dario Frenid1011272018-07-23 20:20:15 +01004868# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004869# A zip of the symbols directory. Keep the full paths to make it
4870# more obvious where these files came from.
4871#
4872name := $(TARGET_PRODUCT)
4873ifeq ($(TARGET_BUILD_TYPE),debug)
4874 name := $(name)_debug
4875endif
4876name := $(name)-symbols-$(FILE_NAME_TAG)
4877
4878SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004879# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004880ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004881$(SYMBOLS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4882 $(INTERNAL_RAMDISK_FILES) \
4883 $(INTERNAL_USERDATAIMAGE_FILES) \
4884 $(INTERNAL_VENDORIMAGE_FILES) \
4885 $(INTERNAL_PRODUCTIMAGE_FILES) \
4886 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4887 $(INTERNAL_ODMIMAGE_FILES) \
4888 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4889 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Anton Hansson6d814982018-11-26 18:12:05 +00004890 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004891endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004892$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4893$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004894 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004895 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4896 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004897 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004898 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004899# -----------------------------------------------------------------
4900# A zip of the coverage directory.
4901#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004902name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004903ifeq ($(TARGET_BUILD_TYPE),debug)
4904name := $(name)_debug
4905endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004906COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004907ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07004908$(COVERAGE_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
4909 $(INTERNAL_RAMDISK_FILES) \
4910 $(INTERNAL_USERDATAIMAGE_FILES) \
4911 $(INTERNAL_VENDORIMAGE_FILES) \
4912 $(INTERNAL_PRODUCTIMAGE_FILES) \
4913 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4914 $(INTERNAL_ODMIMAGE_FILES) \
4915 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4916 $(INTERNAL_ODM_DLKMIMAGE_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004917endif
4918$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4919$(COVERAGE_ZIP): $(SOONG_ZIP)
4920 @echo "Package coverage: $@"
4921 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4922 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4923 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4924 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004925
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004926#------------------------------------------------------------------
4927# Export the LLVM profile data tool and dependencies for Clang coverage processing
4928#
4929ifeq (true,$(CLANG_COVERAGE))
4930 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4931 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4932 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4933 $(PROFDATA_ZIP): $(SOONG_ZIP)
4934 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4935
Kun Niud322d8d2020-05-14 16:32:29 -07004936 $(call dist-for-goals,droidcore apps_only,$(PROFDATA_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004937endif
4938
The Android Open Source Project88b60792009-03-03 19:28:42 -08004939# -----------------------------------------------------------------
4940# A zip of the Android Apps. Not keeping full path so that we don't
4941# include product names when distributing
4942#
4943name := $(TARGET_PRODUCT)
4944ifeq ($(TARGET_BUILD_TYPE),debug)
4945 name := $(name)_debug
4946endif
4947name := $(name)-apps-$(FILE_NAME_TAG)
4948
4949APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07004950$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004951 @echo "Package apps: $@"
4952 $(hide) rm -rf $@
4953 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004954 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4955 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004956 echo "No apps to zip up. Generating empty apps archive." ; \
4957 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004958 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004959 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004960 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004961
Ying Wangbc415dd2012-08-15 12:22:44 -07004962ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004963#------------------------------------------------------------------
4964# An archive of classes for use in generating code-coverage reports
4965# These are the uninstrumented versions of any classes that were
4966# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004967# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004968
Colin Crossa6bc3a82017-09-27 14:28:41 -07004969JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004970$(JACOCO_REPORT_CLASSES_ALL) :
4971 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004972 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4973 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004974
Ying Wangbc415dd2012-08-15 12:22:44 -07004975endif # EMMA_INSTRUMENT=true
4976
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004977
Ying Wangae9115a2013-08-22 20:52:47 -07004978#------------------------------------------------------------------
4979# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004980#
Ying Wangc62c92c2013-08-28 18:38:25 -07004981PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004982# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004983ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004984$(PROGUARD_DICT_ZIP): \
Colin Crosscda30c72020-08-26 18:43:21 -07004985 $(FULL_SYSTEMIMAGE_DEPS) \
4986 $(INTERNAL_RAMDISK_FILES) \
4987 $(INTERNAL_USERDATAIMAGE_FILES) \
4988 $(INTERNAL_VENDORIMAGE_FILES) \
4989 $(INTERNAL_PRODUCTIMAGE_FILES) \
4990 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4991 $(INTERNAL_ODMIMAGE_FILES) \
4992 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4993 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Colin Cross114e8df2019-09-05 17:19:35 -07004994 $(updater_dep)
4995endif
4996$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4997$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004998 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004999 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5000 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
5001 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
5002 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07005003
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005004#------------------------------------------------------------------
5005# A zip of Proguard usage files.
5006#
5007PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
5008# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5009ifeq (,$(TARGET_BUILD_UNBUNDLED))
5010$(PROGUARD_USAGE_ZIP): \
5011 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5012 $(INSTALLED_RAMDISK_TARGET) \
5013 $(INSTALLED_BOOTIMAGE_TARGET) \
5014 $(INSTALLED_USERDATAIMAGE_TARGET) \
5015 $(INSTALLED_VENDORIMAGE_TARGET) \
5016 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5017 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5018 $(INSTALLED_ODMIMAGE_TARGET) \
5019 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
5020 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
5021 $(updater_dep)
5022endif
5023$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
5024$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
5025 @echo "Packaging Proguard usage files."
5026 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5027 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
5028 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07005029
5030ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5031
5032# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5033# $(1): output file
5034define dump-super-image-info
5035 $(call dump-dynamic-partitions-info,$(1))
5036 $(if $(filter true,$(AB_OTA_UPDATER)), \
5037 echo "ab_update=true" >> $(1))
5038endef
5039
5040endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5041
The Android Open Source Project88b60792009-03-03 19:28:42 -08005042# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005043# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005044
5045ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5046
5047# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5048ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5049
5050ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005051
5052# For real devices and for dist builds, build super image from target files to an intermediate directory.
5053INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5054$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5055$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5056 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005057 PATH=$(dir $(LPMAKE)):$$PATH \
5058 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005059
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005060# Skip packing it in dist package because it is in update package.
5061ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005062$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005063endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005064
5065.PHONY: superimage_dist
5066superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005067
5068endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005069endif # BOARD_SUPER_PARTITION_SIZE != ""
5070endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005071
Yifan Hongacd862a2019-04-16 15:44:30 -07005072# -----------------------------------------------------------------
5073# super partition image for development
5074
5075ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5076ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5077ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5078
5079# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5080# $(1): built image path
5081# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5082define build-superimage-target
5083 mkdir -p $(dir $(2))
5084 rm -rf $(2)
5085 $(call dump-super-image-info,$(2))
5086 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5087 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005088 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5089 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005090 mkdir -p $(dir $(1))
5091 PATH=$(dir $(LPMAKE)):$$PATH \
5092 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5093endef
5094
5095INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5096INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5097 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5098
changho.shina8f9f112019-10-15 13:26:19 +09005099ifdef BUILDING_SYSTEM_OTHER_IMAGE
5100ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5101INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5102endif
5103endif
5104
Yifan Hongacd862a2019-04-16 15:44:30 -07005105# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5106# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5107# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5108# virtual devices.
5109ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5110$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5111 $(call pretty,"Target super fs image for debug: $@")
5112 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005113 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005114
5115droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5116
5117# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5118.PHONY: superimage
5119superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005120
5121$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005122endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5123
5124# Build $(PRODUCT_OUT)/super.img without dependencies.
5125.PHONY: superimage-nodeps supernod
5126superimage-nodeps supernod: intermediates :=
5127superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5128 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5129 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5130 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5131
5132endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5133endif # BOARD_SUPER_PARTITION_SIZE != ""
5134endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5135
5136# -----------------------------------------------------------------
5137# super empty image
5138
Tao Bao48a2feb2019-06-28 11:00:05 -07005139ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005140ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005141
Yifan Hong8b79d162018-11-29 12:32:00 -08005142INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5143$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5144$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5145 $(call pretty,"Target empty super fs image: $@")
5146 mkdir -p $(intermediates)
5147 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005148 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005149 PATH=$(dir $(LPMAKE)):$$PATH \
5150 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005151
5152$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5153
Yifan Hong2b891ac2018-11-29 12:06:31 -08005154endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005155endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005156
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005157
5158# -----------------------------------------------------------------
5159# The update package
5160
5161name := $(TARGET_PRODUCT)
5162ifeq ($(TARGET_BUILD_TYPE),debug)
5163 name := $(name)_debug
5164endif
5165name := $(name)-img-$(FILE_NAME_TAG)
5166
5167INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5168
Tao Bao57f8ed62019-08-14 23:08:18 -07005169$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5170 $(call pretty,"Package: $@")
5171 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5172 $(IMG_FROM_TARGET_FILES) \
5173 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5174 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005175
5176.PHONY: updatepackage
5177updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005178$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005179
5180
Yifan Hong2b891ac2018-11-29 12:06:31 -08005181# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005182# dalvik something
5183.PHONY: dalvikfiles
5184dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5185
Bo Huf0d50bb2017-08-01 19:02:09 +00005186ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005187MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005188MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005189SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005190
5191ifdef INSTALLED_SYSTEMIMAGE_TARGET
5192INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005193INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5194$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5195 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5196 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005197$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005198 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5199 @echo Create system-qemu.img now
5200 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005201 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005202
5203systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5204droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005205endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005206ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005207INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005208$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005209 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005210 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005211
5212vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5213droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5214endif
bohu8fd437c2020-03-30 20:16:13 -07005215
5216ifdef INSTALLED_RAMDISK_TARGET
5217ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5218ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5219INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5220$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5221 @echo Create ramdisk-qemu.img
5222 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5223
5224droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5225endif
5226endif
5227endif
5228
Anton Hansson32c76fe2018-12-13 14:34:18 +00005229ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005230INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005231$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005232 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005233 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005234
5235productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5236droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5237endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005238ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5239INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5240$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5241 @echo Create system_ext-qemu.img
5242 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005243
Justin Yun6151e3f2019-06-25 15:58:13 +09005244systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5245droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005246endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005247ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005248INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5249$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5250 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005251 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005252
5253odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5254droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5255endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005256
Yifan Hongcfb917a2020-05-07 14:58:20 -07005257ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5258INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5259$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5260 @echo Create vendor_dlkm-qemu.img
5261 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5262
5263vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5264droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5265endif
5266
Yifan Hongf496f1b2020-07-15 16:52:59 -07005267ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5268INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5269$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5270 @echo Create odm_dlkm-qemu.img
5271 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5272
5273odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5274droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5275endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005276
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005277QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005278$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5279 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005280 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005281 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5282 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005283
5284systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5285droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005286
Bo Huf0d50bb2017-08-01 19:02:09 +00005287endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005288# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005289# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005290ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005291INTERNAL_EMULATOR_PACKAGE_FILES += \
5292 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005293 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005294 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005295 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5296 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005297
5298name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5299
5300INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5301
Ying Wang5d887702015-11-04 10:06:25 -08005302$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005303 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005304 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005305
Ying Wang7d8c5352012-07-26 10:15:21 -07005306endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005307
The Android Open Source Project88b60792009-03-03 19:28:42 -08005308
5309# -----------------------------------------------------------------
5310# The SDK
5311
The Android Open Source Project88b60792009-03-03 19:28:42 -08005312# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005313sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005314
5315# Build a name that looks like:
5316#
5317# linux-x86 --> android-sdk_12345_linux-x86
5318# darwin-x86 --> android-sdk_12345_mac-x86
5319# windows-x86 --> android-sdk_12345_windows
5320#
5321sdk_name := android-sdk_$(FILE_NAME_TAG)
5322ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005323 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005324else
Joe Onorato03fbe402009-04-13 08:31:16 -07005325 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005326endif
5327ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005328 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005329endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005330sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005331
5332sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5333
5334ATREE_FILES :=
5335-include $(sdk_dep_file)
5336
5337# if we don't have a real list, then use "everything"
5338ifeq ($(strip $(ATREE_FILES)),)
5339ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005340 $(ALL_DEFAULT_INSTALLED_MODULES) \
5341 $(INSTALLED_RAMDISK_TARGET) \
5342 $(ALL_DOCS) \
5343 $(ALL_SDK_FILES)
5344endif
5345
5346atree_dir := development/build
5347
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005348
The Android Open Source Project88b60792009-03-03 19:28:42 -08005349sdk_atree_files := \
5350 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005351 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005352
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005353# development/build/sdk-android-<abi>.atree is used to differentiate
5354# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5355# files like the kernel image. We use TARGET_CPU_ABI because we don't
5356# have a better way to distinguish between CPU models.
5357ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5358 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5359endif
5360
Anton Hansson8dab0a62019-03-28 15:45:40 +00005361ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5362sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005363else
5364sdk_atree_files += $(atree_dir)/sdk.atree
5365endif
5366
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005367include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005368
The Android Open Source Project88b60792009-03-03 19:28:42 -08005369deps := \
5370 $(target_notice_file_txt) \
5371 $(tools_notice_file_txt) \
5372 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005373 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005374 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005375 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005376 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005377 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005378 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005379 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005380 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005381 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005382 $(INSTALLED_USERDATAIMAGE_TARGET) \
5383 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005384 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005385 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005386 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005387 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005388 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005389 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005390 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005391
5392INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5393$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5394$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5395$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5396$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5397
5398# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5399#
5400#SDK_GNU_ERROR := true
5401
Ying Wang5d887702015-11-04 10:06:25 -08005402$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005403 @echo "Package SDK: $@"
5404 $(hide) rm -rf $(PRIVATE_DIR) $@
5405 $(hide) for f in $(target_gnu_MODULES); do \
5406 if [ -f $$f ]; then \
5407 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5408 including GNU target $$f >&2; \
5409 FAIL=$(SDK_GNU_ERROR); \
5410 fi; \
5411 done; \
5412 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005413 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005414 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005415 ATREE_STRIP="$(HOST_STRIP) -x" \
5416 $(HOST_OUT_EXECUTABLES)/atree \
5417 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5418 -m $(PRIVATE_DEP_FILE) \
5419 -I . \
5420 -I $(PRODUCT_OUT) \
5421 -I $(HOST_OUT) \
5422 -I $(TARGET_COMMON_OUT_ROOT) \
5423 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5424 -v "OUT_DIR=$(OUT_DIR)" \
5425 -v "HOST_OUT=$(HOST_OUT)" \
5426 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5427 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5428 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5429 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5430 -o $(PRIVATE_DIR) && \
5431 cp -f $(target_notice_file_txt) \
5432 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5433 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5434 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5435 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5436 chmod -R ug+rwX $(PRIVATE_DIR) && \
5437 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005438 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5439
Raphael3d224a02010-04-16 17:50:09 -07005440
5441# Is a Windows SDK requested? If so, we need some definitions from here
5442# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005443MAIN_SDK_NAME := $(sdk_name)
5444MAIN_SDK_DIR := $(sdk_dir)
5445MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005446ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005447include $(TOPDIR)development/build/tools/windows_sdk.mk
5448endif
5449
The Android Open Source Project88b60792009-03-03 19:28:42 -08005450# -----------------------------------------------------------------
5451# Findbugs
5452INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5453INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5454$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5455 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005456 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005457 > $@
5458$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5459 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005460 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005461 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005462
5463# -----------------------------------------------------------------
5464# Findbugs
5465
5466# -----------------------------------------------------------------
5467# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005468ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005469include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005470-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005471-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005472-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005473# Also the project-specific tasks
5474-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5475-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005476-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005477# Also add test specifc tasks
5478include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005479include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005480endif
Raphaelc4d47312011-02-15 16:09:36 -08005481
Ying Wang67132ba2015-10-28 16:42:39 -07005482include $(BUILD_SYSTEM)/product-graph.mk
5483
Raphaelc4d47312011-02-15 16:09:36 -08005484# -----------------------------------------------------------------
5485# Create SDK repository packages. Must be done after tasks/* since
5486# we need the addon rules defined.
5487ifneq ($(sdk_repo_goal),)
5488include $(TOPDIR)development/build/tools/sdk_repo.mk
5489endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005490
5491# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005492# Soong generates the list of all shared libraries that are depended on by fuzz
5493# targets. It saves this list as a source:destination pair to
5494# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5495# build of the unstripped shared library, and the destination is the
5496# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5497# where fuzz target shared libraries are to be "reinstalled". The
5498# copy-many-files below generates the rules to copy the unstripped shared
5499# libraries to the device or host "reinstallation" directory. These rules are
5500# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5501# a dependency on each shared library that it needs to be "reinstalled".
5502FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5503
5504# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005505# The rule to build all fuzz targets, and package them.
5506# Note: The packages are created in Soong, and in a perfect world,
5507# we'd be able to create the phony rule there. But, if we want to
5508# have dist goals for the fuzz target, we need to have the PHONY
5509# target defined in make. MakeVarsContext.DistForGoal doesn't take
5510# into account that a PHONY rule create by Soong won't be available
5511# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005512# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005513# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005514.PHONY: haiku
5515haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5516$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))