blob: c862e97c7dade16ccaddfd2c22f66cf5681dd375 [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 Rosenberg6cc2c812019-12-17 17:36:31 -08001574 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1575 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001576 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001577)
Yifan Hong760d3c02018-05-30 11:16:46 -07001578$(if $(filter $(2),cache),\
1579 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1580 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001581 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001582)
1583$(if $(filter $(2),vendor),\
1584 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1585 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1586 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1587 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1588 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1589 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1590 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1591 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1592 $(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 +00001593 $(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 -07001594 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001595 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001596)
1597$(if $(filter $(2),product),\
1598 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1599 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1600 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1601 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1602 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1603 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1604 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1605 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1606 $(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 +00001607 $(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 -07001608 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001609 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001610)
Justin Yun6151e3f2019-06-25 15:58:13 +09001611$(if $(filter $(2),system_ext),\
1612 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1613 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1614 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1615 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1616 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1617 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1618 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1619 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1620 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1621 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1622 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001623)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001624$(if $(filter $(2),odm),\
1625 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1626 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1627 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1628 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1629 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1630 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1631 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1632 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1633 $(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 +00001634 $(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 +08001635 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001636 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001637)
Yifan Hong760d3c02018-05-30 11:16:46 -07001638$(if $(filter $(2),oem),\
1639 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1640 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1641 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1642 $(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 -07001643 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001644)
Tao Bao3602eca2018-07-10 10:53:55 -07001645$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001646
Tao Bao3602eca2018-07-10 10:53:55 -07001647$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001648$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001649$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001650$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001651$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1652$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1653$(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 +00001654$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1655$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1656$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1657$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1658$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001659$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001660$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1661$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1662$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001663$(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 +00001664$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1665$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1666$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1667$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1668$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001669$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001670$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1671$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1672$(if $(BOARD_AVB_ENABLE),\
1673 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1674 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1675 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1676 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001677$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1678$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1679$(if $(BOARD_AVB_ENABLE),\
1680 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1681 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001682 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001683$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1684$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1685$(if $(BOARD_AVB_ENABLE),\
1686 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1687 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1688 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1689 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001690$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1691$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1692$(if $(BOARD_AVB_ENABLE),\
1693 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1694 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1695 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1696 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001697$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001698$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001699 $(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 +01001700$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001701 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1702 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1703 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1704 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001705$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1706$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1707$(if $(BOARD_AVB_ENABLE),\
1708 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1709 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1710 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1711 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001712$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1713 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001714$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001715 $(hide) echo "system_root_image=true" >> $(1))
1716$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Yifan Hong2dae5722018-07-31 12:47:27 -07001717$(if $(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),$(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001718$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1719endef
1720
1721# $(1): the path of the output dictionary file
1722# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001723PROP_DICTIONARY_IMAGES := oem
1724ifdef BUILDING_CACHE_IMAGE
1725 PROP_DICTIONARY_IMAGES += cache
1726endif
1727ifdef BUILDING_SYSTEM_IMAGE
1728 PROP_DICTIONARY_IMAGES += system
1729endif
1730ifdef BUILDING_USERDATA_IMAGE
1731 PROP_DICTIONARY_IMAGES += userdata
1732endif
1733ifdef BUILDING_VENDOR_IMAGE
1734 PROP_DICTIONARY_IMAGES += vendor
1735endif
1736ifdef BUILDING_PRODUCT_IMAGE
1737 PROP_DICTIONARY_IMAGES += product
1738endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001739ifdef BUILDING_SYSTEM_EXT_IMAGE
1740 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001741endif
1742ifdef BUILDING_ODM_IMAGE
1743 PROP_DICTIONARY_IMAGES += odm
1744endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001745define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001746 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001747endef
1748
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001749# $(1): the path of the input dictionary file, where each line has the format key=value
1750# $(2): the key to look up
1751define read-image-prop-dictionary
1752$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1753endef
1754
The Android Open Source Project88b60792009-03-03 19:28:42 -08001755# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001756# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001757
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001758# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001759ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001760
Ying Wang37526142015-03-10 12:02:57 -07001761INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1762 $(ALL_DEFAULT_INSTALLED_MODULES))
1763
Tao Bao10fc9492018-08-14 12:17:48 -07001764INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1765INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1766
1767# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1768# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1769# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1770# the call to FILELIST.
1771ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001772INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001773$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1774else
1775$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1776endif
1777
1778$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001779$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001780 @echo Installed file list: $@
1781 @mkdir -p $(dir $@)
1782 @rm -f $@
1783 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001784 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001785
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001786recovery_sepolicy := \
1787 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001788 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001789 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001790 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1791 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1792 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001793 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001794 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001795 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1796 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1797 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001798
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001799# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1800# SELinux files
1801IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1802
Doug Zongker4647f122009-07-02 09:00:54 -07001803recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1804recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Doug Zongker4647f122009-07-02 09:00:54 -07001805recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001806
Anton Hansson45a40da2019-01-18 14:06:34 +00001807# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1808# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1809# which get remapped to a bucket.
1810recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001811ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1812recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001813# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001814# ------160------240------320----------480------------640------
1815# mdpi hdpi xhdpi xxhdpi xxxhdpi
1816recovery_density := $(strip \
1817 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1818 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1819 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1820 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001821endif
1822
1823ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1824recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1825else
Doug Zongker25d55f82014-04-04 13:51:15 -07001826recovery_resources_common := $(recovery_resources_common)-xhdpi
1827endif
1828
Tao Baoe1e829e2018-08-29 20:36:00 -07001829# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1830# Note that the font selected here can be overridden for a particular device by putting a font.png
1831# in its private recovery resources.
1832ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001833recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1834else
1835recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1836endif
1837
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001838
1839# We will only generate the recovery background text images if the variable
1840# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1841# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1842# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1843# BoardConfig in order to use this feature.
1844ifeq ($(recovery_density),xxxhdpi)
1845TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1846else ifeq ($(recovery_density),xxhdpi)
1847TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1848endif
1849
1850ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1851# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1852ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1853 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1854else
1855 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1856endif
1857
1858
1859RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,PACKAGING,recovery_text_res)/installing_text.png
1860RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1861RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1862RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1863RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1864
xunchangcc57d312018-12-07 12:12:17 -08001865RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1866RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1867RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1868RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1869RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1870
1871generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001872 $(RECOVERY_INSTALLING_TEXT_FILE) \
1873 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1874 $(RECOVERY_ERASING_TEXT_FILE) \
1875 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001876 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1877 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1878 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1879 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1880 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1881 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001882
1883resource_dir := $(call include-path-for, recovery)/tools/recovery_l10n/res/
1884image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001885zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001886$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
1887$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,PACKAGING,recovery_font_files)
1888$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1889$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001890$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001891$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001892$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001893 recovery_installing \
1894 recovery_installing_security \
1895 recovery_erasing \
1896 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001897 recovery_no_command
1898$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001899 recovery_cancel_wipe_data \
1900 recovery_factory_data_reset \
1901 recovery_try_again \
1902 recovery_wipe_data_menu_header \
1903 recovery_wipe_data_confirmation
1904$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
1905$(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 -08001906 # Prepares the font directory.
1907 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1908 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001909 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001910 @rm -rf $(dir $@)
1911 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001912 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001913 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001914 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001915 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1916 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1917 --text_name $(text_name) \
1918 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1919 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001920 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001921 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001922else
1923RECOVERY_INSTALLING_TEXT_FILE :=
1924RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1925RECOVERY_ERASING_TEXT_FILE :=
1926RECOVERY_ERROR_TEXT_FILE :=
1927RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001928RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1929RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1930RECOVERY_TRY_AGAIN_TEXT_FILE :=
1931RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1932RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001933endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1934
Ying Wang9a175682015-08-06 11:47:47 -07001935ifndef TARGET_PRIVATE_RES_DIRS
1936TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1937endif
Doug Zongker4647f122009-07-02 09:00:54 -07001938recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001939 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001940recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001941
1942
Andrew Boiefa61ff02012-09-28 09:33:45 -07001943ifdef TARGET_RECOVERY_FSTAB
1944recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1945else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001946recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001947endif
Tao Baoc3c17532016-06-10 10:11:54 -07001948ifdef TARGET_RECOVERY_WIPE
1949recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001950else
Tao Baoc3c17532016-06-10 10:11:54 -07001951recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001952endif
Tao Bao8beab692015-07-22 12:33:18 -07001953
Tao Bao6d5d6232018-03-09 17:04:42 -08001954# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001955# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001956# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1957# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001958#
1959# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001960# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001961# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001962# b) We build a single image that contains boot and recovery both - no recovery image to install
1963# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001964# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001965# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001966# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1967# do bsdiff because boot and recovery will contain different number of entries
1968# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001969# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1970# do bsdiff because boot and recovery will contain different number of entries
1971# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001972
Tom Cherry2929cad2018-09-20 11:04:37 -07001973ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001974 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001975# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001976RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1977ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001978else
Tao Bao8beab692015-07-22 12:33:18 -07001979RECOVERY_RESOURCE_ZIP :=
1980endif
Doug Zongker4647f122009-07-02 09:00:54 -07001981
Tao Bao139c7272018-07-31 13:26:54 -07001982INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1983
1984$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001985 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1986 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1987 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1988 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1989 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1990 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1991 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1992 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1993
1994# Parses the given list of build variables and writes their values as build properties if defined.
1995# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1996# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1997# $(1): Map from the build variable names to property names
1998# $(2): Output file
1999define append-recovery-ui-properties
2000echo "#" >> $(2)
2001echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2002echo "#" >> $(2)
2003$(foreach prop,$(1), \
2004 $(eval _varname := $(call word-colon,1,$(prop))) \
2005 $(eval _propname := $(call word-colon,2,$(prop))) \
2006 $(eval _value := $($(_varname))) \
2007 $(if $(_value), \
2008 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2009endef
2010
2011$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00002012 $(INSTALLED_DEFAULT_PROP_TARGET) \
2013 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
2014 $(intermediate_system_build_prop) \
2015 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2016 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2017 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002018 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002019 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002020 $(hide) mkdir -p $(dir $@)
2021 $(hide) rm -f $@
2022 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) > $@
2023 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) >> $@
Tao Bao6eb1a992018-08-06 07:33:45 -07002024 $(hide) cat $(intermediate_system_build_prop) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002025 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002026 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002027 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002028 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002029 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2030
Steve Mucklee1b10862019-07-10 10:49:37 -07002031ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
2032 INTERNAL_RECOVERYIMAGE_ARGS := \
2033 --kernel $(recovery_kernel) --ramdisk $(recovery_ramdisk)
2034ifdef GENERIC_KERNEL_CMDLINE
2035 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
2036endif
2037else # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
2038 INTERNAL_RECOVERYIMAGE_ARGS := \
2039 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
2040 --kernel $(recovery_kernel) --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07002041# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002042ifdef INTERNAL_KERNEL_CMDLINE
2043 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07002044endif
2045ifdef BOARD_KERNEL_BASE
2046 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2047endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002048ifdef BOARD_KERNEL_PAGESIZE
2049 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2050endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002051ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002052ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2053 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2054else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002055 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2056endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002057endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002058ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2059 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2060endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002061ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2062 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2063endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002064endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Doug Zongker4647f122009-07-02 09:00:54 -07002065
Ying Wang747b9f12015-01-30 14:05:22 -08002066# $(1): output file
2067define build-recoveryimage-target
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002068 # Making recovery image
Ying Wang747b9f12015-01-30 14:05:22 -08002069 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao696bb332018-08-17 16:27:01 -07002070 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002071 # Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002072 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
Tao Bao696bb332018-08-17 16:27:01 -07002073 $(hide) rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002074 # Modifying ramdisk contents...
Tom Cherry3871f0f2018-11-06 14:23:44 -08002075 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2076 $(hide) ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
Bowgo Tsaib5b3bc62017-09-25 17:50:41 +08002077 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2078 $(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 -07002079 $(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 -08002080 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2081 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2082 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
xunchangcc57d312018-12-07 12:12:17 -08002083 $(hide) $(foreach recovery_text_file,$(generated_recovery_text_files), \
2084 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
Ying Wang747b9f12015-01-30 14:05:22 -08002085 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07002086 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2087 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08002088 $(hide) $(foreach item,$(recovery_fstab), \
Tao Bao696bb332018-08-17 16:27:01 -07002089 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07002090 $(if $(strip $(recovery_wipe)), \
Tao Bao696bb332018-08-17 16:27:01 -07002091 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
Hung-ying Tyanf829b402017-05-01 21:56:26 +08002092 $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07002093 $(BOARD_RECOVERY_IMAGE_PREPARE)
Thierry Strudel74a81e62015-07-09 09:54:55 -07002094 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002095 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00002096 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
Jooyung Han72b65ab2019-05-23 19:48:13 +09002097 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002098 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002099 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002100 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2101 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002102 )\
2103 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002104 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2105 $(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 +08002106 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
2107 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
2108 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002109 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2110 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
2111 $(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),\
2112 $(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 -08002113endef
2114
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002115ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002116ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Ying Wangbd07ad02016-03-10 12:57:33 -08002117$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
2118endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002119ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Ying Wangbd07ad02016-03-10 12:57:33 -08002120$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
2121endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002122ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002123$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002124endif
Tao Baof4866c72018-08-22 14:35:09 -07002125ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002126ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2127$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2128else
Tao Baof4866c72018-08-22 14:35:09 -07002129$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2130endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002131endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002132ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2133$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2134endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002135ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2136$(INSTALLED_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2137endif
Tao Baof4866c72018-08-22 14:35:09 -07002138
Jiyong Parkce3e34f2018-05-24 14:24:50 +09002139$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Anton Hansson6d814982018-11-26 18:12:05 +00002140 $(INTERNAL_ROOT_FILES) \
2141 $(INSTALLED_RAMDISK_TARGET) \
2142 $(INTERNAL_RECOVERYIMAGE_FILES) \
Tom Cherry89eea962019-11-04 10:41:51 -08002143 $(recovery_sepolicy) $(recovery_kernel) \
Anton Hansson6d814982018-11-26 18:12:05 +00002144 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2145 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2146 $(recovery_resource_deps) \
Colin Cross4f60e362019-06-05 11:53:43 -07002147 $(recovery_fstab)
Tao Baof4866c72018-08-22 14:35:09 -07002148 $(call pretty,"Target boot image from recovery: $@")
2149 $(call build-recoveryimage-target, $@)
Daniel Mentz4d6017d2019-12-19 20:48:43 -08002150$(INSTALLED_BOOTIMAGE_TARGET): .KATI_IMPLICIT_OUTPUTS += $(recovery_ramdisk)
Tao Baof4866c72018-08-22 14:35:09 -07002151endif # BOARD_USES_RECOVERY_AS_BOOT
2152
2153ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002154ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2155$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2156else
Tao Baof4866c72018-08-22 14:35:09 -07002157$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002158endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002159endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002160ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2161$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2162endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002163ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2164$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2165endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002166
Jiyong Parkce3e34f2018-05-24 14:24:50 +09002167$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Anton Hansson6d814982018-11-26 18:12:05 +00002168 $(INTERNAL_ROOT_FILES) \
2169 $(INSTALLED_RAMDISK_TARGET) \
2170 $(INSTALLED_BOOTIMAGE_TARGET) \
2171 $(INTERNAL_RECOVERYIMAGE_FILES) \
Tom Cherry89eea962019-11-04 10:41:51 -08002172 $(recovery_sepolicy) $(recovery_kernel) \
Anton Hansson6d814982018-11-26 18:12:05 +00002173 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2174 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2175 $(recovery_resource_deps) \
Colin Cross4f60e362019-06-05 11:53:43 -07002176 $(recovery_fstab)
Tao Baof4866c72018-08-22 14:35:09 -07002177 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07002178
Tao Bao4594d0e2015-12-22 09:47:46 -08002179ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002180$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002181 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002182 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2183 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002184endif
Doug Zongker56588872012-08-20 15:38:58 -07002185
Ying Wang747b9f12015-01-30 14:05:22 -08002186.PHONY: recoveryimage-nodeps
2187recoveryimage-nodeps:
2188 @echo "make $@: ignoring dependencies"
2189 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
2190
Chris Grossa784ef12019-04-22 11:09:57 -07002191else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002192RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002193endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002194
2195.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002196recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002197
Jiyong Park03eb0612017-10-04 21:22:41 +09002198ifneq ($(BOARD_NAND_PAGE_SIZE),)
2199$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002200endif
2201
Jiyong Park03eb0612017-10-04 21:22:41 +09002202ifneq ($(BOARD_NAND_SPARE_SIZE),)
2203$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002204endif
2205
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002206ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002207# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002208# the debug ramdisk, which is the original ramdisk plus additional
2209# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2210# When /force_debuggable is present, /init will load userdebug sepolicy
2211# and property files to allow adb root, if the device is unlocked.
2212
2213ifdef BUILDING_RAMDISK_IMAGE
2214BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2215INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2216
2217INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2218 $(ALL_GENERATED_SOURCES) \
2219 $(ALL_DEFAULT_INSTALLED_MODULES))
2220
2221# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2222# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2223# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2224my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2225
2226INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2227INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2228$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2229$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2230
2231# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2232# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2233# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2234$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002235$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002236 echo Installed file list: $@
2237 mkdir -p $(dir $@)
2238 rm -f $@
2239 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002240 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002241
2242# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2243# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2244ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2245my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2246else
2247my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2248endif # BOARD_USES_RECOVERY_AS_BOOT
2249
2250$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2251$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002252
2253ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2254# 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 +08002255$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002256else
2257# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2258$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2259endif # BOARD_USES_RECOVERY_AS_BOOT
Bowgo Tsai0013f552019-03-20 17:59:52 +08002260$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(MINIGZIP)
2261 $(call pretty,"Target debug ram disk: $@")
2262 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2263 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002264 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002265 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2266
2267.PHONY: ramdisk_debug-nodeps
2268ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2269ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2270ramdisk_debug-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2271 echo "make $@: ignoring dependencies"
2272 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2273 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002274 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002275 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
2276
2277my_debug_ramdisk_sync_dir :=
2278my_debug_ramdisk_root_dir :=
2279
2280endif # BUILDING_RAMDISK_IMAGE
2281
2282# -----------------------------------------------------------------
2283# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2284#
2285# Note: it's intentional to skip signing for boot-debug.img, because it
2286# can only be used if the device is unlocked with verification error.
2287ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2288
2289INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2290
2291# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2292ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2293INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2294else
2295INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2296endif
2297
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002298# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2299# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2300# Using a test key to sign boot-debug.img to continue booting with the mismatched
2301# public key, if the device is unlocked.
2302ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002303$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002304endif
2305
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002306BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2307INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2308# $(1): the bootimage to sign
2309define test-key-sign-bootimage
2310$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
2311$(AVBTOOL) add_hash_footer \
2312 --image $(1) \
2313 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
2314 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2315 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
2316$(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
2317endef
2318
Bowgo Tsai0013f552019-03-20 17:59:52 +08002319# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2320$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2321 $(call pretty,"Target boot debug image: $@")
2322 $(MKBOOTIMG) $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002323 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002324
2325.PHONY: bootimage_debug-nodeps
2326bootimage_debug-nodeps: $(MKBOOTIMG)
2327 echo "make $@: ignoring dependencies"
2328 $(MKBOOTIMG) $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002329 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET)))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002330
2331endif # TARGET_NO_KERNEL
2332
2333# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002334# The test harness ramdisk, which is based off debug_ramdisk, plus a
2335# few additional test-harness-specific properties in adb_debug.prop.
2336
2337ifdef BUILDING_RAMDISK_IMAGE
2338BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2339INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2340
2341# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2342# appends a few test harness specific properties into the adb_debug.prop.
2343TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2344TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2345
2346# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2347# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2348TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2349ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2350ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2351
2352# $(1): a list of key=value pairs for additional property assignments
2353# $(2): the target .prop file to append the properties from $(1)
2354define append-test-harness-props
2355 echo "#" >> $(2); \
2356 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2357 echo "#" >> $(2);
2358 $(foreach line,$(1), echo "$(line)" >> $(2);)
2359endef
2360
2361$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
2362$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(MINIGZIP)
2363 $(call pretty,"Target test harness ram disk: $@")
2364 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2365 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2366 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2367
2368.PHONY: ramdisk_test_harness-nodeps
2369ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2370 echo "make $@: ignoring dependencies"
2371 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2372 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2373 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2374
2375endif # BUILDING_RAMDISK_IMAGE
2376
2377# -----------------------------------------------------------------
2378# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2379#
2380# Note: it's intentional to skip signing for boot-test-harness.img, because it
2381# can only be used if the device is unlocked with verification error.
2382ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2383
2384INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2385
2386# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2387INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2388
2389# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2390# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2391# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2392# public key, if the device is unlocked.
2393ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2394$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2395endif
2396
2397# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2398$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2399 $(call pretty,"Target boot test harness image: $@")
2400 $(MKBOOTIMG) $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2401 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2402
2403.PHONY: bootimage_test_harness-nodeps
2404bootimage_test_harness-nodeps: $(MKBOOTIMG)
2405 echo "make $@: ignoring dependencies"
2406 $(MKBOOTIMG) $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
2407 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)))
2408
2409endif # TARGET_NO_KERNEL
2410endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2411
2412# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002413# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002414#
Ying Wang9c649a72012-08-08 15:27:00 -07002415# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2416PDK_FUSION_SYSIMG_FILES := \
2417 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2418 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002419
Dan Willemsen37a19862018-10-31 16:31:46 -07002420INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002421 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002422 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002423 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002424 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002425
Ying Wang82cceba2012-08-13 15:03:00 -07002426FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002427
2428# ASAN libraries in the system image - add dependency.
2429ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002430ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002431 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2432 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2433 endif
2434endif
2435
Tom Cherryd14b8952018-08-09 14:26:00 -07002436FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002437
Ying Wange5e8c5f2011-09-09 16:35:53 -07002438# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002439ifdef BUILDING_SYSTEM_IMAGE
2440
Ying Wange5e8c5f2011-09-09 16:35:53 -07002441# installed file list
2442# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2443# We put installed-files.txt ahead of image itself in the dependency graph
2444# so that we can get the size stat even if the build fails due to too large
2445# system image.
2446INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002447INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2448$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002449$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002450 @echo Installed file list: $@
2451 @mkdir -p $(dir $@)
2452 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002453 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002454 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002455
2456.PHONY: installed-file-list
2457installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002458
2459$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002460
2461systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002462 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002463BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2464
Ying Wang23898df2014-06-18 20:26:24 -07002465# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002466ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002467define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002468$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2469 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2470 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2471 exit 1; \
2472fi
Ying Wang23898df2014-06-18 20:26:24 -07002473$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2474endef
2475else
2476define create-system-vendor-symlink
2477endef
2478endif
2479
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002480# Create symlink /system/product to /product if necessary.
2481ifdef BOARD_USES_PRODUCTIMAGE
2482define create-system-product-symlink
2483$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2484 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2485 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2486 exit 1; \
2487fi
2488$(hide) ln -sf /product $(TARGET_OUT)/product
2489endef
2490else
2491define create-system-product-symlink
2492endef
2493endif
2494
Justin Yun6151e3f2019-06-25 15:58:13 +09002495# Create symlink /system/system_ext to /system_ext if necessary.
2496ifdef BOARD_USES_SYSTEM_EXTIMAGE
2497define create-system-system_ext-symlink
2498$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2499 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2500 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 +01002501 exit 1; \
2502fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002503$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002504endef
2505else
Justin Yun6151e3f2019-06-25 15:58:13 +09002506define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002507endef
2508endif
2509
The Android Open Source Project88b60792009-03-03 19:28:42 -08002510# $(1): output file
2511define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002512 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002513 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002514 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002515 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002516 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002517 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002518 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002519 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002520 $(BUILD_IMAGE) \
2521 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2522 || ( mkdir -p $${DIST_DIR}; \
2523 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2524 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002525endef
2526
Dan Willemsen6b72c732019-06-12 21:33:38 +00002527ifeq ($(BOARD_AVB_ENABLE),true)
2528$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2529endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002530$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002531 $(call build-systemimage-target,$@)
2532
Tao Baoe9d61b02018-08-20 21:09:07 -07002533INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002534SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002535
Tao Baoe9d61b02018-08-20 21:09:07 -07002536# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2537# compatibility, in case device-specific Makefiles still refer to the old name.
2538INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2539
Doug Zongker73ef8252009-07-23 15:12:53 -07002540# The system partition needs room for the recovery image as well. We
2541# now store the recovery image as a binary patch using the boot image
2542# as the source (since they are very similar). Generate the patch so
2543# we can see how big it's going to be, and include that in the system
2544# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002545ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002546ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002547ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002548ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002549diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2550else
2551diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2552endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002553intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2554RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002555$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2556$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002557 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2558 $(INSTALLED_BOOTIMAGE_TARGET) \
2559 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002560 @echo "Construct recovery from boot"
2561 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002562 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002563else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2564RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002565endif # BOARD_USES_FULL_RECOVERY_IMAGE
2566endif # INSTALLED_RECOVERYIMAGE_TARGET
2567endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002568
Tao Baoe9d61b02018-08-20 21:09:07 -07002569$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002570 @echo "Install system fs image: $@"
2571 $(copy-file-to-target)
Yifan Hong8c3dce02019-04-09 17:03:57 +00002572 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002573
Tao Baoe9d61b02018-08-20 21:09:07 -07002574systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002575
2576.PHONY: systemimage-nodeps snod
2577systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002578 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002579 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002580 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002581 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002582
Ying Wangacf01ec2012-02-24 11:05:48 -08002583ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
2584ifeq (true,$(WITH_DEXPREOPT))
2585$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
2586endif
2587endif
2588
Dan Willemsen67495202019-01-16 12:42:05 -08002589endif # BUILDING_SYSTEM_IMAGE
2590
Anton Hansson30e061b2018-11-12 13:36:46 +00002591.PHONY: sync syncsys
2592sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002593
Ying Wang3a61eeb2016-03-11 10:32:01 -08002594# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002595## platform.zip: system, plus other files to be used in PDK fusion build,
2596## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002597##
2598## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2599## The variable will be typically set from BoardConfig.mk.
2600## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002601ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002602pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
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_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002605 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002606pdk_classes_dex := $(strip \
2607 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002608 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002609
2610pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2611$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2612$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2613$(pdk_odex_config_mk) :
2614 @echo "PDK odex config makefile: $@"
2615 $(hide) mkdir -p $(dir $@)
2616 $(hide) echo "# Auto-generated. Do not modify." > $@
2617 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2618 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2619 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2620 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2621 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2622 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2623 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2624 )
2625 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002626 $(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 -08002627 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2628 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2629 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2630 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002631 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002632 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2633 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2634 )
2635
keunyoungc0178062013-07-22 14:54:58 -07002636PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002637INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002638
2639$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2640$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002641$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2642# dependencies for the other partitions are defined below after their file lists
2643# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002644$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002645 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002646 rm -f $@ $@.lst
2647 echo "-C $(PRODUCT_OUT)" >> $@.lst
2648 echo "-D $(TARGET_OUT)" >> $@.lst
2649 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2650 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002651ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002652 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002653endif
Dan Willemsen67495202019-01-16 12:42:05 -08002654ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002655 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002656endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002657ifdef BUILDING_SYSTEM_EXT_IMAGE
2658 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002659endif
Dan Willemsen67495202019-01-16 12:42:05 -08002660ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002661 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002662endif
Colin Crossc451a372013-12-18 19:36:44 -08002663ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002664 echo "-C $(OUT_DIR)" >> $@.lst
2665 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2666 if [ -e $$f ]; then \
2667 echo "-f $$f"; \
2668 fi \
2669 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002670endif
keunyoungc0178062013-07-22 14:54:58 -07002671ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002672 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002673endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002674 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002675 $(if $(PRIVATE_DEX_FILES),\
2676 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002677 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002678 touch $(PRODUCT_OUT)/pdk.mk
2679 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2680 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002681
2682.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002683platform: $(INSTALLED_PLATFORM_ZIP)
2684
2685.PHONY: platform-java
2686platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002687
2688# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002689ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2690$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002691endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002692
Colin Cross53c8f972018-09-28 16:19:42 -07002693endif # BUILD_PLATFORM_ZIP
2694
Ying Wang3a61eeb2016-03-11 10:32:01 -08002695# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002696# data partition image
2697INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002698 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002699
Dan Willemsen67495202019-01-16 12:42:05 -08002700ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002701userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002702 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002703BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2704
Ying Wangbd93d422011-10-28 17:02:30 -07002705define build-userdataimage-target
2706 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2707 @mkdir -p $(TARGET_OUT_DATA)
2708 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002709 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002710 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002711 $(BUILD_IMAGE) \
2712 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2713 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2714 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002715endef
2716
Joe Onorato64d85d02009-04-09 19:31:12 -07002717# We just build this directly to the install location.
2718INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002719INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2720 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002721 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002722$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002723 $(build-userdataimage-target)
2724
2725.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002726userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002727 $(build-userdataimage-target)
2728
Dan Willemsen67495202019-01-16 12:42:05 -08002729endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002730
Andreas Gampe039b5c72017-03-24 16:06:31 -07002731# ASAN libraries in the system image - build rule.
2732ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2733 $(TARGET_OUT_SHARED_LIBRARIES) \
2734 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2735 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2736 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002737# Extra options: Enforce the system user for the files to avoid having to change ownership.
2738ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002739# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2740# enough space.
2741$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002742 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 -07002743
The Android Open Source Project88b60792009-03-03 19:28:42 -08002744# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002745# partition table image
2746ifdef BOARD_BPT_INPUT_FILES
2747
2748BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002749BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002750
2751INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2752 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002753 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002754 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2755
2756ifdef BOARD_BPT_DISK_SIZE
2757INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2758endif
2759
2760define build-bptimage-target
2761 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2762 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2763endef
2764
2765INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002766$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2767 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2768
David Zeuthen25328622016-04-08 15:08:03 -04002769$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2770 $(build-bptimage-target)
2771
2772.PHONY: bptimage-nodeps
2773bptimage-nodeps:
2774 $(build-bptimage-target)
2775
2776endif # BOARD_BPT_INPUT_FILES
2777
2778# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002779# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002780ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002781INTERNAL_CACHEIMAGE_FILES := \
2782 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2783
2784cacheimage_intermediates := \
2785 $(call intermediates-dir-for,PACKAGING,cache)
2786BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2787
2788define build-cacheimage-target
2789 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2790 @mkdir -p $(TARGET_OUT_CACHE)
2791 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002792 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002793 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002794 $(BUILD_IMAGE) \
2795 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2796 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2797 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002798endef
2799
2800# We just build this directly to the install location.
2801INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002802$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002803 $(build-cacheimage-target)
2804
2805.PHONY: cacheimage-nodeps
2806cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2807 $(build-cacheimage-target)
2808
Dan Willemsen67495202019-01-16 12:42:05 -08002809else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002810# we need to ignore the broken cache link when doing the rsync
2811IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002812endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002813
David Zeuthen0eb10972016-09-28 17:55:27 -04002814# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002815# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002816ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002817ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002818# Marker file to identify that odex files are installed
2819INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2820ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2821$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2822 $(hide) touch $@
2823endif
2824
Alex Light4e358ab2016-06-16 14:47:10 -07002825INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2826 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2827 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002828 $(ALL_PDK_FUSION_FILES)) \
2829 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002830
Colin Cross6db5b0e2018-11-16 21:26:33 -08002831# system_other dex files are installed as a side-effect of installing system image files
2832INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2833
Alex Light4e358ab2016-06-16 14:47:10 -07002834INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002835INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2836$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002837$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002838 @echo Installed file list: $@
2839 @mkdir -p $(dir $@)
2840 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002841 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002842 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002843
Bowgo Tsai867ab662019-01-29 13:30:18 +08002844# Determines partition size for system_other.img.
2845ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2846ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2847INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2848endif
2849endif
2850
2851ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2852INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2853endif
2854
Alex Light4e358ab2016-06-16 14:47:10 -07002855systemotherimage_intermediates := \
2856 $(call intermediates-dir-for,PACKAGING,system_other)
2857BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2858
2859# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2860define build-systemotherimage-target
2861 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2862 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2863 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002864 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002865 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002866 $(BUILD_IMAGE) \
2867 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2868 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2869 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002870endef
2871
2872# We just build this directly to the install location.
2873INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002874ifneq (true,$(SANITIZE_LITE))
2875# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002876$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2877 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002878endif
Alex Light4e358ab2016-06-16 14:47:10 -07002879
2880.PHONY: systemotherimage-nodeps
2881systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2882 $(build-systemotherimage-target)
2883
Dan Willemsen67495202019-01-16 12:42:05 -08002884endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002885
2886
2887# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002888# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002889ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002890INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002891 $(filter $(TARGET_OUT_VENDOR)/%,\
2892 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002893 $(ALL_PDK_FUSION_FILES)) \
2894 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07002895
2896# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
2897$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07002898
Ying Wang8da19e32015-09-15 14:22:12 -07002899INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002900INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2901$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002902$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07002903 @echo Installed file list: $@
2904 @mkdir -p $(dir $@)
2905 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002906 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002907 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002908
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002909# Create symlink /vendor/odm to /odm if necessary.
2910ifdef BOARD_USES_ODMIMAGE
2911define create-vendor-odm-symlink
2912$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
2913 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
2914 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
2915 exit 1; \
2916fi
2917$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
2918endef
2919else
2920define create-vendor-odm-symlink
2921endef
2922endif
2923
Ying Wanga0febe52013-03-20 11:02:05 -07002924vendorimage_intermediates := \
2925 $(call intermediates-dir-for,PACKAGING,vendor)
2926BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002927define build-vendorimage-target
2928 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2929 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002930 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002931 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002932 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002933 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002934 $(BUILD_IMAGE) \
2935 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2936 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
2937 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002938endef
2939
2940# We just build this directly to the install location.
2941INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002942$(INSTALLED_VENDORIMAGE_TARGET): \
2943 $(INTERNAL_USERIMAGES_DEPS) \
2944 $(INTERNAL_VENDORIMAGE_FILES) \
2945 $(INSTALLED_FILES_FILE_VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07002946 $(build-vendorimage-target)
2947
Steven Morelanda2e734d2017-03-07 12:10:09 -08002948.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002949vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002950 $(build-vendorimage-target)
2951
Colin Cross91a52272017-06-20 16:57:52 -07002952sync: $(INTERNAL_VENDORIMAGE_FILES)
2953
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002954else ifdef BOARD_PREBUILT_VENDORIMAGE
2955INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2956$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2957endif
Ying Wanga0febe52013-03-20 11:02:05 -07002958
Ying Wang9f8e8db2011-11-04 11:37:01 -07002959# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002960# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002961ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002962INTERNAL_PRODUCTIMAGE_FILES := \
2963 $(filter $(TARGET_OUT_PRODUCT)/%,\
2964 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002965 $(ALL_PDK_FUSION_FILES)) \
2966 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002967
2968# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2969$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2970
2971INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002972INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2973$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002974$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002975 @echo Installed file list: $@
2976 @mkdir -p $(dir $@)
2977 @rm -f $@
2978 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002979 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002980
2981productimage_intermediates := \
2982 $(call intermediates-dir-for,PACKAGING,product)
2983BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2984define build-productimage-target
2985 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2986 @mkdir -p $(TARGET_OUT_PRODUCT)
2987 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002988 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002989 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002990 $(BUILD_IMAGE) \
2991 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2992 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2993 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002994endef
2995
2996# We just build this directly to the install location.
2997INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002998$(INSTALLED_PRODUCTIMAGE_TARGET): \
2999 $(INTERNAL_USERIMAGES_DEPS) \
3000 $(INTERNAL_PRODUCTIMAGE_FILES) \
3001 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003002 $(build-productimage-target)
3003
3004.PHONY: productimage-nodeps pnod
3005productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3006 $(build-productimage-target)
3007
3008sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3009
3010else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3011INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3012$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3013endif
3014
3015# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003016# system_ext partition image
3017ifdef BUILDING_SYSTEM_EXT_IMAGE
3018INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3019 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01003020 $(ALL_DEFAULT_INSTALLED_MODULES)\
3021 $(ALL_PDK_FUSION_FILES)) \
3022 $(PDK_FUSION_SYMLINK_STAMP)
3023
Justin Yun6151e3f2019-06-25 15:58:13 +09003024# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
3025$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003026
Justin Yun6151e3f2019-06-25 15:58:13 +09003027INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3028INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3029$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3030$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003031 @echo Installed file list: $@
3032 @mkdir -p $(dir $@)
3033 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09003034 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003035 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003036
Justin Yun6151e3f2019-06-25 15:58:13 +09003037system_extimage_intermediates := \
3038 $(call intermediates-dir-for,PACKAGING,system_ext)
3039BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3040define build-system_extimage-target
3041 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3042 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3043 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3044 $(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 -07003045 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003046 $(BUILD_IMAGE) \
3047 $(TARGET_OUT_SYSTEM_EXT) \
3048 $(system_extimage_intermediates)/system_ext_image_info.txt \
3049 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3050 $(TARGET_OUT)
3051 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003052endef
3053
3054# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003055INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003056$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3057 $(INTERNAL_USERIMAGES_DEPS) \
3058 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3059 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003060 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003061
Justin Yun6151e3f2019-06-25 15:58:13 +09003062.PHONY: systemextimage-nodeps senod
3063systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3064 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003065
Justin Yun6151e3f2019-06-25 15:58:13 +09003066sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003067
Justin Yun6151e3f2019-06-25 15:58:13 +09003068else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3069INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3070$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003071endif
3072
3073# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003074# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003075ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003076INTERNAL_ODMIMAGE_FILES := \
3077 $(filter $(TARGET_OUT_ODM)/%,\
3078 $(ALL_DEFAULT_INSTALLED_MODULES)\
3079 $(ALL_PDK_FUSION_FILES)) \
3080 $(PDK_FUSION_SYMLINK_STAMP)
3081# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
3082$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
3083
3084INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3085INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3086$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003087$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003088 @echo Installed file list: $@
3089 @mkdir -p $(dir $@)
3090 @rm -f $@
3091 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003092 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003093
3094odmimage_intermediates := \
3095 $(call intermediates-dir-for,PACKAGING,odm)
3096BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3097define build-odmimage-target
3098 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3099 @mkdir -p $(TARGET_OUT_ODM)
3100 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3101 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003102 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003103 $(BUILD_IMAGE) \
3104 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3105 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3106 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003107endef
3108
3109# We just build this directly to the install location.
3110INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003111$(INSTALLED_ODMIMAGE_TARGET): \
3112 $(INTERNAL_USERIMAGES_DEPS) \
3113 $(INTERNAL_ODMIMAGE_FILES) \
3114 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003115 $(build-odmimage-target)
3116
3117.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003118odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003119 $(build-odmimage-target)
3120
3121sync: $(INTERNAL_ODMIMAGE_FILES)
3122
3123else ifdef BOARD_PREBUILT_ODMIMAGE
3124INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3125$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3126endif
3127
3128# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003129# dtbo image
3130ifdef BOARD_PREBUILT_DTBOIMAGE
3131INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3132
3133ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003134$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003135 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3136 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003137 --image $@ \
3138 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3139 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3140 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003141else
3142$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3143 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3144endif
3145
Tao Bao0da43472018-08-22 22:53:41 -07003146endif # BOARD_PREBUILT_DTBOIMAGE
3147
3148# Returns a list of image targets corresponding to the given list of partitions. For example, it
3149# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3150# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003151# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003152define images-for-partitions
3153$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3154endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003155
3156# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003157# vbmeta image
3158ifeq ($(BOARD_AVB_ENABLE),true)
3159
3160BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003161AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003162
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003163ifdef BOARD_AVB_KEY_PATH
3164$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3165else
3166# If key path isn't specified, use the 4096-bit test key.
3167BOARD_AVB_ALGORITHM := SHA256_RSA4096
3168BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3169endif
3170
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003171# AVB signing for system_other.img.
3172ifdef BUILDING_SYSTEM_OTHER_IMAGE
3173ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3174$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3175else
3176# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3177BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3178BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3179endif
3180
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003181$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3182 @echo Extracting system_other avb key: $@
3183 @rm -f $@
3184 @mkdir -p $(dir $@)
3185 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003186
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003187ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3188BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3189endif
3190
3191BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3192endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3193
Tao Bao744c4c72018-08-20 21:09:07 -07003194INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003195 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003196 $(BOARD_AVB_VBMETA_VENDOR)
3197
3198# Not allowing the same partition to appear in multiple groups.
3199ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003200 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003201endif
3202
cfig1aeef722019-09-20 22:45:06 +08003203# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3204# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3205# details.
3206ifneq ($(AB_OTA_UPDATER),true)
3207ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3208$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
3209 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for non-A/B devices. \
3210 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3211endif
3212endif
3213
Bowgo Tsai9b548012019-05-14 16:57:03 +08003214# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003215
3216BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003217 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003218 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003219 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3220
3221BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003222 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003223 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003224 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3225
Justin Yun6151e3f2019-06-25 15:58:13 +09003226BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003227 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003228 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3229 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003230
Bowgo Tsai9b548012019-05-14 16:57:03 +08003231BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003232 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003233 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3234
Tao Bao19b02fe2019-10-09 00:04:28 -07003235BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3236 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3237
3238BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3239 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3240
Bowgo Tsai9b548012019-05-14 16:57:03 +08003241BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003242 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003243 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3244
3245BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003246 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003247 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3248
Tao Bao19b02fe2019-10-09 00:04:28 -07003249BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3250 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3251
Bowgo Tsai9b548012019-05-14 16:57:03 +08003252# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003253ifdef BOOT_SECURITY_PATCH
3254BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3255 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3256endif
3257
3258ifdef VENDOR_SECURITY_PATCH
3259BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3260 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3261endif
3262
3263ifdef ODM_SECURITY_PATCH
3264BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3265 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3266endif
3267
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003268BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003269VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003270DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3271SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3272VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003273RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003274PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003275SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003276ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003277
Tao Bao0da43472018-08-22 22:53:41 -07003278# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003279# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003280define _check-and-set-avb-chain-args
3281$(eval part := $(1))
3282$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003283
3284$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3285$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3286$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3287$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3288$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3289$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3290$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3291$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3292
3293# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3294$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3295$(eval $(_signing_args) := \
3296 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3297
cfig1aeef722019-09-20 22:45:06 +08003298# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3299# partition descriptor for recovery partition into vbmeta.img.
3300$(if $(or $(filter true,$(AB_OTA_UPDATER)),$(filter-out recovery,$(part))),\
3301 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3302 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003303
Tao Bao744c4c72018-08-20 21:09:07 -07003304# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003305# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003306$(if $(filter $(part),$(part:vbmeta_%=%)),\
3307 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3308 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003309endef
3310
Tao Bao0da43472018-08-22 22:53:41 -07003311# Checks and sets the required build variables for an AVB partition. The partition will be
3312# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003313# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3314# VBMeta image.
Tao Bao0da43472018-08-22 22:53:41 -07003315# $(1): Partition name, e.g. boot or system.
3316define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003317$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003318$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003319 $(if $(_in_chained_vbmeta),\
3320 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003321 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003322 $(if $(_in_chained_vbmeta),,\
3323 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3324 --include_descriptors_from_image $(call images-for-partitions,$(1)))))
Tao Bao0da43472018-08-22 22:53:41 -07003325endef
3326
Tao Baob1a2e352018-08-14 16:17:12 -07003327ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003328$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003329endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003330
Steve Mucklee1b10862019-07-10 10:49:37 -07003331ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3332$(eval $(call check-and-set-avb-args,vendor_boot))
3333endif
3334
Tao Bao0da43472018-08-22 22:53:41 -07003335$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003336
3337ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003338$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003339endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003340
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003341ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003342$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003343endif
3344
Justin Yun6151e3f2019-06-25 15:58:13 +09003345ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3346$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003347endif
3348
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003349ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003350$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003351endif
3352
Yueyao Zhu211c9012017-04-27 00:34:50 -07003353ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003354$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003355endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003356
David Zeuthen8fecb282017-12-01 16:24:01 -05003357ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003358$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003359endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003360
David Anderson7709ab22018-10-15 14:41:34 -07003361# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3362ifdef BOARD_AVB_VBMETA_SYSTEM
3363$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003364endif
3365
3366ifdef BOARD_AVB_VBMETA_VENDOR
3367$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3368endif
3369
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003370# Add kernel cmdline descriptor for kernel to mount system.img as root with
3371# dm-verity. This works when system.img is either chained or not-chained:
3372# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3373# cmdline descriptor to system.img
3374# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3375# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003376ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003377ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003378BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003379endif
David Anderson8916a2a2018-09-18 15:46:59 -07003380endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003381
Tao Bao0da43472018-08-22 22:53:41 -07003382BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003383BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003384BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3385
3386ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003387# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003388BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003389endif
Tao Bao0da43472018-08-22 22:53:41 -07003390
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003391ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003392BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003393endif
3394
David Anderson7709ab22018-10-15 14:41:34 -07003395ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3396BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3397 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003398endif
3399
3400ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3401BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3402 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003403endif
3404
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003405# $(1): the directory to extract public keys to
3406define extract-avb-chain-public-keys
3407 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3408 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3409 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003410 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3411 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3412 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003413 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3414 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3415 --output $(1)/system.avbpubkey)
3416 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3417 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3418 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003419 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3420 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3421 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003422 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3423 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3424 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003425 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3426 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3427 --output $(1)/odm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003428 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3429 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3430 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003431 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3432 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3433 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003434 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3435 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3436 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003437 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3438 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3439 --output $(1)/vbmeta_vendor.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003440endef
3441
Tao Bao744c4c72018-08-20 21:09:07 -07003442# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3443# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003444# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003445# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3446# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003447# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003448# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003449# $(2): Output filename.
3450define build-chained-vbmeta-image
3451 $(call pretty,"Target chained vbmeta image: $@")
3452 $(hide) $(AVBTOOL) make_vbmeta_image \
3453 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3454 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3455 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3456 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3457 --output $@
3458endef
3459
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003460ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003461ifdef BOARD_AVB_VBMETA_SYSTEM
3462INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3463$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003464 $(AVBTOOL) \
3465 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3466 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003467 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003468endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003469endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003470
3471ifdef BOARD_AVB_VBMETA_VENDOR
3472INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3473$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003474 $(AVBTOOL) \
3475 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3476 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003477 $(call build-chained-vbmeta-image,vbmeta_vendor)
3478endif
3479
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003480define build-vbmetaimage-target
3481 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003482 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3483 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003484 $(hide) $(AVBTOOL) make_vbmeta_image \
3485 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003486 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003487 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3488 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003489 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003490endef
3491
Paul Trautrim4e143232019-08-13 16:30:57 +09003492ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003493INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003494$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3495 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3496
David Zeuthen8fecb282017-12-01 16:24:01 -05003497$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003498 $(AVBTOOL) \
3499 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003500 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003501 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3502 $(INSTALLED_VENDORIMAGE_TARGET) \
3503 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003504 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003505 $(INSTALLED_ODMIMAGE_TARGET) \
3506 $(INSTALLED_DTBOIMAGE_TARGET) \
3507 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3508 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3509 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3510 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3511 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3512 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003513 $(build-vbmetaimage-target)
3514
3515.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003516vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3517 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003518vbmetaimage-nodeps:
3519 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003520endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003521
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003522endif # BOARD_AVB_ENABLE
3523
3524# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003525# Check VINTF of build
3526
3527ifndef TARGET_BUILD_APPS
3528intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3529check_vintf_all_deps :=
3530
Yifan Hongaf9b0702020-01-21 12:46:57 -08003531# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3532# because they are only used for prebuilt images.
3533check_vintf_common_srcs_patterns := \
3534 $(TARGET_OUT)/etc/vintf/% \
3535 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3536 $(TARGET_OUT_ODM)/etc/vintf/% \
3537 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3538 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3539
3540check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3541 $(INTERNAL_SYSTEMIMAGE_FILES) \
3542 $(INTERNAL_VENDORIMAGE_FILES) \
3543 $(INTERNAL_ODMIMAGE_FILES) \
3544 $(INTERNAL_PRODUCTIMAGE_FILES) \
3545 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3546))
3547check_vintf_common_srcs_patterns :=
3548
3549check_vintf_has_system :=
3550check_vintf_has_vendor :=
3551
Yifan Hong605ea042020-01-14 21:36:00 +00003552# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003553check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3554ifneq ($(check_vintf_system_deps),)
3555check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003556check_vintf_system_log := $(intermediates)/check_vintf_system_log
3557check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003558$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003559 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3560check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003561endif # check_vintf_system_deps
3562check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003563
3564# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003565check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3566ifneq ($(check_vintf_vendor_deps),)
3567check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003568check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3569check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003570$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003571 @( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3572check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003573endif # check_vintf_vendor_deps
3574check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003575
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003576# -- Check VINTF compatibility of build.
3577# Skip partial builds; only check full builds. Only check if:
3578# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003579# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003580# - Building product / system_ext / odm images if board has product / system_ext / odm images
3581ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003582ifeq ($(check_vintf_has_system),true)
3583ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003584ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3585ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3586ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3587
3588check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3589check_vintf_all_deps += $(check_vintf_compatible_log)
3590
3591check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003592check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003593
3594# -- Kernel version and configurations.
3595ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3596
Yifan Hong605ea042020-01-14 21:36:00 +00003597BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3598BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3599
3600my_board_extracted_kernel :=
3601
3602# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3603# from INSTALLED_KERNEL_TARGET.
3604ifdef BOARD_KERNEL_CONFIG_FILE
3605ifdef BOARD_KERNEL_VERSION
3606$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3607 cp $< $@
3608$(BUILT_KERNEL_VERSION_FILE):
3609 echo $(BOARD_KERNEL_VERSION) > $@
3610
3611my_board_extracted_kernel := true
3612endif # BOARD_KERNEL_VERSION
3613endif # BOARD_KERNEL_CONFIG_FILE
3614
3615ifneq ($(my_board_extracted_kernel),true)
3616ifndef INSTALLED_KERNEL_TARGET
3617$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3618 is true. Information about the updated kernel cannot be built into OTA update package. \
3619 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3620 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3621 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3622 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3623 manually.)
3624else
3625
3626# Tools for decompression that is not in PATH.
3627# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3628# Algorithms that are in the script but not in this list will be found in PATH.
3629my_decompress_tools := \
3630 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3631
3632$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3633$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3634$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
3635$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(INSTALLED_KERNEL_TARGET)
3636 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(INSTALLED_KERNEL_TARGET) \
3637 --output-configs $@ \
3638 --output-version $(BUILT_KERNEL_VERSION_FILE)
3639
3640my_decompress_tools :=
3641
3642endif # my_board_extracted_kernel
3643my_board_extracted_kernel :=
3644
3645endif # INSTALLED_KERNEL_TARGET
3646
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003647check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3648check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3649
3650endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3651
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003652check_vintf_compatible_args += \
3653 --dirmap /system:$(TARGET_OUT) \
3654 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3655 --dirmap /odm:$(TARGET_OUT_ODM) \
3656 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3657 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3658
3659ifdef PRODUCT_SHIPPING_API_LEVEL
3660check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3661endif # PRODUCT_SHIPPING_API_LEVEL
3662
3663$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3664$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
3665$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3666 @echo -n -e 'Deps: \n ' > $@
3667 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3668 @echo -n -e 'Args: \n ' >> $@
3669 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
3670 @echo -n -e 'For empty SKU:' >> $@
3671 @( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) >> $@ 2>&1 ) || ( cat $@ && exit 1 )
3672 $(foreach sku,$(ODM_MANIFEST_SKUS), \
3673 echo "For SKU = $(sku):" >> $@; \
3674 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
3675 --property ro.boot.product.hardware.sku=$(sku) >> $@ 2>&1 ) || ( cat $@ && exit 1 ); )
3676
3677check_vintf_compatible_log :=
3678check_vintf_compatible_args :=
3679check_vintf_compatible_deps :=
3680
3681endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3682endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3683endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003684endif # check_vintf_has_vendor
3685endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003686endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3687
3688# Add all logs of VINTF checks to dist builds
3689droid_targets: $(check_vintf_all_deps)
3690$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3691
3692# Helper alias to check all VINTF of current build.
3693.PHONY: check-vintf-all
3694check-vintf-all: $(check_vintf_all_deps)
3695 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3696
Yifan Hongaf9b0702020-01-21 12:46:57 -08003697check_vintf_has_vendor :=
3698check_vintf_has_system :=
3699check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003700check_vintf_all_deps :=
3701intermediates :=
3702endif # !TARGET_BUILD_APPS
3703
3704# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003705# Check image sizes <= size of super partition
3706
3707ifeq (,$(TARGET_BUILD_APPS))
3708# Do not check for apps-only build
3709
3710ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003711
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003712# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003713# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003714define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003715 mkdir -p $(dir $(1))
3716 rm -f $(1)
3717 $(call dump-super-image-info, $(1))
3718 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3719 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003720 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003721endef
3722
Yifan Hong30910932019-10-25 20:36:55 -07003723check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3724droid_targets: $(check_all_partition_sizes_log)
3725$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003726
Yifan Hong30910932019-10-25 20:36:55 -07003727$(check_all_partition_sizes_log): \
3728 $(CHECK_PARTITION_SIZES) \
3729 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3730 $(call check-all-partition-sizes-target, \
3731 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3732 $@)
3733
3734.PHONY: check-all-partition-sizes
3735check-all-partition-sizes: $(check_all_partition_sizes_log)
3736
3737.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003738check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003739 $(call check-all-partition-sizes-target, \
3740 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003741
Yifan Hong2dae5722018-07-31 12:47:27 -07003742endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003743
3744endif # TARGET_BUILD_APPS
3745
3746# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003747# bring in the installer image generation defines if necessary
3748ifeq ($(TARGET_USE_DISKINSTALLER),true)
3749include bootable/diskinstaller/config.mk
3750endif
3751
3752# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003753# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003754
Ying Wangbd2d0242015-09-22 11:17:52 -07003755ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003756 build_ota_package := false
3757 build_otatools_package := false
3758else
Tao Bao9be20c72019-04-08 21:11:59 -07003759 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003760 build_ota_package := true
3761 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3762 build_ota_package := false
3763 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003764 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003765 build_ota_package := false
3766 endif
3767 ifeq ($(TARGET_PRODUCT),sdk)
3768 build_ota_package := false
3769 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003770 ifeq ($(TARGET_BUILD_PDK),true)
3771 build_ota_package := false
3772 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003773 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3774 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3775 build_ota_package := false
3776 endif
3777 ifeq ($(TARGET_NO_KERNEL),true)
3778 build_ota_package := false
3779 endif
3780 ifeq ($(recovery_fstab),)
3781 build_ota_package := false
3782 endif
3783 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003784
Tao Bao9be20c72019-04-08 21:11:59 -07003785 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003786 build_otatools_package := true
3787 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3788 build_otatools_package := false
3789 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003790endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003791
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003792ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003793
3794INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003795 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003796 add_img_to_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003797 append2simg \
3798 avbtool \
3799 blk_alloc_to_base_fs \
3800 boot_signer \
3801 brillo_update_payload \
3802 brotli \
3803 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003804 build_image \
3805 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003806 build_verity_metadata \
3807 build_verity_tree \
3808 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003809 check_ota_package_signature \
3810 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003811 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003812 checkvintf \
3813 delta_generator \
3814 e2fsck \
3815 e2fsdroid \
3816 fc_sort \
3817 fec \
3818 fs_config \
3819 generate_verity_key \
3820 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003821 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003822 imgdiff \
3823 libconscrypt_openjdk_jni \
3824 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003825 lpunpack \
Tao Bao96daeeb2019-05-01 21:17:13 -07003826 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07003827 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003828 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003829 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003830 mkbootfs \
3831 mkbootimg \
3832 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003833 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003834 mkf2fsuserimg.sh \
3835 mksquashfs \
3836 mksquashfsimage.sh \
3837 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003838 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003839 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003840 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003841 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003842 sign_apex \
3843 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003844 signapk \
3845 simg2img \
3846 sload_f2fs \
3847 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003848 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003849 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003850 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003851 verity_signer \
3852 verity_verifier \
3853 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003854
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003855# Additional tools to unpack and repack the apex file.
3856INTERNAL_OTATOOLS_MODULES += \
3857 apexer \
3858 deapexer \
3859 debugfs_static \
3860 merge_zips \
3861 resize2fs \
3862 soong_zip \
3863
Anton Hansson8dab0a62019-03-28 15:45:40 +00003864ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003865INTERNAL_OTATOOLS_MODULES += \
3866 futility \
3867 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003868endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003869
Tao Bao96daeeb2019-05-01 21:17:13 -07003870INTERNAL_OTATOOLS_FILES := \
3871 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003872
Ying Wang06898662010-06-17 17:52:18 -07003873.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003874otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003875
Tao Bao96daeeb2019-05-01 21:17:13 -07003876# For each module, recursively resolve its host shared library dependencies. Then we have a full
3877# list of modules whose installed files need to be packed.
3878INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3879 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3880 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003881
Tao Bao96daeeb2019-05-01 21:17:13 -07003882INTERNAL_OTATOOLS_PACKAGE_FILES := \
3883 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3884
3885INTERNAL_OTATOOLS_PACKAGE_FILES += \
3886 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3887 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003888
3889ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003890INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003891 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003892 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003893endif
3894ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003895INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003896 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3897 -name "atx_metadata.bin"))
3898endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003899ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003900INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003901 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003902endif
3903
Tao Bao96daeeb2019-05-01 21:17:13 -07003904INTERNAL_OTATOOLS_RELEASETOOLS := \
3905 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3906 \( -type f -o -type l \) -print))
3907
3908BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3909$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3910$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3911$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3912$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003913$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003914 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003915 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3916 mkdir -p $(dir $@)
3917 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3918 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003919 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003920 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003921
3922.PHONY: otatools-package
3923otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3924
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003925endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003926
The Android Open Source Project88b60792009-03-03 19:28:42 -08003927# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003928# misc_info.txt
3929
3930INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3931
3932ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3933# default to common dir for device vendor
3934tool_extensions := $(TARGET_DEVICE_DIR)/../common
3935else
3936tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3937endif
3938.KATI_READONLY := tool_extensions
3939
3940$(INSTALLED_MISC_INFO_TARGET):
3941 rm -f $@
3942 $(call pretty,"Target misc_info.txt: $@")
3943 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3944 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3945ifdef BOARD_FLASH_BLOCK_SIZE
3946 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3947endif
3948ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
3949 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $@
3950endif
3951ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3952 $(hide) echo "no_boot=true" >> $@
3953endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003954ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3955 echo "vendor_boot=true" >> $@
3956 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3957endif
Daniel Normane1e48082019-06-27 13:55:23 -07003958ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3959 $(hide) echo "no_recovery=true" >> $@
3960endif
3961ifdef BOARD_INCLUDE_RECOVERY_DTBO
3962 $(hide) echo "include_recovery_dtbo=true" >> $@
3963endif
3964ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3965 $(hide) echo "include_recovery_acpio=true" >> $@
3966endif
3967ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3968 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3969endif
3970ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3971 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3972 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3973else
3974 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3975endif
3976 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
3977 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
3978ifdef PRODUCT_EXTRA_RECOVERY_KEYS
3979 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
3980endif
3981 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
3982 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
3983 $(hide) echo "multistage_support=1" >> $@
3984 $(hide) echo "blockimgdiff_versions=3,4" >> $@
3985ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3986 $(hide) echo "build_generic_ota_package=true" >> $@
3987endif
3988ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
3989 # OTA scripts are only interested in fingerprint related properties
3990 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
3991endif
3992ifneq (,$(filter address, $(SANITIZE_TARGET)))
3993 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
3994 $(hide) echo "userdata_img_with_data=true" >> $@
3995endif
3996ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
3997 $(hide) echo "full_recovery_image=true" >> $@
3998endif
Bill Peckhame868aec2019-09-17 17:06:47 -07003999ifdef BOARD_USES_VENDORIMAGE
4000 $(hide) echo "board_uses_vendorimage=true" >> $@
4001endif
Daniel Normane1e48082019-06-27 13:55:23 -07004002ifeq ($(BOARD_AVB_ENABLE),true)
4003 $(hide) echo "avb_enable=true" >> $@
4004 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4005 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4006 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4007 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4008ifdef BOARD_AVB_BOOT_KEY_PATH
4009 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4010 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4011 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4012endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004013 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4014ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4015 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4016 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4017 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4018endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004019 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4020ifdef BOARD_AVB_RECOVERY_KEY_PATH
4021 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4022 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4023 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4024endif # BOARD_AVB_RECOVERY_KEY_PATH
4025ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4026 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4027 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4028 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4029 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4030 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4031endif # BOARD_AVB_VBMETA_SYSTEM
4032ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4033 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4034 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4035 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4036 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4037 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4038endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4039endif # BOARD_AVB_ENABLE
4040ifdef BOARD_BPT_INPUT_FILES
4041 $(hide) echo "board_bpt_enable=true" >> $@
4042 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4043 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4044endif
4045ifdef BOARD_BPT_DISK_SIZE
4046 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4047endif
4048 $(call generate-userimage-prop-dictionary, $@)
4049ifeq ($(AB_OTA_UPDATER),true)
4050 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4051 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4052 $(hide) echo "ab_update=true" >> $@
4053endif
4054ifdef BOARD_PREBUILT_DTBOIMAGE
4055 $(hide) echo "has_dtbo=true" >> $@
4056ifeq ($(BOARD_AVB_ENABLE),true)
4057 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4058 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4059ifdef BOARD_AVB_DTBO_KEY_PATH
4060 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4061 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4062 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4063endif # BOARD_AVB_DTBO_KEY_PATH
4064endif # BOARD_AVB_ENABLE
4065endif # BOARD_PREBUILT_DTBOIMAGE
4066 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004067 @# VINTF checks
4068ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4069 $(hide) echo "vintf_enforce=true" >> $@
4070endif
4071ifdef ODM_MANIFEST_SKUS
4072 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4073endif
Daniel Normane1e48082019-06-27 13:55:23 -07004074
4075.PHONY: misc_info
4076misc_info: $(INSTALLED_MISC_INFO_TARGET)
4077
4078droidcore: $(INSTALLED_MISC_INFO_TARGET)
4079
4080# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004081# A zip of the directories that map to the target filesystem.
4082# This zip can be used to create an OTA package or filesystem image
4083# as a post-build step.
4084#
4085name := $(TARGET_PRODUCT)
4086ifeq ($(TARGET_BUILD_TYPE),debug)
4087 name := $(name)_debug
4088endif
4089name := $(name)-target_files-$(FILE_NAME_TAG)
4090
4091intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4092BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4093$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4094$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004095 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004096
4097# $(1): Directory to copy
4098# $(2): Location to copy it to
4099# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4100define package_files-copy-root
4101 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4102 mkdir -p $(2) && \
4103 $(ACP) -rd $(strip $(1))/* $(2); \
4104 fi
4105endef
4106
Tao Baoa04fca32015-11-30 12:22:24 -08004107built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004108
4109# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004110ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004111built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07004112 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
4113endif
4114
The Android Open Source Project88b60792009-03-03 19:28:42 -08004115$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4116
Dan Willemsen653bea92017-03-21 15:47:37 -07004117tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004118$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004119
Sen Jiang4438fd92016-03-07 16:51:01 -08004120ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004121updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08004122else
Steve Fung48e49f52015-10-01 23:53:31 -07004123# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004124updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004125endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004126$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004127
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004128# If we are using recovery as boot, output recovery files to BOOT/.
4129ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4130$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4131else
4132$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4133endif
4134
Dan Willemsen653bea92017-03-21 15:47:37 -07004135ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004136 ifdef OSRELEASED_DIRECTORY
4137 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4138 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4139 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4140 endif
Tao Baoa835f382019-07-18 15:55:30 -07004141
4142 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4143 # additionally include radio or bootloader partitions).
4144 ifeq ($(AB_OTA_PARTITIONS),)
4145 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4146 endif
4147endif
4148
4149ifneq ($(AB_OTA_PARTITIONS),)
4150 ifneq ($(AB_OTA_UPDATER),true)
4151 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4152 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004153endif
4154
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004155# Run fs_config while creating the target files package
4156# $1: root directory
4157# $2: add prefix
4158define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004159(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 -08004160endef
4161
Yifan Hong60bfcc42019-11-01 11:39:45 -07004162# Filter out vendor from the list for AOSP targets.
4163# $(1): list
4164define filter-out-missing-vendor
4165$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4166endef
4167
4168# Information related to dynamic partitions and virtual A/B. This information
4169# is needed for building the super image (see dump-super-image-info) and
4170# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004171# $(1): file
4172define dump-dynamic-partitions-info
4173 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4174 echo "use_dynamic_partitions=true" >> $(1))
4175 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4176 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004177 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4178 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4179 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004180 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4181 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004182 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4183 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4184 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4185 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4186 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4187 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004188 echo "dynamic_partition_list=$(call filter-out-missing-vendor, $(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004189 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4190 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4191 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4192 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4193 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004194 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 -07004195 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4196 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004197 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4198 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004199 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4200 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004201 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4202 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4203 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4204 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4205 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4206 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4207 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4208 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004209 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4210 echo "virtual_ab=true" >> $(1))
4211 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4212 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004213endef
4214
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004215# By conditionally including the dependency of the target files package on the
4216# full system image deps, we speed up builds that do not build the system
4217# image.
4218ifdef BUILDING_SYSTEM_IMAGE
4219$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4220endif
4221
Isaac Chen9e09d472019-07-05 17:30:41 +08004222ifeq ($(BUILD_QEMU_IMAGES),true)
4223MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4224$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4225endif
4226
The Android Open Source Project88b60792009-03-03 19:28:42 -08004227# Depending on the various images guarantees that the underlying
4228# directories are up-to-date.
4229$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004230 $(INSTALLED_RAMDISK_TARGET) \
4231 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004232 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004233 $(INSTALLED_RADIOIMAGE_TARGET) \
4234 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004235 $(INSTALLED_USERDATAIMAGE_TARGET) \
4236 $(INSTALLED_CACHEIMAGE_TARGET) \
4237 $(INSTALLED_VENDORIMAGE_TARGET) \
4238 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004239 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004240 $(INSTALLED_VBMETAIMAGE_TARGET) \
4241 $(INSTALLED_ODMIMAGE_TARGET) \
4242 $(INSTALLED_DTBOIMAGE_TARGET) \
4243 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4244 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4245 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004246 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004247 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4248 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004249 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004250 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004251 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4252 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4253 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004254 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004255 $(PRODUCT_ODM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004256 $(LPMAKE) \
4257 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004258 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004259 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004260 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004261 $(SOONG_ZIP) \
4262 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004263 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004264 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004265 $(BUILT_KERNEL_CONFIGS_FILE) \
4266 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004267 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004268 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004269 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004270 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004271 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004272 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004273 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004274 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004275ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004276 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004277 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004278 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004279 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004280ifdef INSTALLED_KERNEL_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004281 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004282endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004283ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4284 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
4285else # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
The Android Open Source Project88b60792009-03-03 19:28:42 -08004286ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004287 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004288endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004289ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004290ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004291 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004292else
Steve Mucklee1b10862019-07-10 10:49:37 -07004293 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004294endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004295endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004296ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004297 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004298endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004299ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004300 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004301endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004302ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004303 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004304endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004305ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004306 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004307endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004308ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004309 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004310endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004311endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004312endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004313 @# Components of the boot image
4314 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004315 $(hide) mkdir -p $(zip_root)/ROOT
4316 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004317 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004318 @# If we are using recovery as boot, this is already done when processing recovery.
4319ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004320ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004321 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004322 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004323endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004324ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004325 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004326endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004327ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004328ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004329 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004330endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004331ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004332 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004333endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004334 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004335ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004336 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004337endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004338ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004339 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004340endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004341else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4342 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4343endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4344endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004345 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4346 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004347 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004348ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4349 mkdir -p $(zip_root)/VENDOR_BOOT
4350 $(call package_files-copy-root, \
4351 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4352ifdef INSTALLED_DTBIMAGE_TARGET
4353 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4354endif
4355ifdef BOARD_KERNEL_BASE
4356 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4357endif
4358ifdef BOARD_KERNEL_PAGESIZE
4359 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4360endif
4361 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4362endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004363ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004364 @# Contents of the system image
4365 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004366 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004367endif
4368ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004369 @# Contents of the data image
4370 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004371 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004372endif
4373ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004374 @# Contents of the vendor image
4375 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004376 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004377endif
Dan Willemsen67495202019-01-16 12:42:05 -08004378ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004379 @# Contents of the product image
4380 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004381 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004382endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004383ifdef BUILDING_SYSTEM_EXT_IMAGE
4384 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004385 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004386 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004387endif
Dan Willemsen67495202019-01-16 12:42:05 -08004388ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004389 @# Contents of the odm image
4390 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004391 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004392endif
Dan Willemsen67495202019-01-16 12:42:05 -08004393ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004394 @# Contents of the system_other image
4395 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004396 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004397endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004398 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004399 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004400 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07004401ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004402ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004403 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004404 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004405endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004406endif
Doug Zongker8678df42009-06-15 14:30:14 -07004407 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004408 @# build them.
4409 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004410 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004411 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004412ifneq ($(tool_extension),)
4413 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4414endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004415 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004416 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004417 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004418ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4419 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4420 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004421endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004422ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4423 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4424 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004425endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004426ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4427 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4428 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004429endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004430ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4431 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4432 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004433endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004434ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4435 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4436 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004437endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004438ifneq ($(AB_OTA_UPDATER),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004439ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004440 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004441 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004442endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004443endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004444ifeq ($(AB_OTA_UPDATER),true)
4445 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004446 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004447 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004448 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4449 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004450 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4451 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4452 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004453ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004454 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4455 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4456 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004457endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004458endif
Steve Fungdfbab492015-09-24 18:12:33 -07004459ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004460 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004461 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004462endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004463ifdef BOARD_PREBUILT_VENDORIMAGE
4464 $(hide) mkdir -p $(zip_root)/IMAGES
4465 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4466endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004467ifdef BOARD_PREBUILT_PRODUCTIMAGE
4468 $(hide) mkdir -p $(zip_root)/IMAGES
4469 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4470endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004471ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004472 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004473 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004474endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004475ifdef BOARD_PREBUILT_BOOTIMAGE
4476 $(hide) mkdir -p $(zip_root)/IMAGES
4477 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4478endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004479ifdef BOARD_PREBUILT_ODMIMAGE
4480 $(hide) mkdir -p $(zip_root)/IMAGES
4481 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4482endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004483ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004484 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4485 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004486endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07004487 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4488 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4489 @# INSTALLED_RADIOIMAGE_TARGET.
4490 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4491 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004492 @# Run fs_config on all the system, vendor, boot ramdisk,
4493 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004494ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004495 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004496endif
4497ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004498 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4499endif
Dan Willemsen67495202019-01-16 12:42:05 -08004500ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004501 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4502endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004503ifdef BUILDING_SYSTEM_EXT_IMAGE
4504 $(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 +01004505endif
Dan Willemsen67495202019-01-16 12:42:05 -08004506ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004507 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4508endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004509 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004510 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004511ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004512 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004513 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004514endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004515ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4516 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4517endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004518ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4519 @# 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 -08004520 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4521endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004522ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4523 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4524endif
Dan Willemsen67495202019-01-16 12:42:05 -08004525ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004526 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4527endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004528 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004529ifdef BUILT_KERNEL_CONFIGS_FILE
4530 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4531endif
4532ifdef BUILT_KERNEL_VERSION_FILE
4533 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4534endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004535 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4536ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4537 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4538endif
Tao Baocbd6d492019-10-07 22:46:02 -07004539 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4540 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004541ifeq ($(BUILD_QEMU_IMAGES),true)
4542 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4543 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4544endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004545 @# Zip everything up, preserving symlinks and placing META/ files first to
4546 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004547 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004548 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004549 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004550
Ying Wanga0febe52013-03-20 11:02:05 -07004551.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004552target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4553
Ying Wang4709d7c2014-04-14 17:25:43 -07004554ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4555$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4556endif
Doug Zongker367910f2009-06-15 18:56:51 -07004557
Dan Albert4d323332016-10-14 13:23:06 -07004558# -----------------------------------------------------------------
4559# NDK Sysroot Package
4560NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004561$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004562 @echo Package NDK sysroot...
4563 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4564
4565$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4566
Ying Wang09c4b682015-08-11 11:24:19 -07004567ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004568# -----------------------------------------------------------------
4569# OTA update package
4570
Yifan Hong50e79542018-11-08 17:44:12 -08004571# $(1): output file
4572# $(2): additional args
4573define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004574PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004575 $(OTA_FROM_TARGET_FILES) \
4576 --verbose \
4577 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4578 --path $(HOST_OUT) \
4579 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4580 $(2) \
4581 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004582endef
4583
Doug Zongker8678df42009-06-15 14:30:14 -07004584name := $(TARGET_PRODUCT)
4585ifeq ($(TARGET_BUILD_TYPE),debug)
4586 name := $(name)_debug
4587endif
4588name := $(name)-ota-$(FILE_NAME_TAG)
4589
4590INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004591INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4592
Doug Zongker8678df42009-06-15 14:30:14 -07004593$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004594$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004595$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004596 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004597 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004598
4599.PHONY: otapackage
4600otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4601
Tao Bao519d1822018-12-27 12:47:23 -08004602ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004603name := $(TARGET_PRODUCT)
4604ifeq ($(TARGET_BUILD_TYPE),debug)
4605 name := $(name)_debug
4606endif
4607name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4608
4609INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004610$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004611$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4612 $(BUILT_TARGET_FILES_PACKAGE) \
4613 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004614 @echo "Package OTA (retrofit dynamic partitions): $@"
4615 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4616
4617.PHONY: otardppackage
4618
4619otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4620
Tao Bao519d1822018-12-27 12:47:23 -08004621endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004622
Ying Wang09c4b682015-08-11 11:24:19 -07004623endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004624
Ying Wang09a00a62010-10-20 14:01:09 -07004625# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004626# A zip of the appcompat directory containing logs
4627APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4628# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4629ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004630$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004631 $(INSTALLED_RAMDISK_TARGET) \
4632 $(INSTALLED_BOOTIMAGE_TARGET) \
4633 $(INSTALLED_USERDATAIMAGE_TARGET) \
4634 $(INSTALLED_VENDORIMAGE_TARGET) \
4635 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004636 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004637endif
4638$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4639$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4640 @echo "appcompat logs: $@"
4641 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4642 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4643 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4644 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4645
Dario Frenid1011272018-07-23 20:20:15 +01004646# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004647# A zip of the symbols directory. Keep the full paths to make it
4648# more obvious where these files came from.
4649#
4650name := $(TARGET_PRODUCT)
4651ifeq ($(TARGET_BUILD_TYPE),debug)
4652 name := $(name)_debug
4653endif
4654name := $(name)-symbols-$(FILE_NAME_TAG)
4655
4656SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004657# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07004658ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004659$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004660 $(INSTALLED_RAMDISK_TARGET) \
4661 $(INSTALLED_BOOTIMAGE_TARGET) \
4662 $(INSTALLED_USERDATAIMAGE_TARGET) \
4663 $(INSTALLED_VENDORIMAGE_TARGET) \
4664 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004665 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004666 $(INSTALLED_ODMIMAGE_TARGET) \
4667 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004668endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004669$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4670$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004671 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004672 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4673 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004674 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004675 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004676# -----------------------------------------------------------------
4677# A zip of the coverage directory.
4678#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004679name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004680ifeq ($(TARGET_BUILD_TYPE),debug)
4681name := $(name)_debug
4682endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004683COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
4684ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004685$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004686 $(INSTALLED_RAMDISK_TARGET) \
4687 $(INSTALLED_BOOTIMAGE_TARGET) \
4688 $(INSTALLED_USERDATAIMAGE_TARGET) \
4689 $(INSTALLED_VENDORIMAGE_TARGET) \
4690 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004691 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004692 $(INSTALLED_ODMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004693endif
4694$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4695$(COVERAGE_ZIP): $(SOONG_ZIP)
4696 @echo "Package coverage: $@"
4697 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4698 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4699 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4700 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004701
4702# -----------------------------------------------------------------
4703# A zip of the Android Apps. Not keeping full path so that we don't
4704# include product names when distributing
4705#
4706name := $(TARGET_PRODUCT)
4707ifeq ($(TARGET_BUILD_TYPE),debug)
4708 name := $(name)_debug
4709endif
4710name := $(name)-apps-$(FILE_NAME_TAG)
4711
4712APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004713$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004714 @echo "Package apps: $@"
4715 $(hide) rm -rf $@
4716 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004717 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4718 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004719 echo "No apps to zip up. Generating empty apps archive." ; \
4720 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004721 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004722 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004723 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004724
Ying Wangbc415dd2012-08-15 12:22:44 -07004725ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004726#------------------------------------------------------------------
4727# An archive of classes for use in generating code-coverage reports
4728# These are the uninstrumented versions of any classes that were
4729# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004730# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004731
Colin Crossa6bc3a82017-09-27 14:28:41 -07004732JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004733$(JACOCO_REPORT_CLASSES_ALL) :
4734 @echo "Collecting uninstrumented classes"
4735 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" | \
Anton Hansson6d814982018-11-26 18:12:05 +00004736 zip -@ -0 -q -X $@
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004737# Meaning of these options:
4738# -@ scan stdin for file paths to add to the zip
4739# -0 don't do any compression
4740# -q supress most output
4741# -X skip storing extended file attributes
4742
Ying Wangbc415dd2012-08-15 12:22:44 -07004743endif # EMMA_INSTRUMENT=true
4744
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004745
Ying Wangae9115a2013-08-22 20:52:47 -07004746#------------------------------------------------------------------
4747# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004748#
Ying Wangc62c92c2013-08-28 18:38:25 -07004749PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004750# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4751ifndef TARGET_BUILD_APPS
4752$(PROGUARD_DICT_ZIP): \
4753 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4754 $(INSTALLED_RAMDISK_TARGET) \
4755 $(INSTALLED_BOOTIMAGE_TARGET) \
4756 $(INSTALLED_USERDATAIMAGE_TARGET) \
4757 $(INSTALLED_VENDORIMAGE_TARGET) \
4758 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4759 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4760 $(INSTALLED_ODMIMAGE_TARGET) \
4761 $(updater_dep)
4762endif
4763$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4764$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004765 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004766 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4767 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4768 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4769 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004770
Tao Bao48a2feb2019-06-28 11:00:05 -07004771
4772ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4773
4774# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4775# $(1): output file
4776define dump-super-image-info
4777 $(call dump-dynamic-partitions-info,$(1))
4778 $(if $(filter true,$(AB_OTA_UPDATER)), \
4779 echo "ab_update=true" >> $(1))
4780endef
4781
4782endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4783
The Android Open Source Project88b60792009-03-03 19:28:42 -08004784# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004785# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004786
4787ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4788
4789# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4790ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4791
4792ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004793
4794# For real devices and for dist builds, build super image from target files to an intermediate directory.
4795INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4796$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4797$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4798 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004799 PATH=$(dir $(LPMAKE)):$$PATH \
4800 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004801
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004802# Skip packing it in dist package because it is in update package.
4803ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004804$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004805endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004806
4807.PHONY: superimage_dist
4808superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07004809
4810endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07004811endif # BOARD_SUPER_PARTITION_SIZE != ""
4812endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004813
Yifan Hongacd862a2019-04-16 15:44:30 -07004814# -----------------------------------------------------------------
4815# super partition image for development
4816
4817ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4818ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4819ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
4820
4821# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
4822# $(1): built image path
4823# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
4824define build-superimage-target
4825 mkdir -p $(dir $(2))
4826 rm -rf $(2)
4827 $(call dump-super-image-info,$(2))
4828 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4829 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09004830 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
4831 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07004832 mkdir -p $(dir $(1))
4833 PATH=$(dir $(LPMAKE)):$$PATH \
4834 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
4835endef
4836
4837INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
4838INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
4839 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
4840
changho.shina8f9f112019-10-15 13:26:19 +09004841ifdef BUILDING_SYSTEM_OTHER_IMAGE
4842ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
4843INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
4844endif
4845endif
4846
Yifan Hongacd862a2019-04-16 15:44:30 -07004847# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
4848# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
4849# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
4850# virtual devices.
4851ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
4852$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4853 $(call pretty,"Target super fs image for debug: $@")
4854 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08004855 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004856
4857droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
4858
4859# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
4860.PHONY: superimage
4861superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08004862
4863$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004864endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
4865
4866# Build $(PRODUCT_OUT)/super.img without dependencies.
4867.PHONY: superimage-nodeps supernod
4868superimage-nodeps supernod: intermediates :=
4869superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4870 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
4871 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
4872 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
4873
4874endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
4875endif # BOARD_SUPER_PARTITION_SIZE != ""
4876endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
4877
4878# -----------------------------------------------------------------
4879# super empty image
4880
Tao Bao48a2feb2019-06-28 11:00:05 -07004881ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004882ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004883
Yifan Hong8b79d162018-11-29 12:32:00 -08004884INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
4885$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
4886$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
4887 $(call pretty,"Target empty super fs image: $@")
4888 mkdir -p $(intermediates)
4889 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07004890 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08004891 PATH=$(dir $(LPMAKE)):$$PATH \
4892 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08004893
4894$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
4895
Yifan Hong2b891ac2018-11-29 12:06:31 -08004896endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07004897endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004898
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004899
4900# -----------------------------------------------------------------
4901# The update package
4902
4903name := $(TARGET_PRODUCT)
4904ifeq ($(TARGET_BUILD_TYPE),debug)
4905 name := $(name)_debug
4906endif
4907name := $(name)-img-$(FILE_NAME_TAG)
4908
4909INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
4910
Tao Bao57f8ed62019-08-14 23:08:18 -07004911$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
4912 $(call pretty,"Package: $@")
4913 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
4914 $(IMG_FROM_TARGET_FILES) \
4915 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
4916 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004917
4918.PHONY: updatepackage
4919updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07004920$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004921
4922
Yifan Hong2b891ac2018-11-29 12:06:31 -08004923# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004924# dalvik something
4925.PHONY: dalvikfiles
4926dalvikfiles: $(INTERNAL_DALVIK_MODULES)
4927
Bo Huf0d50bb2017-08-01 19:02:09 +00004928ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00004929MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08004930MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00004931SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08004932
4933ifdef INSTALLED_SYSTEMIMAGE_TARGET
4934INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08004935INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
4936$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
4937 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
4938 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08004939$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08004940 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
4941 @echo Create system-qemu.img now
4942 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08004943 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00004944
4945systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
4946droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08004947endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004948ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00004949INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004950$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00004951 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004952 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00004953
4954vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
4955droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
4956endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004957ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004958INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004959$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004960 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004961 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004962
4963productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
4964droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
4965endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004966ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4967INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
4968$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
4969 @echo Create system_ext-qemu.img
4970 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01004971
Justin Yun6151e3f2019-06-25 15:58:13 +09004972systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
4973droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01004974endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004975ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004976INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
4977$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
4978 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004979 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004980
4981odmimage: $(INSTALLED_QEMU_ODMIMAGE)
4982droidcore: $(INSTALLED_QEMU_ODMIMAGE)
4983endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004984
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004985QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08004986$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
4987 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004988 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08004989 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
4990 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07004991
4992systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
4993droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08004994
Bo Huf0d50bb2017-08-01 19:02:09 +00004995endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004996# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004997# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07004998ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004999INTERNAL_EMULATOR_PACKAGE_FILES += \
5000 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005001 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005002 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005003 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5004 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005005
5006name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5007
5008INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5009
Ying Wang5d887702015-11-04 10:06:25 -08005010$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005011 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005012 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005013
Ying Wang7d8c5352012-07-26 10:15:21 -07005014endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005015# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005016# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005017# The pdk package (Platform Development Kit)
5018
Keun young Park7fc7aad2012-02-27 15:49:23 -08005019#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5020# include development/pdk/Pdk.mk
5021#endif
5022
The Android Open Source Project88b60792009-03-03 19:28:42 -08005023
5024# -----------------------------------------------------------------
5025# The SDK
5026
The Android Open Source Project88b60792009-03-03 19:28:42 -08005027# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005028sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005029
5030# Build a name that looks like:
5031#
5032# linux-x86 --> android-sdk_12345_linux-x86
5033# darwin-x86 --> android-sdk_12345_mac-x86
5034# windows-x86 --> android-sdk_12345_windows
5035#
5036sdk_name := android-sdk_$(FILE_NAME_TAG)
5037ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005038 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005039else
Joe Onorato03fbe402009-04-13 08:31:16 -07005040 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005041endif
5042ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005043 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005044endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005045sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005046
5047sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5048
5049ATREE_FILES :=
5050-include $(sdk_dep_file)
5051
5052# if we don't have a real list, then use "everything"
5053ifeq ($(strip $(ATREE_FILES)),)
5054ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005055 $(ALL_DEFAULT_INSTALLED_MODULES) \
5056 $(INSTALLED_RAMDISK_TARGET) \
5057 $(ALL_DOCS) \
Nan Zhangcb0a6882018-08-07 15:26:32 -07005058 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api-stubs-docs_annotations.zip \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005059 $(ALL_SDK_FILES)
5060endif
5061
5062atree_dir := development/build
5063
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005064
The Android Open Source Project88b60792009-03-03 19:28:42 -08005065sdk_atree_files := \
5066 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005067 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005068
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005069# development/build/sdk-android-<abi>.atree is used to differentiate
5070# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5071# files like the kernel image. We use TARGET_CPU_ABI because we don't
5072# have a better way to distinguish between CPU models.
5073ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5074 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5075endif
5076
Anton Hansson8dab0a62019-03-28 15:45:40 +00005077ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5078sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005079else
5080sdk_atree_files += $(atree_dir)/sdk.atree
5081endif
5082
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005083include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005084
The Android Open Source Project88b60792009-03-03 19:28:42 -08005085deps := \
5086 $(target_notice_file_txt) \
5087 $(tools_notice_file_txt) \
5088 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005089 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005090 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005091 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005092 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005093 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005094 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005095 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005096 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005097 $(INSTALLED_USERDATAIMAGE_TARGET) \
5098 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005099 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005100 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005101 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005102 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005103 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005104 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005105 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005106
5107INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5108$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5109$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5110$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5111$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5112
5113# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5114#
5115#SDK_GNU_ERROR := true
5116
Ying Wang5d887702015-11-04 10:06:25 -08005117$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005118 @echo "Package SDK: $@"
5119 $(hide) rm -rf $(PRIVATE_DIR) $@
5120 $(hide) for f in $(target_gnu_MODULES); do \
5121 if [ -f $$f ]; then \
5122 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5123 including GNU target $$f >&2; \
5124 FAIL=$(SDK_GNU_ERROR); \
5125 fi; \
5126 done; \
5127 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005128 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005129 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005130 ATREE_STRIP="$(HOST_STRIP) -x" \
5131 $(HOST_OUT_EXECUTABLES)/atree \
5132 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5133 -m $(PRIVATE_DEP_FILE) \
5134 -I . \
5135 -I $(PRODUCT_OUT) \
5136 -I $(HOST_OUT) \
5137 -I $(TARGET_COMMON_OUT_ROOT) \
5138 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5139 -v "OUT_DIR=$(OUT_DIR)" \
5140 -v "HOST_OUT=$(HOST_OUT)" \
5141 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5142 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5143 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5144 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5145 -o $(PRIVATE_DIR) && \
5146 cp -f $(target_notice_file_txt) \
5147 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5148 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5149 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5150 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5151 chmod -R ug+rwX $(PRIVATE_DIR) && \
5152 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005153 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5154
Raphael3d224a02010-04-16 17:50:09 -07005155
5156# Is a Windows SDK requested? If so, we need some definitions from here
5157# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005158MAIN_SDK_NAME := $(sdk_name)
5159MAIN_SDK_DIR := $(sdk_dir)
5160MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005161ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005162include $(TOPDIR)development/build/tools/windows_sdk.mk
5163endif
5164
The Android Open Source Project88b60792009-03-03 19:28:42 -08005165# -----------------------------------------------------------------
5166# Findbugs
5167INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5168INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5169$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5170 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005171 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005172 > $@
5173$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5174 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005175 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005176 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005177
5178# -----------------------------------------------------------------
5179# Findbugs
5180
5181# -----------------------------------------------------------------
5182# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005183ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005184include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005185-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005186-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005187-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005188# Also the project-specific tasks
5189-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5190-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005191-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005192# Also add test specifc tasks
5193include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005194include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005195endif
Raphaelc4d47312011-02-15 16:09:36 -08005196
Ying Wang67132ba2015-10-28 16:42:39 -07005197include $(BUILD_SYSTEM)/product-graph.mk
5198
Raphaelc4d47312011-02-15 16:09:36 -08005199# -----------------------------------------------------------------
5200# Create SDK repository packages. Must be done after tasks/* since
5201# we need the addon rules defined.
5202ifneq ($(sdk_repo_goal),)
5203include $(TOPDIR)development/build/tools/sdk_repo.mk
5204endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005205
5206# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005207# Soong generates the list of all shared libraries that are depended on by fuzz
5208# targets. It saves this list as a source:destination pair to
5209# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5210# build of the unstripped shared library, and the destination is the
5211# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5212# where fuzz target shared libraries are to be "reinstalled". The
5213# copy-many-files below generates the rules to copy the unstripped shared
5214# libraries to the device or host "reinstallation" directory. These rules are
5215# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5216# a dependency on each shared library that it needs to be "reinstalled".
5217FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5218
5219# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005220# The rule to build all fuzz targets, and package them.
5221# Note: The packages are created in Soong, and in a perfect world,
5222# we'd be able to create the phony rule there. But, if we want to
5223# have dist goals for the fuzz target, we need to have the PHONY
5224# target defined in make. MakeVarsContext.DistForGoal doesn't take
5225# into account that a PHONY rule create by Soong won't be available
5226# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005227# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005228# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005229.PHONY: haiku
5230haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5231$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))