blob: d01340c082343ec15d50729813c6e5ffa22b909c [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
Ying Wang619fccf2012-09-05 18:08:29 -070042# filter out the duplicate <source file>:<dest file> pairs.
43unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080044$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070045 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
46 $(eval unique_product_copy_files_pairs += $(cf))))
47unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080048product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070049$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070050 $(eval _src := $(call word-colon,1,$(cf))) \
51 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070052 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080053 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080054 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070055 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070056 $(if $(filter %.xml,$(_dest)),\
57 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010058 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
59 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070060 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
61 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
62 $(eval $(call copy-one-file,$(_src),$(_fulldest)))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070063 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080064
65# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070066pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
67$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
68$(pcf_ignored_file):
69 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080070
Dan Willemsen7537fd02018-10-16 23:15:08 -070071$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
72
73pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080074product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070075unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070076unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080077
78# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080079# Returns the max allowed size for an image suitable for hash verification
80# (e.g., boot.img, recovery.img, etc).
81# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
82# $(1): partition size to flash the image
83define get-hash-image-max-size
84$(if $(1), \
85 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
86 $(eval _hash_meta_size := 69632), \
87 $(eval _hash_meta_size := 0)) \
88 $(1)-$(_hash_meta_size))
89endef
90
91# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -080092# Define rules to copy headers defined in copy_headers.mk
93# If more than one makefile declared a header, print a warning,
94# then copy the last one defined. This matches the previous make
95# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -070096has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -080097$(foreach dest,$(ALL_COPIED_HEADERS), \
98 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -080099 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800100 $(if $(call streq,$(_src),$(_srcs)),, \
101 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800102 $(warning _ Using $(_src)) \
103 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
104 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
105 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
106 $(warning _ Ignoring $(src)) \
107 $(warning __ from $(firstword $(_makefiles))) \
108 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
109 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800110 $(eval $(call copy-one-header,$(_src),$(dest))))
111all_copied_headers: $(ALL_COPIED_HEADERS)
112
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700113ifdef has_dup_copy_headers
114 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700115 $(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 -0700116endif
117
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800118$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
119
Dan Willemsen6f60f022016-02-23 13:40:07 -0800120# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -0700122ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800123gen := $(OUT_DOCS)/index.html
124ALL_DOCS += $(gen)
125$(gen): frameworks/base/docs/docs-redirect-index.html
126 @mkdir -p $(dir $@)
127 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700128endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800129
Dan Albert303e6032017-10-04 10:20:20 -0700130ndk_doxygen_out := $(OUT_NDK_DOCS)
131ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
132ndk_docs_src_dir := frameworks/native/docs
133ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
134ifneq ($(wildcard $(ndk_docs_src_dir)),)
135ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
136 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
137$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
138 @mkdir -p $(ndk_doxygen_out)
139 @echo "Generating NDK docs to $(ndk_doxygen_out)"
140 @( cat $(ndk_doxyfile); \
141 echo "INPUT=$(ndk_headers)"; \
142 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
143 ) | doxygen -
144
145# Note: Not a part of the docs target because we don't have doxygen available.
146# You can run this target locally if you have doxygen installed.
147ndk-docs: $(ndk_doxygen_out)/index.html
148.PHONY: ndk-docs
149endif
150
Colin Crossd60401a2019-04-18 14:46:48 -0700151$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800152
153# -----------------------------------------------------------------
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900154# property_overrides_split_enabled
155property_overrides_split_enabled :=
156ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
157 property_overrides_split_enabled := true
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900158endif
159
160# -----------------------------------------------------------------
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900161# FINAL_VENDOR_DEFAULT_PROPERTIES will be installed in vendor/default.prop if
162# property_overrides_split_enabled is true. Otherwise it will be installed in
163# ROOT/default.prop.
164ifdef BOARD_VNDK_VERSION
165 ifeq ($(BOARD_VNDK_VERSION),current)
166 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
167 else
168 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(BOARD_VNDK_VERSION)
169 endif
Logan Chiend73b94c2018-05-04 19:33:17 +0800170 ifdef BOARD_VNDK_RUNTIME_DISABLE
171 FINAL_VENDOR_DEFAULT_PROPERTIES += ro.vndk.lite=true
172 endif
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900173else
Logan Chiend73b94c2018-05-04 19:33:17 +0800174 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
175 FINAL_VENDOR_DEFAULT_PROPERTIES += ro.vndk.lite=true
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900176endif
177FINAL_VENDOR_DEFAULT_PROPERTIES += \
178 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
Tao Bao5f999232018-09-04 11:42:53 -0700179
Anton Hansson30851f22019-02-21 11:51:26 +0000180# Add cpu properties for bionic and ART.
Haibo Huangee0531d2018-11-04 09:20:09 -0800181FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.arch=$(TARGET_ARCH)
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000182FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.cpu_variant=$(TARGET_CPU_VARIANT_RUNTIME)
Haibo Huangee0531d2018-11-04 09:20:09 -0800183FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.2nd_arch=$(TARGET_2ND_ARCH)
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000184FINAL_VENDOR_DEFAULT_PROPERTIES += ro.bionic.2nd_cpu_variant=$(TARGET_2ND_CPU_VARIANT_RUNTIME)
Haibo Huangee0531d2018-11-04 09:20:09 -0800185
Anton Hansson30851f22019-02-21 11:51:26 +0000186FINAL_VENDOR_DEFAULT_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart.so
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000187FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT_RUNTIME)
Anton Hansson30851f22019-02-21 11:51:26 +0000188ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
189 FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
190endif
191
192ifdef TARGET_2ND_ARCH
Anton Hansson71b7f7f2019-02-21 11:36:37 +0000193 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 +0000194 ifneq ($($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
195 FINAL_VENDOR_DEFAULT_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
196 endif
197endif
198
Tao Bao5f999232018-09-04 11:42:53 -0700199# Although these variables are prefixed with TARGET_RECOVERY_, they are also needed under charger
200# mode (via libminui).
201ifdef TARGET_RECOVERY_DEFAULT_ROTATION
202FINAL_VENDOR_DEFAULT_PROPERTIES += \
203 ro.minui.default_rotation=$(TARGET_RECOVERY_DEFAULT_ROTATION)
204endif
205ifdef TARGET_RECOVERY_OVERSCAN_PERCENT
206FINAL_VENDOR_DEFAULT_PROPERTIES += \
207 ro.minui.overscan_percent=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
208endif
209ifdef TARGET_RECOVERY_PIXEL_FORMAT
210FINAL_VENDOR_DEFAULT_PROPERTIES += \
211 ro.minui.pixel_format=$(TARGET_RECOVERY_PIXEL_FORMAT)
212endif
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900213FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
214 $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
215
216# -----------------------------------------------------------------
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800217# prop.default
Anton Hansson1f8729e2018-08-15 12:11:55 +0100218
219BUILDINFO_SH := build/make/tools/buildinfo.sh
220BUILDINFO_COMMON_SH := build/make/tools/buildinfo_common.sh
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700221POST_PROCESS_PROPS :=$= build/make/tools/post_process_props.py
Anton Hanssonee4c9702018-12-21 15:36:00 +0000222
223# Generates a set of sysprops common to all partitions to a file.
Anton Hansson1f8729e2018-08-15 12:11:55 +0100224# $(1): Partition name
225# $(2): Output file name
226define generate-common-build-props
Anton Hanssonee4c9702018-12-21 15:36:00 +0000227 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
228 PRODUCT_DEVICE="$(TARGET_DEVICE)" \
229 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
230 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
231 PRODUCT_NAME="$(TARGET_PRODUCT)" \
232 $(call generate-common-build-props-with-product-vars-set,$(1),$(2))
233endef
234
235# Like the above macro, but requiring the relevant PRODUCT_ environment
236# variables to be set when called.
237define generate-common-build-props-with-product-vars-set
Anton Hansson1f8729e2018-08-15 12:11:55 +0100238 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
239 BUILD_ID="$(BUILD_ID)" \
240 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
241 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
242 DATE="$(DATE_FROM_FILE)" \
243 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
244 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
Anton Hansson1f8729e2018-08-15 12:11:55 +0100245 TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Anton Hansson1f8729e2018-08-15 12:11:55 +0100246 bash $(BUILDINFO_COMMON_SH) "$(1)" >> $(2)
247endef
248
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800249ifdef property_overrides_split_enabled
250INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800251INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
252ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
253$(INSTALLED_DEFAULT_PROP_OLD_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800254else
255# legacy path
The Android Open Source Project88b60792009-03-03 19:28:42 -0800256INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800257endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800258ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900259FINAL_DEFAULT_PROPERTIES := \
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900260 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) \
261 $(call collapse-pairs, $(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900262ifndef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900263 FINAL_DEFAULT_PROPERTIES += \
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900264 $(call collapse-pairs, $(FINAL_VENDOR_DEFAULT_PROPERTIES))
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900265endif
Jaekyun Seok294286d2017-01-20 13:17:12 +0900266FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
267 $(FINAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800268
Andres Moralesb8876e12015-05-06 20:44:22 -0700269intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
270
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700271$(INSTALLED_DEFAULT_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(intermediate_system_build_prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800272 @echo Target buildinfo: $@
273 @mkdir -p $(dir $@)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800274 @rm -f $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800275 $(hide) echo "#" > $@; \
276 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
277 echo "#" >> $@;
Jaekyun Seok294286d2017-01-20 13:17:12 +0900278 $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000279 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700280 $(hide) $(POST_PROCESS_PROPS) $@
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800281ifdef property_overrides_split_enabled
282 $(hide) mkdir -p $(TARGET_ROOT_OUT)
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800283 $(hide) ln -sf system/etc/prop.default $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800284endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800285
286# -----------------------------------------------------------------
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900287# vendor default.prop
288INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900289ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900290INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
291ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
292
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700293$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET) $(POST_PROCESS_PROPS)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900294 @echo Target buildinfo: $@
295 @mkdir -p $(dir $@)
296 $(hide) echo "#" > $@; \
297 echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
298 echo "#" >> $@;
299 $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000300 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700301 $(hide) $(POST_PROCESS_PROPS) $@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900302
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900303endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900304
305# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800306# build.prop
307INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
308ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900309FINAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -0700310 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
Jaekyun Seok294286d2017-01-20 13:17:12 +0900311FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
312 $(FINAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800313
314# A list of arbitrary tags describing the build configuration.
315# Force ":=" so we can use +=
316BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
317ifeq ($(TARGET_BUILD_TYPE),debug)
318 BUILD_VERSION_TAGS += debug
319endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700320# The "test-keys" tag marks builds signed with the old test keys,
321# which are available in the SDK. "dev-keys" marks builds signed with
322# non-default dev keys (usually private keys from a vendor directory).
323# Both of these tags will be removed and replaced with "release-keys"
324# when the target-files is signed in a post-build step.
Dan Willemsen0ab1be62019-04-09 21:35:37 -0700325ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700326BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700327else
Doug Zongkera8608a72013-07-23 11:51:04 -0700328BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700329endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700330BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800331BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
332
333# A human-readable string that descibes this build in detail.
Colin Crossf37b4552015-07-16 17:15:19 -0700334build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS)
Andres Moralesb8876e12015-05-06 20:44:22 -0700335$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800336
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700337# 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 -0800338ifeq (,$(strip $(BUILD_FINGERPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800339 ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
Dan Willemsen63e48db2019-01-02 12:27:43 -0800340 BF_BUILD_NUMBER := $(BUILD_USERNAME)$$($(DATE_FROM_FILE) +%m%d%H%M)
Ying Wang50367cc2014-06-12 18:42:53 -0700341 else
Nan Zhang0abdb582018-02-20 17:00:39 -0800342 BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE))
Ying Wang50367cc2014-06-12 18:42:53 -0700343 endif
344 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 -0800345endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800346# unset it for safety.
347BF_BUILD_NUMBER :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800348
Nan Zhang0abdb582018-02-20 17:00:39 -0800349BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt
350ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE) && grep " " $(BUILD_FINGERPRINT_FILE)))
351 $(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))")
352endif
353BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE))
354# unset it for safety.
355BUILD_FINGERPRINT :=
Colin Crossf37b4552015-07-16 17:15:19 -0700356
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700357# The string used to uniquely identify the system build; used by the OTA server.
358# This purposefully excludes any product-specific variables.
359ifeq (,$(strip $(BUILD_THUMBPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800360 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700361endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800362
363BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt
364ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE)))
365 $(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))")
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700366endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800367BUILD_THUMBPRINT_FROM_FILE := $$(cat $(BUILD_THUMBPRINT_FILE))
368# unset it for safety.
369BUILD_THUMBPRINT :=
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700370
Ying Wange24e17a2014-10-07 18:42:11 -0700371KNOWN_OEM_THUMBPRINT_PROPERTIES := \
372 ro.product.brand \
373 ro.product.name \
374 ro.product.device
375OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
Anton Hansson8dab0a62019-03-28 15:45:40 +0000376 $(PRODUCT_OEM_PROPERTIES))
Ying Wange24e17a2014-10-07 18:42:11 -0700377
Sriram Raman7b641242009-03-24 22:40:59 -0700378# Display parameters shown under Settings -> About Phone
379ifeq ($(TARGET_BUILD_VARIANT),user)
380 # User builds should show:
381 # release build number or branch.buld_number non-release builds
382
383 # Dev. branches should have DISPLAY_BUILD_NUMBER set
Colin Cross63fe36a2017-02-21 17:23:02 -0800384 ifeq (true,$(DISPLAY_BUILD_NUMBER))
Colin Crossf37b4552015-07-16 17:15:19 -0700385 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700386 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700387 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700388 endif
389else
390 # Non-user builds should show detailed build information
391 BUILD_DISPLAY_ID := $(build_desc)
392endif
393
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000394# Accepts a whitespace separated list of product locales such as
395# (en_US en_AU en_GB...) and returns the first locale in the list with
396# underscores replaced with hyphens. In the example above, this will
397# return "en-US".
398define get-default-product-locale
399$(strip $(subst _,-, $(firstword $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800400endef
401
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700402# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test
403# harness to distinguish builds. Only add _asan for a sanitized build
404# if it isn't already a part of the flavor (via a dedicated lunch
405# config for example).
Ying Wang21ec03d2015-10-28 18:45:03 -0700406TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
Ivan Lozano0f71db32017-08-14 07:57:37 -0700407ifneq (, $(filter address, $(SANITIZE_TARGET)))
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700408ifeq (,$(findstring _asan,$(TARGET_BUILD_FLAVOR)))
Ying Wang21ec03d2015-10-28 18:45:03 -0700409TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
410endif
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700411endif
Ying Wang21ec03d2015-10-28 18:45:03 -0700412
Andrew Boiefa61ff02012-09-28 09:33:45 -0700413ifdef TARGET_SYSTEM_PROP
414system_prop_file := $(TARGET_SYSTEM_PROP)
415else
416system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
417endif
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700418$(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 -0800419 @echo Target buildinfo: $@
420 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700421 $(hide) echo > $@
Anton Hansson8dab0a62019-03-28 15:45:40 +0000422ifneq ($(PRODUCT_OEM_PROPERTIES),)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700423 $(hide) echo "#" >> $@; \
424 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700425 echo "#" >> $@;
Anton Hansson8dab0a62019-03-28 15:45:40 +0000426 $(hide) $(foreach prop,$(PRODUCT_OEM_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000427 echo "import /oem/oem.prop $(prop)" >> $@;)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700428endif
Anton Hanssonee4c9702018-12-21 15:36:00 +0000429 $(hide) PRODUCT_BRAND="$(PRODUCT_SYSTEM_BRAND)" \
430 PRODUCT_MANUFACTURER="$(PRODUCT_SYSTEM_MANUFACTURER)" \
431 PRODUCT_MODEL="$(PRODUCT_SYSTEM_MODEL)" \
432 PRODUCT_NAME="$(PRODUCT_SYSTEM_NAME)" \
433 PRODUCT_DEVICE="$(PRODUCT_SYSTEM_DEVICE)" \
434 $(call generate-common-build-props-with-product-vars-set,system,$@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800435 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000436 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
437 TARGET_DEVICE="$(TARGET_DEVICE)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000438 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
439 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000440 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
441 BUILD_ID="$(BUILD_ID)" \
442 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
443 DATE="$(DATE_FROM_FILE)" \
Dan Willemsen63e48db2019-01-02 12:27:43 -0800444 BUILD_USERNAME="$(BUILD_USERNAME)" \
445 BUILD_HOSTNAME="$(BUILD_HOSTNAME)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000446 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
447 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000448 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
449 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
450 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
451 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
452 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \
Colin Crossd60401a2019-04-18 14:46:48 -0700453 PLATFORM_PREVIEW_SDK_FINGERPRINT="$$(cat $(API_FINGERPRINT))" \
Anton Hansson6d814982018-11-26 18:12:05 +0000454 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
455 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
456 PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION="$(PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)" \
457 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
Anton Hansson6d814982018-11-26 18:12:05 +0000458 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT_FROM_FILE)") \
459 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
460 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
461 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
462 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
463 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700464 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200465 $(hide) $(foreach file,$(system_prop_file), \
Anton Hansson6d814982018-11-26 18:12:05 +0000466 if [ -f "$(file)" ]; then \
467 echo Target buildinfo from: "$(file)"; \
468 echo "" >> $@; \
469 echo "#" >> $@; \
470 echo "# from $(file)" >> $@; \
471 echo "#" >> $@; \
472 cat $(file) >> $@; \
473 echo "# end of $(file)" >> $@; \
474 fi;)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900475 $(if $(FINAL_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000476 $(hide) echo >> $@; \
477 echo "#" >> $@; \
478 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
479 echo "#" >> $@; )
Jaekyun Seok294286d2017-01-20 13:17:12 +0900480 $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000481 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700482 $(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800483
484build_desc :=
485
Andres Moralesb8876e12015-05-06 20:44:22 -0700486INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700487ifdef BUILDING_RECOVERY_IMAGE
488ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
489INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
490endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700491endif
492
Jooyung Han72b65ab2019-05-23 19:48:13 +0900493$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop)
Andres Moralesb8876e12015-05-06 20:44:22 -0700494 @echo "Target build info: $@"
Steven Morelandec082652017-10-22 02:11:47 -0700495 $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@
Andres Moralesb8876e12015-05-06 20:44:22 -0700496
The Android Open Source Project88b60792009-03-03 19:28:42 -0800497# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700498# vendor build.prop
499#
Alex Naidis47e24e92016-01-10 14:18:54 +0000500# For verifying that the vendor build is what we think it is
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700501INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
502ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900503
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900504ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900505FINAL_VENDOR_BUILD_PROPERTIES += \
506 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
507FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
508 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900509endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900510
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700511$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(intermediate_system_build_prop)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700512 @echo Target vendor buildinfo: $@
513 @mkdir -p $(dir $@)
514 $(hide) echo > $@
Hridya Valsaraju1fd498d2019-05-07 10:28:49 -0700515ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
516 $(hide) echo ro.boot.dynamic_partitions=true >> $@
517endif
518ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
519 $(hide) echo ro.boot.dynamic_partitions_retrofit=true >> $@
520endif
Sandeep Patil127f5012017-10-23 19:47:43 -0700521 $(hide) grep 'ro.product.first_api_level' $(intermediate_system_build_prop) >> $@ || true
Max Biresa1749982018-03-28 15:48:13 -0700522 $(hide) echo ro.vendor.build.security_patch="$(VENDOR_SECURITY_PATCH)">>$@
Isaac Chen8d11feb2018-01-31 14:27:37 +0800523 $(hide) echo ro.vendor.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
524 $(hide) echo ro.vendor.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
525 $(hide) echo ro.vendor.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Anton Hansson1f8729e2018-08-15 12:11:55 +0100526 $(hide) echo ro.product.board="$(TARGET_BOOTLOADER_BOARD_NAME)">>$@
527 $(hide) echo ro.board.platform="$(TARGET_BOARD_PLATFORM)">>$@
Stan Iliev144d26a2018-12-14 13:18:05 -0500528 $(hide) echo ro.hwui.use_vulkan="$(TARGET_USES_VULKAN)">>$@
Anton Hansson45a40da2019-01-18 14:06:34 +0000529ifdef TARGET_SCREEN_DENSITY
530 $(hide) echo ro.sf.lcd_density="$(TARGET_SCREEN_DENSITY)">>$@
531endif
Tao Bao67932ab2019-04-19 00:09:16 -0700532ifeq ($(AB_OTA_UPDATER),true)
533 $(hide) echo ro.build.ab_update=true >> $@
534endif
Anton Hansson1f8729e2018-08-15 12:11:55 +0100535 $(hide) $(call generate-common-build-props,vendor,$@)
Anton Hansson15794ca2019-04-08 17:47:35 +0100536 $(hide) echo "#" >> $@; \
537 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
538 echo "#" >> $@;
Anton Hanssonf2998892019-04-29 15:39:10 +0100539 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
540 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
541 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900542 $(hide) echo "#" >> $@; \
543 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
544 echo "#" >> $@;
Anton Hanssonc65ebaf2019-04-09 16:21:51 +0100545 $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@
546ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900547 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000548 echo "$(line)" >> $@;)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900549endif # property_overrides_split_enabled
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700550 $(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_VENDOR_PROPERTY_BLACKLIST)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700551
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900552# -----------------------------------------------------------------
553# product build.prop
554INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
555ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
556
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000557ifdef TARGET_PRODUCT_PROP
558product_prop_files := $(TARGET_PRODUCT_PROP)
559else
560product_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/product.prop)
561endif
562
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900563FINAL_PRODUCT_PROPERTIES += \
Yifan Hongaf9e7f02018-07-27 13:11:50 -0700564 $(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES) $(ADDITIONAL_PRODUCT_PROPERTIES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900565FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \
566 $(FINAL_PRODUCT_PROPERTIES),=)
567
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700568$(INSTALLED_PRODUCT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(product_prop_files)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900569 @echo Target product buildinfo: $@
570 @mkdir -p $(dir $@)
571 $(hide) echo > $@
572ifdef BOARD_USES_PRODUCTIMAGE
Anton Hansson1f8729e2018-08-15 12:11:55 +0100573 $(hide) $(call generate-common-build-props,product,$@)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900574endif # BOARD_USES_PRODUCTIMAGE
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000575 $(hide) $(foreach file,$(product_prop_files), \
Anton Hansson6d814982018-11-26 18:12:05 +0000576 if [ -f "$(file)" ]; then \
577 echo Target product properties from: "$(file)"; \
578 echo "" >> $@; \
579 echo "#" >> $@; \
580 echo "# from $(file)" >> $@; \
581 echo "#" >> $@; \
582 cat $(file) >> $@; \
583 echo "# end of $(file)" >> $@; \
584 fi;)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900585 $(hide) echo "#" >> $@; \
586 echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \
Anton Hansson5ac408b2018-11-05 17:29:28 +0000587 echo "#" >> $@; \
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000588 echo "ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)" >> $@;
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900589 $(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000590 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700591 $(hide) $(POST_PROCESS_PROPS) $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900592
Andres Morales9c820f82015-01-13 15:30:34 -0800593# ----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800594# odm build.prop
Bowgo Tsai71a4d5c2019-05-17 23:21:48 +0800595INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/etc/build.prop
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800596ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_ODM_BUILD_PROP_TARGET)
597
598FINAL_ODM_BUILD_PROPERTIES += \
599 $(call collapse-pairs, $(PRODUCT_ODM_PROPERTIES))
600FINAL_ODM_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
601 $(FINAL_ODM_BUILD_PROPERTIES),=)
602
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700603$(INSTALLED_ODM_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800604 @echo Target odm buildinfo: $@
605 @mkdir -p $(dir $@)
606 $(hide) echo > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800607 $(hide) echo ro.odm.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
608 $(hide) echo ro.odm.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
609 $(hide) echo ro.odm.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Anton Hansson1f8729e2018-08-15 12:11:55 +0100610 $(hide) $(call generate-common-build-props,odm,$@)
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800611 $(hide) echo "#" >> $@; \
612 echo "# ADDITIONAL ODM BUILD PROPERTIES" >> $@; \
613 echo "#" >> $@;
614 $(hide) $(foreach line,$(FINAL_ODM_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000615 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700616 $(hide) $(POST_PROCESS_PROPS) $@
Andres Morales9c820f82015-01-13 15:30:34 -0800617
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700618# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +0900619# system_ext build.prop
620INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/build.prop
621ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Dario Freni5f681e12018-05-29 13:09:01 +0100622
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800623ifdef TARGET_SYSTEM_EXT_PROP
624system_ext_prop_files := $(TARGET_SYSTEM_EXT_PROP)
625else
626system_ext_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/system_ext.prop)
627endif
628
Justin Yun6151e3f2019-06-25 15:58:13 +0900629FINAL_SYSTEM_EXT_PROPERTIES += \
630 $(call collapse-pairs, $(PRODUCT_SYSTEM_EXT_PROPERTIES))
631FINAL_SYSTEM_EXT_PROPERTIES := $(call uniq-pairs-by-first-component, \
632 $(FINAL_SYSTEM_EXT_PROPERTIES),=)
633
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800634$(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(system_ext_prop_files)
Justin Yun6151e3f2019-06-25 15:58:13 +0900635 @echo Target system_ext buildinfo: $@
Dario Freni5f681e12018-05-29 13:09:01 +0100636 @mkdir -p $(dir $@)
637 $(hide) echo > $@
Justin Yun6151e3f2019-06-25 15:58:13 +0900638 $(hide) $(call generate-common-build-props,system_ext,$@)
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800639 $(hide) $(foreach file,$(system_ext_prop_files), \
640 if [ -f "$(file)" ]; then \
641 echo Target system_ext properties from: "$(file)"; \
642 echo "" >> $@; \
643 echo "#" >> $@; \
644 echo "# from $(file)" >> $@; \
645 echo "#" >> $@; \
646 cat $(file) >> $@; \
647 echo "# end of $(file)" >> $@; \
648 fi;)
Dario Freni5f681e12018-05-29 13:09:01 +0100649 $(hide) echo "#" >> $@; \
Justin Yun6151e3f2019-06-25 15:58:13 +0900650 echo "# ADDITIONAL SYSTEM_EXT BUILD PROPERTIES" >> $@; \
Dario Freni5f681e12018-05-29 13:09:01 +0100651 echo "#" >> $@;
Justin Yun6151e3f2019-06-25 15:58:13 +0900652 $(hide) $(foreach line,$(FINAL_SYSTEM_EXT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000653 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700654 $(hide) $(POST_PROCESS_PROPS) $@
Dario Freni5f681e12018-05-29 13:09:01 +0100655
656# ----------------------------------------------------------------
657
658# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800659# sdk-build.prop
660#
661# There are certain things in build.prop that we don't want to
662# ship with the sdk; remove them.
663
664# This must be a list of entire property keys followed by
665# "=" characters, without any internal spaces.
666sdk_build_prop_remove := \
667 ro.build.user= \
668 ro.build.host= \
669 ro.product.brand= \
670 ro.product.manufacturer= \
671 ro.product.device=
672# TODO: Remove this soon-to-be obsolete property
673sdk_build_prop_remove += ro.build.product=
674INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
675$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
676 @echo SDK buildinfo: $@
677 @mkdir -p $(dir $@)
678 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000679 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800680 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000681 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800682 $(hide) mv $@.tmp $@
683
684# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700685# kernel modules
686
687# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
688DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
689
690# $(1): modules list
691# $(2): output dir
692# $(3): mount point
693# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700694# $(5): module load list
695# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800696# $(7): module archive
Colin Cross4f60e362019-06-05 11:53:43 -0700697# Returns the a list of src:dest pairs to install the modules using copy-many-files.
698define build-image-kernel-modules
699 $(foreach module,$(1),$(module):$(2)/lib/modules/$(notdir $(module))) \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800700 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2))) \
Colin Cross4f60e362019-06-05 11:53:43 -0700701 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/modules.dep \
Steve Muckle474e4d02019-06-19 12:56:48 -0700702 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/modules.alias \
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700703 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/modules.softdep \
Steve Muckle474e4d02019-06-19 12:56:48 -0700704 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700705endef
706
707# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700708# $(2): mount point
709# $(3): staging dir
710# $(4): module load list
711# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800712# $(6): module archive
713# $(7): output dir
714# TODO(b/144844424): If a module archive is being used, this step (which
715# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
716# the output directory. This should be moved to a module with a
717# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
718# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700719define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700720$(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 -0700721$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
722$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
723$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
724$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules
725$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
726$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
727$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800728$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
729$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
730$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700731 @echo depmod $$(PRIVATE_STAGING_DIR)
732 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700733 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800734 $(if $(6),\
735 unzip -qo -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
736 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
737 rm -rf $$(PRIVATE_OUTPUT_DIR)/lib/modules; \
738 cp -r $$(PRIVATE_MODULE_DIR) $$(PRIVATE_OUTPUT_DIR)/lib/; \
739 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
740 )
741 $(if $(1),\
742 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
743 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
744 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
745 done; \
746 )
Colin Cross4f60e362019-06-05 11:53:43 -0700747 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
748 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700749 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
750 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700751endef
752
Steve Muckle474e4d02019-06-19 12:56:48 -0700753# $(1): staging dir
754# $(2): module load list
755# $(3): module load list filename
756# $(4): output dir
757define module-load-list-copy-paths
758 $(eval $(call build-image-module-load-list,$(1),$(2),$(3))) \
759 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(3):$(4)/lib/modules/$(3)
760endef
761
762# $(1): staging dir
763# $(2): module load list
764# $(3): module load list filename
765define build-image-module-load-list
766$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_STAGING_DIR := $(1)
767$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_LOAD_MODULES := $(2)
768$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_LOAD_FILENAME := $(3)
769$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): $(2)
770 rm -f $$@
771 (for MODULE in $$(PRIVATE_LOAD_MODULES); do basename $$$$MODULE >> $$@; done)
772endef
773
Steve Mucklee1b10862019-07-10 10:49:37 -0700774ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
775 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
776 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700777 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700778 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
779endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700780
781ifeq ($(BOARD_RECOVERY_KERNEL_MODULES_LOAD),)
782 BOARD_RECOVERY_KERNEL_MODULES_LOAD := $(BOARD_RECOVERY_KERNEL_MODULES)
783endif
Steve Muckle69280d22019-07-11 12:23:38 -0700784ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
785 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700786endif
787
Steve Mucklee1b10862019-07-10 10:49:37 -0700788ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700789 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700790 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700791 endif
792endif
793
Steve Muckle810a0ba2019-11-13 13:29:02 -0800794ifneq ($(strip $(BOARD_RECOVERY_KERNEL_MODULES))$(strip $(BOARD_RECOVERY_KERNEL_MODULES_ARCHIVE)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700795 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700796 ifdef BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD
797 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 -0700798 endif
799 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800800 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 -0700801endif
802
Steve Muckle810a0ba2019-11-13 13:29:02 -0800803ifneq ($(strip $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES))$(strip $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_ARCHIVE)),)
Steve Mucklee1b10862019-07-10 10:49:37 -0700804 ifeq ($(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD),)
805 BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
806 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800807 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 -0700808endif
809
Steve Muckle474e4d02019-06-19 12:56:48 -0700810ifneq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Mucklee1b10862019-07-10 10:49:37 -0700811 ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800812 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 -0700813 endif
Colin Cross4f60e362019-06-05 11:53:43 -0700814endif
815
Steve Muckle810a0ba2019-11-13 13:29:02 -0800816ifneq ($(strip $(BOARD_VENDOR_KERNEL_MODULES)$(strip $(BOARD_VENDOR_KERNEL_MODULES_ARCHIVE))),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700817 ifeq ($(BOARD_VENDOR_KERNEL_MODULES_LOAD),)
818 BOARD_VENDOR_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_KERNEL_MODULES)
819 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800820 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 -0700821endif
822
Steve Muckle810a0ba2019-11-13 13:29:02 -0800823ifneq ($(strip $(BOARD_ODM_KERNEL_MODULES))$(strip $(BOARD_ODM_KERNEL_MODULES_ARCHIVE)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700824 ifeq ($(BOARD_RECOVERY_KERNEL_MODULES_LOAD),)
825 BOARD_ODM_KERNEL_MODULES_LOAD := $(BOARD_ODM_KERNEL_MODULES)
826 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800827 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 -0700828endif
829
830# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800831# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700832# Use a macro to add newline to each echo command
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100833define _apkcerts_write_line
834$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $5
835$(if $(4), $(hide) echo -n ' compressed="$4"' >> $5)
836$(hide) echo '' >> $5
Ying Wangd9a88d52012-10-26 09:21:28 -0700837
838endef
839
The Android Open Source Project88b60792009-03-03 19:28:42 -0800840name := $(TARGET_PRODUCT)
841ifeq ($(TARGET_BUILD_TYPE),debug)
842 name := $(name)_debug
843endif
844name := $(name)-apkcerts-$(FILE_NAME_TAG)
845intermediates := \
846 $(call intermediates-dir-for,PACKAGING,apkcerts)
847APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800848# We don't need to really build all the modules.
849# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700850$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800851 @echo APK certs list: $@
852 @mkdir -p $(dir $@)
853 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700854 $(foreach p,$(sort $(PACKAGES)),\
Ying Wangd9a88d52012-10-26 09:21:28 -0700855 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100856 $(call _apkcerts_write_line,$(p),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$@),\
857 $(call _apkcerts_write_line,$(p),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700858 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700859 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800860
861.PHONY: apkcerts-list
862apkcerts-list: $(APKCERTS_FILE)
863
Ying Wang15e487a2011-02-15 10:56:18 -0800864ifneq (,$(TARGET_BUILD_APPS))
865 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900866 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800867endif
Ying Wangefb21682010-07-23 16:42:13 -0700868
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900869
The Android Open Source Project88b60792009-03-03 19:28:42 -0800870# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700871# build system stats
872BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
873$(BUILD_SYSTEM_STATS):
874 @rm -f $@
875 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
876 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
877$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700878
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700879# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800880# build /product/etc/security/avb/system_other.avbpubkey if needed
881ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800882ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800883INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
884ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800885endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800886endif # BUILDING_SYSTEM_OTHER_IMAGE
887
888# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700889# Modules ready to be converted to Soong, ordered by how many
890# modules depend on them.
891SOONG_CONV := $(sort $(SOONG_CONV))
892SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
893$(SOONG_CONV_DATA):
894 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800895 @$(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 -0700896
Colin Crossfdea8932017-12-06 14:38:40 -0800897SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700898SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
899$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
900 @rm -f $@
901 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
902$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
903
904# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800905# Modules use -Wno-error, or added default -Wall -Werror
906WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
907$(WALL_WERROR):
908 @rm -f $@
909 echo "# Modules using -Wno-error" >> $@
910 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 -0800911 echo "# Modules added default -Wall" >> $@
912 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
913
914$(call dist-for-goals,droidcore,$(WALL_WERROR))
915
916# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700917# C/C++ flag information for modules
918$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
919
920# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800921# Modules missing profile files
922PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
923$(PGO_PROFILE_MISSING):
924 @rm -f $@
925 echo "# Modules missing PGO profile files" >> $@
926 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
927
928$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
929
930# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700931# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700932# for future OTA packages installed by this system. Actual product
933# deliverables will be re-signed by hand. We expect this file to
934# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700935DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700936
937
Jeff Browne33ba4c2011-07-11 22:11:46 -0700938# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800939# if they don't do anything.
940.PHONY: systemimage
941systemimage:
942
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800943# -----------------------------------------------------------------
944
945.PHONY: event-log-tags
946
Joe Onoratob7510532010-07-14 10:22:54 -0700947# Produce an event logs tag file for everything we know about, in order
948# to properly allocate numbers. Then produce a file that's filtered
949# for what's going to be installed.
950
951all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
952
Colin Crossdc8f8e42012-04-12 13:25:54 -0700953event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
954
Joe Onoratob7510532010-07-14 10:22:54 -0700955# Include tags from all packages that we know about
956all_event_log_tags_src := \
957 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
958
Colin Crossdc8f8e42012-04-12 13:25:54 -0700959# PDK builds will already have a full list of tags that needs to get merged
960# in with the ones from source
961pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
962
963$(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 -0800964$(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 -0700965 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900966 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700967
Doug Zongkera34fa952011-02-23 12:17:29 -0800968# Include tags from all packages included in this product, plus all
969# tags that are part of the system (ie, not in a vendor/ or device/
970# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800971event_log_tags_src := \
972 $(sort $(foreach m,\
Anton Hansson8dab0a62019-03-28 15:45:40 +0000973 $(PRODUCT_PACKAGES) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800974 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800975 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
976 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800977
Colin Crossdc8f8e42012-04-12 13:25:54 -0700978$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700979$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800980$(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 -0800981 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900982 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800983
984event-log-tags: $(event_log_tags_file)
985
986ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
987
Joe Onoratob7510532010-07-14 10:22:54 -0700988
The Android Open Source Project88b60792009-03-03 19:28:42 -0800989# #################################################################
990# Targets for boot/OS images
991# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800992ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
993 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
994 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
995 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
996 else
997 INSTALLED_2NDBOOTLOADER_TARGET :=
998 endif
999else
1000 INSTALLED_BOOTLOADER_MODULE :=
1001 INSTALLED_2NDBOOTLOADER_TARGET :=
1002endif # TARGET_NO_BOOTLOADER
1003ifneq ($(strip $(TARGET_NO_KERNEL)),true)
1004 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
1005else
1006 INSTALLED_KERNEL_TARGET :=
1007endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001008
1009# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -07001010# the root dir
1011INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001012 $(ALL_GENERATED_SOURCES) \
1013 $(ALL_DEFAULT_INSTALLED_MODULES))
1014
Luis Hector Chavezff489932018-07-03 15:41:40 -07001015INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
1016INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
1017$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001018$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -07001019 @echo Installed file list: $@
1020 @mkdir -p $(dir $@)
1021 @rm -f $@
1022 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001023 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -07001024
1025$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
1026
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001027#------------------------------------------------------------------
1028# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001029ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001030INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001031ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -08001032$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001033 cat $^ > $@
1034endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001035endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001036
Tom Cherryd14b8952018-08-09 14:26:00 -07001037# -----------------------------------------------------------------
1038# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -08001039ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -07001040INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
1041 $(ALL_GENERATED_SOURCES) \
1042 $(ALL_DEFAULT_INSTALLED_MODULES))
1043
1044INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
1045INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
1046$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001047$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -07001048 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +08001049 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -07001050 @mkdir -p $(dir $@)
1051 @rm -f $@
1052 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001053 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -07001054
1055$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -07001056BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
1057
1058# We just build this directly to the install location.
1059INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Tom Cherryd14b8952018-08-09 14:26:00 -07001060$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001061 $(call pretty,"Target ram disk: $@")
Tom Cherryd14b8952018-08-09 14:26:00 -07001062 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001063
Ying Wangad7fd292013-08-08 16:34:29 -07001064.PHONY: ramdisk-nodeps
1065ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
1066 @echo "make $@: ignoring dependencies"
Tom Cherryd14b8952018-08-09 14:26:00 -07001067 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001068
Dan Willemsen67495202019-01-16 12:42:05 -08001069endif # BUILDING_RAMDISK_IMAGE
1070
The Android Open Source Project88b60792009-03-03 19:28:42 -08001071# -----------------------------------------------------------------
1072# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -07001073
1074# This is defined here since we may be building recovery as boot
1075# below and only want to define this once
1076BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
1077
1078ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001079INTERNAL_BOOTIMAGE_ARGS := \
1080 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001081 --kernel $(INSTALLED_KERNEL_TARGET)
1082
1083ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1084INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
1085endif
1086
Steve Mucklee1b10862019-07-10 10:49:37 -07001087ifndef BUILDING_VENDOR_BOOT_IMAGE
1088ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1089 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1090endif
1091endif
1092
The Android Open Source Project88b60792009-03-03 19:28:42 -08001093INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
1094
Anton Hansson8dab0a62019-03-28 15:45:40 +00001095ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001096ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001097VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001098 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
1099endif
1100endif
1101
Anton Hansson72e36f02019-02-26 17:36:30 +00001102INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -07001103
1104ifndef BUILDING_VENDOR_BOOT_IMAGE
1105ifdef BOARD_KERNEL_BASE
1106 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1107endif
1108ifdef BOARD_KERNEL_PAGESIZE
1109 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1110endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001111ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07001112 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1113endif
1114else
1115# building vendor boot image, dtb/base/pagesize go there
1116ifdef GENERIC_KERNEL_CMDLINE
1117 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1118endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001119endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001120
Sami Tolvanen3303d902016-03-15 16:49:30 +00001121INTERNAL_MKBOOTIMG_VERSION_ARGS := \
1122 --os_version $(PLATFORM_VERSION) \
1123 --os_patch_level $(PLATFORM_SECURITY_PATCH)
1124
Chris Grossa784ef12019-04-22 11:09:57 -07001125# Define these only if we are building boot
1126ifdef BUILDING_BOOT_IMAGE
1127INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1128
The Android Open Source Project88b60792009-03-03 19:28:42 -08001129ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001130$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -04001131
1132else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
1133
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001134$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -04001135 $(call pretty,"Target boot image: $@")
1136 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001137 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001138 $(hide) $(AVBTOOL) add_hash_footer \
1139 --image $@ \
1140 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001141 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001142 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1143
1144.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001145bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -04001146 @echo "make $@: ignoring dependencies"
1147 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001148 $(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 -04001149 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001150 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001151 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001152 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001153 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1154
Anton Hansson8dab0a62019-03-28 15:45:40 +00001155else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -07001156
1157$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
1158 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001159 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Anton Hansson8dab0a62019-03-28 15:45:40 +00001160 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -07001161 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1162
1163.PHONY: bootimage-nodeps
1164bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
1165 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001166 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001167 $(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 -07001168 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1169
Anton Hansson8dab0a62019-03-28 15:45:40 +00001170else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -08001171
Tao Bao4b577412017-02-22 22:54:39 -08001172$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001173 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001174 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +00001175 $(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 -08001176 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1177
1178.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001179bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001180 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001181 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +00001182 $(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 -08001183 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1184
1185else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001186
1187$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
1188 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001189 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001190 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -07001191
1192.PHONY: bootimage-nodeps
1193bootimage-nodeps: $(MKBOOTIMG)
1194 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001195 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001196 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -07001197
The Android Open Source Project88b60792009-03-03 19:28:42 -08001198endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -07001199endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001200
Tao Baob1a2e352018-08-14 16:17:12 -07001201else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001202ifdef BOARD_PREBUILT_BOOTIMAGE
1203ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1204# Remove when b/63676296 is resolved.
1205$(error Prebuilt bootimage is only supported for AB targets)
1206endif
Kiyoung Kim62e22312019-06-20 14:27:45 +09001207INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001208$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -07001209else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -07001210INSTALLED_BOOTIMAGE_TARGET :=
1211endif # BOARD_PREBUILT_BOOTIMAGE
1212endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -08001213
1214# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001215# vendor boot image
1216ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1217
1218ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1219 $(error vboot 1.0 does not support vendor_boot partition)
1220endif
1221
1222INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
1223 $(ALL_GENERATED_SOURCES) \
1224 $(ALL_DEFAULT_INSTALLED_MODULES))
1225
1226INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio.gz
1227$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(MINIGZIP)
1228 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(MINIGZIP) > $@
1229
1230ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1231 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1232endif
1233ifdef BOARD_KERNEL_BASE
1234 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1235endif
1236ifdef BOARD_KERNEL_PAGESIZE
1237 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1238endif
1239ifdef INTERNAL_KERNEL_CMDLINE
1240 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1241endif
1242
1243INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1244$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
1245ifeq ($(BOARD_AVB_ENABLE),true)
1246$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1247 $(call pretty,"Target vendor_boot image: $@")
1248 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
1249 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1250 $(AVBTOOL) add_hash_footer \
1251 --image $@ \
1252 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
1253 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1254 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1255else
1256$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1257 $(call pretty,"Target vendor_boot image: $@")
1258 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
1259 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1260endif
1261endif # BUILDING_VENDOR_BOOT_IMAGE
1262
1263# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001264# NOTICE files
1265#
Steve Blockd14d3b42012-03-01 11:34:41 +00001266# We are required to publish the licenses for all code under BSD, GPL and
1267# Apache licenses (and possibly other more exotic ones as well). We err on the
1268# side of caution, so the licenses for other third-party code are included here
1269# too.
1270#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001271# This needs to be before the systemimage rules, because it adds to
1272# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1273# go into the systemimage.
1274
Steve Block495e5852012-02-29 19:18:08 +00001275.PHONY: notice_files
1276
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001277# Create the rule to combine the files into text and html/xml forms
Chris Grossaad39b32019-06-13 09:43:26 -07001278# $(1) - xml_excluded_system_product_odm|xml_excluded_vendor_product_odm
1279# xml_product|xml_odm|xml_system_ext|xml_system|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001280# $(2) - Plain text output file
1281# $(3) - HTML/XML output file
1282# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001283# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001284# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001285# $(6) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -08001286#
1287# The algorithm here is that we go collect a hash for each of the notice
1288# files and write the names of the files that match that hash. Then
1289# to generate the real files, we go print out all of the files and their
1290# hashes.
1291#
1292# These rules are fairly complex, so they depend on this makefile so if
1293# it changes, they'll run again.
1294#
1295# TODO: We could clean this up so that we just record the locations of the
1296# original notice files instead of making rules to copy them somwehere.
1297# Then we could traverse that without quite as much bash drama.
1298define combine-notice-files
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001299$(2) $(3): PRIVATE_MESSAGE := $(4)
1300$(2) $(3): PRIVATE_DIR := $(5)
1301$(2) : $(3)
Colin Crossfdea8932017-12-06 14:38:40 -08001302$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
1303 build/make/tools/generate-notice-files.py --text-output $(2) \
Chris Grossaad39b32019-06-13 09:43:26 -07001304 $(if $(filter $(1),xml_excluded_vendor_product_odm),-e vendor -e product -e system_ext -e odm --xml-output, \
1305 $(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 +00001306 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001307 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001308 $(if $(filter $(1),xml_system),-i system --xml-output, \
1309 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
1310 --html-output)))))) $(3) \
Anton Hansson6d814982018-11-26 18:12:05 +00001311 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001312notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001313endef
1314
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001315# Notice file logic isn't relevant for TARGET_BUILD_APPS
1316ifndef TARGET_BUILD_APPS
1317
The Android Open Source Project88b60792009-03-03 19:28:42 -08001318# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1319# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1320# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001321target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001322tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001323tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001324kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1325winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
1326pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001327
Steven Morelandae69e572017-12-15 14:49:55 -08001328# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001329ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1330target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1331target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1332installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1333$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001334 $(target_notice_file_txt), \
1335 $(target_notice_file_html), \
1336 "Notices for files contained in the filesystem images in this directory:", \
1337 $(TARGET_OUT_NOTICE_FILES), \
1338 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001339$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1340 $(hide) $(MINIGZIP) -9 < $< > $@
1341$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1342 $(copy-file-to-target)
1343else
1344target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1345target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001346installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1347
1348target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1349target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1350target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1351installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001352
1353target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1354target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1355target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1356installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001357
Justin Yun6151e3f2019-06-25 15:58:13 +09001358target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1359target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1360target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1361installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001362
Chris Gross15d96552019-07-16 14:38:43 -07001363target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1364target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1365target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1366installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1367
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001368# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1369# being built. A notice xml file must depend on all modules that could potentially
1370# install a license file relevant to it.
1371license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)
1372# Phonys/fakes don't have notice files (though their deps might)
1373license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001374# testcases are not relevant to the system image.
1375license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001376license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001377license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1378license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001379license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001380license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001381license_modules_agg := $(license_modules_system) \
1382 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001383 $(license_modules_product) \
1384 $(license_modules_system_ext) \
1385 $(license_modules_odm)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001386license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001387
Chris Grossaad39b32019-06-13 09:43:26 -07001388# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1389# update its notice file, so include those notices in the system partition instead
1390ifdef BOARD_PREBUILT_VENDORIMAGE
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001391license_modules_system += $(license_modules_rest)
Chris Grossaad39b32019-06-13 09:43:26 -07001392system_xml_directories := xml_excluded_vendor_product_odm
1393system_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 -07001394else
1395license_modules_vendor += $(license_modules_rest)
1396system_xml_directories := xml_system
1397system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001398endif
1399
1400$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001401 $(target_notice_file_txt), \
1402 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001403 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001404 $(TARGET_OUT_NOTICE_FILES), \
Chris Grossaad39b32019-06-13 09:43:26 -07001405 $(license_modules_system)))
1406$(eval $(call combine-notice-files, xml_excluded_system_product_odm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001407 $(target_vendor_notice_file_txt), \
1408 $(target_vendor_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001409 "Notices for files contained in all filesystem images except system/system_ext/product/odm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001410 $(TARGET_OUT_NOTICE_FILES), \
1411 $(license_modules_vendor)))
Dario Freniadc972d2018-07-09 18:38:38 +01001412$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001413 $(target_product_notice_file_txt), \
1414 $(target_product_notice_file_xml), \
1415 "Notices for files contained in the product filesystem image in this directory:", \
1416 $(TARGET_OUT_NOTICE_FILES), \
1417 $(license_modules_product)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001418$(eval $(call combine-notice-files, xml_system_ext, \
1419 $(target_system_ext_notice_file_txt), \
1420 $(target_system_ext_notice_file_xml), \
1421 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001422 $(TARGET_OUT_NOTICE_FILES), \
Justin Yun6151e3f2019-06-25 15:58:13 +09001423 $(license_modules_system_ext)))
Chris Gross15d96552019-07-16 14:38:43 -07001424$(eval $(call combine-notice-files, xml_odm, \
1425 $(target_odm_notice_file_txt), \
1426 $(target_odm_notice_file_xml), \
1427 "Notices for files contained in the odm filesystem image in this directory:", \
1428 $(TARGET_OUT_NOTICE_FILES), \
1429 $(license_modules_odm)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001430
1431$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1432 $(hide) $(MINIGZIP) -9 < $< > $@
1433$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1434 $(hide) $(MINIGZIP) -9 < $< > $@
1435$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1436 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001437$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001438 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001439$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1440 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001441$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1442 $(copy-file-to-target)
1443$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1444 $(copy-file-to-target)
1445$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1446 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001447$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001448 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001449$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1450 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001451
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001452ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1453ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1454ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1455ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1456ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001457endif # PRODUCT_NOTICE_SPLIT
1458
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001459ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001460
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001461$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001462 $(tools_notice_file_txt), \
1463 $(tools_notice_file_html), \
1464 "Notices for files contained in the tools directory:", \
1465 $(HOST_OUT_NOTICE_FILES), \
1466 $(ALL_DEFAULT_INSTALLED_MODULES) \
1467 $(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001468
Ying Wang62c81f82013-08-22 20:02:03 -07001469endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001470
1471# The kernel isn't really a module, so to get its module file in there, we
1472# make the target NOTICE files depend on this particular file too, which will
1473# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001474$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001475
Dan Willemsen288bedf2019-05-28 15:36:47 -07001476$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001477
Doug Zongker8678df42009-06-15 14:30:14 -07001478
The Android Open Source Project88b60792009-03-03 19:28:42 -08001479# #################################################################
1480# Targets for user images
1481# #################################################################
1482
Ying Wang933abf12010-06-16 14:31:34 -07001483INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001484ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001485INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1486else
1487ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001488INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1489else
1490ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001491INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1492endif
1493endif
1494endif
1495
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001496# These options tell the recovery updater/installer how to mount the partitions writebale.
1497# <fstype>=<fstype_opts>[|<fstype_opts>]...
1498# fstype_opts := <opt>[,<opt>]...
1499# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001500# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1501DEFAULT_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 -07001502
Ying Wang542903a2010-11-17 15:40:38 -08001503ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1504 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1505endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001506ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1507 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1508endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001509ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1510 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1511endif
Tao Baodba635a2019-06-24 10:39:54 -07001512
1513INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001514 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001515 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001516 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001517
1518ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1519INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001520endif
1521
Justin Yun6151e3f2019-06-25 15:58:13 +09001522ifneq ($(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 -07001523INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1524endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001525
Anton Hansson8dab0a62019-03-28 15:45:40 +00001526ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001527INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001528ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001529INTERNAL_USERIMAGES_DEPS += $(FEC)
1530endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001531endif
1532
Tao Baodba635a2019-06-24 10:39:54 -07001533ifeq ($(BOARD_AVB_ENABLE),true)
1534INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1535endif
1536
1537# Get a colon-separated list of search paths.
1538INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1539
Alex Klyubin092c9022017-03-13 13:28:34 -07001540SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001541INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1542
Yifan Hongc5c01242018-11-09 10:27:23 -08001543ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001544
Anton Hansson8dab0a62019-03-28 15:45:40 +00001545ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001546 $(error vboot 1.0 doesn't support logical partition)
1547endif
1548
Yifan Hongc5c01242018-11-09 10:27:23 -08001549endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001550
Ying Wangbd93d422011-10-28 17:02:30 -07001551# $(1): the path of the output dictionary file
Justin Yun6151e3f2019-06-25 15:58:13 +09001552# $(2): a subset of "system vendor cache userdata product system_ext oem odm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001553# $(3): additional "key=value" pairs to append to the dictionary file.
1554define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001555$(if $(filter $(2),system),\
1556 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001557 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001558 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1559 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1560 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1561 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1562 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1563 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1564 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1565 $(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 +00001566 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1567 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001568 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001569 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001570)
Yifan Hong760d3c02018-05-30 11:16:46 -07001571$(if $(filter $(2),userdata),\
1572 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1573 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001574 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001575)
Yifan Hong760d3c02018-05-30 11:16:46 -07001576$(if $(filter $(2),cache),\
1577 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1578 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001579 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001580)
1581$(if $(filter $(2),vendor),\
1582 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1583 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1584 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1585 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1586 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1587 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1588 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1589 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1590 $(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 +00001591 $(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 -07001592 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001593 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001594)
1595$(if $(filter $(2),product),\
1596 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1597 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1598 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1599 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1600 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1601 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1602 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1603 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1604 $(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 +00001605 $(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 -07001606 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001607 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001608)
Justin Yun6151e3f2019-06-25 15:58:13 +09001609$(if $(filter $(2),system_ext),\
1610 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1611 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1612 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1613 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1614 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1615 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1616 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1617 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1618 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1619 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1620 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001621)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001622$(if $(filter $(2),odm),\
1623 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1624 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1625 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1626 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1627 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1628 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1629 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1630 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1631 $(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 +00001632 $(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 +08001633 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001634 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001635)
Yifan Hong760d3c02018-05-30 11:16:46 -07001636$(if $(filter $(2),oem),\
1637 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1638 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1639 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1640 $(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 -07001641 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001642)
Tao Bao3602eca2018-07-10 10:53:55 -07001643$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001644
Tao Bao3602eca2018-07-10 10:53:55 -07001645$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001646$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001647$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001648$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001649$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1650$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1651$(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 +00001652$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1653$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1654$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1655$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1656$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001657$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001658$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1659$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1660$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001661$(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 +00001662$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1663$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1664$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1665$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1666$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001667$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001668$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1669$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1670$(if $(BOARD_AVB_ENABLE),\
1671 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1672 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1673 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1674 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001675$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1676$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1677$(if $(BOARD_AVB_ENABLE),\
1678 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1679 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001680 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001681$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1682$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1683$(if $(BOARD_AVB_ENABLE),\
1684 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1685 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1686 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1687 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001688$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1689$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1690$(if $(BOARD_AVB_ENABLE),\
1691 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1692 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1693 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1694 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001695$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001696$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001697 $(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 +01001698$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001699 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1700 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1701 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1702 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001703$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1704$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1705$(if $(BOARD_AVB_ENABLE),\
1706 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1707 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1708 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1709 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001710$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1711 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001712$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001713 $(hide) echo "system_root_image=true" >> $(1))
1714$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Yifan Hong2dae5722018-07-31 12:47:27 -07001715$(if $(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),$(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001716$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1717endef
1718
1719# $(1): the path of the output dictionary file
1720# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001721PROP_DICTIONARY_IMAGES := oem
1722ifdef BUILDING_CACHE_IMAGE
1723 PROP_DICTIONARY_IMAGES += cache
1724endif
1725ifdef BUILDING_SYSTEM_IMAGE
1726 PROP_DICTIONARY_IMAGES += system
1727endif
1728ifdef BUILDING_USERDATA_IMAGE
1729 PROP_DICTIONARY_IMAGES += userdata
1730endif
1731ifdef BUILDING_VENDOR_IMAGE
1732 PROP_DICTIONARY_IMAGES += vendor
1733endif
1734ifdef BUILDING_PRODUCT_IMAGE
1735 PROP_DICTIONARY_IMAGES += product
1736endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001737ifdef BUILDING_SYSTEM_EXT_IMAGE
1738 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001739endif
1740ifdef BUILDING_ODM_IMAGE
1741 PROP_DICTIONARY_IMAGES += odm
1742endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001743define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001744 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001745endef
1746
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001747# $(1): the path of the input dictionary file, where each line has the format key=value
1748# $(2): the key to look up
1749define read-image-prop-dictionary
1750$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1751endef
1752
The Android Open Source Project88b60792009-03-03 19:28:42 -08001753# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001754# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001755
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001756# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001757ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001758
Ying Wang37526142015-03-10 12:02:57 -07001759INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1760 $(ALL_DEFAULT_INSTALLED_MODULES))
1761
Tao Bao10fc9492018-08-14 12:17:48 -07001762INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1763INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1764
1765# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1766# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1767# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1768# the call to FILELIST.
1769ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001770INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001771$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1772else
1773$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1774endif
1775
1776$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001777$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001778 @echo Installed file list: $@
1779 @mkdir -p $(dir $@)
1780 @rm -f $@
1781 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001782 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001783
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001784recovery_sepolicy := \
1785 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001786 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001787 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001788 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1789 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1790 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001791 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001792 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001793 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1794 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1795 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001796
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001797# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1798# SELinux files
1799IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1800
Doug Zongker4647f122009-07-02 09:00:54 -07001801recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1802recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Doug Zongker4647f122009-07-02 09:00:54 -07001803recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001804
Anton Hansson45a40da2019-01-18 14:06:34 +00001805# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1806# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1807# which get remapped to a bucket.
1808recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001809ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1810recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001811# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001812# ------160------240------320----------480------------640------
1813# mdpi hdpi xhdpi xxhdpi xxxhdpi
1814recovery_density := $(strip \
1815 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1816 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1817 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1818 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001819endif
1820
1821ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1822recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1823else
Doug Zongker25d55f82014-04-04 13:51:15 -07001824recovery_resources_common := $(recovery_resources_common)-xhdpi
1825endif
1826
Tao Baoe1e829e2018-08-29 20:36:00 -07001827# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1828# Note that the font selected here can be overridden for a particular device by putting a font.png
1829# in its private recovery resources.
1830ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001831recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1832else
1833recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1834endif
1835
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001836
1837# We will only generate the recovery background text images if the variable
1838# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1839# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1840# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1841# BoardConfig in order to use this feature.
1842ifeq ($(recovery_density),xxxhdpi)
1843TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1844else ifeq ($(recovery_density),xxhdpi)
1845TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1846endif
1847
1848ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1849# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1850ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1851 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1852else
1853 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1854endif
1855
1856
1857RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,PACKAGING,recovery_text_res)/installing_text.png
1858RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1859RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1860RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1861RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1862
xunchangcc57d312018-12-07 12:12:17 -08001863RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1864RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1865RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1866RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1867RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1868
1869generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001870 $(RECOVERY_INSTALLING_TEXT_FILE) \
1871 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1872 $(RECOVERY_ERASING_TEXT_FILE) \
1873 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001874 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1875 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1876 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1877 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1878 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1879 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001880
1881resource_dir := $(call include-path-for, recovery)/tools/recovery_l10n/res/
1882image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001883zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001884$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
1885$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,PACKAGING,recovery_font_files)
1886$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1887$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001888$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001889$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001890$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001891 recovery_installing \
1892 recovery_installing_security \
1893 recovery_erasing \
1894 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001895 recovery_no_command
1896$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001897 recovery_cancel_wipe_data \
1898 recovery_factory_data_reset \
1899 recovery_try_again \
1900 recovery_wipe_data_menu_header \
1901 recovery_wipe_data_confirmation
1902$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
1903$(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 -08001904 # Prepares the font directory.
1905 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1906 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001907 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001908 @rm -rf $(dir $@)
1909 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001910 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001911 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001912 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001913 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1914 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1915 --text_name $(text_name) \
1916 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1917 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001918 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001919 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001920else
1921RECOVERY_INSTALLING_TEXT_FILE :=
1922RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1923RECOVERY_ERASING_TEXT_FILE :=
1924RECOVERY_ERROR_TEXT_FILE :=
1925RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001926RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1927RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1928RECOVERY_TRY_AGAIN_TEXT_FILE :=
1929RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1930RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001931endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1932
Ying Wang9a175682015-08-06 11:47:47 -07001933ifndef TARGET_PRIVATE_RES_DIRS
1934TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1935endif
Doug Zongker4647f122009-07-02 09:00:54 -07001936recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001937 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001938recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001939
1940
Andrew Boiefa61ff02012-09-28 09:33:45 -07001941ifdef TARGET_RECOVERY_FSTAB
1942recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1943else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001944recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001945endif
Tao Baoc3c17532016-06-10 10:11:54 -07001946ifdef TARGET_RECOVERY_WIPE
1947recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001948else
Tao Baoc3c17532016-06-10 10:11:54 -07001949recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001950endif
Tao Bao8beab692015-07-22 12:33:18 -07001951
Tao Bao6d5d6232018-03-09 17:04:42 -08001952# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001953# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001954# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1955# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001956#
1957# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001958# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001959# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001960# b) We build a single image that contains boot and recovery both - no recovery image to install
1961# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001962# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001963# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001964# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1965# do bsdiff because boot and recovery will contain different number of entries
1966# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001967# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1968# do bsdiff because boot and recovery will contain different number of entries
1969# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001970
Tom Cherry2929cad2018-09-20 11:04:37 -07001971ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001972 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001973# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001974RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1975ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001976else
Tao Bao8beab692015-07-22 12:33:18 -07001977RECOVERY_RESOURCE_ZIP :=
1978endif
Doug Zongker4647f122009-07-02 09:00:54 -07001979
Tao Bao139c7272018-07-31 13:26:54 -07001980INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1981
1982$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001983 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1984 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1985 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1986 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1987 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1988 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1989 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1990 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1991
1992# Parses the given list of build variables and writes their values as build properties if defined.
1993# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1994# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1995# $(1): Map from the build variable names to property names
1996# $(2): Output file
1997define append-recovery-ui-properties
1998echo "#" >> $(2)
1999echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2000echo "#" >> $(2)
2001$(foreach prop,$(1), \
2002 $(eval _varname := $(call word-colon,1,$(prop))) \
2003 $(eval _propname := $(call word-colon,2,$(prop))) \
2004 $(eval _value := $($(_varname))) \
2005 $(if $(_value), \
2006 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2007endef
2008
2009$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00002010 $(INSTALLED_DEFAULT_PROP_TARGET) \
2011 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
2012 $(intermediate_system_build_prop) \
2013 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2014 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2015 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002016 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002017 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002018 $(hide) mkdir -p $(dir $@)
2019 $(hide) rm -f $@
2020 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) > $@
2021 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) >> $@
Tao Bao6eb1a992018-08-06 07:33:45 -07002022 $(hide) cat $(intermediate_system_build_prop) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002023 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002024 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002025 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002026 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002027 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2028
Steve Mucklee1b10862019-07-10 10:49:37 -07002029ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
2030 INTERNAL_RECOVERYIMAGE_ARGS := \
2031 --kernel $(recovery_kernel) --ramdisk $(recovery_ramdisk)
2032ifdef GENERIC_KERNEL_CMDLINE
2033 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
2034endif
2035else # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
2036 INTERNAL_RECOVERYIMAGE_ARGS := \
2037 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
2038 --kernel $(recovery_kernel) --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07002039# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002040ifdef INTERNAL_KERNEL_CMDLINE
2041 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07002042endif
2043ifdef BOARD_KERNEL_BASE
2044 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2045endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002046ifdef BOARD_KERNEL_PAGESIZE
2047 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2048endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002049ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002050ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2051 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2052else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002053 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2054endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002055endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002056ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2057 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2058endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002059ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2060 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2061endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002062endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Doug Zongker4647f122009-07-02 09:00:54 -07002063
Ying Wang747b9f12015-01-30 14:05:22 -08002064# $(1): output file
2065define build-recoveryimage-target
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002066 # Making recovery image
Ying Wang747b9f12015-01-30 14:05:22 -08002067 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao696bb332018-08-17 16:27:01 -07002068 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002069 # Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002070 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
Tao Bao696bb332018-08-17 16:27:01 -07002071 $(hide) rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002072 # Modifying ramdisk contents...
Tom Cherry3871f0f2018-11-06 14:23:44 -08002073 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2074 $(hide) ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
Bowgo Tsaib5b3bc62017-09-25 17:50:41 +08002075 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2076 $(hide) find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
Tao Baocf8853b2018-08-13 14:27:32 -07002077 $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
Ying Wang747b9f12015-01-30 14:05:22 -08002078 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2079 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2080 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
xunchangcc57d312018-12-07 12:12:17 -08002081 $(hide) $(foreach recovery_text_file,$(generated_recovery_text_files), \
2082 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
Ying Wang747b9f12015-01-30 14:05:22 -08002083 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07002084 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2085 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08002086 $(hide) $(foreach item,$(recovery_fstab), \
Tao Bao696bb332018-08-17 16:27:01 -07002087 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07002088 $(if $(strip $(recovery_wipe)), \
Tao Bao696bb332018-08-17 16:27:01 -07002089 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
Hung-ying Tyanf829b402017-05-01 21:56:26 +08002090 $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07002091 $(BOARD_RECOVERY_IMAGE_PREPARE)
Thierry Strudel74a81e62015-07-09 09:54:55 -07002092 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002093 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00002094 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
Jooyung Han72b65ab2019-05-23 19:48:13 +09002095 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002096 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002097 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002098 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2099 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002100 )\
2101 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002102 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2103 $(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 +08002104 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
2105 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
2106 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002107 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2108 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
2109 $(hide) $(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),\
2110 $(hide) $(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 -08002111endef
2112
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002113ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002114ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Ying Wangbd07ad02016-03-10 12:57:33 -08002115$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
2116endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002117ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Ying Wangbd07ad02016-03-10 12:57:33 -08002118$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
2119endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002120ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002121$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002122endif
Tao Baof4866c72018-08-22 14:35:09 -07002123ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002124ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2125$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2126else
Tao Baof4866c72018-08-22 14:35:09 -07002127$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2128endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002129endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002130ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2131$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2132endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002133ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2134$(INSTALLED_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2135endif
Tao Baof4866c72018-08-22 14:35:09 -07002136
Jiyong Parkce3e34f2018-05-24 14:24:50 +09002137$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Anton Hansson6d814982018-11-26 18:12:05 +00002138 $(INTERNAL_ROOT_FILES) \
2139 $(INSTALLED_RAMDISK_TARGET) \
2140 $(INTERNAL_RECOVERYIMAGE_FILES) \
Tom Cherry89eea962019-11-04 10:41:51 -08002141 $(recovery_sepolicy) $(recovery_kernel) \
Anton Hansson6d814982018-11-26 18:12:05 +00002142 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2143 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2144 $(recovery_resource_deps) \
Colin Cross4f60e362019-06-05 11:53:43 -07002145 $(recovery_fstab)
Tao Baof4866c72018-08-22 14:35:09 -07002146 $(call pretty,"Target boot image from recovery: $@")
2147 $(call build-recoveryimage-target, $@)
Daniel Mentz4d6017d2019-12-19 20:48:43 -08002148$(INSTALLED_BOOTIMAGE_TARGET): .KATI_IMPLICIT_OUTPUTS += $(recovery_ramdisk)
Tao Baof4866c72018-08-22 14:35:09 -07002149endif # BOARD_USES_RECOVERY_AS_BOOT
2150
2151ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002152ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2153$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2154else
Tao Baof4866c72018-08-22 14:35:09 -07002155$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002156endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002157endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002158ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2159$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2160endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002161ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2162$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2163endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002164
Jiyong Parkce3e34f2018-05-24 14:24:50 +09002165$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Anton Hansson6d814982018-11-26 18:12:05 +00002166 $(INTERNAL_ROOT_FILES) \
2167 $(INSTALLED_RAMDISK_TARGET) \
2168 $(INSTALLED_BOOTIMAGE_TARGET) \
2169 $(INTERNAL_RECOVERYIMAGE_FILES) \
Tom Cherry89eea962019-11-04 10:41:51 -08002170 $(recovery_sepolicy) $(recovery_kernel) \
Anton Hansson6d814982018-11-26 18:12:05 +00002171 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2172 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2173 $(recovery_resource_deps) \
Colin Cross4f60e362019-06-05 11:53:43 -07002174 $(recovery_fstab)
Tao Baof4866c72018-08-22 14:35:09 -07002175 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07002176
Tao Bao4594d0e2015-12-22 09:47:46 -08002177ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002178$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002179 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002180 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2181 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002182endif
Doug Zongker56588872012-08-20 15:38:58 -07002183
Ying Wang747b9f12015-01-30 14:05:22 -08002184.PHONY: recoveryimage-nodeps
2185recoveryimage-nodeps:
2186 @echo "make $@: ignoring dependencies"
2187 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
2188
Chris Grossa784ef12019-04-22 11:09:57 -07002189else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002190RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002191endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002192
2193.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002194recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002195
Jiyong Park03eb0612017-10-04 21:22:41 +09002196ifneq ($(BOARD_NAND_PAGE_SIZE),)
2197$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002198endif
2199
Jiyong Park03eb0612017-10-04 21:22:41 +09002200ifneq ($(BOARD_NAND_SPARE_SIZE),)
2201$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002202endif
2203
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002204ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002205# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002206# the debug ramdisk, which is the original ramdisk plus additional
2207# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2208# When /force_debuggable is present, /init will load userdebug sepolicy
2209# and property files to allow adb root, if the device is unlocked.
2210
2211ifdef BUILDING_RAMDISK_IMAGE
2212BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2213INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2214
2215INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2216 $(ALL_GENERATED_SOURCES) \
2217 $(ALL_DEFAULT_INSTALLED_MODULES))
2218
2219# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2220# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2221# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2222my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2223
2224INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2225INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2226$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2227$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2228
2229# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2230# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2231# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2232$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002233$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002234 echo Installed file list: $@
2235 mkdir -p $(dir $@)
2236 rm -f $@
2237 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002238 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002239
2240# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2241# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2242ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2243my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2244else
2245my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2246endif # BOARD_USES_RECOVERY_AS_BOOT
2247
2248$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2249$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002250
2251ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2252# 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 +08002253$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002254else
2255# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2256$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2257endif # BOARD_USES_RECOVERY_AS_BOOT
Bowgo Tsai0013f552019-03-20 17:59:52 +08002258$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(MINIGZIP)
2259 $(call pretty,"Target debug ram disk: $@")
2260 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2261 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002262 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002263 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2264
2265.PHONY: ramdisk_debug-nodeps
2266ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2267ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2268ramdisk_debug-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2269 echo "make $@: ignoring dependencies"
2270 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2271 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002272 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002273 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
2274
2275my_debug_ramdisk_sync_dir :=
2276my_debug_ramdisk_root_dir :=
2277
2278endif # BUILDING_RAMDISK_IMAGE
2279
2280# -----------------------------------------------------------------
2281# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2282#
2283# Note: it's intentional to skip signing for boot-debug.img, because it
2284# can only be used if the device is unlocked with verification error.
2285ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2286
2287INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2288
2289# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2290ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2291INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2292else
2293INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2294endif
2295
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002296# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2297# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2298# Using a test key to sign boot-debug.img to continue booting with the mismatched
2299# public key, if the device is unlocked.
2300ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002301$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002302endif
2303
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002304BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2305INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2306# $(1): the bootimage to sign
2307define test-key-sign-bootimage
2308$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
2309$(AVBTOOL) add_hash_footer \
2310 --image $(1) \
2311 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
2312 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2313 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
2314$(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
2315endef
2316
Bowgo Tsai0013f552019-03-20 17:59:52 +08002317# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2318$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2319 $(call pretty,"Target boot debug image: $@")
2320 $(MKBOOTIMG) $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002321 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002322
2323.PHONY: bootimage_debug-nodeps
2324bootimage_debug-nodeps: $(MKBOOTIMG)
2325 echo "make $@: ignoring dependencies"
2326 $(MKBOOTIMG) $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002327 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET)))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002328
2329endif # TARGET_NO_KERNEL
2330
2331# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002332# The test harness ramdisk, which is based off debug_ramdisk, plus a
2333# few additional test-harness-specific properties in adb_debug.prop.
2334
2335ifdef BUILDING_RAMDISK_IMAGE
2336BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2337INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2338
2339# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2340# appends a few test harness specific properties into the adb_debug.prop.
2341TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2342TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2343
2344# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2345# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2346TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2347ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2348ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2349
2350# $(1): a list of key=value pairs for additional property assignments
2351# $(2): the target .prop file to append the properties from $(1)
2352define append-test-harness-props
2353 echo "#" >> $(2); \
2354 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2355 echo "#" >> $(2);
2356 $(foreach line,$(1), echo "$(line)" >> $(2);)
2357endef
2358
2359$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
2360$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(MINIGZIP)
2361 $(call pretty,"Target test harness ram disk: $@")
2362 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2363 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2364 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2365
2366.PHONY: ramdisk_test_harness-nodeps
2367ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2368 echo "make $@: ignoring dependencies"
2369 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2370 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2371 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2372
2373endif # BUILDING_RAMDISK_IMAGE
2374
2375# -----------------------------------------------------------------
2376# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2377#
2378# Note: it's intentional to skip signing for boot-test-harness.img, because it
2379# can only be used if the device is unlocked with verification error.
2380ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2381
2382INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2383
2384# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2385INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2386
2387# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2388# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2389# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2390# public key, if the device is unlocked.
2391ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2392$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2393endif
2394
2395# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2396$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2397 $(call pretty,"Target boot test harness image: $@")
2398 $(MKBOOTIMG) $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2399 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2400
2401.PHONY: bootimage_test_harness-nodeps
2402bootimage_test_harness-nodeps: $(MKBOOTIMG)
2403 echo "make $@: ignoring dependencies"
2404 $(MKBOOTIMG) $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
2405 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)))
2406
2407endif # TARGET_NO_KERNEL
2408endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2409
2410# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002411# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002412#
Ying Wang9c649a72012-08-08 15:27:00 -07002413# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2414PDK_FUSION_SYSIMG_FILES := \
2415 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2416 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002417
Dan Willemsen37a19862018-10-31 16:31:46 -07002418INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002419 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002420 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002421 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002422 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002423
Ying Wang82cceba2012-08-13 15:03:00 -07002424FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002425
2426# ASAN libraries in the system image - add dependency.
2427ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002428ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002429 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2430 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2431 endif
2432endif
2433
Tom Cherryd14b8952018-08-09 14:26:00 -07002434FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002435
Ying Wange5e8c5f2011-09-09 16:35:53 -07002436# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002437ifdef BUILDING_SYSTEM_IMAGE
2438
Ying Wange5e8c5f2011-09-09 16:35:53 -07002439# installed file list
2440# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2441# We put installed-files.txt ahead of image itself in the dependency graph
2442# so that we can get the size stat even if the build fails due to too large
2443# system image.
2444INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002445INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2446$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002447$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002448 @echo Installed file list: $@
2449 @mkdir -p $(dir $@)
2450 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002451 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002452 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002453
2454.PHONY: installed-file-list
2455installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002456
2457$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002458
2459systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002460 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002461BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2462
Ying Wang23898df2014-06-18 20:26:24 -07002463# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002464ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002465define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002466$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2467 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2468 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2469 exit 1; \
2470fi
Ying Wang23898df2014-06-18 20:26:24 -07002471$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2472endef
2473else
2474define create-system-vendor-symlink
2475endef
2476endif
2477
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002478# Create symlink /system/product to /product if necessary.
2479ifdef BOARD_USES_PRODUCTIMAGE
2480define create-system-product-symlink
2481$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2482 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2483 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2484 exit 1; \
2485fi
2486$(hide) ln -sf /product $(TARGET_OUT)/product
2487endef
2488else
2489define create-system-product-symlink
2490endef
2491endif
2492
Justin Yun6151e3f2019-06-25 15:58:13 +09002493# Create symlink /system/system_ext to /system_ext if necessary.
2494ifdef BOARD_USES_SYSTEM_EXTIMAGE
2495define create-system-system_ext-symlink
2496$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2497 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2498 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 +01002499 exit 1; \
2500fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002501$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002502endef
2503else
Justin Yun6151e3f2019-06-25 15:58:13 +09002504define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002505endef
2506endif
2507
The Android Open Source Project88b60792009-03-03 19:28:42 -08002508# $(1): output file
2509define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002510 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002511 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002512 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002513 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002514 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002515 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002516 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002517 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002518 $(BUILD_IMAGE) \
2519 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2520 || ( mkdir -p $${DIST_DIR}; \
2521 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2522 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002523endef
2524
Dan Willemsen6b72c732019-06-12 21:33:38 +00002525ifeq ($(BOARD_AVB_ENABLE),true)
2526$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2527endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002528$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002529 $(call build-systemimage-target,$@)
2530
Tao Baoe9d61b02018-08-20 21:09:07 -07002531INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002532SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002533
Tao Baoe9d61b02018-08-20 21:09:07 -07002534# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2535# compatibility, in case device-specific Makefiles still refer to the old name.
2536INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2537
Doug Zongker73ef8252009-07-23 15:12:53 -07002538# The system partition needs room for the recovery image as well. We
2539# now store the recovery image as a binary patch using the boot image
2540# as the source (since they are very similar). Generate the patch so
2541# we can see how big it's going to be, and include that in the system
2542# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002543ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002544ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002545ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002546ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002547diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2548else
2549diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2550endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002551intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2552RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002553$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2554$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002555 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2556 $(INSTALLED_BOOTIMAGE_TARGET) \
2557 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002558 @echo "Construct recovery from boot"
2559 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002560 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002561else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2562RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002563endif # BOARD_USES_FULL_RECOVERY_IMAGE
2564endif # INSTALLED_RECOVERYIMAGE_TARGET
2565endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002566
Tao Baoe9d61b02018-08-20 21:09:07 -07002567$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002568 @echo "Install system fs image: $@"
2569 $(copy-file-to-target)
Yifan Hong8c3dce02019-04-09 17:03:57 +00002570 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002571
Tao Baoe9d61b02018-08-20 21:09:07 -07002572systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002573
2574.PHONY: systemimage-nodeps snod
2575systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002576 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002577 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002578 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002579 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002580
Ying Wangacf01ec2012-02-24 11:05:48 -08002581ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
2582ifeq (true,$(WITH_DEXPREOPT))
2583$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
2584endif
2585endif
2586
Dan Willemsen67495202019-01-16 12:42:05 -08002587endif # BUILDING_SYSTEM_IMAGE
2588
Anton Hansson30e061b2018-11-12 13:36:46 +00002589.PHONY: sync syncsys
2590sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002591
Ying Wang3a61eeb2016-03-11 10:32:01 -08002592# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002593## platform.zip: system, plus other files to be used in PDK fusion build,
2594## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002595##
2596## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2597## The variable will be typically set from BoardConfig.mk.
2598## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002599ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002600pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002601 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002602pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002603 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002604pdk_classes_dex := $(strip \
2605 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002606 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002607
2608pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2609$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2610$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2611$(pdk_odex_config_mk) :
2612 @echo "PDK odex config makefile: $@"
2613 $(hide) mkdir -p $(dir $@)
2614 $(hide) echo "# Auto-generated. Do not modify." > $@
2615 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2616 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2617 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2618 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2619 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2620 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2621 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2622 )
2623 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002624 $(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 -08002625 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2626 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2627 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2628 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002629 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002630 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2631 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2632 )
2633
keunyoungc0178062013-07-22 14:54:58 -07002634PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002635INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002636
2637$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2638$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002639$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2640# dependencies for the other partitions are defined below after their file lists
2641# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002642$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002643 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002644 rm -f $@ $@.lst
2645 echo "-C $(PRODUCT_OUT)" >> $@.lst
2646 echo "-D $(TARGET_OUT)" >> $@.lst
2647 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2648 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002649ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002650 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002651endif
Dan Willemsen67495202019-01-16 12:42:05 -08002652ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002653 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002654endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002655ifdef BUILDING_SYSTEM_EXT_IMAGE
2656 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002657endif
Dan Willemsen67495202019-01-16 12:42:05 -08002658ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002659 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002660endif
Colin Crossc451a372013-12-18 19:36:44 -08002661ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002662 echo "-C $(OUT_DIR)" >> $@.lst
2663 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2664 if [ -e $$f ]; then \
2665 echo "-f $$f"; \
2666 fi \
2667 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002668endif
keunyoungc0178062013-07-22 14:54:58 -07002669ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002670 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002671endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002672 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002673 $(if $(PRIVATE_DEX_FILES),\
2674 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002675 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002676 touch $(PRODUCT_OUT)/pdk.mk
2677 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2678 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002679
2680.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002681platform: $(INSTALLED_PLATFORM_ZIP)
2682
2683.PHONY: platform-java
2684platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002685
2686# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002687ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2688$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002689endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002690
Colin Cross53c8f972018-09-28 16:19:42 -07002691endif # BUILD_PLATFORM_ZIP
2692
Ying Wang3a61eeb2016-03-11 10:32:01 -08002693# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002694# data partition image
2695INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002696 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002697
Dan Willemsen67495202019-01-16 12:42:05 -08002698ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002699userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002700 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002701BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2702
Ying Wangbd93d422011-10-28 17:02:30 -07002703define build-userdataimage-target
2704 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2705 @mkdir -p $(TARGET_OUT_DATA)
2706 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002707 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002708 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002709 $(BUILD_IMAGE) \
2710 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2711 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2712 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002713endef
2714
Joe Onorato64d85d02009-04-09 19:31:12 -07002715# We just build this directly to the install location.
2716INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002717INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2718 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002719 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002720$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002721 $(build-userdataimage-target)
2722
2723.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002724userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002725 $(build-userdataimage-target)
2726
Dan Willemsen67495202019-01-16 12:42:05 -08002727endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002728
Andreas Gampe039b5c72017-03-24 16:06:31 -07002729# ASAN libraries in the system image - build rule.
2730ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2731 $(TARGET_OUT_SHARED_LIBRARIES) \
2732 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2733 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2734 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002735# Extra options: Enforce the system user for the files to avoid having to change ownership.
2736ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002737# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2738# enough space.
2739$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002740 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 -07002741
The Android Open Source Project88b60792009-03-03 19:28:42 -08002742# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002743# partition table image
2744ifdef BOARD_BPT_INPUT_FILES
2745
2746BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002747BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002748
2749INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2750 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002751 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002752 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2753
2754ifdef BOARD_BPT_DISK_SIZE
2755INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2756endif
2757
2758define build-bptimage-target
2759 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2760 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2761endef
2762
2763INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002764$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2765 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2766
David Zeuthen25328622016-04-08 15:08:03 -04002767$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2768 $(build-bptimage-target)
2769
2770.PHONY: bptimage-nodeps
2771bptimage-nodeps:
2772 $(build-bptimage-target)
2773
2774endif # BOARD_BPT_INPUT_FILES
2775
2776# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002777# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002778ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002779INTERNAL_CACHEIMAGE_FILES := \
2780 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2781
2782cacheimage_intermediates := \
2783 $(call intermediates-dir-for,PACKAGING,cache)
2784BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2785
2786define build-cacheimage-target
2787 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2788 @mkdir -p $(TARGET_OUT_CACHE)
2789 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002790 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002791 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002792 $(BUILD_IMAGE) \
2793 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2794 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2795 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002796endef
2797
2798# We just build this directly to the install location.
2799INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002800$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002801 $(build-cacheimage-target)
2802
2803.PHONY: cacheimage-nodeps
2804cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2805 $(build-cacheimage-target)
2806
Dan Willemsen67495202019-01-16 12:42:05 -08002807else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002808# we need to ignore the broken cache link when doing the rsync
2809IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002810endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002811
David Zeuthen0eb10972016-09-28 17:55:27 -04002812# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002813# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002814ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002815ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002816# Marker file to identify that odex files are installed
2817INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2818ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2819$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2820 $(hide) touch $@
2821endif
2822
Alex Light4e358ab2016-06-16 14:47:10 -07002823INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2824 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2825 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002826 $(ALL_PDK_FUSION_FILES)) \
2827 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002828
Colin Cross6db5b0e2018-11-16 21:26:33 -08002829# system_other dex files are installed as a side-effect of installing system image files
2830INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2831
Alex Light4e358ab2016-06-16 14:47:10 -07002832INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002833INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2834$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002835$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002836 @echo Installed file list: $@
2837 @mkdir -p $(dir $@)
2838 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002839 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002840 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002841
Bowgo Tsai867ab662019-01-29 13:30:18 +08002842# Determines partition size for system_other.img.
2843ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2844ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2845INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2846endif
2847endif
2848
2849ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2850INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2851endif
2852
Alex Light4e358ab2016-06-16 14:47:10 -07002853systemotherimage_intermediates := \
2854 $(call intermediates-dir-for,PACKAGING,system_other)
2855BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2856
2857# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2858define build-systemotherimage-target
2859 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2860 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2861 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002862 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002863 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002864 $(BUILD_IMAGE) \
2865 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2866 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2867 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002868endef
2869
2870# We just build this directly to the install location.
2871INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002872ifneq (true,$(SANITIZE_LITE))
2873# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002874$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2875 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002876endif
Alex Light4e358ab2016-06-16 14:47:10 -07002877
2878.PHONY: systemotherimage-nodeps
2879systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2880 $(build-systemotherimage-target)
2881
Dan Willemsen67495202019-01-16 12:42:05 -08002882endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002883
2884
2885# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002886# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002887ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002888INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002889 $(filter $(TARGET_OUT_VENDOR)/%,\
2890 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002891 $(ALL_PDK_FUSION_FILES)) \
2892 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07002893
2894# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
2895$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07002896
Ying Wang8da19e32015-09-15 14:22:12 -07002897INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002898INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2899$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002900$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07002901 @echo Installed file list: $@
2902 @mkdir -p $(dir $@)
2903 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002904 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002905 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002906
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002907# Create symlink /vendor/odm to /odm if necessary.
2908ifdef BOARD_USES_ODMIMAGE
2909define create-vendor-odm-symlink
2910$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
2911 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
2912 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
2913 exit 1; \
2914fi
2915$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
2916endef
2917else
2918define create-vendor-odm-symlink
2919endef
2920endif
2921
Ying Wanga0febe52013-03-20 11:02:05 -07002922vendorimage_intermediates := \
2923 $(call intermediates-dir-for,PACKAGING,vendor)
2924BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002925define build-vendorimage-target
2926 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2927 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002928 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002929 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002930 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002931 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002932 $(BUILD_IMAGE) \
2933 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2934 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
2935 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002936endef
2937
2938# We just build this directly to the install location.
2939INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002940$(INSTALLED_VENDORIMAGE_TARGET): \
2941 $(INTERNAL_USERIMAGES_DEPS) \
2942 $(INTERNAL_VENDORIMAGE_FILES) \
2943 $(INSTALLED_FILES_FILE_VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07002944 $(build-vendorimage-target)
2945
Steven Morelanda2e734d2017-03-07 12:10:09 -08002946.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002947vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002948 $(build-vendorimage-target)
2949
Colin Cross91a52272017-06-20 16:57:52 -07002950sync: $(INTERNAL_VENDORIMAGE_FILES)
2951
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002952else ifdef BOARD_PREBUILT_VENDORIMAGE
2953INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2954$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2955endif
Ying Wanga0febe52013-03-20 11:02:05 -07002956
Ying Wang9f8e8db2011-11-04 11:37:01 -07002957# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002958# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002959ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002960INTERNAL_PRODUCTIMAGE_FILES := \
2961 $(filter $(TARGET_OUT_PRODUCT)/%,\
2962 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002963 $(ALL_PDK_FUSION_FILES)) \
2964 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002965
2966# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2967$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2968
2969INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002970INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2971$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002972$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002973 @echo Installed file list: $@
2974 @mkdir -p $(dir $@)
2975 @rm -f $@
2976 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002977 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002978
2979productimage_intermediates := \
2980 $(call intermediates-dir-for,PACKAGING,product)
2981BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2982define build-productimage-target
2983 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2984 @mkdir -p $(TARGET_OUT_PRODUCT)
2985 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002986 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002987 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002988 $(BUILD_IMAGE) \
2989 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2990 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2991 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002992endef
2993
2994# We just build this directly to the install location.
2995INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002996$(INSTALLED_PRODUCTIMAGE_TARGET): \
2997 $(INTERNAL_USERIMAGES_DEPS) \
2998 $(INTERNAL_PRODUCTIMAGE_FILES) \
2999 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003000 $(build-productimage-target)
3001
3002.PHONY: productimage-nodeps pnod
3003productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3004 $(build-productimage-target)
3005
3006sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3007
3008else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3009INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3010$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3011endif
3012
3013# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003014# system_ext partition image
3015ifdef BUILDING_SYSTEM_EXT_IMAGE
3016INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3017 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01003018 $(ALL_DEFAULT_INSTALLED_MODULES)\
3019 $(ALL_PDK_FUSION_FILES)) \
3020 $(PDK_FUSION_SYMLINK_STAMP)
3021
Justin Yun6151e3f2019-06-25 15:58:13 +09003022# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
3023$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003024
Justin Yun6151e3f2019-06-25 15:58:13 +09003025INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3026INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3027$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3028$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003029 @echo Installed file list: $@
3030 @mkdir -p $(dir $@)
3031 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09003032 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003033 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003034
Justin Yun6151e3f2019-06-25 15:58:13 +09003035system_extimage_intermediates := \
3036 $(call intermediates-dir-for,PACKAGING,system_ext)
3037BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3038define build-system_extimage-target
3039 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3040 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3041 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3042 $(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 -07003043 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003044 $(BUILD_IMAGE) \
3045 $(TARGET_OUT_SYSTEM_EXT) \
3046 $(system_extimage_intermediates)/system_ext_image_info.txt \
3047 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3048 $(TARGET_OUT)
3049 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003050endef
3051
3052# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003053INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003054$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3055 $(INTERNAL_USERIMAGES_DEPS) \
3056 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3057 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003058 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003059
Justin Yun6151e3f2019-06-25 15:58:13 +09003060.PHONY: systemextimage-nodeps senod
3061systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3062 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003063
Justin Yun6151e3f2019-06-25 15:58:13 +09003064sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003065
Justin Yun6151e3f2019-06-25 15:58:13 +09003066else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3067INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3068$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003069endif
3070
3071# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003072# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003073ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003074INTERNAL_ODMIMAGE_FILES := \
3075 $(filter $(TARGET_OUT_ODM)/%,\
3076 $(ALL_DEFAULT_INSTALLED_MODULES)\
3077 $(ALL_PDK_FUSION_FILES)) \
3078 $(PDK_FUSION_SYMLINK_STAMP)
3079# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
3080$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
3081
3082INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3083INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3084$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003085$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003086 @echo Installed file list: $@
3087 @mkdir -p $(dir $@)
3088 @rm -f $@
3089 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003090 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003091
3092odmimage_intermediates := \
3093 $(call intermediates-dir-for,PACKAGING,odm)
3094BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3095define build-odmimage-target
3096 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3097 @mkdir -p $(TARGET_OUT_ODM)
3098 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3099 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003100 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003101 $(BUILD_IMAGE) \
3102 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3103 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3104 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003105endef
3106
3107# We just build this directly to the install location.
3108INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003109$(INSTALLED_ODMIMAGE_TARGET): \
3110 $(INTERNAL_USERIMAGES_DEPS) \
3111 $(INTERNAL_ODMIMAGE_FILES) \
3112 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003113 $(build-odmimage-target)
3114
3115.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003116odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003117 $(build-odmimage-target)
3118
3119sync: $(INTERNAL_ODMIMAGE_FILES)
3120
3121else ifdef BOARD_PREBUILT_ODMIMAGE
3122INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3123$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3124endif
3125
3126# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003127# dtbo image
3128ifdef BOARD_PREBUILT_DTBOIMAGE
3129INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3130
3131ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003132$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003133 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3134 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003135 --image $@ \
3136 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3137 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3138 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003139else
3140$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3141 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3142endif
3143
Tao Bao0da43472018-08-22 22:53:41 -07003144endif # BOARD_PREBUILT_DTBOIMAGE
3145
3146# Returns a list of image targets corresponding to the given list of partitions. For example, it
3147# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3148# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003149# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003150define images-for-partitions
3151$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3152endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003153
3154# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003155# vbmeta image
3156ifeq ($(BOARD_AVB_ENABLE),true)
3157
3158BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003159AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003160
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003161ifdef BOARD_AVB_KEY_PATH
3162$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3163else
3164# If key path isn't specified, use the 4096-bit test key.
3165BOARD_AVB_ALGORITHM := SHA256_RSA4096
3166BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3167endif
3168
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003169# AVB signing for system_other.img.
3170ifdef BUILDING_SYSTEM_OTHER_IMAGE
3171ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3172$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3173else
3174# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3175BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3176BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3177endif
3178
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003179$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3180 @echo Extracting system_other avb key: $@
3181 @rm -f $@
3182 @mkdir -p $(dir $@)
3183 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003184
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003185ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3186BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3187endif
3188
3189BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3190endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3191
Tao Bao744c4c72018-08-20 21:09:07 -07003192INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003193 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003194 $(BOARD_AVB_VBMETA_VENDOR)
3195
3196# Not allowing the same partition to appear in multiple groups.
3197ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003198 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003199endif
3200
cfig1aeef722019-09-20 22:45:06 +08003201# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3202# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3203# details.
3204ifneq ($(AB_OTA_UPDATER),true)
3205ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3206$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
3207 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for non-A/B devices. \
3208 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3209endif
3210endif
3211
Bowgo Tsai9b548012019-05-14 16:57:03 +08003212# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003213
3214BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003215 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003216 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003217 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3218
3219BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003220 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003221 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003222 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3223
Justin Yun6151e3f2019-06-25 15:58:13 +09003224BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003225 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003226 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3227 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003228
Bowgo Tsai9b548012019-05-14 16:57:03 +08003229BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003230 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003231 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3232
Tao Bao19b02fe2019-10-09 00:04:28 -07003233BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3234 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3235
3236BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3237 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3238
Bowgo Tsai9b548012019-05-14 16:57:03 +08003239BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003240 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003241 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3242
3243BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003244 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003245 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3246
Tao Bao19b02fe2019-10-09 00:04:28 -07003247BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3248 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3249
Bowgo Tsai9b548012019-05-14 16:57:03 +08003250# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003251ifdef BOOT_SECURITY_PATCH
3252BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3253 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3254endif
3255
3256ifdef VENDOR_SECURITY_PATCH
3257BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3258 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3259endif
3260
3261ifdef ODM_SECURITY_PATCH
3262BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3263 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3264endif
3265
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003266BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003267VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003268DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3269SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3270VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003271RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003272PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003273SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003274ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003275
Tao Bao0da43472018-08-22 22:53:41 -07003276# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003277# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003278define _check-and-set-avb-chain-args
3279$(eval part := $(1))
3280$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003281
3282$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3283$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3284$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3285$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3286$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3287$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3288$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3289$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3290
3291# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3292$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3293$(eval $(_signing_args) := \
3294 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3295
cfig1aeef722019-09-20 22:45:06 +08003296# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3297# partition descriptor for recovery partition into vbmeta.img.
3298$(if $(or $(filter true,$(AB_OTA_UPDATER)),$(filter-out recovery,$(part))),\
3299 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3300 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003301
Tao Bao744c4c72018-08-20 21:09:07 -07003302# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003303# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003304$(if $(filter $(part),$(part:vbmeta_%=%)),\
3305 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3306 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003307endef
3308
Tao Bao0da43472018-08-22 22:53:41 -07003309# Checks and sets the required build variables for an AVB partition. The partition will be
3310# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003311# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3312# VBMeta image.
Tao Bao0da43472018-08-22 22:53:41 -07003313# $(1): Partition name, e.g. boot or system.
3314define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003315$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003316$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003317 $(if $(_in_chained_vbmeta),\
3318 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003319 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003320 $(if $(_in_chained_vbmeta),,\
3321 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3322 --include_descriptors_from_image $(call images-for-partitions,$(1)))))
Tao Bao0da43472018-08-22 22:53:41 -07003323endef
3324
Tao Baob1a2e352018-08-14 16:17:12 -07003325ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003326$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003327endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003328
Steve Mucklee1b10862019-07-10 10:49:37 -07003329ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3330$(eval $(call check-and-set-avb-args,vendor_boot))
3331endif
3332
Tao Bao0da43472018-08-22 22:53:41 -07003333$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003334
3335ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003336$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003337endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003338
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003339ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003340$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003341endif
3342
Justin Yun6151e3f2019-06-25 15:58:13 +09003343ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3344$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003345endif
3346
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003347ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003348$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003349endif
3350
Yueyao Zhu211c9012017-04-27 00:34:50 -07003351ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003352$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003353endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003354
David Zeuthen8fecb282017-12-01 16:24:01 -05003355ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003356$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003357endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003358
David Anderson7709ab22018-10-15 14:41:34 -07003359# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3360ifdef BOARD_AVB_VBMETA_SYSTEM
3361$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003362endif
3363
3364ifdef BOARD_AVB_VBMETA_VENDOR
3365$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3366endif
3367
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003368# Add kernel cmdline descriptor for kernel to mount system.img as root with
3369# dm-verity. This works when system.img is either chained or not-chained:
3370# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3371# cmdline descriptor to system.img
3372# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3373# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003374ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003375ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003376BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003377endif
David Anderson8916a2a2018-09-18 15:46:59 -07003378endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003379
Tao Bao0da43472018-08-22 22:53:41 -07003380BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003381BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003382BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3383
3384ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003385# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003386BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003387endif
Tao Bao0da43472018-08-22 22:53:41 -07003388
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003389ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003390BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003391endif
3392
David Anderson7709ab22018-10-15 14:41:34 -07003393ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3394BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3395 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003396endif
3397
3398ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3399BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3400 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003401endif
3402
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003403# $(1): the directory to extract public keys to
3404define extract-avb-chain-public-keys
3405 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3406 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3407 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003408 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3409 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3410 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003411 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3412 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3413 --output $(1)/system.avbpubkey)
3414 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3415 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3416 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003417 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3418 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3419 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003420 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3421 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3422 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003423 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3424 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3425 --output $(1)/odm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003426 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3427 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3428 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003429 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3430 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3431 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003432 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3433 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3434 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003435 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3436 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3437 --output $(1)/vbmeta_vendor.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003438endef
3439
Tao Bao744c4c72018-08-20 21:09:07 -07003440# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3441# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003442# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003443# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3444# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003445# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003446# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003447# $(2): Output filename.
3448define build-chained-vbmeta-image
3449 $(call pretty,"Target chained vbmeta image: $@")
3450 $(hide) $(AVBTOOL) make_vbmeta_image \
3451 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3452 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3453 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3454 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3455 --output $@
3456endef
3457
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003458ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003459ifdef BOARD_AVB_VBMETA_SYSTEM
3460INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3461$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003462 $(AVBTOOL) \
3463 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3464 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003465 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003466endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003467endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003468
3469ifdef BOARD_AVB_VBMETA_VENDOR
3470INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3471$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003472 $(AVBTOOL) \
3473 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3474 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003475 $(call build-chained-vbmeta-image,vbmeta_vendor)
3476endif
3477
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003478define build-vbmetaimage-target
3479 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003480 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3481 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003482 $(hide) $(AVBTOOL) make_vbmeta_image \
3483 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003484 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003485 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3486 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003487 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003488endef
3489
Paul Trautrim4e143232019-08-13 16:30:57 +09003490ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003491INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003492$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3493 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3494
David Zeuthen8fecb282017-12-01 16:24:01 -05003495$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003496 $(AVBTOOL) \
3497 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003498 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003499 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3500 $(INSTALLED_VENDORIMAGE_TARGET) \
3501 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003502 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003503 $(INSTALLED_ODMIMAGE_TARGET) \
3504 $(INSTALLED_DTBOIMAGE_TARGET) \
3505 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3506 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3507 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3508 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3509 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3510 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003511 $(build-vbmetaimage-target)
3512
3513.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003514vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3515 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003516vbmetaimage-nodeps:
3517 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003518endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003519
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003520endif # BOARD_AVB_ENABLE
3521
3522# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003523# Check VINTF of build
3524
3525ifndef TARGET_BUILD_APPS
3526intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3527check_vintf_all_deps :=
3528
Yifan Hongaf9b0702020-01-21 12:46:57 -08003529# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3530# because they are only used for prebuilt images.
3531check_vintf_common_srcs_patterns := \
3532 $(TARGET_OUT)/etc/vintf/% \
3533 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3534 $(TARGET_OUT_ODM)/etc/vintf/% \
3535 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3536 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3537
3538check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3539 $(INTERNAL_SYSTEMIMAGE_FILES) \
3540 $(INTERNAL_VENDORIMAGE_FILES) \
3541 $(INTERNAL_ODMIMAGE_FILES) \
3542 $(INTERNAL_PRODUCTIMAGE_FILES) \
3543 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3544))
3545check_vintf_common_srcs_patterns :=
3546
3547check_vintf_has_system :=
3548check_vintf_has_vendor :=
3549
Yifan Hong605ea042020-01-14 21:36:00 +00003550# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003551check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3552ifneq ($(check_vintf_system_deps),)
3553check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003554check_vintf_system_log := $(intermediates)/check_vintf_system_log
3555check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003556$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003557 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3558check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003559endif # check_vintf_system_deps
3560check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003561
3562# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003563check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3564ifneq ($(check_vintf_vendor_deps),)
3565check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003566check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3567check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003568$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003569 @( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3570check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003571endif # check_vintf_vendor_deps
3572check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003573
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003574# -- Check VINTF compatibility of build.
3575# Skip partial builds; only check full builds. Only check if:
3576# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003577# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003578# - Building product / system_ext / odm images if board has product / system_ext / odm images
3579ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003580ifeq ($(check_vintf_has_system),true)
3581ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003582ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3583ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3584ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3585
3586check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3587check_vintf_all_deps += $(check_vintf_compatible_log)
3588
3589check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003590check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003591
3592# -- Kernel version and configurations.
3593ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3594
Yifan Hong605ea042020-01-14 21:36:00 +00003595BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3596BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3597
3598my_board_extracted_kernel :=
3599
3600# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3601# from INSTALLED_KERNEL_TARGET.
3602ifdef BOARD_KERNEL_CONFIG_FILE
3603ifdef BOARD_KERNEL_VERSION
3604$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3605 cp $< $@
3606$(BUILT_KERNEL_VERSION_FILE):
3607 echo $(BOARD_KERNEL_VERSION) > $@
3608
3609my_board_extracted_kernel := true
3610endif # BOARD_KERNEL_VERSION
3611endif # BOARD_KERNEL_CONFIG_FILE
3612
3613ifneq ($(my_board_extracted_kernel),true)
3614ifndef INSTALLED_KERNEL_TARGET
3615$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3616 is true. Information about the updated kernel cannot be built into OTA update package. \
3617 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3618 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3619 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3620 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3621 manually.)
3622else
3623
3624# Tools for decompression that is not in PATH.
3625# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3626# Algorithms that are in the script but not in this list will be found in PATH.
3627my_decompress_tools := \
3628 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3629
3630$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3631$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3632$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
3633$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(INSTALLED_KERNEL_TARGET)
3634 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(INSTALLED_KERNEL_TARGET) \
3635 --output-configs $@ \
3636 --output-version $(BUILT_KERNEL_VERSION_FILE)
3637
3638my_decompress_tools :=
3639
3640endif # my_board_extracted_kernel
3641my_board_extracted_kernel :=
3642
3643endif # INSTALLED_KERNEL_TARGET
3644
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003645check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3646check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3647
3648endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3649
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003650check_vintf_compatible_args += \
3651 --dirmap /system:$(TARGET_OUT) \
3652 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3653 --dirmap /odm:$(TARGET_OUT_ODM) \
3654 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3655 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3656
3657ifdef PRODUCT_SHIPPING_API_LEVEL
3658check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3659endif # PRODUCT_SHIPPING_API_LEVEL
3660
3661$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3662$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
3663$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3664 @echo -n -e 'Deps: \n ' > $@
3665 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3666 @echo -n -e 'Args: \n ' >> $@
3667 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
3668 @echo -n -e 'For empty SKU:' >> $@
3669 @( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) >> $@ 2>&1 ) || ( cat $@ && exit 1 )
3670 $(foreach sku,$(ODM_MANIFEST_SKUS), \
3671 echo "For SKU = $(sku):" >> $@; \
3672 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
3673 --property ro.boot.product.hardware.sku=$(sku) >> $@ 2>&1 ) || ( cat $@ && exit 1 ); )
3674
3675check_vintf_compatible_log :=
3676check_vintf_compatible_args :=
3677check_vintf_compatible_deps :=
3678
3679endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3680endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3681endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003682endif # check_vintf_has_vendor
3683endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003684endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3685
3686# Add all logs of VINTF checks to dist builds
3687droid_targets: $(check_vintf_all_deps)
3688$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3689
3690# Helper alias to check all VINTF of current build.
3691.PHONY: check-vintf-all
3692check-vintf-all: $(check_vintf_all_deps)
3693 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3694
Yifan Hongaf9b0702020-01-21 12:46:57 -08003695check_vintf_has_vendor :=
3696check_vintf_has_system :=
3697check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003698check_vintf_all_deps :=
3699intermediates :=
3700endif # !TARGET_BUILD_APPS
3701
3702# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003703# Check image sizes <= size of super partition
3704
3705ifeq (,$(TARGET_BUILD_APPS))
3706# Do not check for apps-only build
3707
3708ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003709
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003710# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003711# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003712define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003713 mkdir -p $(dir $(1))
3714 rm -f $(1)
3715 $(call dump-super-image-info, $(1))
3716 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3717 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003718 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003719endef
3720
Yifan Hong30910932019-10-25 20:36:55 -07003721check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3722droid_targets: $(check_all_partition_sizes_log)
3723$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003724
Yifan Hong30910932019-10-25 20:36:55 -07003725$(check_all_partition_sizes_log): \
3726 $(CHECK_PARTITION_SIZES) \
3727 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3728 $(call check-all-partition-sizes-target, \
3729 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3730 $@)
3731
3732.PHONY: check-all-partition-sizes
3733check-all-partition-sizes: $(check_all_partition_sizes_log)
3734
3735.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003736check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003737 $(call check-all-partition-sizes-target, \
3738 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003739
Yifan Hong2dae5722018-07-31 12:47:27 -07003740endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003741
3742endif # TARGET_BUILD_APPS
3743
3744# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003745# bring in the installer image generation defines if necessary
3746ifeq ($(TARGET_USE_DISKINSTALLER),true)
3747include bootable/diskinstaller/config.mk
3748endif
3749
3750# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003751# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003752
Ying Wangbd2d0242015-09-22 11:17:52 -07003753ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003754 build_ota_package := false
3755 build_otatools_package := false
3756else
Tao Bao9be20c72019-04-08 21:11:59 -07003757 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003758 build_ota_package := true
3759 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3760 build_ota_package := false
3761 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003762 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003763 build_ota_package := false
3764 endif
3765 ifeq ($(TARGET_PRODUCT),sdk)
3766 build_ota_package := false
3767 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003768 ifeq ($(TARGET_BUILD_PDK),true)
3769 build_ota_package := false
3770 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003771 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3772 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3773 build_ota_package := false
3774 endif
3775 ifeq ($(TARGET_NO_KERNEL),true)
3776 build_ota_package := false
3777 endif
3778 ifeq ($(recovery_fstab),)
3779 build_ota_package := false
3780 endif
3781 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003782
Tao Bao9be20c72019-04-08 21:11:59 -07003783 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003784 build_otatools_package := true
3785 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3786 build_otatools_package := false
3787 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003788endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003789
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003790ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003791
3792INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003793 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003794 add_img_to_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003795 append2simg \
3796 avbtool \
3797 blk_alloc_to_base_fs \
3798 boot_signer \
3799 brillo_update_payload \
3800 brotli \
3801 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003802 build_image \
3803 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003804 build_verity_metadata \
3805 build_verity_tree \
3806 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003807 check_ota_package_signature \
3808 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003809 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003810 checkvintf \
3811 delta_generator \
3812 e2fsck \
3813 e2fsdroid \
3814 fc_sort \
3815 fec \
3816 fs_config \
3817 generate_verity_key \
3818 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003819 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003820 imgdiff \
3821 libconscrypt_openjdk_jni \
3822 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003823 lpunpack \
Tao Bao96daeeb2019-05-01 21:17:13 -07003824 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07003825 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003826 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003827 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003828 mkbootfs \
3829 mkbootimg \
3830 mke2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07003831 mkf2fsuserimg.sh \
3832 mksquashfs \
3833 mksquashfsimage.sh \
3834 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003835 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003836 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003837 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003838 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003839 sign_apex \
3840 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003841 signapk \
3842 simg2img \
3843 sload_f2fs \
3844 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003845 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003846 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003847 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003848 verity_signer \
3849 verity_verifier \
3850 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003851
Anton Hansson8dab0a62019-03-28 15:45:40 +00003852ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003853INTERNAL_OTATOOLS_MODULES += \
3854 futility \
3855 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003856endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003857
Tao Bao96daeeb2019-05-01 21:17:13 -07003858INTERNAL_OTATOOLS_FILES := \
3859 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003860
Ying Wang06898662010-06-17 17:52:18 -07003861.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003862otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003863
Tao Bao96daeeb2019-05-01 21:17:13 -07003864# For each module, recursively resolve its host shared library dependencies. Then we have a full
3865# list of modules whose installed files need to be packed.
3866INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3867 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3868 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003869
Tao Bao96daeeb2019-05-01 21:17:13 -07003870INTERNAL_OTATOOLS_PACKAGE_FILES := \
3871 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3872
3873INTERNAL_OTATOOLS_PACKAGE_FILES += \
3874 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3875 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003876
3877ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003878INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003879 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003880 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003881endif
3882ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003883INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003884 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3885 -name "atx_metadata.bin"))
3886endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003887ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003888INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003889 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003890endif
3891
Tao Bao96daeeb2019-05-01 21:17:13 -07003892INTERNAL_OTATOOLS_RELEASETOOLS := \
3893 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3894 \( -type f -o -type l \) -print))
3895
3896BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3897$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3898$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3899$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3900$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003901$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003902 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003903 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3904 mkdir -p $(dir $@)
3905 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3906 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tao Bao57f8ed62019-08-14 23:08:18 -07003907 cp $(SOONG_ZIP) $(ZIP2ZIP) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003908 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003909
3910.PHONY: otatools-package
3911otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3912
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003913endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003914
The Android Open Source Project88b60792009-03-03 19:28:42 -08003915# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003916# misc_info.txt
3917
3918INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3919
3920ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3921# default to common dir for device vendor
3922tool_extensions := $(TARGET_DEVICE_DIR)/../common
3923else
3924tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3925endif
3926.KATI_READONLY := tool_extensions
3927
3928$(INSTALLED_MISC_INFO_TARGET):
3929 rm -f $@
3930 $(call pretty,"Target misc_info.txt: $@")
3931 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3932 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3933ifdef BOARD_FLASH_BLOCK_SIZE
3934 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3935endif
3936ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
3937 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $@
3938endif
3939ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3940 $(hide) echo "no_boot=true" >> $@
3941endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003942ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3943 echo "vendor_boot=true" >> $@
3944 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3945endif
Daniel Normane1e48082019-06-27 13:55:23 -07003946ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3947 $(hide) echo "no_recovery=true" >> $@
3948endif
3949ifdef BOARD_INCLUDE_RECOVERY_DTBO
3950 $(hide) echo "include_recovery_dtbo=true" >> $@
3951endif
3952ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3953 $(hide) echo "include_recovery_acpio=true" >> $@
3954endif
3955ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3956 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3957endif
3958ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3959 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3960 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3961else
3962 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3963endif
3964 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
3965 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
3966ifdef PRODUCT_EXTRA_RECOVERY_KEYS
3967 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
3968endif
3969 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
3970 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
3971 $(hide) echo "multistage_support=1" >> $@
3972 $(hide) echo "blockimgdiff_versions=3,4" >> $@
3973ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3974 $(hide) echo "build_generic_ota_package=true" >> $@
3975endif
3976ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
3977 # OTA scripts are only interested in fingerprint related properties
3978 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
3979endif
3980ifneq (,$(filter address, $(SANITIZE_TARGET)))
3981 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
3982 $(hide) echo "userdata_img_with_data=true" >> $@
3983endif
3984ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
3985 $(hide) echo "full_recovery_image=true" >> $@
3986endif
Bill Peckhame868aec2019-09-17 17:06:47 -07003987ifdef BOARD_USES_VENDORIMAGE
3988 $(hide) echo "board_uses_vendorimage=true" >> $@
3989endif
Daniel Normane1e48082019-06-27 13:55:23 -07003990ifeq ($(BOARD_AVB_ENABLE),true)
3991 $(hide) echo "avb_enable=true" >> $@
3992 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
3993 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
3994 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
3995 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
3996ifdef BOARD_AVB_BOOT_KEY_PATH
3997 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
3998 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
3999 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4000endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004001 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4002ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4003 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4004 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4005 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4006endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004007 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4008ifdef BOARD_AVB_RECOVERY_KEY_PATH
4009 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4010 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4011 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4012endif # BOARD_AVB_RECOVERY_KEY_PATH
4013ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4014 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4015 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4016 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4017 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4018 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4019endif # BOARD_AVB_VBMETA_SYSTEM
4020ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4021 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4022 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4023 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4024 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4025 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4026endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4027endif # BOARD_AVB_ENABLE
4028ifdef BOARD_BPT_INPUT_FILES
4029 $(hide) echo "board_bpt_enable=true" >> $@
4030 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4031 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4032endif
4033ifdef BOARD_BPT_DISK_SIZE
4034 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4035endif
4036 $(call generate-userimage-prop-dictionary, $@)
4037ifeq ($(AB_OTA_UPDATER),true)
4038 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4039 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4040 $(hide) echo "ab_update=true" >> $@
4041endif
4042ifdef BOARD_PREBUILT_DTBOIMAGE
4043 $(hide) echo "has_dtbo=true" >> $@
4044ifeq ($(BOARD_AVB_ENABLE),true)
4045 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4046 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4047ifdef BOARD_AVB_DTBO_KEY_PATH
4048 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4049 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4050 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4051endif # BOARD_AVB_DTBO_KEY_PATH
4052endif # BOARD_AVB_ENABLE
4053endif # BOARD_PREBUILT_DTBOIMAGE
4054 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004055 @# VINTF checks
4056ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4057 $(hide) echo "vintf_enforce=true" >> $@
4058endif
4059ifdef ODM_MANIFEST_SKUS
4060 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4061endif
Daniel Normane1e48082019-06-27 13:55:23 -07004062
4063.PHONY: misc_info
4064misc_info: $(INSTALLED_MISC_INFO_TARGET)
4065
4066droidcore: $(INSTALLED_MISC_INFO_TARGET)
4067
4068# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004069# A zip of the directories that map to the target filesystem.
4070# This zip can be used to create an OTA package or filesystem image
4071# as a post-build step.
4072#
4073name := $(TARGET_PRODUCT)
4074ifeq ($(TARGET_BUILD_TYPE),debug)
4075 name := $(name)_debug
4076endif
4077name := $(name)-target_files-$(FILE_NAME_TAG)
4078
4079intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4080BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4081$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4082$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004083 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004084
4085# $(1): Directory to copy
4086# $(2): Location to copy it to
4087# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4088define package_files-copy-root
4089 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4090 mkdir -p $(2) && \
4091 $(ACP) -rd $(strip $(1))/* $(2); \
4092 fi
4093endef
4094
Tao Baoa04fca32015-11-30 12:22:24 -08004095built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004096
4097# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004098ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004099built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07004100 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
4101endif
4102
The Android Open Source Project88b60792009-03-03 19:28:42 -08004103$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4104
Dan Willemsen653bea92017-03-21 15:47:37 -07004105tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004106$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004107
Sen Jiang4438fd92016-03-07 16:51:01 -08004108ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004109updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08004110else
Steve Fung48e49f52015-10-01 23:53:31 -07004111# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004112updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004113endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004114$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004115
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004116# If we are using recovery as boot, output recovery files to BOOT/.
4117ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4118$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4119else
4120$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4121endif
4122
Dan Willemsen653bea92017-03-21 15:47:37 -07004123ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004124 ifdef OSRELEASED_DIRECTORY
4125 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4126 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4127 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4128 endif
Tao Baoa835f382019-07-18 15:55:30 -07004129
4130 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4131 # additionally include radio or bootloader partitions).
4132 ifeq ($(AB_OTA_PARTITIONS),)
4133 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4134 endif
4135endif
4136
4137ifneq ($(AB_OTA_PARTITIONS),)
4138 ifneq ($(AB_OTA_UPDATER),true)
4139 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4140 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004141endif
4142
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004143# Run fs_config while creating the target files package
4144# $1: root directory
4145# $2: add prefix
4146define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004147(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 -08004148endef
4149
Yifan Hong60bfcc42019-11-01 11:39:45 -07004150# Filter out vendor from the list for AOSP targets.
4151# $(1): list
4152define filter-out-missing-vendor
4153$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4154endef
4155
4156# Information related to dynamic partitions and virtual A/B. This information
4157# is needed for building the super image (see dump-super-image-info) and
4158# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004159# $(1): file
4160define dump-dynamic-partitions-info
4161 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4162 echo "use_dynamic_partitions=true" >> $(1))
4163 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4164 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004165 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4166 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4167 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004168 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4169 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004170 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4171 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4172 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4173 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4174 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4175 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004176 echo "dynamic_partition_list=$(call filter-out-missing-vendor, $(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004177 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4178 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4179 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4180 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4181 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004182 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 -07004183 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4184 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004185 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4186 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004187 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4188 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004189 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4190 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4191 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4192 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4193 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4194 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4195 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4196 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004197 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4198 echo "virtual_ab=true" >> $(1))
4199 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4200 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004201endef
4202
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004203# By conditionally including the dependency of the target files package on the
4204# full system image deps, we speed up builds that do not build the system
4205# image.
4206ifdef BUILDING_SYSTEM_IMAGE
4207$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4208endif
4209
Isaac Chen9e09d472019-07-05 17:30:41 +08004210ifeq ($(BUILD_QEMU_IMAGES),true)
4211MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4212$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4213endif
4214
The Android Open Source Project88b60792009-03-03 19:28:42 -08004215# Depending on the various images guarantees that the underlying
4216# directories are up-to-date.
4217$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004218 $(INSTALLED_RAMDISK_TARGET) \
4219 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004220 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004221 $(INSTALLED_RADIOIMAGE_TARGET) \
4222 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004223 $(INSTALLED_USERDATAIMAGE_TARGET) \
4224 $(INSTALLED_CACHEIMAGE_TARGET) \
4225 $(INSTALLED_VENDORIMAGE_TARGET) \
4226 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004227 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004228 $(INSTALLED_VBMETAIMAGE_TARGET) \
4229 $(INSTALLED_ODMIMAGE_TARGET) \
4230 $(INSTALLED_DTBOIMAGE_TARGET) \
4231 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4232 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4233 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004234 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004235 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4236 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004237 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004238 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004239 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4240 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4241 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004242 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004243 $(PRODUCT_ODM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004244 $(LPMAKE) \
4245 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004246 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004247 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004248 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004249 $(SOONG_ZIP) \
4250 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004251 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004252 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004253 $(BUILT_KERNEL_CONFIGS_FILE) \
4254 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004255 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004256 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004257 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004258 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004259 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004260 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004261 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004262 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004263ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004264 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004265 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004266 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004267 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004268ifdef INSTALLED_KERNEL_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004269 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004270endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004271ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4272 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
4273else # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
The Android Open Source Project88b60792009-03-03 19:28:42 -08004274ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004275 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004276endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004277ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004278ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004279 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004280else
Steve Mucklee1b10862019-07-10 10:49:37 -07004281 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004282endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004283endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004284ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004285 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004286endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004287ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004288 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004289endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004290ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004291 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004292endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004293ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004294 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004295endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004296ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004297 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004298endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004299endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004300endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004301 @# Components of the boot image
4302 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004303 $(hide) mkdir -p $(zip_root)/ROOT
4304 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004305 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004306 @# If we are using recovery as boot, this is already done when processing recovery.
4307ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004308ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004309 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004310 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004311endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004312ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004313 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004314endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004315ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004316ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004317 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004318endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004319ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004320 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004321endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004322 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004323ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004324 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004325endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004326ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004327 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004328endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004329else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4330 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4331endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4332endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004333 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4334 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004335 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004336ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4337 mkdir -p $(zip_root)/VENDOR_BOOT
4338 $(call package_files-copy-root, \
4339 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4340ifdef INSTALLED_DTBIMAGE_TARGET
4341 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4342endif
4343ifdef BOARD_KERNEL_BASE
4344 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4345endif
4346ifdef BOARD_KERNEL_PAGESIZE
4347 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4348endif
4349 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4350endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004351ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004352 @# Contents of the system image
4353 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004354 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004355endif
4356ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004357 @# Contents of the data image
4358 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004359 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004360endif
4361ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004362 @# Contents of the vendor image
4363 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004364 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004365endif
Dan Willemsen67495202019-01-16 12:42:05 -08004366ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004367 @# Contents of the product image
4368 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004369 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004370endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004371ifdef BUILDING_SYSTEM_EXT_IMAGE
4372 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004373 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004374 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004375endif
Dan Willemsen67495202019-01-16 12:42:05 -08004376ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004377 @# Contents of the odm image
4378 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004379 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004380endif
Dan Willemsen67495202019-01-16 12:42:05 -08004381ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004382 @# Contents of the system_other image
4383 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004384 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004385endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004386 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004387 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004388 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07004389ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004390ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004391 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004392 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004393endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004394endif
Doug Zongker8678df42009-06-15 14:30:14 -07004395 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004396 @# build them.
4397 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004398 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004399 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004400ifneq ($(tool_extension),)
4401 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4402endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004403 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004404 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004405 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004406ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4407 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4408 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004409endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004410ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4411 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4412 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004413endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004414ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4415 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4416 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004417endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004418ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4419 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4420 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004421endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004422ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4423 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4424 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004425endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004426ifneq ($(AB_OTA_UPDATER),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004427ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004428 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004429 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004430endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004431endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004432ifeq ($(AB_OTA_UPDATER),true)
4433 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004434 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004435 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004436 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4437 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004438 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4439 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4440 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004441ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004442 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4443 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4444 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004445endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004446endif
Steve Fungdfbab492015-09-24 18:12:33 -07004447ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004448 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004449 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004450endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004451ifdef BOARD_PREBUILT_VENDORIMAGE
4452 $(hide) mkdir -p $(zip_root)/IMAGES
4453 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4454endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004455ifdef BOARD_PREBUILT_PRODUCTIMAGE
4456 $(hide) mkdir -p $(zip_root)/IMAGES
4457 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4458endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004459ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004460 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004461 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004462endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004463ifdef BOARD_PREBUILT_BOOTIMAGE
4464 $(hide) mkdir -p $(zip_root)/IMAGES
4465 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4466endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004467ifdef BOARD_PREBUILT_ODMIMAGE
4468 $(hide) mkdir -p $(zip_root)/IMAGES
4469 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4470endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004471ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004472 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4473 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004474endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07004475 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4476 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4477 @# INSTALLED_RADIOIMAGE_TARGET.
4478 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4479 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004480 @# Run fs_config on all the system, vendor, boot ramdisk,
4481 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004482ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004483 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004484endif
4485ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004486 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4487endif
Dan Willemsen67495202019-01-16 12:42:05 -08004488ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004489 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4490endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004491ifdef BUILDING_SYSTEM_EXT_IMAGE
4492 $(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 +01004493endif
Dan Willemsen67495202019-01-16 12:42:05 -08004494ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004495 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4496endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004497 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004498 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004499ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004500 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004501 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004502endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004503ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4504 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4505endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004506ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4507 @# 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 -08004508 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4509endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004510ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4511 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4512endif
Dan Willemsen67495202019-01-16 12:42:05 -08004513ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004514 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4515endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004516 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004517ifdef BUILT_KERNEL_CONFIGS_FILE
4518 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4519endif
4520ifdef BUILT_KERNEL_VERSION_FILE
4521 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4522endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004523 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4524ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4525 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4526endif
Tao Baocbd6d492019-10-07 22:46:02 -07004527 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4528 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004529ifeq ($(BUILD_QEMU_IMAGES),true)
4530 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4531 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4532endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004533 @# Zip everything up, preserving symlinks and placing META/ files first to
4534 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004535 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004536 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004537 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004538
Ying Wanga0febe52013-03-20 11:02:05 -07004539.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004540target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4541
Ying Wang4709d7c2014-04-14 17:25:43 -07004542ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4543$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4544endif
Doug Zongker367910f2009-06-15 18:56:51 -07004545
Dan Albert4d323332016-10-14 13:23:06 -07004546# -----------------------------------------------------------------
4547# NDK Sysroot Package
4548NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004549$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004550 @echo Package NDK sysroot...
4551 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4552
4553$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4554
Ying Wang09c4b682015-08-11 11:24:19 -07004555ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004556# -----------------------------------------------------------------
4557# OTA update package
4558
Yifan Hong50e79542018-11-08 17:44:12 -08004559# $(1): output file
4560# $(2): additional args
4561define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004562PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004563 $(OTA_FROM_TARGET_FILES) \
4564 --verbose \
4565 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4566 --path $(HOST_OUT) \
4567 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4568 $(2) \
4569 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004570endef
4571
Doug Zongker8678df42009-06-15 14:30:14 -07004572name := $(TARGET_PRODUCT)
4573ifeq ($(TARGET_BUILD_TYPE),debug)
4574 name := $(name)_debug
4575endif
4576name := $(name)-ota-$(FILE_NAME_TAG)
4577
4578INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004579INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4580
Doug Zongker8678df42009-06-15 14:30:14 -07004581$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004582$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004583$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004584 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004585 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004586
4587.PHONY: otapackage
4588otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4589
Tao Bao519d1822018-12-27 12:47:23 -08004590ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004591name := $(TARGET_PRODUCT)
4592ifeq ($(TARGET_BUILD_TYPE),debug)
4593 name := $(name)_debug
4594endif
4595name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4596
4597INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004598$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004599$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4600 $(BUILT_TARGET_FILES_PACKAGE) \
4601 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004602 @echo "Package OTA (retrofit dynamic partitions): $@"
4603 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4604
4605.PHONY: otardppackage
4606
4607otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4608
Tao Bao519d1822018-12-27 12:47:23 -08004609endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004610
Ying Wang09c4b682015-08-11 11:24:19 -07004611endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004612
Ying Wang09a00a62010-10-20 14:01:09 -07004613# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004614# A zip of the appcompat directory containing logs
4615APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4616# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4617ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004618$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004619 $(INSTALLED_RAMDISK_TARGET) \
4620 $(INSTALLED_BOOTIMAGE_TARGET) \
4621 $(INSTALLED_USERDATAIMAGE_TARGET) \
4622 $(INSTALLED_VENDORIMAGE_TARGET) \
4623 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004624 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004625endif
4626$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4627$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4628 @echo "appcompat logs: $@"
4629 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4630 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4631 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4632 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4633
Dario Frenid1011272018-07-23 20:20:15 +01004634# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004635# A zip of the symbols directory. Keep the full paths to make it
4636# more obvious where these files came from.
4637#
4638name := $(TARGET_PRODUCT)
4639ifeq ($(TARGET_BUILD_TYPE),debug)
4640 name := $(name)_debug
4641endif
4642name := $(name)-symbols-$(FILE_NAME_TAG)
4643
4644SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004645# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07004646ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004647$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004648 $(INSTALLED_RAMDISK_TARGET) \
4649 $(INSTALLED_BOOTIMAGE_TARGET) \
4650 $(INSTALLED_USERDATAIMAGE_TARGET) \
4651 $(INSTALLED_VENDORIMAGE_TARGET) \
4652 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004653 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004654 $(INSTALLED_ODMIMAGE_TARGET) \
4655 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004656endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004657$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4658$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004659 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004660 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4661 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004662 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004663 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004664# -----------------------------------------------------------------
4665# A zip of the coverage directory.
4666#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004667name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004668ifeq ($(TARGET_BUILD_TYPE),debug)
4669name := $(name)_debug
4670endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004671COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
4672ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004673$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004674 $(INSTALLED_RAMDISK_TARGET) \
4675 $(INSTALLED_BOOTIMAGE_TARGET) \
4676 $(INSTALLED_USERDATAIMAGE_TARGET) \
4677 $(INSTALLED_VENDORIMAGE_TARGET) \
4678 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004679 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004680 $(INSTALLED_ODMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004681endif
4682$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4683$(COVERAGE_ZIP): $(SOONG_ZIP)
4684 @echo "Package coverage: $@"
4685 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4686 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4687 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4688 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004689
4690# -----------------------------------------------------------------
4691# A zip of the Android Apps. Not keeping full path so that we don't
4692# include product names when distributing
4693#
4694name := $(TARGET_PRODUCT)
4695ifeq ($(TARGET_BUILD_TYPE),debug)
4696 name := $(name)_debug
4697endif
4698name := $(name)-apps-$(FILE_NAME_TAG)
4699
4700APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004701$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004702 @echo "Package apps: $@"
4703 $(hide) rm -rf $@
4704 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004705 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4706 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004707 echo "No apps to zip up. Generating empty apps archive." ; \
4708 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004709 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004710 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004711 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004712
Ying Wangbc415dd2012-08-15 12:22:44 -07004713ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004714#------------------------------------------------------------------
4715# An archive of classes for use in generating code-coverage reports
4716# These are the uninstrumented versions of any classes that were
4717# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004718# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004719
Colin Crossa6bc3a82017-09-27 14:28:41 -07004720JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004721$(JACOCO_REPORT_CLASSES_ALL) :
4722 @echo "Collecting uninstrumented classes"
4723 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" | \
Anton Hansson6d814982018-11-26 18:12:05 +00004724 zip -@ -0 -q -X $@
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004725# Meaning of these options:
4726# -@ scan stdin for file paths to add to the zip
4727# -0 don't do any compression
4728# -q supress most output
4729# -X skip storing extended file attributes
4730
Ying Wangbc415dd2012-08-15 12:22:44 -07004731endif # EMMA_INSTRUMENT=true
4732
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004733
Ying Wangae9115a2013-08-22 20:52:47 -07004734#------------------------------------------------------------------
4735# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004736#
Ying Wangc62c92c2013-08-28 18:38:25 -07004737PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004738# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4739ifndef TARGET_BUILD_APPS
4740$(PROGUARD_DICT_ZIP): \
4741 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4742 $(INSTALLED_RAMDISK_TARGET) \
4743 $(INSTALLED_BOOTIMAGE_TARGET) \
4744 $(INSTALLED_USERDATAIMAGE_TARGET) \
4745 $(INSTALLED_VENDORIMAGE_TARGET) \
4746 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4747 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4748 $(INSTALLED_ODMIMAGE_TARGET) \
4749 $(updater_dep)
4750endif
4751$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4752$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004753 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004754 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4755 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4756 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4757 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004758
Tao Bao48a2feb2019-06-28 11:00:05 -07004759
4760ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4761
4762# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4763# $(1): output file
4764define dump-super-image-info
4765 $(call dump-dynamic-partitions-info,$(1))
4766 $(if $(filter true,$(AB_OTA_UPDATER)), \
4767 echo "ab_update=true" >> $(1))
4768endef
4769
4770endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4771
The Android Open Source Project88b60792009-03-03 19:28:42 -08004772# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004773# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004774
4775ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4776
4777# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4778ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4779
4780ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004781
4782# For real devices and for dist builds, build super image from target files to an intermediate directory.
4783INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4784$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4785$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4786 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004787 PATH=$(dir $(LPMAKE)):$$PATH \
4788 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004789
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004790# Skip packing it in dist package because it is in update package.
4791ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004792$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004793endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004794
4795.PHONY: superimage_dist
4796superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07004797
4798endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07004799endif # BOARD_SUPER_PARTITION_SIZE != ""
4800endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004801
Yifan Hongacd862a2019-04-16 15:44:30 -07004802# -----------------------------------------------------------------
4803# super partition image for development
4804
4805ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4806ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4807ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
4808
4809# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
4810# $(1): built image path
4811# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
4812define build-superimage-target
4813 mkdir -p $(dir $(2))
4814 rm -rf $(2)
4815 $(call dump-super-image-info,$(2))
4816 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4817 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09004818 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
4819 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07004820 mkdir -p $(dir $(1))
4821 PATH=$(dir $(LPMAKE)):$$PATH \
4822 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
4823endef
4824
4825INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
4826INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
4827 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
4828
changho.shina8f9f112019-10-15 13:26:19 +09004829ifdef BUILDING_SYSTEM_OTHER_IMAGE
4830ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
4831INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
4832endif
4833endif
4834
Yifan Hongacd862a2019-04-16 15:44:30 -07004835# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
4836# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
4837# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
4838# virtual devices.
4839ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
4840$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4841 $(call pretty,"Target super fs image for debug: $@")
4842 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08004843 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004844
4845droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
4846
4847# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
4848.PHONY: superimage
4849superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08004850
4851$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004852endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
4853
4854# Build $(PRODUCT_OUT)/super.img without dependencies.
4855.PHONY: superimage-nodeps supernod
4856superimage-nodeps supernod: intermediates :=
4857superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4858 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
4859 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
4860 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
4861
4862endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
4863endif # BOARD_SUPER_PARTITION_SIZE != ""
4864endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
4865
4866# -----------------------------------------------------------------
4867# super empty image
4868
Tao Bao48a2feb2019-06-28 11:00:05 -07004869ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004870ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004871
Yifan Hong8b79d162018-11-29 12:32:00 -08004872INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
4873$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
4874$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
4875 $(call pretty,"Target empty super fs image: $@")
4876 mkdir -p $(intermediates)
4877 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07004878 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08004879 PATH=$(dir $(LPMAKE)):$$PATH \
4880 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08004881
4882$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
4883
Yifan Hong2b891ac2018-11-29 12:06:31 -08004884endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07004885endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004886
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004887
4888# -----------------------------------------------------------------
4889# The update package
4890
4891name := $(TARGET_PRODUCT)
4892ifeq ($(TARGET_BUILD_TYPE),debug)
4893 name := $(name)_debug
4894endif
4895name := $(name)-img-$(FILE_NAME_TAG)
4896
4897INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
4898
Tao Bao57f8ed62019-08-14 23:08:18 -07004899$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
4900 $(call pretty,"Package: $@")
4901 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
4902 $(IMG_FROM_TARGET_FILES) \
4903 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
4904 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004905
4906.PHONY: updatepackage
4907updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07004908$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004909
4910
Yifan Hong2b891ac2018-11-29 12:06:31 -08004911# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004912# dalvik something
4913.PHONY: dalvikfiles
4914dalvikfiles: $(INTERNAL_DALVIK_MODULES)
4915
Bo Huf0d50bb2017-08-01 19:02:09 +00004916ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00004917MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08004918MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00004919SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08004920
4921ifdef INSTALLED_SYSTEMIMAGE_TARGET
4922INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08004923INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
4924$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
4925 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
4926 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08004927$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08004928 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
4929 @echo Create system-qemu.img now
4930 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08004931 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00004932
4933systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
4934droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08004935endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004936ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00004937INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004938$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00004939 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004940 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00004941
4942vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
4943droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
4944endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004945ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004946INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004947$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004948 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004949 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004950
4951productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
4952droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
4953endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004954ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4955INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
4956$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
4957 @echo Create system_ext-qemu.img
4958 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01004959
Justin Yun6151e3f2019-06-25 15:58:13 +09004960systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
4961droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01004962endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004963ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004964INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
4965$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
4966 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004967 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004968
4969odmimage: $(INSTALLED_QEMU_ODMIMAGE)
4970droidcore: $(INSTALLED_QEMU_ODMIMAGE)
4971endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004972
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004973QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08004974$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
4975 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004976 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08004977 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
4978 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004979
4980systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
4981droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08004982
Bo Huf0d50bb2017-08-01 19:02:09 +00004983endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004984# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004985# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07004986ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004987INTERNAL_EMULATOR_PACKAGE_FILES += \
4988 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08004989 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08004990 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07004991 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4992 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004993
4994name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
4995
4996INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
4997
Ying Wang5d887702015-11-04 10:06:25 -08004998$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004999 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005000 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005001
Ying Wang7d8c5352012-07-26 10:15:21 -07005002endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005003# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005004# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005005# The pdk package (Platform Development Kit)
5006
Keun young Park7fc7aad2012-02-27 15:49:23 -08005007#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5008# include development/pdk/Pdk.mk
5009#endif
5010
The Android Open Source Project88b60792009-03-03 19:28:42 -08005011
5012# -----------------------------------------------------------------
5013# The SDK
5014
The Android Open Source Project88b60792009-03-03 19:28:42 -08005015# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005016sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005017
5018# Build a name that looks like:
5019#
5020# linux-x86 --> android-sdk_12345_linux-x86
5021# darwin-x86 --> android-sdk_12345_mac-x86
5022# windows-x86 --> android-sdk_12345_windows
5023#
5024sdk_name := android-sdk_$(FILE_NAME_TAG)
5025ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005026 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005027else
Joe Onorato03fbe402009-04-13 08:31:16 -07005028 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005029endif
5030ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005031 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005032endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005033sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005034
5035sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5036
5037ATREE_FILES :=
5038-include $(sdk_dep_file)
5039
5040# if we don't have a real list, then use "everything"
5041ifeq ($(strip $(ATREE_FILES)),)
5042ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005043 $(ALL_DEFAULT_INSTALLED_MODULES) \
5044 $(INSTALLED_RAMDISK_TARGET) \
5045 $(ALL_DOCS) \
Nan Zhangcb0a6882018-08-07 15:26:32 -07005046 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api-stubs-docs_annotations.zip \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005047 $(ALL_SDK_FILES)
5048endif
5049
5050atree_dir := development/build
5051
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005052
The Android Open Source Project88b60792009-03-03 19:28:42 -08005053sdk_atree_files := \
5054 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005055 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005056
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005057# development/build/sdk-android-<abi>.atree is used to differentiate
5058# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5059# files like the kernel image. We use TARGET_CPU_ABI because we don't
5060# have a better way to distinguish between CPU models.
5061ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5062 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5063endif
5064
Anton Hansson8dab0a62019-03-28 15:45:40 +00005065ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5066sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005067else
5068sdk_atree_files += $(atree_dir)/sdk.atree
5069endif
5070
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005071include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005072
The Android Open Source Project88b60792009-03-03 19:28:42 -08005073deps := \
5074 $(target_notice_file_txt) \
5075 $(tools_notice_file_txt) \
5076 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005077 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005078 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005079 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005080 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005081 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005082 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005083 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005084 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005085 $(INSTALLED_USERDATAIMAGE_TARGET) \
5086 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005087 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005088 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005089 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005090 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005091 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005092 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005093 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005094
5095INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5096$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5097$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5098$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5099$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5100
5101# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5102#
5103#SDK_GNU_ERROR := true
5104
Ying Wang5d887702015-11-04 10:06:25 -08005105$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005106 @echo "Package SDK: $@"
5107 $(hide) rm -rf $(PRIVATE_DIR) $@
5108 $(hide) for f in $(target_gnu_MODULES); do \
5109 if [ -f $$f ]; then \
5110 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5111 including GNU target $$f >&2; \
5112 FAIL=$(SDK_GNU_ERROR); \
5113 fi; \
5114 done; \
5115 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005116 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005117 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005118 ATREE_STRIP="$(HOST_STRIP) -x" \
5119 $(HOST_OUT_EXECUTABLES)/atree \
5120 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5121 -m $(PRIVATE_DEP_FILE) \
5122 -I . \
5123 -I $(PRODUCT_OUT) \
5124 -I $(HOST_OUT) \
5125 -I $(TARGET_COMMON_OUT_ROOT) \
5126 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5127 -v "OUT_DIR=$(OUT_DIR)" \
5128 -v "HOST_OUT=$(HOST_OUT)" \
5129 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5130 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5131 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5132 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5133 -o $(PRIVATE_DIR) && \
5134 cp -f $(target_notice_file_txt) \
5135 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5136 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5137 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5138 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5139 chmod -R ug+rwX $(PRIVATE_DIR) && \
5140 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005141 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5142
Raphael3d224a02010-04-16 17:50:09 -07005143
5144# Is a Windows SDK requested? If so, we need some definitions from here
5145# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005146MAIN_SDK_NAME := $(sdk_name)
5147MAIN_SDK_DIR := $(sdk_dir)
5148MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005149ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005150include $(TOPDIR)development/build/tools/windows_sdk.mk
5151endif
5152
The Android Open Source Project88b60792009-03-03 19:28:42 -08005153# -----------------------------------------------------------------
5154# Findbugs
5155INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5156INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5157$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5158 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005159 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005160 > $@
5161$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5162 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005163 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005164 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005165
5166# -----------------------------------------------------------------
5167# Findbugs
5168
5169# -----------------------------------------------------------------
5170# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005171ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005172include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005173-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005174-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005175-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005176# Also the project-specific tasks
5177-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5178-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005179-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005180# Also add test specifc tasks
5181include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005182include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005183endif
Raphaelc4d47312011-02-15 16:09:36 -08005184
Ying Wang67132ba2015-10-28 16:42:39 -07005185include $(BUILD_SYSTEM)/product-graph.mk
5186
Raphaelc4d47312011-02-15 16:09:36 -08005187# -----------------------------------------------------------------
5188# Create SDK repository packages. Must be done after tasks/* since
5189# we need the addon rules defined.
5190ifneq ($(sdk_repo_goal),)
5191include $(TOPDIR)development/build/tools/sdk_repo.mk
5192endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005193
5194# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005195# Soong generates the list of all shared libraries that are depended on by fuzz
5196# targets. It saves this list as a source:destination pair to
5197# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5198# build of the unstripped shared library, and the destination is the
5199# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5200# where fuzz target shared libraries are to be "reinstalled". The
5201# copy-many-files below generates the rules to copy the unstripped shared
5202# libraries to the device or host "reinstallation" directory. These rules are
5203# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5204# a dependency on each shared library that it needs to be "reinstalled".
5205FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5206
5207# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005208# The rule to build all fuzz targets, and package them.
5209# Note: The packages are created in Soong, and in a perfect world,
5210# we'd be able to create the phony rule there. But, if we want to
5211# have dist goals for the fuzz target, we need to have the PHONY
5212# target defined in make. MakeVarsContext.DistForGoal doesn't take
5213# into account that a PHONY rule create by Soong won't be available
5214# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005215# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005216# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005217.PHONY: haiku
5218haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5219$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))