blob: 69ee80ff124167d06cb3a385ac92754153977361 [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
43# TODO(b/140560012): Flip BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES to default
44# false after all problematic devices are tagged.
45check_elf_prebuilt_product_copy_files :=
46ifneq (,$(filter false,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
47check_elf_prebuilt_product_copy_files := true
48endif
49check_elf_prebuilt_product_copy_files_hint := \
50 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
51
Ying Wang619fccf2012-09-05 18:08:29 -070052# filter out the duplicate <source file>:<dest file> pairs.
53unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080054$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070055 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
56 $(eval unique_product_copy_files_pairs += $(cf))))
57unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080058product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070059$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070060 $(eval _src := $(call word-colon,1,$(cf))) \
61 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070062 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080063 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080064 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070065 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070066 $(if $(filter %.xml,$(_dest)),\
67 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010068 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
69 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070070 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
71 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080072 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
73 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
74 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
75 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070076 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080077
78# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070079pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
80$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
81$(pcf_ignored_file):
82 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080083
Dan Willemsen7537fd02018-10-16 23:15:08 -070084$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
85
86pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080087product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070088unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070089unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080090
91# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080092# Returns the max allowed size for an image suitable for hash verification
93# (e.g., boot.img, recovery.img, etc).
94# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
95# $(1): partition size to flash the image
96define get-hash-image-max-size
97$(if $(1), \
98 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
99 $(eval _hash_meta_size := 69632), \
100 $(eval _hash_meta_size := 0)) \
101 $(1)-$(_hash_meta_size))
102endef
103
104# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800105# Define rules to copy headers defined in copy_headers.mk
106# If more than one makefile declared a header, print a warning,
107# then copy the last one defined. This matches the previous make
108# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700109has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800110$(foreach dest,$(ALL_COPIED_HEADERS), \
111 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800112 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800113 $(if $(call streq,$(_src),$(_srcs)),, \
114 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800115 $(warning _ Using $(_src)) \
116 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
117 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
118 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
119 $(warning _ Ignoring $(src)) \
120 $(warning __ from $(firstword $(_makefiles))) \
121 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
122 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800123 $(eval $(call copy-one-header,$(_src),$(dest))))
124all_copied_headers: $(ALL_COPIED_HEADERS)
125
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700126ifdef has_dup_copy_headers
127 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700128 $(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 -0700129endif
130
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800131$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
132
Dan Willemsen6f60f022016-02-23 13:40:07 -0800133# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -0700135ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136gen := $(OUT_DOCS)/index.html
137ALL_DOCS += $(gen)
138$(gen): frameworks/base/docs/docs-redirect-index.html
139 @mkdir -p $(dir $@)
140 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700141endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800142
Dan Albert303e6032017-10-04 10:20:20 -0700143ndk_doxygen_out := $(OUT_NDK_DOCS)
144ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
145ndk_docs_src_dir := frameworks/native/docs
146ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
147ifneq ($(wildcard $(ndk_docs_src_dir)),)
148ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
149 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
150$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
151 @mkdir -p $(ndk_doxygen_out)
152 @echo "Generating NDK docs to $(ndk_doxygen_out)"
153 @( cat $(ndk_doxyfile); \
154 echo "INPUT=$(ndk_headers)"; \
155 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
156 ) | doxygen -
157
158# Note: Not a part of the docs target because we don't have doxygen available.
159# You can run this target locally if you have doxygen installed.
160ndk-docs: $(ndk_doxygen_out)/index.html
161.PHONY: ndk-docs
162endif
163
Colin Crossd60401a2019-04-18 14:46:48 -0700164$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800165
166# -----------------------------------------------------------------
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900167# property_overrides_split_enabled
168property_overrides_split_enabled :=
169ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
170 property_overrides_split_enabled := true
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900171endif
172
173# -----------------------------------------------------------------
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900174# FINAL_VENDOR_DEFAULT_PROPERTIES will be installed in vendor/default.prop if
175# property_overrides_split_enabled is true. Otherwise it will be installed in
176# ROOT/default.prop.
177ifdef BOARD_VNDK_VERSION
178 ifeq ($(BOARD_VNDK_VERSION),current)
179 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
180 else
181 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(BOARD_VNDK_VERSION)
182 endif
Logan Chiend73b94c2018-05-04 19:33:17 +0800183 ifdef BOARD_VNDK_RUNTIME_DISABLE
184 FINAL_VENDOR_DEFAULT_PROPERTIES += ro.vndk.lite=true
185 endif
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900186else
Logan Chiend73b94c2018-05-04 19:33:17 +0800187 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
188 FINAL_VENDOR_DEFAULT_PROPERTIES += ro.vndk.lite=true
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900189endif
190FINAL_VENDOR_DEFAULT_PROPERTIES += \
191 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
Tao Bao5f999232018-09-04 11:42:53 -0700192
Anton Hansson30851f22019-02-21 11:51:26 +0000193# Add cpu properties for bionic and ART.
Haibo Huangee0531d2018-11-04 09:20:09 -0800194FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.arch=$(TARGET_ARCH)
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000195FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.cpu_variant=$(TARGET_CPU_VARIANT_RUNTIME)
Haibo Huangee0531d2018-11-04 09:20:09 -0800196FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.2nd_arch=$(TARGET_2ND_ARCH)
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000197FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.2nd_cpu_variant=$(TARGET_2ND_CPU_VARIANT_RUNTIME)
Haibo Huangee0531d2018-11-04 09:20:09 -0800198
Anton Hansson30851f22019-02-21 11:51:26 +0000199FINAL_VENDOR_DEFAULT_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart.so
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000200FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT_RUNTIME)
Anton Hansson30851f22019-02-21 11:51:26 +0000201ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
202 FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
203endif
204
205ifdef TARGET_2ND_ARCH
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000206 FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).variant=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT_RUNTIME)
Anton Hansson30851f22019-02-21 11:51:26 +0000207 ifneq ($($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
208 FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
209 endif
210endif
211
Tao Bao5f999232018-09-04 11:42:53 -0700212# Although these variables are prefixed with TARGET_RECOVERY_, they are also needed under charger
213# mode (via libminui).
214ifdef TARGET_RECOVERY_DEFAULT_ROTATION
215FINAL_VENDOR_DEFAULT_PROPERTIES += \
216 ro.minui.default_rotation=$(TARGET_RECOVERY_DEFAULT_ROTATION)
217endif
218ifdef TARGET_RECOVERY_OVERSCAN_PERCENT
219FINAL_VENDOR_DEFAULT_PROPERTIES += \
220 ro.minui.overscan_percent=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
221endif
222ifdef TARGET_RECOVERY_PIXEL_FORMAT
223FINAL_VENDOR_DEFAULT_PROPERTIES += \
224 ro.minui.pixel_format=$(TARGET_RECOVERY_PIXEL_FORMAT)
225endif
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900226FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
227 $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
228
229# -----------------------------------------------------------------
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800230# prop.default
Anton Hansson1f8729e2018-08-15 12:11:55 +0100231
232BUILDINFO_SH := build/make/tools/buildinfo.sh
233BUILDINFO_COMMON_SH := build/make/tools/buildinfo_common.sh
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700234POST_PROCESS_PROPS :=$= build/make/tools/post_process_props.py
Anton Hanssonee4c9702018-12-21 15:36:00 +0000235
236# Generates a set of sysprops common to all partitions to a file.
Anton Hansson1f8729e2018-08-15 12:11:55 +0100237# $(1): Partition name
238# $(2): Output file name
239define generate-common-build-props
Anton Hanssonee4c9702018-12-21 15:36:00 +0000240 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
241 PRODUCT_DEVICE="$(TARGET_DEVICE)" \
242 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
243 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
244 PRODUCT_NAME="$(TARGET_PRODUCT)" \
245 $(call generate-common-build-props-with-product-vars-set,$(1),$(2))
246endef
247
248# Like the above macro, but requiring the relevant PRODUCT_ environment
249# variables to be set when called.
250define generate-common-build-props-with-product-vars-set
Anton Hansson1f8729e2018-08-15 12:11:55 +0100251 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
252 BUILD_ID="$(BUILD_ID)" \
253 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
254 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
255 DATE="$(DATE_FROM_FILE)" \
256 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
257 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
Anton Hansson1f8729e2018-08-15 12:11:55 +0100258 TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Anton Hansson1f8729e2018-08-15 12:11:55 +0100259 bash $(BUILDINFO_COMMON_SH) "$(1)" >> $(2)
260endef
261
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800262ifdef property_overrides_split_enabled
263INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800264INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
265ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700266$(INSTALLED_DEFAULT_PROP_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800267else
268# legacy path
The Android Open Source Project88b60792009-03-03 19:28:42 -0800269INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800270endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800271ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900272FINAL_DEFAULT_PROPERTIES := \
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900273 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) \
274 $(call collapse-pairs, $(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900275ifndef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900276 FINAL_DEFAULT_PROPERTIES += \
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900277 $(call collapse-pairs, $(FINAL_VENDOR_DEFAULT_PROPERTIES))
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900278endif
Jaekyun Seok294286d2017-01-20 13:17:12 +0900279FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
280 $(FINAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800281
Andres Moralesb8876e12015-05-06 20:44:22 -0700282intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
283
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700284$(INSTALLED_DEFAULT_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(intermediate_system_build_prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800285 @echo Target buildinfo: $@
286 @mkdir -p $(dir $@)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800287 @rm -f $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800288 $(hide) echo "#" > $@; \
289 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
290 echo "#" >> $@;
Jaekyun Seok294286d2017-01-20 13:17:12 +0900291 $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000292 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700293 $(hide) $(POST_PROCESS_PROPS) $@
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800294ifdef property_overrides_split_enabled
295 $(hide) mkdir -p $(TARGET_ROOT_OUT)
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800296 $(hide) ln -sf system/etc/prop.default $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800297endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800298
299# -----------------------------------------------------------------
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900300# vendor default.prop
301INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900302ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900303INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
304ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
305
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700306$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET) $(POST_PROCESS_PROPS)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900307 @echo Target buildinfo: $@
308 @mkdir -p $(dir $@)
309 $(hide) echo "#" > $@; \
310 echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
311 echo "#" >> $@;
312 $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000313 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700314 $(hide) $(POST_PROCESS_PROPS) $@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900315
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900316endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900317
318# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800319# build.prop
320INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
321ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900322FINAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -0700323 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
Jaekyun Seok294286d2017-01-20 13:17:12 +0900324FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
325 $(FINAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326
327# A list of arbitrary tags describing the build configuration.
328# Force ":=" so we can use +=
329BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
330ifeq ($(TARGET_BUILD_TYPE),debug)
331 BUILD_VERSION_TAGS += debug
332endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700333# The "test-keys" tag marks builds signed with the old test keys,
334# which are available in the SDK. "dev-keys" marks builds signed with
335# non-default dev keys (usually private keys from a vendor directory).
336# Both of these tags will be removed and replaced with "release-keys"
337# when the target-files is signed in a post-build step.
Dan Willemsen0ab1be62019-04-09 21:35:37 -0700338ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700339BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700340else
Doug Zongkera8608a72013-07-23 11:51:04 -0700341BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700342endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700343BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800344BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
345
346# A human-readable string that descibes this build in detail.
Colin Crossf37b4552015-07-16 17:15:19 -0700347build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS)
Andres Moralesb8876e12015-05-06 20:44:22 -0700348$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800349
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700350# The string used to uniquely identify the combined build and product; used by the OTA server.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800351ifeq (,$(strip $(BUILD_FINGERPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800352 ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
Dan Willemsen63e48db2019-01-02 12:27:43 -0800353 BF_BUILD_NUMBER := $(BUILD_USERNAME)$$($(DATE_FROM_FILE) +%m%d%H%M)
Ying Wang50367cc2014-06-12 18:42:53 -0700354 else
Nan Zhang0abdb582018-02-20 17:00:39 -0800355 BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE))
Ying Wang50367cc2014-06-12 18:42:53 -0700356 endif
357 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800358endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800359# unset it for safety.
360BF_BUILD_NUMBER :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800361
Nan Zhang0abdb582018-02-20 17:00:39 -0800362BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt
363ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE) && grep " " $(BUILD_FINGERPRINT_FILE)))
364 $(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))")
365endif
366BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE))
367# unset it for safety.
368BUILD_FINGERPRINT :=
Colin Crossf37b4552015-07-16 17:15:19 -0700369
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700370# The string used to uniquely identify the system build; used by the OTA server.
371# This purposefully excludes any product-specific variables.
372ifeq (,$(strip $(BUILD_THUMBPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800373 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700374endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800375
376BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt
377ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE)))
378 $(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))")
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700379endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800380BUILD_THUMBPRINT_FROM_FILE := $$(cat $(BUILD_THUMBPRINT_FILE))
381# unset it for safety.
382BUILD_THUMBPRINT :=
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700383
Ying Wange24e17a2014-10-07 18:42:11 -0700384KNOWN_OEM_THUMBPRINT_PROPERTIES := \
385 ro.product.brand \
386 ro.product.name \
387 ro.product.device
388OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
Anton Hansson8dab0a62019-03-28 15:45:40 +0000389 $(PRODUCT_OEM_PROPERTIES))
Ying Wange24e17a2014-10-07 18:42:11 -0700390
Sriram Raman7b641242009-03-24 22:40:59 -0700391# Display parameters shown under Settings -> About Phone
392ifeq ($(TARGET_BUILD_VARIANT),user)
393 # User builds should show:
394 # release build number or branch.buld_number non-release builds
395
396 # Dev. branches should have DISPLAY_BUILD_NUMBER set
Colin Cross63fe36a2017-02-21 17:23:02 -0800397 ifeq (true,$(DISPLAY_BUILD_NUMBER))
Colin Crossf37b4552015-07-16 17:15:19 -0700398 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700399 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700400 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700401 endif
402else
403 # Non-user builds should show detailed build information
404 BUILD_DISPLAY_ID := $(build_desc)
405endif
406
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000407# Accepts a whitespace separated list of product locales such as
408# (en_US en_AU en_GB...) and returns the first locale in the list with
409# underscores replaced with hyphens. In the example above, this will
410# return "en-US".
411define get-default-product-locale
412$(strip $(subst _,-, $(firstword $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800413endef
414
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700415# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test
416# harness to distinguish builds. Only add _asan for a sanitized build
417# if it isn't already a part of the flavor (via a dedicated lunch
418# config for example).
Ying Wang21ec03d2015-10-28 18:45:03 -0700419TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
Ivan Lozano0f71db32017-08-14 07:57:37 -0700420ifneq (, $(filter address, $(SANITIZE_TARGET)))
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700421ifeq (,$(findstring _asan,$(TARGET_BUILD_FLAVOR)))
Ying Wang21ec03d2015-10-28 18:45:03 -0700422TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
423endif
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700424endif
Ying Wang21ec03d2015-10-28 18:45:03 -0700425
Andrew Boiefa61ff02012-09-28 09:33:45 -0700426ifdef TARGET_SYSTEM_PROP
427system_prop_file := $(TARGET_SYSTEM_PROP)
428else
429system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
430endif
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700431$(intermediate_system_build_prop): $(BUILDINFO_SH) $(BUILDINFO_COMMON_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(API_FINGERPRINT) $(POST_PROCESS_PROPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800432 @echo Target buildinfo: $@
433 @mkdir -p $(dir $@)
Luca Stefani033c7eb2020-03-27 12:26:12 +0000434 $(hide) rm -f $@ && touch $@
Anton Hansson8dab0a62019-03-28 15:45:40 +0000435ifneq ($(PRODUCT_OEM_PROPERTIES),)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700436 $(hide) echo "#" >> $@; \
437 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700438 echo "#" >> $@;
Anton Hansson8dab0a62019-03-28 15:45:40 +0000439 $(hide) $(foreach prop,$(PRODUCT_OEM_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000440 echo "import /oem/oem.prop $(prop)" >> $@;)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700441endif
Anton Hanssonee4c9702018-12-21 15:36:00 +0000442 $(hide) PRODUCT_BRAND="$(PRODUCT_SYSTEM_BRAND)" \
443 PRODUCT_MANUFACTURER="$(PRODUCT_SYSTEM_MANUFACTURER)" \
444 PRODUCT_MODEL="$(PRODUCT_SYSTEM_MODEL)" \
445 PRODUCT_NAME="$(PRODUCT_SYSTEM_NAME)" \
446 PRODUCT_DEVICE="$(PRODUCT_SYSTEM_DEVICE)" \
447 $(call generate-common-build-props-with-product-vars-set,system,$@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000449 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
450 TARGET_DEVICE="$(TARGET_DEVICE)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000451 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
452 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000453 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
454 BUILD_ID="$(BUILD_ID)" \
455 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
456 DATE="$(DATE_FROM_FILE)" \
Dan Willemsen63e48db2019-01-02 12:27:43 -0800457 BUILD_USERNAME="$(BUILD_USERNAME)" \
458 BUILD_HOSTNAME="$(BUILD_HOSTNAME)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000459 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
460 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000461 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
462 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
463 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
464 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
465 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \
Colin Crossd60401a2019-04-18 14:46:48 -0700466 PLATFORM_PREVIEW_SDK_FINGERPRINT="$$(cat $(API_FINGERPRINT))" \
Anton Hansson6d814982018-11-26 18:12:05 +0000467 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
468 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
469 PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION="$(PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)" \
470 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000471 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT_FROM_FILE)") \
472 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
473 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
474 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
475 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
476 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700477 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200478 $(hide) $(foreach file,$(system_prop_file), \
Anton Hansson6d814982018-11-26 18:12:05 +0000479 if [ -f "$(file)" ]; then \
480 echo Target buildinfo from: "$(file)"; \
481 echo "" >> $@; \
482 echo "#" >> $@; \
483 echo "# from $(file)" >> $@; \
484 echo "#" >> $@; \
485 cat $(file) >> $@; \
486 echo "# end of $(file)" >> $@; \
487 fi;)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900488 $(if $(FINAL_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000489 $(hide) echo >> $@; \
490 echo "#" >> $@; \
491 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
492 echo "#" >> $@; )
Jaekyun Seok294286d2017-01-20 13:17:12 +0900493 $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000494 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700495 $(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800496
497build_desc :=
498
Andres Moralesb8876e12015-05-06 20:44:22 -0700499INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700500ifdef BUILDING_RECOVERY_IMAGE
501ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
502INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
503endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700504endif
505
Jooyung Han72b65ab2019-05-23 19:48:13 +0900506$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop)
Andres Moralesb8876e12015-05-06 20:44:22 -0700507 @echo "Target build info: $@"
Steven Morelandec082652017-10-22 02:11:47 -0700508 $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@
Andres Moralesb8876e12015-05-06 20:44:22 -0700509
The Android Open Source Project88b60792009-03-03 19:28:42 -0800510# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700511# vendor build.prop
512#
Alex Naidis47e24e92016-01-10 14:18:54 +0000513# For verifying that the vendor build is what we think it is
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700514INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
515ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900516
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200517ifdef TARGET_VENDOR_PROP
518vendor_prop_files := $(TARGET_VENDOR_PROP)
519else
520vendor_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/vendor.prop)
521endif
522
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900523ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900524FINAL_VENDOR_BUILD_PROPERTIES += \
525 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
526FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
527 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900528endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900529
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200530$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(intermediate_system_build_prop) $(vendor_prop_files)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700531 @echo Target vendor buildinfo: $@
532 @mkdir -p $(dir $@)
Luca Stefani033c7eb2020-03-27 12:26:12 +0000533 $(hide) rm -f $@ && touch $@
Hridya Valsaraju1fd498d2019-05-07 10:28:49 -0700534ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
535 $(hide) echo ro.boot.dynamic_partitions=true >> $@
536endif
537ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
538 $(hide) echo ro.boot.dynamic_partitions_retrofit=true >> $@
539endif
Sandeep Patil127f5012017-10-23 19:47:43 -0700540 $(hide) grep 'ro.product.first_api_level' $(intermediate_system_build_prop) >> $@ || true
Max Biresa1749982018-03-28 15:48:13 -0700541 $(hide) echo ro.vendor.build.security_patch="$(VENDOR_SECURITY_PATCH)">>$@
Isaac Chen8d11feb2018-01-31 14:27:37 +0800542 $(hide) echo ro.vendor.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
543 $(hide) echo ro.vendor.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
544 $(hide) echo ro.vendor.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Anton Hansson1f8729e2018-08-15 12:11:55 +0100545 $(hide) echo ro.product.board="$(TARGET_BOOTLOADER_BOARD_NAME)">>$@
546 $(hide) echo ro.board.platform="$(TARGET_BOARD_PLATFORM)">>$@
Stan Iliev144d26a2018-12-14 13:18:05 -0500547 $(hide) echo ro.hwui.use_vulkan="$(TARGET_USES_VULKAN)">>$@
Anton Hansson45a40da2019-01-18 14:06:34 +0000548ifdef TARGET_SCREEN_DENSITY
549 $(hide) echo ro.sf.lcd_density="$(TARGET_SCREEN_DENSITY)">>$@
550endif
Tao Bao67932ab2019-04-19 00:09:16 -0700551ifeq ($(AB_OTA_UPDATER),true)
552 $(hide) echo ro.build.ab_update=true >> $@
553endif
Anton Hansson1f8729e2018-08-15 12:11:55 +0100554 $(hide) $(call generate-common-build-props,vendor,$@)
Anton Hansson15794ca2019-04-08 17:47:35 +0100555 $(hide) echo "#" >> $@; \
556 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
557 echo "#" >> $@;
Anton Hanssonf2998892019-04-29 15:39:10 +0100558 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
559 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
560 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900561 $(hide) echo "#" >> $@; \
562 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
563 echo "#" >> $@;
Anton Hanssonc65ebaf2019-04-09 16:21:51 +0100564 $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@
565ifdef property_overrides_split_enabled
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200566 $(hide) $(foreach file,$(vendor_prop_files), \
567 if [ -f "$(file)" ]; then \
568 echo Target vendor properties from: "$(file)"; \
569 echo "" >> $@; \
570 echo "#" >> $@; \
571 echo "# from $(file)" >> $@; \
572 echo "#" >> $@; \
573 cat $(file) >> $@; \
574 echo "# end of $(file)" >> $@; \
575 fi;)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900576 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000577 echo "$(line)" >> $@;)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900578endif # property_overrides_split_enabled
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700579 $(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_VENDOR_PROPERTY_BLACKLIST)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700580
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900581# -----------------------------------------------------------------
582# product build.prop
583INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
584ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
585
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000586ifdef TARGET_PRODUCT_PROP
587product_prop_files := $(TARGET_PRODUCT_PROP)
588else
589product_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/product.prop)
590endif
591
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900592FINAL_PRODUCT_PROPERTIES += \
Yifan Hongaf9e7f02018-07-27 13:11:50 -0700593 $(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES) $(ADDITIONAL_PRODUCT_PROPERTIES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900594FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \
595 $(FINAL_PRODUCT_PROPERTIES),=)
596
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700597$(INSTALLED_PRODUCT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(product_prop_files)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900598 @echo Target product buildinfo: $@
599 @mkdir -p $(dir $@)
Luca Stefani033c7eb2020-03-27 12:26:12 +0000600 $(hide) rm -f $@ && touch $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900601ifdef BOARD_USES_PRODUCTIMAGE
Anton Hansson1f8729e2018-08-15 12:11:55 +0100602 $(hide) $(call generate-common-build-props,product,$@)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900603endif # BOARD_USES_PRODUCTIMAGE
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000604 $(hide) $(foreach file,$(product_prop_files), \
Anton Hansson6d814982018-11-26 18:12:05 +0000605 if [ -f "$(file)" ]; then \
606 echo Target product properties from: "$(file)"; \
607 echo "" >> $@; \
608 echo "#" >> $@; \
609 echo "# from $(file)" >> $@; \
610 echo "#" >> $@; \
611 cat $(file) >> $@; \
612 echo "# end of $(file)" >> $@; \
613 fi;)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900614 $(hide) echo "#" >> $@; \
615 echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \
Anton Hansson5ac408b2018-11-05 17:29:28 +0000616 echo "#" >> $@; \
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000617 echo "ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)" >> $@;
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900618 $(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000619 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700620 $(hide) $(POST_PROCESS_PROPS) $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900621
Andres Morales9c820f82015-01-13 15:30:34 -0800622# ----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800623# odm build.prop
Bowgo Tsai71a4d5c2019-05-17 23:21:48 +0800624INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/etc/build.prop
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800625ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_ODM_BUILD_PROP_TARGET)
626
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200627ifdef TARGET_ODM_PROP
628odm_prop_files := $(TARGET_ODM_PROP)
629else
630odm_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/odm.prop)
631endif
632
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800633FINAL_ODM_BUILD_PROPERTIES += \
634 $(call collapse-pairs, $(PRODUCT_ODM_PROPERTIES))
635FINAL_ODM_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
636 $(FINAL_ODM_BUILD_PROPERTIES),=)
637
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200638$(INSTALLED_ODM_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(odm_prop_files)
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800639 @echo Target odm buildinfo: $@
640 @mkdir -p $(dir $@)
Luca Stefani033c7eb2020-03-27 12:26:12 +0000641 $(hide) rm -f $@ && touch $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800642 $(hide) echo ro.odm.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
643 $(hide) echo ro.odm.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
644 $(hide) echo ro.odm.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Anton Hansson1f8729e2018-08-15 12:11:55 +0100645 $(hide) $(call generate-common-build-props,odm,$@)
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200646 $(hide) $(foreach file,$(odm_prop_files), \
647 if [ -f "$(file)" ]; then \
648 echo Target odm properties from: "$(file)"; \
649 echo "" >> $@; \
650 echo "#" >> $@; \
651 echo "# from $(file)" >> $@; \
652 echo "#" >> $@; \
653 cat $(file) >> $@; \
654 echo "# end of $(file)" >> $@; \
655 fi;)
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800656 $(hide) echo "#" >> $@; \
657 echo "# ADDITIONAL ODM BUILD PROPERTIES" >> $@; \
658 echo "#" >> $@;
659 $(hide) $(foreach line,$(FINAL_ODM_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000660 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700661 $(hide) $(POST_PROCESS_PROPS) $@
Andres Morales9c820f82015-01-13 15:30:34 -0800662
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700663# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +0900664# system_ext build.prop
665INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/build.prop
666ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Dario Freni5f681e12018-05-29 13:09:01 +0100667
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800668ifdef TARGET_SYSTEM_EXT_PROP
669system_ext_prop_files := $(TARGET_SYSTEM_EXT_PROP)
670else
671system_ext_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/system_ext.prop)
672endif
673
Justin Yun6151e3f2019-06-25 15:58:13 +0900674FINAL_SYSTEM_EXT_PROPERTIES += \
675 $(call collapse-pairs, $(PRODUCT_SYSTEM_EXT_PROPERTIES))
676FINAL_SYSTEM_EXT_PROPERTIES := $(call uniq-pairs-by-first-component, \
677 $(FINAL_SYSTEM_EXT_PROPERTIES),=)
678
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800679$(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(system_ext_prop_files)
Justin Yun6151e3f2019-06-25 15:58:13 +0900680 @echo Target system_ext buildinfo: $@
Dario Freni5f681e12018-05-29 13:09:01 +0100681 @mkdir -p $(dir $@)
Luca Stefani033c7eb2020-03-27 12:26:12 +0000682 $(hide) rm -f $@ && touch $@
Justin Yun6151e3f2019-06-25 15:58:13 +0900683 $(hide) $(call generate-common-build-props,system_ext,$@)
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800684 $(hide) $(foreach file,$(system_ext_prop_files), \
685 if [ -f "$(file)" ]; then \
686 echo Target system_ext properties from: "$(file)"; \
687 echo "" >> $@; \
688 echo "#" >> $@; \
689 echo "# from $(file)" >> $@; \
690 echo "#" >> $@; \
691 cat $(file) >> $@; \
692 echo "# end of $(file)" >> $@; \
693 fi;)
Dario Freni5f681e12018-05-29 13:09:01 +0100694 $(hide) echo "#" >> $@; \
Justin Yun6151e3f2019-06-25 15:58:13 +0900695 echo "# ADDITIONAL SYSTEM_EXT BUILD PROPERTIES" >> $@; \
Dario Freni5f681e12018-05-29 13:09:01 +0100696 echo "#" >> $@;
Justin Yun6151e3f2019-06-25 15:58:13 +0900697 $(hide) $(foreach line,$(FINAL_SYSTEM_EXT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000698 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700699 $(hide) $(POST_PROCESS_PROPS) $@
Dario Freni5f681e12018-05-29 13:09:01 +0100700
701# ----------------------------------------------------------------
702
703# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800704# sdk-build.prop
705#
706# There are certain things in build.prop that we don't want to
707# ship with the sdk; remove them.
708
709# This must be a list of entire property keys followed by
710# "=" characters, without any internal spaces.
711sdk_build_prop_remove := \
712 ro.build.user= \
713 ro.build.host= \
714 ro.product.brand= \
715 ro.product.manufacturer= \
716 ro.product.device=
717# TODO: Remove this soon-to-be obsolete property
718sdk_build_prop_remove += ro.build.product=
719INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
720$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
721 @echo SDK buildinfo: $@
722 @mkdir -p $(dir $@)
723 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000724 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800725 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000726 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727 $(hide) mv $@.tmp $@
728
729# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700730# kernel modules
731
732# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
733DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
734
735# $(1): modules list
736# $(2): output dir
737# $(3): mount point
738# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700739# $(5): module load list
740# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800741# $(7): module archive
Colin Cross4f60e362019-06-05 11:53:43 -0700742# Returns the a list of src:dest pairs to install the modules using copy-many-files.
743define build-image-kernel-modules
744 $(foreach module,$(1),$(module):$(2)/lib/modules/$(notdir $(module))) \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800745 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2))) \
Colin Cross4f60e362019-06-05 11:53:43 -0700746 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/modules.dep \
Steve Muckle474e4d02019-06-19 12:56:48 -0700747 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/modules.alias \
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700748 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/modules.softdep \
Steve Muckle474e4d02019-06-19 12:56:48 -0700749 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700750endef
751
752# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700753# $(2): mount point
754# $(3): staging dir
755# $(4): module load list
756# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800757# $(6): module archive
758# $(7): output dir
759# TODO(b/144844424): If a module archive is being used, this step (which
760# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
761# the output directory. This should be moved to a module with a
762# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
763# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700764define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700765$(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 -0700766$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
767$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
768$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
769$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules
770$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
771$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
772$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800773$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
774$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
775$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700776 @echo depmod $$(PRIVATE_STAGING_DIR)
777 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700778 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800779 $(if $(6),\
780 unzip -qo -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
781 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800782 cp -r $$(PRIVATE_MODULE_DIR) $$(PRIVATE_OUTPUT_DIR)/lib/; \
783 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
784 )
785 $(if $(1),\
786 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
787 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
788 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
789 done; \
790 )
Colin Cross4f60e362019-06-05 11:53:43 -0700791 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
792 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700793 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
794 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700795endef
796
Steve Muckle474e4d02019-06-19 12:56:48 -0700797# $(1): staging dir
798# $(2): module load list
799# $(3): module load list filename
800# $(4): output dir
801define module-load-list-copy-paths
802 $(eval $(call build-image-module-load-list,$(1),$(2),$(3))) \
803 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(3):$(4)/lib/modules/$(3)
804endef
805
806# $(1): staging dir
807# $(2): module load list
808# $(3): module load list filename
809define build-image-module-load-list
810$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_STAGING_DIR := $(1)
811$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_LOAD_MODULES := $(2)
812$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_LOAD_FILENAME := $(3)
813$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): $(2)
814 rm -f $$@
815 (for MODULE in $$(PRIVATE_LOAD_MODULES); do basename $$$$MODULE >> $$@; done)
816endef
817
Steve Mucklee1b10862019-07-10 10:49:37 -0700818ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
819 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
820 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700821 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700822 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
823endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700824
825ifeq ($(BOARD_RECOVERY_KERNEL_MODULES_LOAD),)
826 BOARD_RECOVERY_KERNEL_MODULES_LOAD := $(BOARD_RECOVERY_KERNEL_MODULES)
827endif
Steve Muckle69280d22019-07-11 12:23:38 -0700828ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
829 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700830endif
831
Steve Mucklee1b10862019-07-10 10:49:37 -0700832ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700833 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700834 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700835 endif
836endif
837
Steve Muckle810a0ba2019-11-13 13:29:02 -0800838ifneq ($(strip $(BOARD_RECOVERY_KERNEL_MODULES))$(strip $(BOARD_RECOVERY_KERNEL_MODULES_ARCHIVE)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700839 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700840 ifdef BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD
841 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_modules),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),modules.load,$(TARGET_RECOVERY_ROOT_OUT)))
Steve Muckle474e4d02019-06-19 12:56:48 -0700842 endif
843 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800844 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery),$(BOARD_RECOVERY_KERNEL_MODULES_LOAD),modules.load.recovery,$(BOARD_RECOVERY_KERNEL_MODULES_ARCHIVE)))
Steve Muckle474e4d02019-06-19 12:56:48 -0700845endif
846
Steve Muckle810a0ba2019-11-13 13:29:02 -0800847ifneq ($(strip $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES))$(strip $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_ARCHIVE)),)
Steve Mucklee1b10862019-07-10 10:49:37 -0700848 ifeq ($(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD),)
849 BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
850 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800851 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES),$(TARGET_VENDOR_RAMDISK_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD),modules.load,$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_ARCHIVE)))
Steve Mucklee1b10862019-07-10 10:49:37 -0700852endif
853
Steve Muckle474e4d02019-06-19 12:56:48 -0700854ifneq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Mucklee1b10862019-07-10 10:49:37 -0700855 ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800856 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES),$(TARGET_RAMDISK_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_ramdisk),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),modules.load,))
Steve Muckle474e4d02019-06-19 12:56:48 -0700857 endif
Colin Cross4f60e362019-06-05 11:53:43 -0700858endif
859
Steve Muckle810a0ba2019-11-13 13:29:02 -0800860ifneq ($(strip $(BOARD_VENDOR_KERNEL_MODULES)$(strip $(BOARD_VENDOR_KERNEL_MODULES_ARCHIVE))),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700861 ifeq ($(BOARD_VENDOR_KERNEL_MODULES_LOAD),)
862 BOARD_VENDOR_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_KERNEL_MODULES)
863 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800864 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_VENDOR_KERNEL_MODULES),$(TARGET_OUT_VENDOR),vendor,$(call intermediates-dir-for,PACKAGING,depmod_vendor),$(BOARD_VENDOR_KERNEL_MODULES_LOAD),modules.load,$(BOARD_VENDOR_KERNEL_MODULES_ARCHIVE)))
Colin Cross4f60e362019-06-05 11:53:43 -0700865endif
866
Steve Muckle810a0ba2019-11-13 13:29:02 -0800867ifneq ($(strip $(BOARD_ODM_KERNEL_MODULES))$(strip $(BOARD_ODM_KERNEL_MODULES_ARCHIVE)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700868 ifeq ($(BOARD_RECOVERY_KERNEL_MODULES_LOAD),)
869 BOARD_ODM_KERNEL_MODULES_LOAD := $(BOARD_ODM_KERNEL_MODULES)
870 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800871 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_ODM_KERNEL_MODULES),$(TARGET_OUT_ODM),odm,$(call intermediates-dir-for,PACKAGING,depmod_odm),$(BOARD_ODM_KERNEL_MODULES_LOAD),modules.load,$(BOARD_ODM_KERNEL_MODULES_ARCHIVE)))
Colin Cross4f60e362019-06-05 11:53:43 -0700872endif
873
874# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800875# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700876# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900877# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700878# $2 certificate
879# $3 private key
880# $4 compressed
881# $5 partition tag
882# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100883define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700884$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
885$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
886$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
887$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700888
889endef
890
The Android Open Source Project88b60792009-03-03 19:28:42 -0800891name := $(TARGET_PRODUCT)
892ifeq ($(TARGET_BUILD_TYPE),debug)
893 name := $(name)_debug
894endif
895name := $(name)-apkcerts-$(FILE_NAME_TAG)
896intermediates := \
897 $(call intermediates-dir-for,PACKAGING,apkcerts)
898APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800899# We don't need to really build all the modules.
900# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700901$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902 @echo APK certs list: $@
903 @mkdir -p $(dir $@)
904 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700905 $(foreach p,$(sort $(PACKAGES)),\
Ying Wangd9a88d52012-10-26 09:21:28 -0700906 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jiyong Park7b96c592020-05-01 10:29:09 +0900907 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
908 $(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 -0700909 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700910 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800911
912.PHONY: apkcerts-list
913apkcerts-list: $(APKCERTS_FILE)
914
Ying Wang15e487a2011-02-15 10:56:18 -0800915ifneq (,$(TARGET_BUILD_APPS))
916 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900917 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800918endif
Ying Wangefb21682010-07-23 16:42:13 -0700919
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900920
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700922# build system stats
923BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
924$(BUILD_SYSTEM_STATS):
925 @rm -f $@
926 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
927 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
928$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700929
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700930# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800931# build /product/etc/security/avb/system_other.avbpubkey if needed
932ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800933ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800934INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
935ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800936endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800937endif # BUILDING_SYSTEM_OTHER_IMAGE
938
939# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700940# Modules ready to be converted to Soong, ordered by how many
941# modules depend on them.
942SOONG_CONV := $(sort $(SOONG_CONV))
943SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
944$(SOONG_CONV_DATA):
945 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800946 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS)))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700947
Colin Crossfdea8932017-12-06 14:38:40 -0800948SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700949SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
950$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
951 @rm -f $@
952 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
953$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
954
955# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800956# Modules use -Wno-error, or added default -Wall -Werror
957WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
958$(WALL_WERROR):
959 @rm -f $@
960 echo "# Modules using -Wno-error" >> $@
961 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 -0800962 echo "# Modules added default -Wall" >> $@
963 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
964
965$(call dist-for-goals,droidcore,$(WALL_WERROR))
966
967# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700968# C/C++ flag information for modules
969$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
970
971# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800972# Modules missing profile files
973PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
974$(PGO_PROFILE_MISSING):
975 @rm -f $@
976 echo "# Modules missing PGO profile files" >> $@
977 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
978
979$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
980
981# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700982# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700983# for future OTA packages installed by this system. Actual product
984# deliverables will be re-signed by hand. We expect this file to
985# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700986DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700987
988
Jeff Browne33ba4c2011-07-11 22:11:46 -0700989# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800990# if they don't do anything.
991.PHONY: systemimage
992systemimage:
993
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800994# -----------------------------------------------------------------
995
996.PHONY: event-log-tags
997
Joe Onoratob7510532010-07-14 10:22:54 -0700998# Produce an event logs tag file for everything we know about, in order
999# to properly allocate numbers. Then produce a file that's filtered
1000# for what's going to be installed.
1001
1002all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
1003
Colin Crossdc8f8e42012-04-12 13:25:54 -07001004event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
1005
Joe Onoratob7510532010-07-14 10:22:54 -07001006# Include tags from all packages that we know about
1007all_event_log_tags_src := \
1008 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
1009
Colin Crossdc8f8e42012-04-12 13:25:54 -07001010# PDK builds will already have a full list of tags that needs to get merged
1011# in with the ones from source
1012pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
1013
1014$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -08001015$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -07001016 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +09001017 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -07001018
Doug Zongkera34fa952011-02-23 12:17:29 -08001019# Include tags from all packages included in this product, plus all
1020# tags that are part of the system (ie, not in a vendor/ or device/
1021# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001022event_log_tags_src := \
1023 $(sort $(foreach m,\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001024 $(PRODUCT_PACKAGES) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001025 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -08001026 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
1027 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001028
Colin Crossdc8f8e42012-04-12 13:25:54 -07001029$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -07001030$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -08001031$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001032 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +09001033 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001034
1035event-log-tags: $(event_log_tags_file)
1036
1037ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
1038
Joe Onoratob7510532010-07-14 10:22:54 -07001039
The Android Open Source Project88b60792009-03-03 19:28:42 -08001040# #################################################################
1041# Targets for boot/OS images
1042# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -08001043ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
1044 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
1045 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
1046 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
1047 else
1048 INSTALLED_2NDBOOTLOADER_TARGET :=
1049 endif
1050else
1051 INSTALLED_BOOTLOADER_MODULE :=
1052 INSTALLED_2NDBOOTLOADER_TARGET :=
1053endif # TARGET_NO_BOOTLOADER
1054ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07001055 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
1056 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
1057 $(PRODUCT_OUT)/$(k))
1058 else
1059 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
1060 endif
Ying Wangc6349742014-01-13 16:14:20 -08001061else
1062 INSTALLED_KERNEL_TARGET :=
1063endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001064
1065# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -07001066# the root dir
1067INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001068 $(ALL_GENERATED_SOURCES) \
1069 $(ALL_DEFAULT_INSTALLED_MODULES))
1070
Luis Hector Chavezff489932018-07-03 15:41:40 -07001071INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
1072INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
1073$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001074$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -07001075 @echo Installed file list: $@
1076 @mkdir -p $(dir $@)
1077 @rm -f $@
1078 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001079 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -07001080
1081$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
1082
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001083#------------------------------------------------------------------
1084# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001085ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001086INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001087ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -08001088$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001089 cat $^ > $@
1090endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001091endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001092
Tom Cherryd14b8952018-08-09 14:26:00 -07001093# -----------------------------------------------------------------
1094# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -08001095ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -07001096INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
1097 $(ALL_GENERATED_SOURCES) \
1098 $(ALL_DEFAULT_INSTALLED_MODULES))
1099
1100INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
1101INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
1102$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001103$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -07001104 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +08001105 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -07001106 @mkdir -p $(dir $@)
1107 @rm -f $@
1108 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001109 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -07001110
1111$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -07001112BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
1113
1114# We just build this directly to the install location.
1115INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Tom Cherryd14b8952018-08-09 14:26:00 -07001116$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001117 $(call pretty,"Target ram disk: $@")
Tom Cherryd14b8952018-08-09 14:26:00 -07001118 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001119
Ying Wangad7fd292013-08-08 16:34:29 -07001120.PHONY: ramdisk-nodeps
1121ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
1122 @echo "make $@: ignoring dependencies"
Tom Cherryd14b8952018-08-09 14:26:00 -07001123 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001124
Dan Willemsen67495202019-01-16 12:42:05 -08001125endif # BUILDING_RAMDISK_IMAGE
1126
The Android Open Source Project88b60792009-03-03 19:28:42 -08001127# -----------------------------------------------------------------
1128# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -07001129
1130# This is defined here since we may be building recovery as boot
1131# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -07001132ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
1133 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
1134else
1135 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
1136endif
1137
Chris Grossa784ef12019-04-22 11:09:57 -07001138
1139ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001140INTERNAL_BOOTIMAGE_ARGS := \
1141 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001142 --kernel $(INSTALLED_KERNEL_TARGET)
1143
1144ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1145INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
1146endif
1147
Steve Mucklee1b10862019-07-10 10:49:37 -07001148ifndef BUILDING_VENDOR_BOOT_IMAGE
1149ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1150 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1151endif
1152endif
1153
The Android Open Source Project88b60792009-03-03 19:28:42 -08001154INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
1155
Anton Hansson8dab0a62019-03-28 15:45:40 +00001156ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001157ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001158VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001159 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
1160endif
1161endif
1162
Anton Hansson72e36f02019-02-26 17:36:30 +00001163INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -07001164
1165ifndef BUILDING_VENDOR_BOOT_IMAGE
1166ifdef BOARD_KERNEL_BASE
1167 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1168endif
1169ifdef BOARD_KERNEL_PAGESIZE
1170 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1171endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001172ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07001173 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1174endif
1175else
1176# building vendor boot image, dtb/base/pagesize go there
1177ifdef GENERIC_KERNEL_CMDLINE
1178 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1179endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001180endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001181
Sami Tolvanen3303d902016-03-15 16:49:30 +00001182INTERNAL_MKBOOTIMG_VERSION_ARGS := \
1183 --os_version $(PLATFORM_VERSION) \
1184 --os_patch_level $(PLATFORM_SECURITY_PATCH)
1185
Chris Grossa784ef12019-04-22 11:09:57 -07001186# Define these only if we are building boot
1187ifdef BUILDING_BOOT_IMAGE
1188INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1189
The Android Open Source Project88b60792009-03-03 19:28:42 -08001190ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001191$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -04001192
1193else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
1194
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001195$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -04001196 $(call pretty,"Target boot image: $@")
1197 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001198 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001199 $(hide) $(AVBTOOL) add_hash_footer \
1200 --image $@ \
1201 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001202 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001203 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1204
1205.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001206bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -04001207 @echo "make $@: ignoring dependencies"
1208 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001209 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001210 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001211 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001212 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001213 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001214 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1215
Anton Hansson8dab0a62019-03-28 15:45:40 +00001216else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -07001217
1218$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
1219 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001220 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Anton Hansson8dab0a62019-03-28 15:45:40 +00001221 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -07001222 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1223
1224.PHONY: bootimage-nodeps
1225bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
1226 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001227 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001228 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET)
Geremy Condra740b6632014-07-08 20:07:41 -07001229 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1230
Anton Hansson8dab0a62019-03-28 15:45:40 +00001231else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -08001232
Tao Bao4b577412017-02-22 22:54:39 -08001233$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001234 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001235 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +00001236 $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@
David Riley17be3d32015-03-03 08:54:11 -08001237 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1238
1239.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001240bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001241 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001242 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +00001243 $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
David Riley17be3d32015-03-03 08:54:11 -08001244 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1245
1246else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001247
1248$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
1249 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001250 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001251 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -07001252
1253.PHONY: bootimage-nodeps
1254bootimage-nodeps: $(MKBOOTIMG)
1255 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001256 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001257 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -07001258
The Android Open Source Project88b60792009-03-03 19:28:42 -08001259endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -07001260endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001261
Tao Baob1a2e352018-08-14 16:17:12 -07001262else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001263ifdef BOARD_PREBUILT_BOOTIMAGE
1264ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1265# Remove when b/63676296 is resolved.
1266$(error Prebuilt bootimage is only supported for AB targets)
1267endif
Kiyoung Kim62e22312019-06-20 14:27:45 +09001268INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001269$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -07001270else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -07001271INSTALLED_BOOTIMAGE_TARGET :=
1272endif # BOARD_PREBUILT_BOOTIMAGE
1273endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -08001274
1275# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001276# vendor boot image
1277ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1278
1279ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1280 $(error vboot 1.0 does not support vendor_boot partition)
1281endif
1282
1283INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
1284 $(ALL_GENERATED_SOURCES) \
1285 $(ALL_DEFAULT_INSTALLED_MODULES))
1286
1287INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio.gz
1288$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(MINIGZIP)
1289 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(MINIGZIP) > $@
1290
1291ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1292 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1293endif
1294ifdef BOARD_KERNEL_BASE
1295 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1296endif
1297ifdef BOARD_KERNEL_PAGESIZE
1298 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1299endif
1300ifdef INTERNAL_KERNEL_CMDLINE
1301 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1302endif
1303
1304INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1305$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
1306ifeq ($(BOARD_AVB_ENABLE),true)
1307$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1308 $(call pretty,"Target vendor_boot image: $@")
1309 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
1310 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1311 $(AVBTOOL) add_hash_footer \
1312 --image $@ \
1313 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
1314 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1315 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1316else
1317$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1318 $(call pretty,"Target vendor_boot image: $@")
1319 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
1320 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1321endif
1322endif # BUILDING_VENDOR_BOOT_IMAGE
1323
1324# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001325# NOTICE files
1326#
Steve Blockd14d3b42012-03-01 11:34:41 +00001327# We are required to publish the licenses for all code under BSD, GPL and
1328# Apache licenses (and possibly other more exotic ones as well). We err on the
1329# side of caution, so the licenses for other third-party code are included here
1330# too.
1331#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001332# This needs to be before the systemimage rules, because it adds to
1333# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1334# go into the systemimage.
1335
Steve Block495e5852012-02-29 19:18:08 +00001336.PHONY: notice_files
1337
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001338# Create the rule to combine the files into text and html/xml forms
Chris Grossaad39b32019-06-13 09:43:26 -07001339# $(1) - xml_excluded_system_product_odm|xml_excluded_vendor_product_odm
1340# xml_product|xml_odm|xml_system_ext|xml_system|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001341# $(2) - Plain text output file
1342# $(3) - HTML/XML output file
1343# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001344# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001345# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001346# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -08001347# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -08001348#
1349# The algorithm here is that we go collect a hash for each of the notice
1350# files and write the names of the files that match that hash. Then
1351# to generate the real files, we go print out all of the files and their
1352# hashes.
1353#
1354# These rules are fairly complex, so they depend on this makefile so if
1355# it changes, they'll run again.
1356#
1357# TODO: We could clean this up so that we just record the locations of the
1358# original notice files instead of making rules to copy them somwehere.
1359# Then we could traverse that without quite as much bash drama.
1360define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -07001361$(2): PRIVATE_MESSAGE := $(4)
1362$(2): PRIVATE_DIR := $(5)
1363$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
1364$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -08001365 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Chris Grossaad39b32019-06-13 09:43:26 -07001366 $(if $(filter $(1),xml_excluded_vendor_product_odm),-e vendor -e product -e system_ext -e odm --xml-output, \
1367 $(if $(filter $(1),xml_excluded_system_product_odm),-e system -e product -e system_ext -e odm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +00001368 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001369 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001370 $(if $(filter $(1),xml_system),-i system --xml-output, \
1371 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
1372 --html-output)))))) $(3) \
Anton Hansson6d814982018-11-26 18:12:05 +00001373 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001374notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001375endef
1376
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001377# Notice file logic isn't relevant for TARGET_BUILD_APPS
1378ifndef TARGET_BUILD_APPS
1379
The Android Open Source Project88b60792009-03-03 19:28:42 -08001380# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1381# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1382# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001383target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001384tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001385tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001386kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1387winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
1388pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001389
Bob Badour4b25c902020-01-28 13:23:39 -08001390# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1391# reasons--not to be flashed onto any device. Targets under these directories
1392# need no associated notice file on the device UI.
1393exclude_target_dirs := apex
1394
Steven Morelandae69e572017-12-15 14:49:55 -08001395# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001396ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1397target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1398target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1399installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1400$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001401 $(target_notice_file_txt), \
1402 $(target_notice_file_html), \
1403 "Notices for files contained in the filesystem images in this directory:", \
1404 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001405 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files), \
1406 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001407$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1408 $(hide) $(MINIGZIP) -9 < $< > $@
1409$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1410 $(copy-file-to-target)
1411else
1412target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1413target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001414installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1415
1416target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1417target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1418target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1419installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001420
1421target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1422target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1423target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1424installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001425
Justin Yun6151e3f2019-06-25 15:58:13 +09001426target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1427target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1428target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1429installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001430
Chris Gross15d96552019-07-16 14:38:43 -07001431target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1432target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1433target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1434installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1435
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001436# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1437# being built. A notice xml file must depend on all modules that could potentially
1438# install a license file relevant to it.
1439license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)
Bob Badour4b25c902020-01-28 13:23:39 -08001440# Only files copied to a system image need system image notices.
1441license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001442# Phonys/fakes don't have notice files (though their deps might)
1443license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001444# testcases are not relevant to the system image.
1445license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001446# filesystem images: system, vendor, product, system_ext, and odm
Chris Grossaad39b32019-06-13 09:43:26 -07001447license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001448license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1449license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001450license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001451license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001452license_modules_agg := $(license_modules_system) \
1453 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001454 $(license_modules_product) \
1455 $(license_modules_system_ext) \
1456 $(license_modules_odm)
Bob Badour4b25c902020-01-28 13:23:39 -08001457# targets used for debug symbols only and do not get copied to the device
1458license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1459
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001460license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001461license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1462
1463# Identify the other targets we expect to have notices for:
1464# targets copied to the device but are not readable by the UI (e.g. must boot
1465# into a different partition to read or don't have an associated /etc
1466# directory) must have their notices built somewhere readable.
1467license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1468license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1469license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1470license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1471license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1472license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1473license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1474license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1475license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1476license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1477license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1478license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1479license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1480
1481# after removing targets in system images, targets reported in system images, and
1482# targets used for debug symbols that do not need notices, nothing must remain.
1483license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1484$(call maybe-print-list-and-error, $(license_modules_rest), \
1485 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001486
Chris Grossaad39b32019-06-13 09:43:26 -07001487# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1488# update its notice file, so include those notices in the system partition instead
1489ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001490license_modules_system += $(license_modules_rehomed)
Chris Grossaad39b32019-06-13 09:43:26 -07001491system_xml_directories := xml_excluded_vendor_product_odm
1492system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001493else
Bob Badour4b25c902020-01-28 13:23:39 -08001494license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001495system_xml_directories := xml_system
1496system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001497endif
1498
1499$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001500 $(target_notice_file_txt), \
1501 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001502 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001503 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001504 $(license_modules_system), \
1505 $(exclude_target_dirs)))
Chris Grossaad39b32019-06-13 09:43:26 -07001506$(eval $(call combine-notice-files, xml_excluded_system_product_odm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001507 $(target_vendor_notice_file_txt), \
1508 $(target_vendor_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001509 "Notices for files contained in all filesystem images except system/system_ext/product/odm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001510 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001511 $(license_modules_vendor), \
1512 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001513$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001514 $(target_product_notice_file_txt), \
1515 $(target_product_notice_file_xml), \
1516 "Notices for files contained in the product filesystem image in this directory:", \
1517 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001518 $(license_modules_product), \
1519 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001520$(eval $(call combine-notice-files, xml_system_ext, \
1521 $(target_system_ext_notice_file_txt), \
1522 $(target_system_ext_notice_file_xml), \
1523 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001524 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001525 $(license_modules_system_ext), \
1526 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001527$(eval $(call combine-notice-files, xml_odm, \
1528 $(target_odm_notice_file_txt), \
1529 $(target_odm_notice_file_xml), \
1530 "Notices for files contained in the odm filesystem image in this directory:", \
1531 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001532 $(license_modules_odm), \
1533 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001534
1535$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1536 $(hide) $(MINIGZIP) -9 < $< > $@
1537$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1538 $(hide) $(MINIGZIP) -9 < $< > $@
1539$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1540 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001541$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001542 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001543$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1544 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001545$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1546 $(copy-file-to-target)
1547$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1548 $(copy-file-to-target)
1549$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1550 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001551$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001552 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001553$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1554 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001555
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001556ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1557ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1558ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1559ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1560ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001561endif # PRODUCT_NOTICE_SPLIT
1562
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001563ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001564
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001565$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001566 $(tools_notice_file_txt), \
1567 $(tools_notice_file_html), \
1568 "Notices for files contained in the tools directory:", \
1569 $(HOST_OUT_NOTICE_FILES), \
1570 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001571 $(winpthreads_notice_file), \
1572 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001573
Ying Wang62c81f82013-08-22 20:02:03 -07001574endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001575
1576# The kernel isn't really a module, so to get its module file in there, we
1577# make the target NOTICE files depend on this particular file too, which will
1578# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001579$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001580
Dan Willemsen288bedf2019-05-28 15:36:47 -07001581$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001582
Doug Zongker8678df42009-06-15 14:30:14 -07001583
The Android Open Source Project88b60792009-03-03 19:28:42 -08001584# #################################################################
1585# Targets for user images
1586# #################################################################
1587
Ying Wang933abf12010-06-16 14:31:34 -07001588INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001589ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001590INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1591else
1592ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001593INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1594else
1595ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001596INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1597endif
1598endif
1599endif
1600
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001601# These options tell the recovery updater/installer how to mount the partitions writebale.
1602# <fstype>=<fstype_opts>[|<fstype_opts>]...
1603# fstype_opts := <opt>[,<opt>]...
1604# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001605# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1606DEFAULT_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 -07001607
Ying Wang542903a2010-11-17 15:40:38 -08001608ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1609 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1610endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001611ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1612 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1613endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001614ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1615 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1616endif
Tao Baodba635a2019-06-24 10:39:54 -07001617
1618INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001619 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001620 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001621 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001622
1623ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1624INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001625endif
1626
Justin Yun6151e3f2019-06-25 15:58:13 +09001627ifneq ($(filter $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001628INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1629endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001630
Anton Hansson8dab0a62019-03-28 15:45:40 +00001631ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001632INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001633ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001634INTERNAL_USERIMAGES_DEPS += $(FEC)
1635endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001636endif
1637
Tao Baodba635a2019-06-24 10:39:54 -07001638ifeq ($(BOARD_AVB_ENABLE),true)
1639INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1640endif
1641
1642# Get a colon-separated list of search paths.
1643INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1644
Alex Klyubin092c9022017-03-13 13:28:34 -07001645SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001646INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1647
Yifan Hongc5c01242018-11-09 10:27:23 -08001648ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001649
Anton Hansson8dab0a62019-03-28 15:45:40 +00001650ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001651 $(error vboot 1.0 doesn't support logical partition)
1652endif
1653
Yifan Hongc5c01242018-11-09 10:27:23 -08001654endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001655
Ying Wangbd93d422011-10-28 17:02:30 -07001656# $(1): the path of the output dictionary file
Justin Yun6151e3f2019-06-25 15:58:13 +09001657# $(2): a subset of "system vendor cache userdata product system_ext oem odm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001658# $(3): additional "key=value" pairs to append to the dictionary file.
1659define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001660$(if $(filter $(2),system),\
1661 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001662 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001663 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1664 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1665 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1666 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1667 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1668 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1669 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1670 $(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 +00001671 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1672 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001673 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001674 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001675)
Yifan Hong760d3c02018-05-30 11:16:46 -07001676$(if $(filter $(2),userdata),\
1677 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1678 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001679 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1680 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001681 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001682)
Yifan Hong760d3c02018-05-30 11:16:46 -07001683$(if $(filter $(2),cache),\
1684 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1685 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001686 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001687)
1688$(if $(filter $(2),vendor),\
1689 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1690 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1691 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1692 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1693 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1694 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1695 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1696 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1697 $(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 +00001698 $(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 -07001699 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001700 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001701)
1702$(if $(filter $(2),product),\
1703 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1704 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1705 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1706 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1707 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1708 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1709 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1710 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1711 $(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 +00001712 $(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 -07001713 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001714 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001715)
Justin Yun6151e3f2019-06-25 15:58:13 +09001716$(if $(filter $(2),system_ext),\
1717 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1718 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1719 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1720 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1721 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1722 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1723 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1724 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1725 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1726 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1727 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001728)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001729$(if $(filter $(2),odm),\
1730 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1731 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1732 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1733 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1734 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1735 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1736 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1737 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1738 $(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 +00001739 $(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 +08001740 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001741 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001742)
Yifan Hong760d3c02018-05-30 11:16:46 -07001743$(if $(filter $(2),oem),\
1744 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1745 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1746 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1747 $(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 -07001748 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001749)
Tao Bao3602eca2018-07-10 10:53:55 -07001750$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001751
Tao Bao3602eca2018-07-10 10:53:55 -07001752$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001753$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001754$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001755$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001756$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1757$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1758$(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 +00001759$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1760$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1761$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1762$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1763$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001764$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001765$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1766$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1767$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001768$(if $(PRODUCT_SYSTEM_EXT_VERITY_PARTITION),$(hide) echo "system_ext_verity_block_device=$(PRODUCT_SYSTEM_EXT_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001769$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1770$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1771$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1772$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1773$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001774$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001775$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1776$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1777$(if $(BOARD_AVB_ENABLE),\
1778 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1779 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1780 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1781 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001782$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1783$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1784$(if $(BOARD_AVB_ENABLE),\
1785 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1786 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001787 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001788$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1789$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1790$(if $(BOARD_AVB_ENABLE),\
1791 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1792 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1793 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1794 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001795$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1796$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1797$(if $(BOARD_AVB_ENABLE),\
1798 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1799 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1800 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1801 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001802$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001803$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001804 $(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 +01001805$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001806 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1807 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1808 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1809 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001810$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1811$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1812$(if $(BOARD_AVB_ENABLE),\
1813 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1814 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1815 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1816 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001817$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1818 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001819$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001820 $(hide) echo "system_root_image=true" >> $(1))
1821$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001822$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1823 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001824$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1825endef
1826
1827# $(1): the path of the output dictionary file
1828# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001829PROP_DICTIONARY_IMAGES := oem
1830ifdef BUILDING_CACHE_IMAGE
1831 PROP_DICTIONARY_IMAGES += cache
1832endif
1833ifdef BUILDING_SYSTEM_IMAGE
1834 PROP_DICTIONARY_IMAGES += system
1835endif
1836ifdef BUILDING_USERDATA_IMAGE
1837 PROP_DICTIONARY_IMAGES += userdata
1838endif
1839ifdef BUILDING_VENDOR_IMAGE
1840 PROP_DICTIONARY_IMAGES += vendor
1841endif
1842ifdef BUILDING_PRODUCT_IMAGE
1843 PROP_DICTIONARY_IMAGES += product
1844endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001845ifdef BUILDING_SYSTEM_EXT_IMAGE
1846 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001847endif
1848ifdef BUILDING_ODM_IMAGE
1849 PROP_DICTIONARY_IMAGES += odm
1850endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001851define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001852 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001853endef
1854
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001855# $(1): the path of the input dictionary file, where each line has the format key=value
1856# $(2): the key to look up
1857define read-image-prop-dictionary
1858$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1859endef
1860
The Android Open Source Project88b60792009-03-03 19:28:42 -08001861# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001862# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001863
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001864# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001865ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001866
Ying Wang37526142015-03-10 12:02:57 -07001867INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1868 $(ALL_DEFAULT_INSTALLED_MODULES))
1869
Tao Bao10fc9492018-08-14 12:17:48 -07001870INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1871INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1872
1873# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1874# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1875# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1876# the call to FILELIST.
1877ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001878INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001879$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1880else
1881$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1882endif
1883
1884$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001885$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001886 @echo Installed file list: $@
1887 @mkdir -p $(dir $@)
1888 @rm -f $@
1889 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001890 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001891
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001892recovery_sepolicy := \
1893 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001894 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001895 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001896 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1897 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1898 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001899 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001900 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001901 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1902 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1903 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001904
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001905# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1906# SELinux files
1907IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1908
Doug Zongker4647f122009-07-02 09:00:54 -07001909recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1910recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Doug Zongker4647f122009-07-02 09:00:54 -07001911recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001912
Anton Hansson45a40da2019-01-18 14:06:34 +00001913# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1914# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1915# which get remapped to a bucket.
1916recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001917ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1918recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001919# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001920# ------160------240------320----------480------------640------
1921# mdpi hdpi xhdpi xxhdpi xxxhdpi
1922recovery_density := $(strip \
1923 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1924 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1925 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1926 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001927endif
1928
1929ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1930recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1931else
Doug Zongker25d55f82014-04-04 13:51:15 -07001932recovery_resources_common := $(recovery_resources_common)-xhdpi
1933endif
1934
Tao Baoe1e829e2018-08-29 20:36:00 -07001935# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1936# Note that the font selected here can be overridden for a particular device by putting a font.png
1937# in its private recovery resources.
1938ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001939recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1940else
1941recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1942endif
1943
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001944
1945# We will only generate the recovery background text images if the variable
1946# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1947# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1948# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1949# BoardConfig in order to use this feature.
1950ifeq ($(recovery_density),xxxhdpi)
1951TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1952else ifeq ($(recovery_density),xxhdpi)
1953TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1954endif
1955
1956ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1957# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1958ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1959 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1960else
1961 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1962endif
1963
1964
1965RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,PACKAGING,recovery_text_res)/installing_text.png
1966RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1967RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1968RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1969RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1970
xunchangcc57d312018-12-07 12:12:17 -08001971RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1972RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1973RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1974RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1975RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1976
1977generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001978 $(RECOVERY_INSTALLING_TEXT_FILE) \
1979 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1980 $(RECOVERY_ERASING_TEXT_FILE) \
1981 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001982 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1983 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1984 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1985 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1986 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1987 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001988
1989resource_dir := $(call include-path-for, recovery)/tools/recovery_l10n/res/
1990image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001991zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001992$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
1993$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,PACKAGING,recovery_font_files)
1994$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1995$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001996$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001997$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001998$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001999 recovery_installing \
2000 recovery_installing_security \
2001 recovery_erasing \
2002 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002003 recovery_no_command
2004$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002005 recovery_cancel_wipe_data \
2006 recovery_factory_data_reset \
2007 recovery_try_again \
2008 recovery_wipe_data_menu_header \
2009 recovery_wipe_data_confirmation
2010$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
2011$(RECOVERY_INSTALLING_TEXT_FILE): $(image_generator_jar) $(resource_dir) $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep) $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002012 # Prepares the font directory.
2013 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2014 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002015 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002016 @rm -rf $(dir $@)
2017 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002018 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002019 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002020 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002021 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2022 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2023 --text_name $(text_name) \
2024 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2025 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002026 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002027 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002028else
2029RECOVERY_INSTALLING_TEXT_FILE :=
2030RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2031RECOVERY_ERASING_TEXT_FILE :=
2032RECOVERY_ERROR_TEXT_FILE :=
2033RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002034RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2035RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2036RECOVERY_TRY_AGAIN_TEXT_FILE :=
2037RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2038RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002039endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2040
Ying Wang9a175682015-08-06 11:47:47 -07002041ifndef TARGET_PRIVATE_RES_DIRS
2042TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2043endif
Doug Zongker4647f122009-07-02 09:00:54 -07002044recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002045 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002046recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002047
2048
Andrew Boiefa61ff02012-09-28 09:33:45 -07002049ifdef TARGET_RECOVERY_FSTAB
2050recovery_fstab := $(TARGET_RECOVERY_FSTAB)
2051else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002052recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002053endif
Tao Baoc3c17532016-06-10 10:11:54 -07002054ifdef TARGET_RECOVERY_WIPE
2055recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002056else
Tao Baoc3c17532016-06-10 10:11:54 -07002057recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002058endif
Tao Bao8beab692015-07-22 12:33:18 -07002059
Tao Bao6d5d6232018-03-09 17:04:42 -08002060# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002061# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002062# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2063# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002064#
2065# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002066# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002067# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002068# b) We build a single image that contains boot and recovery both - no recovery image to install
2069# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07002070# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08002071# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002072# d) We include the recovery DTBO image within recovery - not needing the resource file as we
2073# do bsdiff because boot and recovery will contain different number of entries
2074# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002075# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
2076# do bsdiff because boot and recovery will contain different number of entries
2077# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002078
Tom Cherry2929cad2018-09-20 11:04:37 -07002079ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002080 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07002081# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002082RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2083ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002084else
Tao Bao8beab692015-07-22 12:33:18 -07002085RECOVERY_RESOURCE_ZIP :=
2086endif
Doug Zongker4647f122009-07-02 09:00:54 -07002087
Tao Bao139c7272018-07-31 13:26:54 -07002088INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2089
2090$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002091 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2092 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2093 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2094 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2095 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2096 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2097 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2098 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2099
2100# Parses the given list of build variables and writes their values as build properties if defined.
2101# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2102# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2103# $(1): Map from the build variable names to property names
2104# $(2): Output file
2105define append-recovery-ui-properties
2106echo "#" >> $(2)
2107echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2108echo "#" >> $(2)
2109$(foreach prop,$(1), \
2110 $(eval _varname := $(call word-colon,1,$(prop))) \
2111 $(eval _propname := $(call word-colon,2,$(prop))) \
2112 $(eval _value := $($(_varname))) \
2113 $(if $(_value), \
2114 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2115endef
2116
2117$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00002118 $(INSTALLED_DEFAULT_PROP_TARGET) \
2119 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
2120 $(intermediate_system_build_prop) \
2121 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2122 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2123 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002124 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002125 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002126 $(hide) mkdir -p $(dir $@)
2127 $(hide) rm -f $@
2128 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) > $@
2129 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) >> $@
Tao Bao6eb1a992018-08-06 07:33:45 -07002130 $(hide) cat $(intermediate_system_build_prop) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002131 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002132 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002133 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002134 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002135 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2136
Steve Mucklef84668e2020-03-16 19:13:46 -07002137ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07002138 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07002139ifdef GENERIC_KERNEL_CMDLINE
2140 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
2141endif
Steve Mucklef84668e2020-03-16 19:13:46 -07002142else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07002143 INTERNAL_RECOVERYIMAGE_ARGS := \
2144 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002145 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07002146# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002147ifdef INTERNAL_KERNEL_CMDLINE
2148 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07002149endif
2150ifdef BOARD_KERNEL_BASE
2151 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2152endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002153ifdef BOARD_KERNEL_PAGESIZE
2154 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2155endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002156ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002157ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2158 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2159else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002160 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2161endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002162endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002163ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2164 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2165endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002166ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2167 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2168endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002169endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07002170ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2171 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2172endif
Doug Zongker4647f122009-07-02 09:00:54 -07002173
Steve Muckleb3dda772020-03-11 16:03:07 -07002174$(recovery_ramdisk): $(MKBOOTFS) $(MINIGZIP) \
2175 $(INTERNAL_ROOT_FILES) \
2176 $(INSTALLED_RAMDISK_TARGET) \
2177 $(INTERNAL_RECOVERYIMAGE_FILES) \
2178 $(recovery_sepolicy) \
2179 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2180 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2181 $(recovery_resource_deps) \
2182 $(recovery_fstab)
2183 # Making recovery image
2184 mkdir -p $(TARGET_RECOVERY_OUT)
2185 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2186 # Copying baseline ramdisk...
2187 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2188 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2189 # Modifying ramdisk contents...
2190 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2191 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
2192 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2193 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2194 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2195 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2196 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2197 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2198 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2199 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2200 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2201 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2202 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2203 $(foreach item,$(recovery_fstab), \
2204 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2205 $(if $(strip $(recovery_wipe)), \
2206 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2207 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2208 $(BOARD_RECOVERY_IMAGE_PREPARE)
2209 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
2210
Ying Wang747b9f12015-01-30 14:05:22 -08002211# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07002212# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002213define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002214 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07002215 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002216 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002217 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07002218 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002219 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002220 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002221 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002222 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002223 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2224 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002225 )\
2226 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002227 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2228 $(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 +08002229 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002230 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
2231 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002232 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2233 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002234 $(AVBTOOL) add_hash_footer --image $(1) --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS),\
2235 $(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 -08002236endef
2237
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002238ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002239ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Ying Wangbd07ad02016-03-10 12:57:33 -08002240$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
2241endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002242ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Ying Wangbd07ad02016-03-10 12:57:33 -08002243$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
2244endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002245ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002246$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002247endif
Tao Baof4866c72018-08-22 14:35:09 -07002248ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002249ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2250$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2251else
Tao Baof4866c72018-08-22 14:35:09 -07002252$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2253endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002254endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002255ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2256$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2257endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002258ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2259$(INSTALLED_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2260endif
Tao Baof4866c72018-08-22 14:35:09 -07002261
Steve Muckleb3dda772020-03-11 16:03:07 -07002262$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(recovery_ramdisk) \
2263 $(recovery_kernel)
Tao Baof4866c72018-08-22 14:35:09 -07002264 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002265 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07002266endif # BOARD_USES_RECOVERY_AS_BOOT
2267
2268ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002269ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2270$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2271else
Tao Baof4866c72018-08-22 14:35:09 -07002272$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002273endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002274endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002275ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2276$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2277endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002278ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2279$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2280endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002281
Steve Muckleb3dda772020-03-11 16:03:07 -07002282$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) $(recovery_ramdisk) \
2283 $(recovery_kernel)
2284 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07002285
Tao Bao4594d0e2015-12-22 09:47:46 -08002286ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002287$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002288 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002289 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2290 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002291endif
Doug Zongker56588872012-08-20 15:38:58 -07002292
Ying Wang747b9f12015-01-30 14:05:22 -08002293.PHONY: recoveryimage-nodeps
2294recoveryimage-nodeps:
2295 @echo "make $@: ignoring dependencies"
2296 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
2297
Chris Grossa784ef12019-04-22 11:09:57 -07002298else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002299RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002300endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002301
2302.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002303recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002304
Jiyong Park03eb0612017-10-04 21:22:41 +09002305ifneq ($(BOARD_NAND_PAGE_SIZE),)
2306$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002307endif
2308
Jiyong Park03eb0612017-10-04 21:22:41 +09002309ifneq ($(BOARD_NAND_SPARE_SIZE),)
2310$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002311endif
2312
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002313ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002314# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002315# the debug ramdisk, which is the original ramdisk plus additional
2316# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2317# When /force_debuggable is present, /init will load userdebug sepolicy
2318# and property files to allow adb root, if the device is unlocked.
2319
2320ifdef BUILDING_RAMDISK_IMAGE
2321BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2322INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2323
2324INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2325 $(ALL_GENERATED_SOURCES) \
2326 $(ALL_DEFAULT_INSTALLED_MODULES))
2327
2328# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2329# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2330# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2331my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2332
2333INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2334INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2335$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2336$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2337
2338# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2339# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2340# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2341$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002342$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002343 echo Installed file list: $@
2344 mkdir -p $(dir $@)
2345 rm -f $@
2346 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002347 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002348
2349# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2350# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2351ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2352my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2353else
2354my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2355endif # BOARD_USES_RECOVERY_AS_BOOT
2356
2357$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2358$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002359
2360ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2361# 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 +08002362$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002363else
2364# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2365$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2366endif # BOARD_USES_RECOVERY_AS_BOOT
Bowgo Tsai0013f552019-03-20 17:59:52 +08002367$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(MINIGZIP)
2368 $(call pretty,"Target debug ram disk: $@")
2369 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2370 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002371 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002372 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2373
2374.PHONY: ramdisk_debug-nodeps
2375ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2376ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2377ramdisk_debug-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2378 echo "make $@: ignoring dependencies"
2379 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2380 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002381 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002382 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
2383
2384my_debug_ramdisk_sync_dir :=
2385my_debug_ramdisk_root_dir :=
2386
2387endif # BUILDING_RAMDISK_IMAGE
2388
2389# -----------------------------------------------------------------
2390# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2391#
2392# Note: it's intentional to skip signing for boot-debug.img, because it
2393# can only be used if the device is unlocked with verification error.
2394ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002395ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2396 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2397 $(PRODUCT_OUT)/$(k).img)
2398else
2399 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2400endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002401
2402# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2403ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2404INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2405else
2406INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2407endif
2408
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002409# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2410# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2411# Using a test key to sign boot-debug.img to continue booting with the mismatched
2412# public key, if the device is unlocked.
2413ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002414$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002415endif
2416
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002417BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2418INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2419# $(1): the bootimage to sign
2420define test-key-sign-bootimage
2421$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
2422$(AVBTOOL) add_hash_footer \
2423 --image $(1) \
2424 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
2425 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2426 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
2427$(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
2428endef
2429
Steve Muckleb3dda772020-03-11 16:03:07 -07002430# $(1): output file
2431define build-debug-bootimage-target
2432 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2433 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2434 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2435endef
2436
Bowgo Tsai0013f552019-03-20 17:59:52 +08002437# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2438$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2439 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002440 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002441
2442.PHONY: bootimage_debug-nodeps
2443bootimage_debug-nodeps: $(MKBOOTIMG)
2444 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002445 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002446
2447endif # TARGET_NO_KERNEL
2448
Bowgo Tsai6a683672020-02-14 19:00:15 +08002449ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2450ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2451# -----------------------------------------------------------------
2452# vendor debug ramdisk
2453# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
2454INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio.gz
2455$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2456$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2457
2458INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2459 $(ALL_GENERATED_SOURCES) \
2460 $(ALL_DEFAULT_INSTALLED_MODULES))
2461
2462# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2463# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2464# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2465# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2466$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2467$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2468$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(MINIGZIP)
2469 $(call pretty,"Target vendor debug ram disk: $@")
2470 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2471 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2472 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2473 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2474 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
2475 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(MINIGZIP) > $@
2476
2477INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2478INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2479$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2480$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2481
2482# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2483# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2484$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2485$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2486 echo Installed file list: $@
2487 mkdir -p $(dir $@)
2488 rm -f $@
2489 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2490 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2491
2492# -----------------------------------------------------------------
2493# vendor_boot-debug.img.
2494INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2495
2496# The util to sign vendor_boot-debug.img with a test key.
2497BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2498INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2499# $(1): the vendor bootimage to sign
2500define test-key-sign-vendor-bootimage
2501$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2502$(AVBTOOL) add_hash_footer \
2503 --image $(1) \
2504 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2505 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2506 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2507$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2508endef
2509
2510ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2511$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2512endif
2513
2514# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2515$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2516 $(call pretty,"Target vendor_boot debug image: $@")
2517 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
2518 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2519 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2520
2521endif # BUILDING_RAMDISK_IMAGE
2522endif # BUILDING_VENDOR_BOOT_IMAGE
2523
Bowgo Tsai0013f552019-03-20 17:59:52 +08002524# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002525# The test harness ramdisk, which is based off debug_ramdisk, plus a
2526# few additional test-harness-specific properties in adb_debug.prop.
2527
2528ifdef BUILDING_RAMDISK_IMAGE
2529BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2530INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2531
2532# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2533# appends a few test harness specific properties into the adb_debug.prop.
2534TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2535TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2536
2537# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2538# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2539TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2540ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2541ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2542
2543# $(1): a list of key=value pairs for additional property assignments
2544# $(2): the target .prop file to append the properties from $(1)
2545define append-test-harness-props
2546 echo "#" >> $(2); \
2547 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2548 echo "#" >> $(2);
2549 $(foreach line,$(1), echo "$(line)" >> $(2);)
2550endef
2551
2552$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
2553$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(MINIGZIP)
2554 $(call pretty,"Target test harness ram disk: $@")
2555 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2556 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2557 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2558
2559.PHONY: ramdisk_test_harness-nodeps
2560ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2561 echo "make $@: ignoring dependencies"
2562 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2563 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2564 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2565
2566endif # BUILDING_RAMDISK_IMAGE
2567
2568# -----------------------------------------------------------------
2569# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2570#
2571# Note: it's intentional to skip signing for boot-test-harness.img, because it
2572# can only be used if the device is unlocked with verification error.
2573ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2574
Steve Muckle4866bd62020-04-02 11:31:08 -07002575ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2576 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2577 $(PRODUCT_OUT)/$(k).img)
2578else
2579 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2580endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002581
2582# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2583INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2584
2585# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2586# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2587# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2588# public key, if the device is unlocked.
2589ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2590$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2591endif
2592
Steve Muckle4866bd62020-04-02 11:31:08 -07002593# $(1): output file
2594define build-boot-test-harness-target
2595 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2596 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2597 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2598endef
2599
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002600# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2601$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2602 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002603 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002604
2605.PHONY: bootimage_test_harness-nodeps
2606bootimage_test_harness-nodeps: $(MKBOOTIMG)
2607 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002608 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002609
2610endif # TARGET_NO_KERNEL
2611endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2612
2613# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002614# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002615#
Ying Wang9c649a72012-08-08 15:27:00 -07002616# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2617PDK_FUSION_SYSIMG_FILES := \
2618 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2619 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002620
Dan Willemsen37a19862018-10-31 16:31:46 -07002621INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002622 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002623 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002624 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002625 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002626
Ying Wang82cceba2012-08-13 15:03:00 -07002627FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002628
2629# ASAN libraries in the system image - add dependency.
2630ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002631ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002632 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2633 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2634 endif
2635endif
2636
Tom Cherryd14b8952018-08-09 14:26:00 -07002637FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002638
Ying Wange5e8c5f2011-09-09 16:35:53 -07002639# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002640ifdef BUILDING_SYSTEM_IMAGE
2641
Ying Wange5e8c5f2011-09-09 16:35:53 -07002642# installed file list
2643# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2644# We put installed-files.txt ahead of image itself in the dependency graph
2645# so that we can get the size stat even if the build fails due to too large
2646# system image.
2647INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002648INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2649$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002650$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002651 @echo Installed file list: $@
2652 @mkdir -p $(dir $@)
2653 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002654 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002655 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002656
2657.PHONY: installed-file-list
2658installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002659
2660$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002661
2662systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002663 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002664BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2665
Ying Wang23898df2014-06-18 20:26:24 -07002666# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002667ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002668define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002669$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2670 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2671 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2672 exit 1; \
2673fi
Ying Wang23898df2014-06-18 20:26:24 -07002674$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2675endef
2676else
2677define create-system-vendor-symlink
2678endef
2679endif
2680
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002681# Create symlink /system/product to /product if necessary.
2682ifdef BOARD_USES_PRODUCTIMAGE
2683define create-system-product-symlink
2684$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2685 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2686 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2687 exit 1; \
2688fi
2689$(hide) ln -sf /product $(TARGET_OUT)/product
2690endef
2691else
2692define create-system-product-symlink
2693endef
2694endif
2695
Justin Yun6151e3f2019-06-25 15:58:13 +09002696# Create symlink /system/system_ext to /system_ext if necessary.
2697ifdef BOARD_USES_SYSTEM_EXTIMAGE
2698define create-system-system_ext-symlink
2699$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2700 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2701 echo 'You cannot install files to $(TARGET_OUT)/system_ext while building a separate system_ext.img!' 1>&2; \
Dario Freni5f681e12018-05-29 13:09:01 +01002702 exit 1; \
2703fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002704$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002705endef
2706else
Justin Yun6151e3f2019-06-25 15:58:13 +09002707define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002708endef
2709endif
2710
The Android Open Source Project88b60792009-03-03 19:28:42 -08002711# $(1): output file
2712define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002713 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002714 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002715 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002716 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002717 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002718 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002719 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002720 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002721 $(BUILD_IMAGE) \
2722 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2723 || ( mkdir -p $${DIST_DIR}; \
2724 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2725 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002726endef
2727
Dan Willemsen6b72c732019-06-12 21:33:38 +00002728ifeq ($(BOARD_AVB_ENABLE),true)
2729$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2730endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002731$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002732 $(call build-systemimage-target,$@)
2733
Tao Baoe9d61b02018-08-20 21:09:07 -07002734INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002735SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002736
Tao Baoe9d61b02018-08-20 21:09:07 -07002737# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2738# compatibility, in case device-specific Makefiles still refer to the old name.
2739INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2740
Doug Zongker73ef8252009-07-23 15:12:53 -07002741# The system partition needs room for the recovery image as well. We
2742# now store the recovery image as a binary patch using the boot image
2743# as the source (since they are very similar). Generate the patch so
2744# we can see how big it's going to be, and include that in the system
2745# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002746ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002747ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002748ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002749ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002750diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2751else
2752diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2753endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002754intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2755RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002756$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2757$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002758 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2759 $(INSTALLED_BOOTIMAGE_TARGET) \
2760 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002761 @echo "Construct recovery from boot"
2762 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002763 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002764else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2765RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002766endif # BOARD_USES_FULL_RECOVERY_IMAGE
2767endif # INSTALLED_RECOVERYIMAGE_TARGET
2768endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002769
Yifan Hong9a3cad92020-04-27 19:06:59 -07002770$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002771 @echo "Install system fs image: $@"
2772 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002773 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002774
Tao Baoe9d61b02018-08-20 21:09:07 -07002775systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002776
2777.PHONY: systemimage-nodeps snod
2778systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002779 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002780 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002781 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002782 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002783ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002784 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002785endif
2786
Dan Willemsen67495202019-01-16 12:42:05 -08002787endif # BUILDING_SYSTEM_IMAGE
2788
Anton Hansson30e061b2018-11-12 13:36:46 +00002789.PHONY: sync syncsys
2790sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002791
Ying Wang3a61eeb2016-03-11 10:32:01 -08002792# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002793## platform.zip: system, plus other files to be used in PDK fusion build,
2794## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002795##
2796## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2797## The variable will be typically set from BoardConfig.mk.
2798## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002799ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002800pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002801 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002802pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002803 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002804pdk_classes_dex := $(strip \
2805 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002806 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002807
2808pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2809$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2810$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2811$(pdk_odex_config_mk) :
2812 @echo "PDK odex config makefile: $@"
2813 $(hide) mkdir -p $(dir $@)
2814 $(hide) echo "# Auto-generated. Do not modify." > $@
2815 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2816 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2817 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2818 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2819 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2820 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2821 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2822 )
2823 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002824 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.apk)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002825 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2826 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2827 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2828 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002829 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002830 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2831 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2832 )
2833
keunyoungc0178062013-07-22 14:54:58 -07002834PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002835INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002836
2837$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2838$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002839$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2840# dependencies for the other partitions are defined below after their file lists
2841# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002842$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002843 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002844 rm -f $@ $@.lst
2845 echo "-C $(PRODUCT_OUT)" >> $@.lst
2846 echo "-D $(TARGET_OUT)" >> $@.lst
2847 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2848 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002849ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002850 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002851endif
Dan Willemsen67495202019-01-16 12:42:05 -08002852ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002853 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002854endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002855ifdef BUILDING_SYSTEM_EXT_IMAGE
2856 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002857endif
Dan Willemsen67495202019-01-16 12:42:05 -08002858ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002859 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002860endif
Colin Crossc451a372013-12-18 19:36:44 -08002861ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002862 echo "-C $(OUT_DIR)" >> $@.lst
2863 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2864 if [ -e $$f ]; then \
2865 echo "-f $$f"; \
2866 fi \
2867 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002868endif
keunyoungc0178062013-07-22 14:54:58 -07002869ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002870 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002871endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002872 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002873 $(if $(PRIVATE_DEX_FILES),\
2874 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002875 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002876 touch $(PRODUCT_OUT)/pdk.mk
2877 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2878 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002879
2880.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002881platform: $(INSTALLED_PLATFORM_ZIP)
2882
2883.PHONY: platform-java
2884platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002885
2886# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002887ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2888$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002889endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002890
Colin Cross53c8f972018-09-28 16:19:42 -07002891endif # BUILD_PLATFORM_ZIP
2892
Ying Wang3a61eeb2016-03-11 10:32:01 -08002893# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002894# data partition image
2895INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002896 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002897
Dan Willemsen67495202019-01-16 12:42:05 -08002898ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002899userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002900 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002901BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2902
Ying Wangbd93d422011-10-28 17:02:30 -07002903define build-userdataimage-target
2904 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2905 @mkdir -p $(TARGET_OUT_DATA)
2906 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002907 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002908 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002909 $(BUILD_IMAGE) \
2910 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2911 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2912 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002913endef
2914
Joe Onorato64d85d02009-04-09 19:31:12 -07002915# We just build this directly to the install location.
2916INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002917INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2918 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002919 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002920$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002921 $(build-userdataimage-target)
2922
2923.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002924userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002925 $(build-userdataimage-target)
2926
Dan Willemsen67495202019-01-16 12:42:05 -08002927endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002928
Andreas Gampe039b5c72017-03-24 16:06:31 -07002929# ASAN libraries in the system image - build rule.
2930ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2931 $(TARGET_OUT_SHARED_LIBRARIES) \
2932 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2933 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2934 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002935# Extra options: Enforce the system user for the files to avoid having to change ownership.
2936ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002937# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2938# enough space.
2939$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002940 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 -07002941
The Android Open Source Project88b60792009-03-03 19:28:42 -08002942# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002943# partition table image
2944ifdef BOARD_BPT_INPUT_FILES
2945
2946BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002947BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002948
2949INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2950 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002951 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002952 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2953
2954ifdef BOARD_BPT_DISK_SIZE
2955INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2956endif
2957
2958define build-bptimage-target
2959 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2960 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2961endef
2962
2963INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002964$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2965 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2966
David Zeuthen25328622016-04-08 15:08:03 -04002967$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2968 $(build-bptimage-target)
2969
2970.PHONY: bptimage-nodeps
2971bptimage-nodeps:
2972 $(build-bptimage-target)
2973
2974endif # BOARD_BPT_INPUT_FILES
2975
2976# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002977# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002978ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002979INTERNAL_CACHEIMAGE_FILES := \
2980 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2981
2982cacheimage_intermediates := \
2983 $(call intermediates-dir-for,PACKAGING,cache)
2984BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2985
2986define build-cacheimage-target
2987 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2988 @mkdir -p $(TARGET_OUT_CACHE)
2989 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002990 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002991 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002992 $(BUILD_IMAGE) \
2993 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2994 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2995 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002996endef
2997
2998# We just build this directly to the install location.
2999INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003000$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003001 $(build-cacheimage-target)
3002
3003.PHONY: cacheimage-nodeps
3004cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3005 $(build-cacheimage-target)
3006
Dan Willemsen67495202019-01-16 12:42:05 -08003007else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003008# we need to ignore the broken cache link when doing the rsync
3009IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003010endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003011
David Zeuthen0eb10972016-09-28 17:55:27 -04003012# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003013# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003014ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003015ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003016# Marker file to identify that odex files are installed
3017INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3018ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3019$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3020 $(hide) touch $@
3021endif
3022
Alex Light4e358ab2016-06-16 14:47:10 -07003023INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3024 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
3025 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08003026 $(ALL_PDK_FUSION_FILES)) \
3027 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07003028
Colin Cross6db5b0e2018-11-16 21:26:33 -08003029# system_other dex files are installed as a side-effect of installing system image files
3030INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3031
Alex Light4e358ab2016-06-16 14:47:10 -07003032INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003033INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3034$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003035$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003036 @echo Installed file list: $@
3037 @mkdir -p $(dir $@)
3038 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07003039 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003040 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003041
Bowgo Tsai867ab662019-01-29 13:30:18 +08003042# Determines partition size for system_other.img.
3043ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3044ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3045INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3046endif
3047endif
3048
3049ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3050INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3051endif
3052
Alex Light4e358ab2016-06-16 14:47:10 -07003053systemotherimage_intermediates := \
3054 $(call intermediates-dir-for,PACKAGING,system_other)
3055BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3056
3057# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3058define build-systemotherimage-target
3059 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3060 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3061 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003062 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003063 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003064 $(BUILD_IMAGE) \
3065 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3066 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3067 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003068endef
3069
3070# We just build this directly to the install location.
3071INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003072ifneq (true,$(SANITIZE_LITE))
3073# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003074$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3075 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003076endif
Alex Light4e358ab2016-06-16 14:47:10 -07003077
3078.PHONY: systemotherimage-nodeps
3079systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3080 $(build-systemotherimage-target)
3081
Dan Willemsen67495202019-01-16 12:42:05 -08003082endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003083
3084
3085# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003086# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003087ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003088INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003089 $(filter $(TARGET_OUT_VENDOR)/%,\
3090 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08003091 $(ALL_PDK_FUSION_FILES)) \
3092 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07003093
3094# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
3095$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07003096
Ying Wang8da19e32015-09-15 14:22:12 -07003097INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07003098INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3099$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003100$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07003101 @echo Installed file list: $@
3102 @mkdir -p $(dir $@)
3103 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07003104 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003105 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07003106
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003107# Create symlink /vendor/odm to /odm if necessary.
3108ifdef BOARD_USES_ODMIMAGE
3109define create-vendor-odm-symlink
3110$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
3111 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
3112 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
3113 exit 1; \
3114fi
3115$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
3116endef
3117else
3118define create-vendor-odm-symlink
3119endef
3120endif
3121
Ying Wanga0febe52013-03-20 11:02:05 -07003122vendorimage_intermediates := \
3123 $(call intermediates-dir-for,PACKAGING,vendor)
3124BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003125define build-vendorimage-target
3126 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3127 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003128 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07003129 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003130 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003131 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003132 $(BUILD_IMAGE) \
3133 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3134 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003135 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003136endef
3137
3138# We just build this directly to the install location.
3139INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003140$(INSTALLED_VENDORIMAGE_TARGET): \
3141 $(INTERNAL_USERIMAGES_DEPS) \
3142 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003143 $(INSTALLED_FILES_FILE_VENDOR) \
3144 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003145 $(build-vendorimage-target)
3146
Steven Morelanda2e734d2017-03-07 12:10:09 -08003147.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003148vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003149 $(build-vendorimage-target)
3150
Colin Cross91a52272017-06-20 16:57:52 -07003151sync: $(INTERNAL_VENDORIMAGE_FILES)
3152
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003153else ifdef BOARD_PREBUILT_VENDORIMAGE
3154INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3155$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
3156endif
Ying Wanga0febe52013-03-20 11:02:05 -07003157
Ying Wang9f8e8db2011-11-04 11:37:01 -07003158# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003159# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003160ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003161INTERNAL_PRODUCTIMAGE_FILES := \
3162 $(filter $(TARGET_OUT_PRODUCT)/%,\
3163 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08003164 $(ALL_PDK_FUSION_FILES)) \
3165 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003166
3167# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
3168$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
3169
3170INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003171INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3172$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003173$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003174 @echo Installed file list: $@
3175 @mkdir -p $(dir $@)
3176 @rm -f $@
3177 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003178 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003179
3180productimage_intermediates := \
3181 $(call intermediates-dir-for,PACKAGING,product)
3182BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3183define build-productimage-target
3184 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3185 @mkdir -p $(TARGET_OUT_PRODUCT)
3186 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003187 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003188 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003189 $(BUILD_IMAGE) \
3190 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3191 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3192 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003193endef
3194
3195# We just build this directly to the install location.
3196INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003197$(INSTALLED_PRODUCTIMAGE_TARGET): \
3198 $(INTERNAL_USERIMAGES_DEPS) \
3199 $(INTERNAL_PRODUCTIMAGE_FILES) \
3200 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003201 $(build-productimage-target)
3202
3203.PHONY: productimage-nodeps pnod
3204productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3205 $(build-productimage-target)
3206
3207sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3208
3209else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3210INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3211$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3212endif
3213
3214# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003215# system_ext partition image
3216ifdef BUILDING_SYSTEM_EXT_IMAGE
3217INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3218 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01003219 $(ALL_DEFAULT_INSTALLED_MODULES)\
3220 $(ALL_PDK_FUSION_FILES)) \
3221 $(PDK_FUSION_SYMLINK_STAMP)
3222
Justin Yun6151e3f2019-06-25 15:58:13 +09003223# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
3224$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003225
Justin Yun6151e3f2019-06-25 15:58:13 +09003226INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3227INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3228$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3229$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003230 @echo Installed file list: $@
3231 @mkdir -p $(dir $@)
3232 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09003233 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003234 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003235
Justin Yun6151e3f2019-06-25 15:58:13 +09003236system_extimage_intermediates := \
3237 $(call intermediates-dir-for,PACKAGING,system_ext)
3238BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3239define build-system_extimage-target
3240 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3241 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3242 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3243 $(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 -07003244 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003245 $(BUILD_IMAGE) \
3246 $(TARGET_OUT_SYSTEM_EXT) \
3247 $(system_extimage_intermediates)/system_ext_image_info.txt \
3248 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3249 $(TARGET_OUT)
3250 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003251endef
3252
3253# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003254INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003255$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3256 $(INTERNAL_USERIMAGES_DEPS) \
3257 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3258 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003259 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003260
Justin Yun6151e3f2019-06-25 15:58:13 +09003261.PHONY: systemextimage-nodeps senod
3262systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3263 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003264
Justin Yun6151e3f2019-06-25 15:58:13 +09003265sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003266
Justin Yun6151e3f2019-06-25 15:58:13 +09003267else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3268INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3269$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003270endif
3271
3272# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003273# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003274ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003275INTERNAL_ODMIMAGE_FILES := \
3276 $(filter $(TARGET_OUT_ODM)/%,\
3277 $(ALL_DEFAULT_INSTALLED_MODULES)\
3278 $(ALL_PDK_FUSION_FILES)) \
3279 $(PDK_FUSION_SYMLINK_STAMP)
3280# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
3281$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
3282
3283INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3284INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3285$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003286$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003287 @echo Installed file list: $@
3288 @mkdir -p $(dir $@)
3289 @rm -f $@
3290 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003291 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003292
3293odmimage_intermediates := \
3294 $(call intermediates-dir-for,PACKAGING,odm)
3295BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3296define build-odmimage-target
3297 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3298 @mkdir -p $(TARGET_OUT_ODM)
3299 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3300 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003301 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003302 $(BUILD_IMAGE) \
3303 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3304 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3305 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003306endef
3307
3308# We just build this directly to the install location.
3309INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003310$(INSTALLED_ODMIMAGE_TARGET): \
3311 $(INTERNAL_USERIMAGES_DEPS) \
3312 $(INTERNAL_ODMIMAGE_FILES) \
3313 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003314 $(build-odmimage-target)
3315
3316.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003317odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003318 $(build-odmimage-target)
3319
3320sync: $(INTERNAL_ODMIMAGE_FILES)
3321
3322else ifdef BOARD_PREBUILT_ODMIMAGE
3323INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3324$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3325endif
3326
3327# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003328# dtbo image
3329ifdef BOARD_PREBUILT_DTBOIMAGE
3330INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3331
3332ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003333$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003334 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3335 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003336 --image $@ \
3337 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3338 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3339 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003340else
3341$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3342 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3343endif
3344
Tao Bao0da43472018-08-22 22:53:41 -07003345endif # BOARD_PREBUILT_DTBOIMAGE
3346
3347# Returns a list of image targets corresponding to the given list of partitions. For example, it
3348# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3349# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003350# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003351define images-for-partitions
3352$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3353endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003354
3355# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003356# vbmeta image
3357ifeq ($(BOARD_AVB_ENABLE),true)
3358
3359BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003360AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003361
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003362ifdef BOARD_AVB_KEY_PATH
3363$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3364else
3365# If key path isn't specified, use the 4096-bit test key.
3366BOARD_AVB_ALGORITHM := SHA256_RSA4096
3367BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3368endif
3369
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003370# AVB signing for system_other.img.
3371ifdef BUILDING_SYSTEM_OTHER_IMAGE
3372ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3373$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3374else
3375# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3376BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3377BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3378endif
3379
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003380$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3381 @echo Extracting system_other avb key: $@
3382 @rm -f $@
3383 @mkdir -p $(dir $@)
3384 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003385
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003386ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3387BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3388endif
3389
3390BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3391endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3392
Tao Bao744c4c72018-08-20 21:09:07 -07003393INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003394 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003395 $(BOARD_AVB_VBMETA_VENDOR)
3396
3397# Not allowing the same partition to appear in multiple groups.
3398ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003399 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003400endif
3401
cfig1aeef722019-09-20 22:45:06 +08003402# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3403# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3404# details.
3405ifneq ($(AB_OTA_UPDATER),true)
3406ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3407$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
3408 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for non-A/B devices. \
3409 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3410endif
3411endif
3412
Bowgo Tsai9b548012019-05-14 16:57:03 +08003413# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003414
3415BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003416 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003417 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003418 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3419
3420BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003421 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003422 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003423 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3424
Justin Yun6151e3f2019-06-25 15:58:13 +09003425BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003426 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003427 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3428 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003429
Bowgo Tsai9b548012019-05-14 16:57:03 +08003430BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003431 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003432 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3433
Tao Bao19b02fe2019-10-09 00:04:28 -07003434BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3435 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3436
3437BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3438 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3439
Bowgo Tsai9b548012019-05-14 16:57:03 +08003440BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003441 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003442 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3443
3444BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003445 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003446 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3447
Tao Bao19b02fe2019-10-09 00:04:28 -07003448BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3449 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3450
Bowgo Tsai9b548012019-05-14 16:57:03 +08003451# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003452ifdef BOOT_SECURITY_PATCH
3453BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3454 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3455endif
3456
3457ifdef VENDOR_SECURITY_PATCH
3458BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3459 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3460endif
3461
3462ifdef ODM_SECURITY_PATCH
3463BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3464 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3465endif
3466
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003467BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003468VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003469DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3470SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3471VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003472RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003473PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003474SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003475ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003476
Tao Bao0da43472018-08-22 22:53:41 -07003477# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003478# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003479define _check-and-set-avb-chain-args
3480$(eval part := $(1))
3481$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003482
3483$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3484$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3485$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3486$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3487$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3488$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3489$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3490$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3491
3492# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3493$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3494$(eval $(_signing_args) := \
3495 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3496
cfig1aeef722019-09-20 22:45:06 +08003497# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3498# partition descriptor for recovery partition into vbmeta.img.
3499$(if $(or $(filter true,$(AB_OTA_UPDATER)),$(filter-out recovery,$(part))),\
3500 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3501 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003502
Tao Bao744c4c72018-08-20 21:09:07 -07003503# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003504# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003505$(if $(filter $(part),$(part:vbmeta_%=%)),\
3506 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3507 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003508endef
3509
Tao Bao0da43472018-08-22 22:53:41 -07003510# Checks and sets the required build variables for an AVB partition. The partition will be
3511# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003512# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3513# VBMeta image.
Tao Bao0da43472018-08-22 22:53:41 -07003514# $(1): Partition name, e.g. boot or system.
3515define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003516$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003517$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003518 $(if $(_in_chained_vbmeta),\
3519 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003520 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003521 $(if $(_in_chained_vbmeta),,\
3522 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3523 --include_descriptors_from_image $(call images-for-partitions,$(1)))))
Tao Bao0da43472018-08-22 22:53:41 -07003524endef
3525
Tao Baob1a2e352018-08-14 16:17:12 -07003526ifdef INSTALLED_BOOTIMAGE_TARGET
Steve Muckle0959fbf2020-04-13 17:07:13 -07003527# multiple hashes for an image are not yet supported, fortunately this
3528# only arises for GKI where the boot descriptor can be left out
3529ifeq ($(strip $(BOARD_KERNEL_BINARIES)),)
Tao Bao0da43472018-08-22 22:53:41 -07003530$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003531endif
Steve Muckle0959fbf2020-04-13 17:07:13 -07003532endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003533
Steve Mucklee1b10862019-07-10 10:49:37 -07003534ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3535$(eval $(call check-and-set-avb-args,vendor_boot))
3536endif
3537
Tao Bao0da43472018-08-22 22:53:41 -07003538$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003539
3540ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003541$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003542endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003543
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003544ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003545$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003546endif
3547
Justin Yun6151e3f2019-06-25 15:58:13 +09003548ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3549$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003550endif
3551
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003552ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003553$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003554endif
3555
Yueyao Zhu211c9012017-04-27 00:34:50 -07003556ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003557$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003558endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003559
David Zeuthen8fecb282017-12-01 16:24:01 -05003560ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003561$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003562endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003563
David Anderson7709ab22018-10-15 14:41:34 -07003564# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3565ifdef BOARD_AVB_VBMETA_SYSTEM
3566$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003567endif
3568
3569ifdef BOARD_AVB_VBMETA_VENDOR
3570$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3571endif
3572
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003573# Add kernel cmdline descriptor for kernel to mount system.img as root with
3574# dm-verity. This works when system.img is either chained or not-chained:
3575# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3576# cmdline descriptor to system.img
3577# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3578# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003579ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003580ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003581BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003582endif
David Anderson8916a2a2018-09-18 15:46:59 -07003583endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003584
Tao Bao0da43472018-08-22 22:53:41 -07003585BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003586BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003587BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3588
3589ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003590# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003591BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003592endif
Tao Bao0da43472018-08-22 22:53:41 -07003593
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003594ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003595BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003596endif
3597
David Anderson7709ab22018-10-15 14:41:34 -07003598ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3599BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3600 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003601endif
3602
3603ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3604BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3605 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003606endif
3607
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003608# $(1): the directory to extract public keys to
3609define extract-avb-chain-public-keys
3610 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3611 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3612 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003613 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3614 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3615 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003616 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3617 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3618 --output $(1)/system.avbpubkey)
3619 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3620 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3621 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003622 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3623 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3624 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003625 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3626 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3627 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003628 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3629 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3630 --output $(1)/odm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003631 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3632 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3633 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003634 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3635 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3636 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003637 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3638 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3639 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003640 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3641 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3642 --output $(1)/vbmeta_vendor.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003643endef
3644
Tao Bao744c4c72018-08-20 21:09:07 -07003645# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3646# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003647# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003648# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3649# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003650# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003651# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003652# $(2): Output filename.
3653define build-chained-vbmeta-image
3654 $(call pretty,"Target chained vbmeta image: $@")
3655 $(hide) $(AVBTOOL) make_vbmeta_image \
3656 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3657 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3658 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3659 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3660 --output $@
3661endef
3662
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003663ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003664ifdef BOARD_AVB_VBMETA_SYSTEM
3665INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3666$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003667 $(AVBTOOL) \
3668 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3669 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003670 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003671endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003672endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003673
3674ifdef BOARD_AVB_VBMETA_VENDOR
3675INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3676$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003677 $(AVBTOOL) \
3678 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3679 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003680 $(call build-chained-vbmeta-image,vbmeta_vendor)
3681endif
3682
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003683define build-vbmetaimage-target
3684 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003685 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3686 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003687 $(hide) $(AVBTOOL) make_vbmeta_image \
3688 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003689 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003690 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3691 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003692 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003693endef
3694
Paul Trautrim4e143232019-08-13 16:30:57 +09003695ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003696INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003697$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3698 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3699
David Zeuthen8fecb282017-12-01 16:24:01 -05003700$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003701 $(AVBTOOL) \
3702 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003703 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003704 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3705 $(INSTALLED_VENDORIMAGE_TARGET) \
3706 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003707 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003708 $(INSTALLED_ODMIMAGE_TARGET) \
3709 $(INSTALLED_DTBOIMAGE_TARGET) \
3710 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3711 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3712 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3713 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3714 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3715 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003716 $(build-vbmetaimage-target)
3717
3718.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003719vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3720 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003721vbmetaimage-nodeps:
3722 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003723endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003724
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003725endif # BOARD_AVB_ENABLE
3726
3727# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003728# Check VINTF of build
3729
3730ifndef TARGET_BUILD_APPS
3731intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3732check_vintf_all_deps :=
3733
Yifan Hongaf9b0702020-01-21 12:46:57 -08003734# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3735# because they are only used for prebuilt images.
3736check_vintf_common_srcs_patterns := \
3737 $(TARGET_OUT)/etc/vintf/% \
3738 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3739 $(TARGET_OUT_ODM)/etc/vintf/% \
3740 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3741 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3742
3743check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3744 $(INTERNAL_SYSTEMIMAGE_FILES) \
3745 $(INTERNAL_VENDORIMAGE_FILES) \
3746 $(INTERNAL_ODMIMAGE_FILES) \
3747 $(INTERNAL_PRODUCTIMAGE_FILES) \
3748 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3749))
3750check_vintf_common_srcs_patterns :=
3751
3752check_vintf_has_system :=
3753check_vintf_has_vendor :=
3754
Yifan Hong28ffd732020-03-13 13:11:10 -07003755ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3756$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3757endif
3758ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3759$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3760endif
3761
Yifan Hong605ea042020-01-14 21:36:00 +00003762# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003763check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3764ifneq ($(check_vintf_system_deps),)
3765check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003766check_vintf_system_log := $(intermediates)/check_vintf_system_log
3767check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003768$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003769 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3770check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003771endif # check_vintf_system_deps
3772check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003773
3774# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003775check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3776ifneq ($(check_vintf_vendor_deps),)
3777check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003778check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3779check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003780# Check vendor SKU=(empty) case when:
3781# - DEVICE_MANIFEST_FILE is not empty; OR
3782# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003783$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003784 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3785 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003786 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003787$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003788 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3789 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3790 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3791 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003792check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003793endif # check_vintf_vendor_deps
3794check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003795
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003796# -- Check VINTF compatibility of build.
3797# Skip partial builds; only check full builds. Only check if:
3798# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003799# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003800# - Building product / system_ext / odm images if board has product / system_ext / odm images
3801ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003802ifeq ($(check_vintf_has_system),true)
3803ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003804ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3805ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3806ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3807
3808check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3809check_vintf_all_deps += $(check_vintf_compatible_log)
3810
3811check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003812check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003813
3814# -- Kernel version and configurations.
3815ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3816
Yifan Hong605ea042020-01-14 21:36:00 +00003817BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3818BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3819
3820my_board_extracted_kernel :=
3821
3822# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3823# from INSTALLED_KERNEL_TARGET.
3824ifdef BOARD_KERNEL_CONFIG_FILE
3825ifdef BOARD_KERNEL_VERSION
3826$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3827 cp $< $@
3828$(BUILT_KERNEL_VERSION_FILE):
3829 echo $(BOARD_KERNEL_VERSION) > $@
3830
3831my_board_extracted_kernel := true
3832endif # BOARD_KERNEL_VERSION
3833endif # BOARD_KERNEL_CONFIG_FILE
3834
3835ifneq ($(my_board_extracted_kernel),true)
3836ifndef INSTALLED_KERNEL_TARGET
3837$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3838 is true. Information about the updated kernel cannot be built into OTA update package. \
3839 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3840 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3841 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3842 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3843 manually.)
3844else
3845
3846# Tools for decompression that is not in PATH.
3847# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3848# Algorithms that are in the script but not in this list will be found in PATH.
3849my_decompress_tools := \
3850 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3851
3852$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3853$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3854$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
3855$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(INSTALLED_KERNEL_TARGET)
3856 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(INSTALLED_KERNEL_TARGET) \
3857 --output-configs $@ \
3858 --output-version $(BUILT_KERNEL_VERSION_FILE)
3859
3860my_decompress_tools :=
3861
3862endif # my_board_extracted_kernel
3863my_board_extracted_kernel :=
3864
3865endif # INSTALLED_KERNEL_TARGET
3866
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003867check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3868check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3869
3870endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3871
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003872check_vintf_compatible_args += \
3873 --dirmap /system:$(TARGET_OUT) \
3874 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3875 --dirmap /odm:$(TARGET_OUT_ODM) \
3876 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3877 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3878
3879ifdef PRODUCT_SHIPPING_API_LEVEL
3880check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3881endif # PRODUCT_SHIPPING_API_LEVEL
3882
3883$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3884$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003885# Check ODM SKU=(empty) case when:
3886# - ODM_MANIFEST_FILES is not empty; OR
3887# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003888$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003889 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3890 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003891 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003892# Check vendor SKU=(empty) case when:
3893# - DEVICE_MANIFEST_FILE is not empty; OR
3894# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003895$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003896 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3897 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003898 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003899$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3900 @echo -n -e 'Deps: \n ' > $@
3901 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3902 @echo -n -e 'Args: \n ' >> $@
3903 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003904 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3905 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003906 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003907 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3908 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3909 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003910
3911check_vintf_compatible_log :=
3912check_vintf_compatible_args :=
3913check_vintf_compatible_deps :=
3914
3915endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3916endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3917endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003918endif # check_vintf_has_vendor
3919endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003920endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3921
3922# Add all logs of VINTF checks to dist builds
3923droid_targets: $(check_vintf_all_deps)
3924$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3925
3926# Helper alias to check all VINTF of current build.
3927.PHONY: check-vintf-all
3928check-vintf-all: $(check_vintf_all_deps)
3929 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3930
Yifan Hongaf9b0702020-01-21 12:46:57 -08003931check_vintf_has_vendor :=
3932check_vintf_has_system :=
3933check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003934check_vintf_all_deps :=
3935intermediates :=
3936endif # !TARGET_BUILD_APPS
3937
3938# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003939# Check image sizes <= size of super partition
3940
3941ifeq (,$(TARGET_BUILD_APPS))
3942# Do not check for apps-only build
3943
3944ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003945
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003946# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003947# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003948define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003949 mkdir -p $(dir $(1))
3950 rm -f $(1)
3951 $(call dump-super-image-info, $(1))
3952 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3953 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003954 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003955endef
3956
Yifan Hong30910932019-10-25 20:36:55 -07003957check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3958droid_targets: $(check_all_partition_sizes_log)
3959$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003960
Yifan Hong30910932019-10-25 20:36:55 -07003961$(check_all_partition_sizes_log): \
3962 $(CHECK_PARTITION_SIZES) \
3963 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3964 $(call check-all-partition-sizes-target, \
3965 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3966 $@)
3967
3968.PHONY: check-all-partition-sizes
3969check-all-partition-sizes: $(check_all_partition_sizes_log)
3970
3971.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003972check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003973 $(call check-all-partition-sizes-target, \
3974 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003975
Yifan Hong2dae5722018-07-31 12:47:27 -07003976endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003977
3978endif # TARGET_BUILD_APPS
3979
3980# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003981# bring in the installer image generation defines if necessary
3982ifeq ($(TARGET_USE_DISKINSTALLER),true)
3983include bootable/diskinstaller/config.mk
3984endif
3985
3986# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003987# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003988
Ying Wangbd2d0242015-09-22 11:17:52 -07003989ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003990 build_ota_package := false
3991 build_otatools_package := false
3992else
Tao Bao9be20c72019-04-08 21:11:59 -07003993 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003994 build_ota_package := true
3995 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3996 build_ota_package := false
3997 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003998 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003999 build_ota_package := false
4000 endif
4001 ifeq ($(TARGET_PRODUCT),sdk)
4002 build_ota_package := false
4003 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004004 ifeq ($(TARGET_BUILD_PDK),true)
4005 build_ota_package := false
4006 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004007 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4008 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4009 build_ota_package := false
4010 endif
4011 ifeq ($(TARGET_NO_KERNEL),true)
4012 build_ota_package := false
4013 endif
4014 ifeq ($(recovery_fstab),)
4015 build_ota_package := false
4016 endif
4017 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004018
Tao Bao9be20c72019-04-08 21:11:59 -07004019 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004020 build_otatools_package := true
4021 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4022 build_otatools_package := false
4023 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004024endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004025
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004026ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004027
4028INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004029 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004030 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07004031 aftltool \
Tao Bao96daeeb2019-05-01 21:17:13 -07004032 append2simg \
4033 avbtool \
4034 blk_alloc_to_base_fs \
4035 boot_signer \
4036 brillo_update_payload \
4037 brotli \
4038 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004039 build_image \
4040 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004041 build_verity_metadata \
4042 build_verity_tree \
4043 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004044 check_ota_package_signature \
4045 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004046 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004047 checkvintf \
4048 delta_generator \
4049 e2fsck \
4050 e2fsdroid \
4051 fc_sort \
4052 fec \
4053 fs_config \
4054 generate_verity_key \
4055 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004056 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004057 imgdiff \
4058 libconscrypt_openjdk_jni \
4059 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004060 lpunpack \
Tao Bao96daeeb2019-05-01 21:17:13 -07004061 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07004062 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004063 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004064 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004065 mkbootfs \
4066 mkbootimg \
4067 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004068 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004069 mkf2fsuserimg.sh \
4070 mksquashfs \
4071 mksquashfsimage.sh \
4072 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07004073 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004074 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004075 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004076 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004077 sign_apex \
4078 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07004079 signapk \
4080 simg2img \
4081 sload_f2fs \
4082 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004083 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004084 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004085 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004086 verity_signer \
4087 verity_verifier \
4088 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08004089
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004090# Additional tools to unpack and repack the apex file.
4091INTERNAL_OTATOOLS_MODULES += \
4092 apexer \
4093 deapexer \
4094 debugfs_static \
4095 merge_zips \
4096 resize2fs \
4097 soong_zip \
4098
Anton Hansson8dab0a62019-03-28 15:45:40 +00004099ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004100INTERNAL_OTATOOLS_MODULES += \
4101 futility \
4102 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004103endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004104
Tao Bao96daeeb2019-05-01 21:17:13 -07004105INTERNAL_OTATOOLS_FILES := \
4106 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004107
Ying Wang06898662010-06-17 17:52:18 -07004108.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004109otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004110
Tao Bao96daeeb2019-05-01 21:17:13 -07004111# For each module, recursively resolve its host shared library dependencies. Then we have a full
4112# list of modules whose installed files need to be packed.
4113INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4114 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4115 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004116
Tao Bao96daeeb2019-05-01 21:17:13 -07004117INTERNAL_OTATOOLS_PACKAGE_FILES := \
4118 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4119
4120INTERNAL_OTATOOLS_PACKAGE_FILES += \
4121 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4122 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004123
4124ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004125INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004126 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004127 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004128endif
4129ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004130INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004131 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4132 -name "atx_metadata.bin"))
4133endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004134ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004135INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004136 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004137endif
4138
Tao Bao96daeeb2019-05-01 21:17:13 -07004139INTERNAL_OTATOOLS_RELEASETOOLS := \
4140 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4141 \( -type f -o -type l \) -print))
4142
4143BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4144$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4145$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4146$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4147$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004148$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004149 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004150 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4151 mkdir -p $(dir $@)
4152 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4153 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004154 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004155 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004156
4157.PHONY: otatools-package
4158otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4159
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004160endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004161
The Android Open Source Project88b60792009-03-03 19:28:42 -08004162# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004163# misc_info.txt
4164
4165INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4166
4167ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4168# default to common dir for device vendor
4169tool_extensions := $(TARGET_DEVICE_DIR)/../common
4170else
4171tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4172endif
4173.KATI_READONLY := tool_extensions
4174
4175$(INSTALLED_MISC_INFO_TARGET):
4176 rm -f $@
4177 $(call pretty,"Target misc_info.txt: $@")
4178 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4179 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4180ifdef BOARD_FLASH_BLOCK_SIZE
4181 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4182endif
4183ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
4184 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $@
4185endif
4186ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4187 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004188else
4189 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004190endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004191ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4192 echo "vendor_boot=true" >> $@
4193 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4194endif
Daniel Normane1e48082019-06-27 13:55:23 -07004195ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4196 $(hide) echo "no_recovery=true" >> $@
4197endif
4198ifdef BOARD_INCLUDE_RECOVERY_DTBO
4199 $(hide) echo "include_recovery_dtbo=true" >> $@
4200endif
4201ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4202 $(hide) echo "include_recovery_acpio=true" >> $@
4203endif
4204ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4205 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4206endif
4207ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4208 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4209 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4210else
4211 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4212endif
4213 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4214 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4215ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4216 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4217endif
4218 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004219 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004220 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4221 $(hide) echo "multistage_support=1" >> $@
4222 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4223ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4224 $(hide) echo "build_generic_ota_package=true" >> $@
4225endif
4226ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4227 # OTA scripts are only interested in fingerprint related properties
4228 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4229endif
4230ifneq (,$(filter address, $(SANITIZE_TARGET)))
4231 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4232 $(hide) echo "userdata_img_with_data=true" >> $@
4233endif
4234ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4235 $(hide) echo "full_recovery_image=true" >> $@
4236endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004237ifdef BOARD_USES_VENDORIMAGE
4238 $(hide) echo "board_uses_vendorimage=true" >> $@
4239endif
Daniel Normane1e48082019-06-27 13:55:23 -07004240ifeq ($(BOARD_AVB_ENABLE),true)
4241 $(hide) echo "avb_enable=true" >> $@
4242 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4243 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4244 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4245 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4246ifdef BOARD_AVB_BOOT_KEY_PATH
4247 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4248 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4249 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4250endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004251 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4252ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4253 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4254 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4255 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4256endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004257 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4258ifdef BOARD_AVB_RECOVERY_KEY_PATH
4259 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4260 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4261 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4262endif # BOARD_AVB_RECOVERY_KEY_PATH
4263ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4264 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4265 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4266 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4267 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4268 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4269endif # BOARD_AVB_VBMETA_SYSTEM
4270ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4271 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4272 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4273 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4274 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4275 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4276endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4277endif # BOARD_AVB_ENABLE
4278ifdef BOARD_BPT_INPUT_FILES
4279 $(hide) echo "board_bpt_enable=true" >> $@
4280 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4281 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4282endif
4283ifdef BOARD_BPT_DISK_SIZE
4284 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4285endif
4286 $(call generate-userimage-prop-dictionary, $@)
4287ifeq ($(AB_OTA_UPDATER),true)
4288 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4289 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4290 $(hide) echo "ab_update=true" >> $@
4291endif
4292ifdef BOARD_PREBUILT_DTBOIMAGE
4293 $(hide) echo "has_dtbo=true" >> $@
4294ifeq ($(BOARD_AVB_ENABLE),true)
4295 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4296 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4297ifdef BOARD_AVB_DTBO_KEY_PATH
4298 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4299 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4300 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4301endif # BOARD_AVB_DTBO_KEY_PATH
4302endif # BOARD_AVB_ENABLE
4303endif # BOARD_PREBUILT_DTBOIMAGE
4304 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004305 @# VINTF checks
4306ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4307 $(hide) echo "vintf_enforce=true" >> $@
4308endif
4309ifdef ODM_MANIFEST_SKUS
4310 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4311endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004312ifdef ODM_MANIFEST_FILES
4313 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4314endif
4315ifdef DEVICE_MANIFEST_SKUS
4316 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4317endif
4318ifdef DEVICE_MANIFEST_FILE
4319 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4320endif
Daniel Normane1e48082019-06-27 13:55:23 -07004321
4322.PHONY: misc_info
4323misc_info: $(INSTALLED_MISC_INFO_TARGET)
4324
4325droidcore: $(INSTALLED_MISC_INFO_TARGET)
4326
4327# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004328# A zip of the directories that map to the target filesystem.
4329# This zip can be used to create an OTA package or filesystem image
4330# as a post-build step.
4331#
4332name := $(TARGET_PRODUCT)
4333ifeq ($(TARGET_BUILD_TYPE),debug)
4334 name := $(name)_debug
4335endif
4336name := $(name)-target_files-$(FILE_NAME_TAG)
4337
4338intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4339BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4340$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4341$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004342 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004343
4344# $(1): Directory to copy
4345# $(2): Location to copy it to
4346# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4347define package_files-copy-root
4348 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4349 mkdir -p $(2) && \
4350 $(ACP) -rd $(strip $(1))/* $(2); \
4351 fi
4352endef
4353
Tao Baoa04fca32015-11-30 12:22:24 -08004354built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004355
4356# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004357ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004358built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07004359 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
4360endif
4361
The Android Open Source Project88b60792009-03-03 19:28:42 -08004362$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4363
Dan Willemsen653bea92017-03-21 15:47:37 -07004364tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004365$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004366
Sen Jiang4438fd92016-03-07 16:51:01 -08004367ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004368updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08004369else
Steve Fung48e49f52015-10-01 23:53:31 -07004370# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004371updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004372endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004373$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004374
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004375# If we are using recovery as boot, output recovery files to BOOT/.
4376ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4377$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4378else
4379$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4380endif
4381
Dan Willemsen653bea92017-03-21 15:47:37 -07004382ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004383 ifdef OSRELEASED_DIRECTORY
4384 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4385 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4386 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4387 endif
Tao Baoa835f382019-07-18 15:55:30 -07004388
4389 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4390 # additionally include radio or bootloader partitions).
4391 ifeq ($(AB_OTA_PARTITIONS),)
4392 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4393 endif
4394endif
4395
4396ifneq ($(AB_OTA_PARTITIONS),)
4397 ifneq ($(AB_OTA_UPDATER),true)
4398 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4399 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004400endif
4401
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004402# Run fs_config while creating the target files package
4403# $1: root directory
4404# $2: add prefix
4405define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004406(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 -08004407endef
4408
Yifan Hong60bfcc42019-11-01 11:39:45 -07004409# Filter out vendor from the list for AOSP targets.
4410# $(1): list
4411define filter-out-missing-vendor
4412$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4413endef
4414
4415# Information related to dynamic partitions and virtual A/B. This information
4416# is needed for building the super image (see dump-super-image-info) and
4417# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004418# $(1): file
4419define dump-dynamic-partitions-info
4420 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4421 echo "use_dynamic_partitions=true" >> $(1))
4422 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4423 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004424 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4425 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4426 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004427 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4428 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004429 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4430 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4431 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4432 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4433 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4434 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004435 echo "dynamic_partition_list=$(call filter-out-missing-vendor, $(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004436 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4437 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4438 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4439 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4440 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004441 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 -07004442 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4443 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004444 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4445 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004446 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4447 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004448 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4449 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4450 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4451 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4452 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4453 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4454 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4455 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004456 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4457 echo "virtual_ab=true" >> $(1))
4458 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4459 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004460endef
4461
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004462# By conditionally including the dependency of the target files package on the
4463# full system image deps, we speed up builds that do not build the system
4464# image.
4465ifdef BUILDING_SYSTEM_IMAGE
4466$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4467endif
4468
Isaac Chen9e09d472019-07-05 17:30:41 +08004469ifeq ($(BUILD_QEMU_IMAGES),true)
4470MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4471$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4472endif
4473
The Android Open Source Project88b60792009-03-03 19:28:42 -08004474# Depending on the various images guarantees that the underlying
4475# directories are up-to-date.
4476$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004477 $(INSTALLED_RAMDISK_TARGET) \
4478 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004479 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004480 $(INSTALLED_RADIOIMAGE_TARGET) \
4481 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004482 $(INSTALLED_USERDATAIMAGE_TARGET) \
4483 $(INSTALLED_CACHEIMAGE_TARGET) \
4484 $(INSTALLED_VENDORIMAGE_TARGET) \
4485 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004486 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004487 $(INSTALLED_VBMETAIMAGE_TARGET) \
4488 $(INSTALLED_ODMIMAGE_TARGET) \
4489 $(INSTALLED_DTBOIMAGE_TARGET) \
4490 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4491 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4492 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004493 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004494 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4495 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004496 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004497 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004498 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4499 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4500 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004501 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004502 $(PRODUCT_ODM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004503 $(LPMAKE) \
4504 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004505 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004506 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004507 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004508 $(SOONG_ZIP) \
4509 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004510 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004511 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004512 $(BUILT_KERNEL_CONFIGS_FILE) \
4513 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004514 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004515 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004516 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004517 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004518 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004519 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004520 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004521 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004522ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004523 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004524 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004525 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004526 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004527ifdef INSTALLED_KERNEL_TARGET
Steve Muckleb3dda772020-03-11 16:03:07 -07004528 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004529endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004530ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004531 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004532else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004533ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004534 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004535endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004536ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004537ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004538 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004539else
Steve Mucklee1b10862019-07-10 10:49:37 -07004540 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004541endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004542endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004543ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004544 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004545endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004546ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004547 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004548endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004549ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004550 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004551endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004552ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004553 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004554endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004555ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004556 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004557endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004558endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004559endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004560 @# Components of the boot image
4561 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004562 $(hide) mkdir -p $(zip_root)/ROOT
4563 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004564 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004565 @# If we are using recovery as boot, this is already done when processing recovery.
4566ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004567ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004568 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004569 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004570endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004571ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004572 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004573endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004574ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004575ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004576 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004577endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004578ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004579 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004580endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004581 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004582ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004583 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004584endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004585ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004586 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004587endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004588else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4589 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4590endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4591endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004592 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4593 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004594 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004595ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4596 mkdir -p $(zip_root)/VENDOR_BOOT
4597 $(call package_files-copy-root, \
4598 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4599ifdef INSTALLED_DTBIMAGE_TARGET
4600 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4601endif
4602ifdef BOARD_KERNEL_BASE
4603 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4604endif
4605ifdef BOARD_KERNEL_PAGESIZE
4606 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4607endif
4608 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4609endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004610ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004611 @# Contents of the system image
4612 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004613 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004614endif
4615ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004616 @# Contents of the data image
4617 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004618 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004619endif
4620ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004621 @# Contents of the vendor image
4622 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004623 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004624endif
Dan Willemsen67495202019-01-16 12:42:05 -08004625ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004626 @# Contents of the product image
4627 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004628 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004629endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004630ifdef BUILDING_SYSTEM_EXT_IMAGE
4631 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004632 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004633 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004634endif
Dan Willemsen67495202019-01-16 12:42:05 -08004635ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004636 @# Contents of the odm image
4637 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004638 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004639endif
Dan Willemsen67495202019-01-16 12:42:05 -08004640ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004641 @# Contents of the system_other image
4642 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004643 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004644endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004645 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004646 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004647 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07004648ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004649ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004650 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004651 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004652endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004653endif
Doug Zongker8678df42009-06-15 14:30:14 -07004654 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004655 @# build them.
4656 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004657 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004658 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004659ifneq ($(tool_extension),)
4660 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4661endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004662 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004663 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004664 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004665ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4666 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4667 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004668endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004669ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4670 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4671 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004672endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004673ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4674 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4675 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004676endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004677ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4678 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4679 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004680endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004681ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4682 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4683 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004684endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004685ifneq ($(AB_OTA_UPDATER),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004686ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004687 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004688 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004689endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004690endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004691ifeq ($(AB_OTA_UPDATER),true)
4692 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004693 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004694 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004695 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4696 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004697 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4698 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4699 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004700ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004701 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4702 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4703 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004704endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004705endif
Steve Fungdfbab492015-09-24 18:12:33 -07004706ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004707 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004708 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004709endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004710ifdef BOARD_PREBUILT_VENDORIMAGE
4711 $(hide) mkdir -p $(zip_root)/IMAGES
4712 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4713endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004714ifdef BOARD_PREBUILT_PRODUCTIMAGE
4715 $(hide) mkdir -p $(zip_root)/IMAGES
4716 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4717endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004718ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004719 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004720 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004721endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004722ifdef BOARD_PREBUILT_BOOTIMAGE
4723 $(hide) mkdir -p $(zip_root)/IMAGES
4724 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4725endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004726ifdef BOARD_PREBUILT_ODMIMAGE
4727 $(hide) mkdir -p $(zip_root)/IMAGES
4728 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4729endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004730ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004731 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4732 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004733endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07004734 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4735 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4736 @# INSTALLED_RADIOIMAGE_TARGET.
4737 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4738 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004739 @# Run fs_config on all the system, vendor, boot ramdisk,
4740 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004741ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004742 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004743endif
4744ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004745 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4746endif
Dan Willemsen67495202019-01-16 12:42:05 -08004747ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004748 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4749endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004750ifdef BUILDING_SYSTEM_EXT_IMAGE
4751 $(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 +01004752endif
Dan Willemsen67495202019-01-16 12:42:05 -08004753ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004754 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4755endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004756 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004757 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004758ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004759 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004760 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004761endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004762ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4763 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4764endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004765ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4766 @# 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 -08004767 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4768endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004769ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4770 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4771endif
Dan Willemsen67495202019-01-16 12:42:05 -08004772ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004773 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4774endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004775 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004776ifdef BUILT_KERNEL_CONFIGS_FILE
4777 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4778endif
4779ifdef BUILT_KERNEL_VERSION_FILE
4780 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4781endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004782 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4783ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4784 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4785endif
Tao Baocbd6d492019-10-07 22:46:02 -07004786 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4787 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004788ifeq ($(BUILD_QEMU_IMAGES),true)
4789 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4790 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4791endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004792 @# Zip everything up, preserving symlinks and placing META/ files first to
4793 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004794 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004795 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004796 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004797
Ying Wanga0febe52013-03-20 11:02:05 -07004798.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004799target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4800
Ying Wang4709d7c2014-04-14 17:25:43 -07004801ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4802$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4803endif
Doug Zongker367910f2009-06-15 18:56:51 -07004804
Dan Albert4d323332016-10-14 13:23:06 -07004805# -----------------------------------------------------------------
4806# NDK Sysroot Package
4807NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004808$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004809 @echo Package NDK sysroot...
4810 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4811
4812$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4813
Ying Wang09c4b682015-08-11 11:24:19 -07004814ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004815# -----------------------------------------------------------------
4816# OTA update package
4817
Yifan Hong50e79542018-11-08 17:44:12 -08004818# $(1): output file
4819# $(2): additional args
4820define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004821PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004822 $(OTA_FROM_TARGET_FILES) \
4823 --verbose \
4824 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4825 --path $(HOST_OUT) \
4826 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4827 $(2) \
4828 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004829endef
4830
Doug Zongker8678df42009-06-15 14:30:14 -07004831name := $(TARGET_PRODUCT)
4832ifeq ($(TARGET_BUILD_TYPE),debug)
4833 name := $(name)_debug
4834endif
4835name := $(name)-ota-$(FILE_NAME_TAG)
4836
4837INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004838INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4839
Doug Zongker8678df42009-06-15 14:30:14 -07004840$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004841$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004842$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004843 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004844 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004845
4846.PHONY: otapackage
4847otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4848
Tao Bao519d1822018-12-27 12:47:23 -08004849ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004850name := $(TARGET_PRODUCT)
4851ifeq ($(TARGET_BUILD_TYPE),debug)
4852 name := $(name)_debug
4853endif
4854name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4855
4856INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004857$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004858$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4859 $(BUILT_TARGET_FILES_PACKAGE) \
4860 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004861 @echo "Package OTA (retrofit dynamic partitions): $@"
4862 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4863
4864.PHONY: otardppackage
4865
4866otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4867
Tao Bao519d1822018-12-27 12:47:23 -08004868endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004869
Ying Wang09c4b682015-08-11 11:24:19 -07004870endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004871
Ying Wang09a00a62010-10-20 14:01:09 -07004872# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004873# A zip of the appcompat directory containing logs
4874APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4875# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4876ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004877$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004878 $(INSTALLED_RAMDISK_TARGET) \
4879 $(INSTALLED_BOOTIMAGE_TARGET) \
4880 $(INSTALLED_USERDATAIMAGE_TARGET) \
4881 $(INSTALLED_VENDORIMAGE_TARGET) \
4882 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004883 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004884endif
4885$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4886$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4887 @echo "appcompat logs: $@"
4888 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4889 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4890 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4891 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4892
Dario Frenid1011272018-07-23 20:20:15 +01004893# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004894# A zip of the symbols directory. Keep the full paths to make it
4895# more obvious where these files came from.
4896#
4897name := $(TARGET_PRODUCT)
4898ifeq ($(TARGET_BUILD_TYPE),debug)
4899 name := $(name)_debug
4900endif
4901name := $(name)-symbols-$(FILE_NAME_TAG)
4902
4903SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004904# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07004905ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004906$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004907 $(INSTALLED_RAMDISK_TARGET) \
4908 $(INSTALLED_BOOTIMAGE_TARGET) \
4909 $(INSTALLED_USERDATAIMAGE_TARGET) \
4910 $(INSTALLED_VENDORIMAGE_TARGET) \
4911 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004912 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004913 $(INSTALLED_ODMIMAGE_TARGET) \
4914 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004915endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004916$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4917$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004918 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004919 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4920 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004921 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004922 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004923# -----------------------------------------------------------------
4924# A zip of the coverage directory.
4925#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004926name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004927ifeq ($(TARGET_BUILD_TYPE),debug)
4928name := $(name)_debug
4929endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004930COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
4931ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004932$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004933 $(INSTALLED_RAMDISK_TARGET) \
4934 $(INSTALLED_BOOTIMAGE_TARGET) \
4935 $(INSTALLED_USERDATAIMAGE_TARGET) \
4936 $(INSTALLED_VENDORIMAGE_TARGET) \
4937 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004938 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004939 $(INSTALLED_ODMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004940endif
4941$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4942$(COVERAGE_ZIP): $(SOONG_ZIP)
4943 @echo "Package coverage: $@"
4944 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4945 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4946 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4947 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004948
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004949#------------------------------------------------------------------
4950# Export the LLVM profile data tool and dependencies for Clang coverage processing
4951#
4952ifeq (true,$(CLANG_COVERAGE))
4953 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4954 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4955 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4956 $(PROFDATA_ZIP): $(SOONG_ZIP)
4957 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4958
4959 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4960endif
4961
The Android Open Source Project88b60792009-03-03 19:28:42 -08004962# -----------------------------------------------------------------
4963# A zip of the Android Apps. Not keeping full path so that we don't
4964# include product names when distributing
4965#
4966name := $(TARGET_PRODUCT)
4967ifeq ($(TARGET_BUILD_TYPE),debug)
4968 name := $(name)_debug
4969endif
4970name := $(name)-apps-$(FILE_NAME_TAG)
4971
4972APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004973$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004974 @echo "Package apps: $@"
4975 $(hide) rm -rf $@
4976 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004977 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4978 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004979 echo "No apps to zip up. Generating empty apps archive." ; \
4980 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004981 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004982 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004983 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004984
Ying Wangbc415dd2012-08-15 12:22:44 -07004985ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004986#------------------------------------------------------------------
4987# An archive of classes for use in generating code-coverage reports
4988# These are the uninstrumented versions of any classes that were
4989# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004990# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004991
Colin Crossa6bc3a82017-09-27 14:28:41 -07004992JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004993$(JACOCO_REPORT_CLASSES_ALL) :
4994 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004995 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4996 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004997
Ying Wangbc415dd2012-08-15 12:22:44 -07004998endif # EMMA_INSTRUMENT=true
4999
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005000
Ying Wangae9115a2013-08-22 20:52:47 -07005001#------------------------------------------------------------------
5002# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07005003#
Ying Wangc62c92c2013-08-28 18:38:25 -07005004PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07005005# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5006ifndef TARGET_BUILD_APPS
5007$(PROGUARD_DICT_ZIP): \
5008 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5009 $(INSTALLED_RAMDISK_TARGET) \
5010 $(INSTALLED_BOOTIMAGE_TARGET) \
5011 $(INSTALLED_USERDATAIMAGE_TARGET) \
5012 $(INSTALLED_VENDORIMAGE_TARGET) \
5013 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5014 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5015 $(INSTALLED_ODMIMAGE_TARGET) \
5016 $(updater_dep)
5017endif
5018$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
5019$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07005020 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07005021 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5022 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
5023 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
5024 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07005025
Tao Bao48a2feb2019-06-28 11:00:05 -07005026
5027ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5028
5029# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5030# $(1): output file
5031define dump-super-image-info
5032 $(call dump-dynamic-partitions-info,$(1))
5033 $(if $(filter true,$(AB_OTA_UPDATER)), \
5034 echo "ab_update=true" >> $(1))
5035endef
5036
5037endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5038
The Android Open Source Project88b60792009-03-03 19:28:42 -08005039# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005040# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005041
5042ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5043
5044# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5045ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5046
5047ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005048
5049# For real devices and for dist builds, build super image from target files to an intermediate directory.
5050INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5051$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5052$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5053 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005054 PATH=$(dir $(LPMAKE)):$$PATH \
5055 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005056
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005057# Skip packing it in dist package because it is in update package.
5058ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005059$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005060endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005061
5062.PHONY: superimage_dist
5063superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005064
5065endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005066endif # BOARD_SUPER_PARTITION_SIZE != ""
5067endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005068
Yifan Hongacd862a2019-04-16 15:44:30 -07005069# -----------------------------------------------------------------
5070# super partition image for development
5071
5072ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5073ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5074ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5075
5076# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5077# $(1): built image path
5078# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5079define build-superimage-target
5080 mkdir -p $(dir $(2))
5081 rm -rf $(2)
5082 $(call dump-super-image-info,$(2))
5083 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5084 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005085 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5086 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005087 mkdir -p $(dir $(1))
5088 PATH=$(dir $(LPMAKE)):$$PATH \
5089 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5090endef
5091
5092INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5093INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5094 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5095
changho.shina8f9f112019-10-15 13:26:19 +09005096ifdef BUILDING_SYSTEM_OTHER_IMAGE
5097ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5098INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5099endif
5100endif
5101
Yifan Hongacd862a2019-04-16 15:44:30 -07005102# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5103# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5104# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5105# virtual devices.
5106ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5107$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5108 $(call pretty,"Target super fs image for debug: $@")
5109 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005110 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005111
5112droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5113
5114# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5115.PHONY: superimage
5116superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005117
5118$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005119endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5120
5121# Build $(PRODUCT_OUT)/super.img without dependencies.
5122.PHONY: superimage-nodeps supernod
5123superimage-nodeps supernod: intermediates :=
5124superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5125 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5126 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5127 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5128
5129endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5130endif # BOARD_SUPER_PARTITION_SIZE != ""
5131endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5132
5133# -----------------------------------------------------------------
5134# super empty image
5135
Tao Bao48a2feb2019-06-28 11:00:05 -07005136ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005137ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005138
Yifan Hong8b79d162018-11-29 12:32:00 -08005139INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5140$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5141$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5142 $(call pretty,"Target empty super fs image: $@")
5143 mkdir -p $(intermediates)
5144 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005145 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005146 PATH=$(dir $(LPMAKE)):$$PATH \
5147 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005148
5149$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5150
Yifan Hong2b891ac2018-11-29 12:06:31 -08005151endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005152endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005153
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005154
5155# -----------------------------------------------------------------
5156# The update package
5157
5158name := $(TARGET_PRODUCT)
5159ifeq ($(TARGET_BUILD_TYPE),debug)
5160 name := $(name)_debug
5161endif
5162name := $(name)-img-$(FILE_NAME_TAG)
5163
5164INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5165
Tao Bao57f8ed62019-08-14 23:08:18 -07005166$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5167 $(call pretty,"Package: $@")
5168 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5169 $(IMG_FROM_TARGET_FILES) \
5170 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5171 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005172
5173.PHONY: updatepackage
5174updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005175$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005176
5177
Yifan Hong2b891ac2018-11-29 12:06:31 -08005178# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005179# dalvik something
5180.PHONY: dalvikfiles
5181dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5182
Bo Huf0d50bb2017-08-01 19:02:09 +00005183ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005184MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005185MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005186SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005187
5188ifdef INSTALLED_SYSTEMIMAGE_TARGET
5189INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005190INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5191$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5192 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5193 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005194$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005195 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5196 @echo Create system-qemu.img now
5197 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005198 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005199
5200systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5201droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005202endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005203ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005204INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005205$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005206 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005207 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005208
5209vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5210droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5211endif
bohu8fd437c2020-03-30 20:16:13 -07005212
5213ifdef INSTALLED_RAMDISK_TARGET
5214ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5215ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5216INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5217$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5218 @echo Create ramdisk-qemu.img
5219 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5220
5221droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5222endif
5223endif
5224endif
5225
Anton Hansson32c76fe2018-12-13 14:34:18 +00005226ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005227INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005228$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005229 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005230 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005231
5232productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5233droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5234endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005235ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5236INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5237$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5238 @echo Create system_ext-qemu.img
5239 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005240
Justin Yun6151e3f2019-06-25 15:58:13 +09005241systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5242droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005243endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005244ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005245INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5246$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5247 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005248 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005249
5250odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5251droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5252endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005253
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005254QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005255$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5256 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005257 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005258 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5259 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005260
5261systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5262droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005263
Bo Huf0d50bb2017-08-01 19:02:09 +00005264endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005265# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005266# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005267ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005268INTERNAL_EMULATOR_PACKAGE_FILES += \
5269 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005270 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005271 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005272 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5273 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005274
5275name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5276
5277INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5278
Ying Wang5d887702015-11-04 10:06:25 -08005279$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005280 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005281 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005282
Ying Wang7d8c5352012-07-26 10:15:21 -07005283endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005284# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005285# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005286# The pdk package (Platform Development Kit)
5287
Keun young Park7fc7aad2012-02-27 15:49:23 -08005288#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5289# include development/pdk/Pdk.mk
5290#endif
5291
The Android Open Source Project88b60792009-03-03 19:28:42 -08005292
5293# -----------------------------------------------------------------
5294# The SDK
5295
The Android Open Source Project88b60792009-03-03 19:28:42 -08005296# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005297sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005298
5299# Build a name that looks like:
5300#
5301# linux-x86 --> android-sdk_12345_linux-x86
5302# darwin-x86 --> android-sdk_12345_mac-x86
5303# windows-x86 --> android-sdk_12345_windows
5304#
5305sdk_name := android-sdk_$(FILE_NAME_TAG)
5306ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005307 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005308else
Joe Onorato03fbe402009-04-13 08:31:16 -07005309 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005310endif
5311ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005312 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005313endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005314sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005315
5316sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5317
5318ATREE_FILES :=
5319-include $(sdk_dep_file)
5320
5321# if we don't have a real list, then use "everything"
5322ifeq ($(strip $(ATREE_FILES)),)
5323ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005324 $(ALL_DEFAULT_INSTALLED_MODULES) \
5325 $(INSTALLED_RAMDISK_TARGET) \
5326 $(ALL_DOCS) \
5327 $(ALL_SDK_FILES)
5328endif
5329
5330atree_dir := development/build
5331
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005332
The Android Open Source Project88b60792009-03-03 19:28:42 -08005333sdk_atree_files := \
5334 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005335 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005336
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005337# development/build/sdk-android-<abi>.atree is used to differentiate
5338# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5339# files like the kernel image. We use TARGET_CPU_ABI because we don't
5340# have a better way to distinguish between CPU models.
5341ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5342 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5343endif
5344
Anton Hansson8dab0a62019-03-28 15:45:40 +00005345ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5346sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005347else
5348sdk_atree_files += $(atree_dir)/sdk.atree
5349endif
5350
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005351include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005352
The Android Open Source Project88b60792009-03-03 19:28:42 -08005353deps := \
5354 $(target_notice_file_txt) \
5355 $(tools_notice_file_txt) \
5356 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005357 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005358 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005359 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005360 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005361 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005362 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005363 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005364 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005365 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005366 $(INSTALLED_USERDATAIMAGE_TARGET) \
5367 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005368 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005369 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005370 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005371 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005372 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005373 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005374 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005375
5376INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5377$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5378$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5379$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5380$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5381
5382# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5383#
5384#SDK_GNU_ERROR := true
5385
Ying Wang5d887702015-11-04 10:06:25 -08005386$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005387 @echo "Package SDK: $@"
5388 $(hide) rm -rf $(PRIVATE_DIR) $@
5389 $(hide) for f in $(target_gnu_MODULES); do \
5390 if [ -f $$f ]; then \
5391 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5392 including GNU target $$f >&2; \
5393 FAIL=$(SDK_GNU_ERROR); \
5394 fi; \
5395 done; \
5396 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005397 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005398 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005399 ATREE_STRIP="$(HOST_STRIP) -x" \
5400 $(HOST_OUT_EXECUTABLES)/atree \
5401 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5402 -m $(PRIVATE_DEP_FILE) \
5403 -I . \
5404 -I $(PRODUCT_OUT) \
5405 -I $(HOST_OUT) \
5406 -I $(TARGET_COMMON_OUT_ROOT) \
5407 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5408 -v "OUT_DIR=$(OUT_DIR)" \
5409 -v "HOST_OUT=$(HOST_OUT)" \
5410 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5411 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5412 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5413 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5414 -o $(PRIVATE_DIR) && \
5415 cp -f $(target_notice_file_txt) \
5416 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5417 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5418 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5419 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5420 chmod -R ug+rwX $(PRIVATE_DIR) && \
5421 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005422 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5423
Raphael3d224a02010-04-16 17:50:09 -07005424
5425# Is a Windows SDK requested? If so, we need some definitions from here
5426# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005427MAIN_SDK_NAME := $(sdk_name)
5428MAIN_SDK_DIR := $(sdk_dir)
5429MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005430ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005431include $(TOPDIR)development/build/tools/windows_sdk.mk
5432endif
5433
The Android Open Source Project88b60792009-03-03 19:28:42 -08005434# -----------------------------------------------------------------
5435# Findbugs
5436INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5437INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5438$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5439 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005440 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005441 > $@
5442$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5443 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005444 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005445 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005446
5447# -----------------------------------------------------------------
5448# Findbugs
5449
5450# -----------------------------------------------------------------
5451# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005452ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005453include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005454-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005455-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005456-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005457# Also the project-specific tasks
5458-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5459-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005460-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005461# Also add test specifc tasks
5462include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005463include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005464endif
Raphaelc4d47312011-02-15 16:09:36 -08005465
Ying Wang67132ba2015-10-28 16:42:39 -07005466include $(BUILD_SYSTEM)/product-graph.mk
5467
Raphaelc4d47312011-02-15 16:09:36 -08005468# -----------------------------------------------------------------
5469# Create SDK repository packages. Must be done after tasks/* since
5470# we need the addon rules defined.
5471ifneq ($(sdk_repo_goal),)
5472include $(TOPDIR)development/build/tools/sdk_repo.mk
5473endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005474
5475# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005476# Soong generates the list of all shared libraries that are depended on by fuzz
5477# targets. It saves this list as a source:destination pair to
5478# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5479# build of the unstripped shared library, and the destination is the
5480# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5481# where fuzz target shared libraries are to be "reinstalled". The
5482# copy-many-files below generates the rules to copy the unstripped shared
5483# libraries to the device or host "reinstallation" directory. These rules are
5484# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5485# a dependency on each shared library that it needs to be "reinstalled".
5486FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5487
5488# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005489# The rule to build all fuzz targets, and package them.
5490# Note: The packages are created in Soong, and in a perfect world,
5491# we'd be able to create the phony rule there. But, if we want to
5492# have dist goals for the fuzz target, we need to have the PHONY
5493# target defined in make. MakeVarsContext.DistForGoal doesn't take
5494# into account that a PHONY rule create by Soong won't be available
5495# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005496# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005497# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005498.PHONY: haiku
5499haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5500$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005501
5502# -----------------------------------------------------------------
5503# The makefile for haiku line coverage.
5504include $(BUILD_SYSTEM)/line_coverage.mk