blob: 384b238b297ade3ba304629b40474f90abc1c1b1 [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
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200504ifdef TARGET_VENDOR_PROP
505vendor_prop_files := $(TARGET_VENDOR_PROP)
506else
507vendor_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/vendor.prop)
508endif
509
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900510ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900511FINAL_VENDOR_BUILD_PROPERTIES += \
512 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
513FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
514 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900515endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900516
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200517$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(intermediate_system_build_prop) $(vendor_prop_files)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700518 @echo Target vendor buildinfo: $@
519 @mkdir -p $(dir $@)
520 $(hide) echo > $@
Hridya Valsaraju1fd498d2019-05-07 10:28:49 -0700521ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
522 $(hide) echo ro.boot.dynamic_partitions=true >> $@
523endif
524ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
525 $(hide) echo ro.boot.dynamic_partitions_retrofit=true >> $@
526endif
Sandeep Patil127f5012017-10-23 19:47:43 -0700527 $(hide) grep 'ro.product.first_api_level' $(intermediate_system_build_prop) >> $@ || true
Max Biresa1749982018-03-28 15:48:13 -0700528 $(hide) echo ro.vendor.build.security_patch="$(VENDOR_SECURITY_PATCH)">>$@
Isaac Chen8d11feb2018-01-31 14:27:37 +0800529 $(hide) echo ro.vendor.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
530 $(hide) echo ro.vendor.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
531 $(hide) echo ro.vendor.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Anton Hansson1f8729e2018-08-15 12:11:55 +0100532 $(hide) echo ro.product.board="$(TARGET_BOOTLOADER_BOARD_NAME)">>$@
533 $(hide) echo ro.board.platform="$(TARGET_BOARD_PLATFORM)">>$@
Stan Iliev144d26a2018-12-14 13:18:05 -0500534 $(hide) echo ro.hwui.use_vulkan="$(TARGET_USES_VULKAN)">>$@
Anton Hansson45a40da2019-01-18 14:06:34 +0000535ifdef TARGET_SCREEN_DENSITY
536 $(hide) echo ro.sf.lcd_density="$(TARGET_SCREEN_DENSITY)">>$@
537endif
Tao Bao67932ab2019-04-19 00:09:16 -0700538ifeq ($(AB_OTA_UPDATER),true)
539 $(hide) echo ro.build.ab_update=true >> $@
540endif
Anton Hansson1f8729e2018-08-15 12:11:55 +0100541 $(hide) $(call generate-common-build-props,vendor,$@)
Anton Hansson15794ca2019-04-08 17:47:35 +0100542 $(hide) echo "#" >> $@; \
543 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
544 echo "#" >> $@;
Anton Hanssonf2998892019-04-29 15:39:10 +0100545 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
546 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
547 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900548 $(hide) echo "#" >> $@; \
549 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
550 echo "#" >> $@;
Anton Hanssonc65ebaf2019-04-09 16:21:51 +0100551 $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@
552ifdef property_overrides_split_enabled
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200553 $(hide) $(foreach file,$(vendor_prop_files), \
554 if [ -f "$(file)" ]; then \
555 echo Target vendor properties from: "$(file)"; \
556 echo "" >> $@; \
557 echo "#" >> $@; \
558 echo "# from $(file)" >> $@; \
559 echo "#" >> $@; \
560 cat $(file) >> $@; \
561 echo "# end of $(file)" >> $@; \
562 fi;)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900563 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000564 echo "$(line)" >> $@;)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900565endif # property_overrides_split_enabled
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700566 $(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_VENDOR_PROPERTY_BLACKLIST)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700567
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900568# -----------------------------------------------------------------
569# product build.prop
570INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
571ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
572
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000573ifdef TARGET_PRODUCT_PROP
574product_prop_files := $(TARGET_PRODUCT_PROP)
575else
576product_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/product.prop)
577endif
578
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900579FINAL_PRODUCT_PROPERTIES += \
Yifan Hongaf9e7f02018-07-27 13:11:50 -0700580 $(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES) $(ADDITIONAL_PRODUCT_PROPERTIES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900581FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \
582 $(FINAL_PRODUCT_PROPERTIES),=)
583
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700584$(INSTALLED_PRODUCT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(product_prop_files)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900585 @echo Target product buildinfo: $@
586 @mkdir -p $(dir $@)
587 $(hide) echo > $@
588ifdef BOARD_USES_PRODUCTIMAGE
Anton Hansson1f8729e2018-08-15 12:11:55 +0100589 $(hide) $(call generate-common-build-props,product,$@)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900590endif # BOARD_USES_PRODUCTIMAGE
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000591 $(hide) $(foreach file,$(product_prop_files), \
Anton Hansson6d814982018-11-26 18:12:05 +0000592 if [ -f "$(file)" ]; then \
593 echo Target product properties from: "$(file)"; \
594 echo "" >> $@; \
595 echo "#" >> $@; \
596 echo "# from $(file)" >> $@; \
597 echo "#" >> $@; \
598 cat $(file) >> $@; \
599 echo "# end of $(file)" >> $@; \
600 fi;)
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900601 $(hide) echo "#" >> $@; \
602 echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \
Anton Hansson5ac408b2018-11-05 17:29:28 +0000603 echo "#" >> $@; \
Anton Hanssone9ee80e2018-11-22 15:27:35 +0000604 echo "ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)" >> $@;
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900605 $(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000606 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700607 $(hide) $(POST_PROCESS_PROPS) $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900608
Andres Morales9c820f82015-01-13 15:30:34 -0800609# ----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800610# odm build.prop
Bowgo Tsai71a4d5c2019-05-17 23:21:48 +0800611INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/etc/build.prop
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800612ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_ODM_BUILD_PROP_TARGET)
613
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200614ifdef TARGET_ODM_PROP
615odm_prop_files := $(TARGET_ODM_PROP)
616else
617odm_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/odm.prop)
618endif
619
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800620FINAL_ODM_BUILD_PROPERTIES += \
621 $(call collapse-pairs, $(PRODUCT_ODM_PROPERTIES))
622FINAL_ODM_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
623 $(FINAL_ODM_BUILD_PROPERTIES),=)
624
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200625$(INSTALLED_ODM_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(odm_prop_files)
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800626 @echo Target odm buildinfo: $@
627 @mkdir -p $(dir $@)
628 $(hide) echo > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800629 $(hide) echo ro.odm.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
630 $(hide) echo ro.odm.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
631 $(hide) echo ro.odm.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Anton Hansson1f8729e2018-08-15 12:11:55 +0100632 $(hide) $(call generate-common-build-props,odm,$@)
Rashed Abdel-Tawab194ed8e2017-12-26 01:59:15 +0200633 $(hide) $(foreach file,$(odm_prop_files), \
634 if [ -f "$(file)" ]; then \
635 echo Target odm properties from: "$(file)"; \
636 echo "" >> $@; \
637 echo "#" >> $@; \
638 echo "# from $(file)" >> $@; \
639 echo "#" >> $@; \
640 cat $(file) >> $@; \
641 echo "# end of $(file)" >> $@; \
642 fi;)
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800643 $(hide) echo "#" >> $@; \
644 echo "# ADDITIONAL ODM BUILD PROPERTIES" >> $@; \
645 echo "#" >> $@;
646 $(hide) $(foreach line,$(FINAL_ODM_BUILD_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000647 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700648 $(hide) $(POST_PROCESS_PROPS) $@
Andres Morales9c820f82015-01-13 15:30:34 -0800649
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700650# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +0900651# system_ext build.prop
652INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/build.prop
653ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Dario Freni5f681e12018-05-29 13:09:01 +0100654
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800655ifdef TARGET_SYSTEM_EXT_PROP
656system_ext_prop_files := $(TARGET_SYSTEM_EXT_PROP)
657else
658system_ext_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/system_ext.prop)
659endif
660
Justin Yun6151e3f2019-06-25 15:58:13 +0900661FINAL_SYSTEM_EXT_PROPERTIES += \
662 $(call collapse-pairs, $(PRODUCT_SYSTEM_EXT_PROPERTIES))
663FINAL_SYSTEM_EXT_PROPERTIES := $(call uniq-pairs-by-first-component, \
664 $(FINAL_SYSTEM_EXT_PROPERTIES),=)
665
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800666$(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(system_ext_prop_files)
Justin Yun6151e3f2019-06-25 15:58:13 +0900667 @echo Target system_ext buildinfo: $@
Dario Freni5f681e12018-05-29 13:09:01 +0100668 @mkdir -p $(dir $@)
669 $(hide) echo > $@
Justin Yun6151e3f2019-06-25 15:58:13 +0900670 $(hide) $(call generate-common-build-props,system_ext,$@)
Bowgo Tsai06533fe2019-09-02 18:17:02 +0800671 $(hide) $(foreach file,$(system_ext_prop_files), \
672 if [ -f "$(file)" ]; then \
673 echo Target system_ext properties from: "$(file)"; \
674 echo "" >> $@; \
675 echo "#" >> $@; \
676 echo "# from $(file)" >> $@; \
677 echo "#" >> $@; \
678 cat $(file) >> $@; \
679 echo "# end of $(file)" >> $@; \
680 fi;)
Dario Freni5f681e12018-05-29 13:09:01 +0100681 $(hide) echo "#" >> $@; \
Justin Yun6151e3f2019-06-25 15:58:13 +0900682 echo "# ADDITIONAL SYSTEM_EXT BUILD PROPERTIES" >> $@; \
Dario Freni5f681e12018-05-29 13:09:01 +0100683 echo "#" >> $@;
Justin Yun6151e3f2019-06-25 15:58:13 +0900684 $(hide) $(foreach line,$(FINAL_SYSTEM_EXT_PROPERTIES), \
Anton Hansson6d814982018-11-26 18:12:05 +0000685 echo "$(line)" >> $@;)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700686 $(hide) $(POST_PROCESS_PROPS) $@
Dario Freni5f681e12018-05-29 13:09:01 +0100687
688# ----------------------------------------------------------------
689
690# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800691# sdk-build.prop
692#
693# There are certain things in build.prop that we don't want to
694# ship with the sdk; remove them.
695
696# This must be a list of entire property keys followed by
697# "=" characters, without any internal spaces.
698sdk_build_prop_remove := \
699 ro.build.user= \
700 ro.build.host= \
701 ro.product.brand= \
702 ro.product.manufacturer= \
703 ro.product.device=
704# TODO: Remove this soon-to-be obsolete property
705sdk_build_prop_remove += ro.build.product=
706INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
707$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
708 @echo SDK buildinfo: $@
709 @mkdir -p $(dir $@)
710 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000711 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800712 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000713 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714 $(hide) mv $@.tmp $@
715
716# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700717# kernel modules
718
719# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
720DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
721
722# $(1): modules list
723# $(2): output dir
724# $(3): mount point
725# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700726# $(5): module load list
727# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800728# $(7): module archive
Colin Cross4f60e362019-06-05 11:53:43 -0700729# Returns the a list of src:dest pairs to install the modules using copy-many-files.
730define build-image-kernel-modules
731 $(foreach module,$(1),$(module):$(2)/lib/modules/$(notdir $(module))) \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800732 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2))) \
Colin Cross4f60e362019-06-05 11:53:43 -0700733 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/modules.dep \
Steve Muckle474e4d02019-06-19 12:56:48 -0700734 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/modules.alias \
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700735 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/modules.softdep \
Steve Muckle474e4d02019-06-19 12:56:48 -0700736 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700737endef
738
739# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700740# $(2): mount point
741# $(3): staging dir
742# $(4): module load list
743# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800744# $(6): module archive
745# $(7): output dir
746# TODO(b/144844424): If a module archive is being used, this step (which
747# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
748# the output directory. This should be moved to a module with a
749# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
750# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700751define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700752$(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 -0700753$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
754$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
755$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
756$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules
757$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
758$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
759$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800760$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
761$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
762$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700763 @echo depmod $$(PRIVATE_STAGING_DIR)
764 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700765 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800766 $(if $(6),\
767 unzip -qo -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
768 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800769 cp -r $$(PRIVATE_MODULE_DIR) $$(PRIVATE_OUTPUT_DIR)/lib/; \
770 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
771 )
772 $(if $(1),\
773 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
774 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
775 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
776 done; \
777 )
Colin Cross4f60e362019-06-05 11:53:43 -0700778 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
779 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700780 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
781 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700782endef
783
Steve Muckle474e4d02019-06-19 12:56:48 -0700784# $(1): staging dir
785# $(2): module load list
786# $(3): module load list filename
787# $(4): output dir
788define module-load-list-copy-paths
789 $(eval $(call build-image-module-load-list,$(1),$(2),$(3))) \
790 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(3):$(4)/lib/modules/$(3)
791endef
792
793# $(1): staging dir
794# $(2): module load list
795# $(3): module load list filename
796define build-image-module-load-list
797$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_STAGING_DIR := $(1)
798$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_LOAD_MODULES := $(2)
799$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): PRIVATE_LOAD_FILENAME := $(3)
800$(1)/$(DEPMOD_STAGING_SUBDIR)/$(3): $(2)
801 rm -f $$@
802 (for MODULE in $$(PRIVATE_LOAD_MODULES); do basename $$$$MODULE >> $$@; done)
803endef
804
Steve Mucklee1b10862019-07-10 10:49:37 -0700805ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
806 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
807 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700808 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700809 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
810endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700811
812ifeq ($(BOARD_RECOVERY_KERNEL_MODULES_LOAD),)
813 BOARD_RECOVERY_KERNEL_MODULES_LOAD := $(BOARD_RECOVERY_KERNEL_MODULES)
814endif
Steve Muckle69280d22019-07-11 12:23:38 -0700815ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
816 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700817endif
818
Steve Mucklee1b10862019-07-10 10:49:37 -0700819ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700820 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700821 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700822 endif
823endif
824
Steve Muckle810a0ba2019-11-13 13:29:02 -0800825ifneq ($(strip $(BOARD_RECOVERY_KERNEL_MODULES))$(strip $(BOARD_RECOVERY_KERNEL_MODULES_ARCHIVE)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700826 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700827 ifdef BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD
828 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 -0700829 endif
830 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800831 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 -0700832endif
833
Steve Muckle810a0ba2019-11-13 13:29:02 -0800834ifneq ($(strip $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES))$(strip $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_ARCHIVE)),)
Steve Mucklee1b10862019-07-10 10:49:37 -0700835 ifeq ($(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD),)
836 BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
837 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800838 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 -0700839endif
840
Steve Muckle474e4d02019-06-19 12:56:48 -0700841ifneq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Mucklee1b10862019-07-10 10:49:37 -0700842 ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800843 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 -0700844 endif
Colin Cross4f60e362019-06-05 11:53:43 -0700845endif
846
Steve Muckle810a0ba2019-11-13 13:29:02 -0800847ifneq ($(strip $(BOARD_VENDOR_KERNEL_MODULES)$(strip $(BOARD_VENDOR_KERNEL_MODULES_ARCHIVE))),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700848 ifeq ($(BOARD_VENDOR_KERNEL_MODULES_LOAD),)
849 BOARD_VENDOR_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_KERNEL_MODULES)
850 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800851 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_VENDOR_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 -0700852endif
853
Steve Muckle810a0ba2019-11-13 13:29:02 -0800854ifneq ($(strip $(BOARD_ODM_KERNEL_MODULES))$(strip $(BOARD_ODM_KERNEL_MODULES_ARCHIVE)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700855 ifeq ($(BOARD_RECOVERY_KERNEL_MODULES_LOAD),)
856 BOARD_ODM_KERNEL_MODULES_LOAD := $(BOARD_ODM_KERNEL_MODULES)
857 endif
Steve Muckle810a0ba2019-11-13 13:29:02 -0800858 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 -0700859endif
860
861# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800862# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700863# Use a macro to add newline to each echo command
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100864define _apkcerts_write_line
865$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $5
866$(if $(4), $(hide) echo -n ' compressed="$4"' >> $5)
867$(hide) echo '' >> $5
Ying Wangd9a88d52012-10-26 09:21:28 -0700868
869endef
870
The Android Open Source Project88b60792009-03-03 19:28:42 -0800871name := $(TARGET_PRODUCT)
872ifeq ($(TARGET_BUILD_TYPE),debug)
873 name := $(name)_debug
874endif
875name := $(name)-apkcerts-$(FILE_NAME_TAG)
876intermediates := \
877 $(call intermediates-dir-for,PACKAGING,apkcerts)
878APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800879# We don't need to really build all the modules.
880# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700881$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800882 @echo APK certs list: $@
883 @mkdir -p $(dir $@)
884 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700885 $(foreach p,$(sort $(PACKAGES)),\
Ying Wangd9a88d52012-10-26 09:21:28 -0700886 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100887 $(call _apkcerts_write_line,$(p),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$@),\
888 $(call _apkcerts_write_line,$(p),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700889 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700890 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800891
892.PHONY: apkcerts-list
893apkcerts-list: $(APKCERTS_FILE)
894
Ying Wang15e487a2011-02-15 10:56:18 -0800895ifneq (,$(TARGET_BUILD_APPS))
896 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900897 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800898endif
Ying Wangefb21682010-07-23 16:42:13 -0700899
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900900
The Android Open Source Project88b60792009-03-03 19:28:42 -0800901# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700902# build system stats
903BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
904$(BUILD_SYSTEM_STATS):
905 @rm -f $@
906 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
907 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
908$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700909
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700910# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800911# build /product/etc/security/avb/system_other.avbpubkey if needed
912ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800913ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800914INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
915ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800916endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800917endif # BUILDING_SYSTEM_OTHER_IMAGE
918
919# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700920# Modules ready to be converted to Soong, ordered by how many
921# modules depend on them.
922SOONG_CONV := $(sort $(SOONG_CONV))
923SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
924$(SOONG_CONV_DATA):
925 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800926 @$(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 -0700927
Colin Crossfdea8932017-12-06 14:38:40 -0800928SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700929SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
930$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
931 @rm -f $@
932 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
933$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
934
935# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800936# Modules use -Wno-error, or added default -Wall -Werror
937WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
938$(WALL_WERROR):
939 @rm -f $@
940 echo "# Modules using -Wno-error" >> $@
941 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 -0800942 echo "# Modules added default -Wall" >> $@
943 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
944
945$(call dist-for-goals,droidcore,$(WALL_WERROR))
946
947# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700948# C/C++ flag information for modules
949$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
950
951# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800952# Modules missing profile files
953PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
954$(PGO_PROFILE_MISSING):
955 @rm -f $@
956 echo "# Modules missing PGO profile files" >> $@
957 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
958
959$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
960
961# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700962# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700963# for future OTA packages installed by this system. Actual product
964# deliverables will be re-signed by hand. We expect this file to
965# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700966DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700967
968
Jeff Browne33ba4c2011-07-11 22:11:46 -0700969# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800970# if they don't do anything.
971.PHONY: systemimage
972systemimage:
973
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800974# -----------------------------------------------------------------
975
976.PHONY: event-log-tags
977
Joe Onoratob7510532010-07-14 10:22:54 -0700978# Produce an event logs tag file for everything we know about, in order
979# to properly allocate numbers. Then produce a file that's filtered
980# for what's going to be installed.
981
982all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
983
Colin Crossdc8f8e42012-04-12 13:25:54 -0700984event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
985
Joe Onoratob7510532010-07-14 10:22:54 -0700986# Include tags from all packages that we know about
987all_event_log_tags_src := \
988 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
989
Colin Crossdc8f8e42012-04-12 13:25:54 -0700990# PDK builds will already have a full list of tags that needs to get merged
991# in with the ones from source
992pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
993
994$(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 -0800995$(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 -0700996 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900997 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700998
Doug Zongkera34fa952011-02-23 12:17:29 -0800999# Include tags from all packages included in this product, plus all
1000# tags that are part of the system (ie, not in a vendor/ or device/
1001# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001002event_log_tags_src := \
1003 $(sort $(foreach m,\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001004 $(PRODUCT_PACKAGES) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001005 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -08001006 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
1007 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001008
Colin Crossdc8f8e42012-04-12 13:25:54 -07001009$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -07001010$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -08001011$(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 -08001012 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +09001013 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -08001014
1015event-log-tags: $(event_log_tags_file)
1016
1017ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
1018
Joe Onoratob7510532010-07-14 10:22:54 -07001019
The Android Open Source Project88b60792009-03-03 19:28:42 -08001020# #################################################################
1021# Targets for boot/OS images
1022# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -08001023ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
1024 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
1025 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
1026 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
1027 else
1028 INSTALLED_2NDBOOTLOADER_TARGET :=
1029 endif
1030else
1031 INSTALLED_BOOTLOADER_MODULE :=
1032 INSTALLED_2NDBOOTLOADER_TARGET :=
1033endif # TARGET_NO_BOOTLOADER
1034ifneq ($(strip $(TARGET_NO_KERNEL)),true)
1035 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
1036else
1037 INSTALLED_KERNEL_TARGET :=
1038endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001039
1040# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -07001041# the root dir
1042INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001043 $(ALL_GENERATED_SOURCES) \
1044 $(ALL_DEFAULT_INSTALLED_MODULES))
1045
Luis Hector Chavezff489932018-07-03 15:41:40 -07001046INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
1047INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
1048$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001049$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -07001050 @echo Installed file list: $@
1051 @mkdir -p $(dir $@)
1052 @rm -f $@
1053 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001054 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -07001055
1056$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
1057
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001058#------------------------------------------------------------------
1059# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001060ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001061INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001062ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -08001063$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001064 cat $^ > $@
1065endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07001066endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001067
Tom Cherryd14b8952018-08-09 14:26:00 -07001068# -----------------------------------------------------------------
1069# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -08001070ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -07001071INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
1072 $(ALL_GENERATED_SOURCES) \
1073 $(ALL_DEFAULT_INSTALLED_MODULES))
1074
1075INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
1076INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
1077$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001078$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -07001079 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +08001080 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -07001081 @mkdir -p $(dir $@)
1082 @rm -f $@
1083 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001084 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -07001085
1086$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -07001087BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
1088
1089# We just build this directly to the install location.
1090INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Tom Cherryd14b8952018-08-09 14:26:00 -07001091$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001092 $(call pretty,"Target ram disk: $@")
Tom Cherryd14b8952018-08-09 14:26:00 -07001093 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001094
Ying Wangad7fd292013-08-08 16:34:29 -07001095.PHONY: ramdisk-nodeps
1096ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
1097 @echo "make $@: ignoring dependencies"
Tom Cherryd14b8952018-08-09 14:26:00 -07001098 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001099
Dan Willemsen67495202019-01-16 12:42:05 -08001100endif # BUILDING_RAMDISK_IMAGE
1101
The Android Open Source Project88b60792009-03-03 19:28:42 -08001102# -----------------------------------------------------------------
1103# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -07001104
1105# This is defined here since we may be building recovery as boot
1106# below and only want to define this once
1107BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
1108
1109ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001110INTERNAL_BOOTIMAGE_ARGS := \
1111 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001112 --kernel $(INSTALLED_KERNEL_TARGET)
1113
1114ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1115INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
1116endif
1117
Steve Mucklee1b10862019-07-10 10:49:37 -07001118ifndef BUILDING_VENDOR_BOOT_IMAGE
1119ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1120 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1121endif
1122endif
1123
The Android Open Source Project88b60792009-03-03 19:28:42 -08001124INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
1125
Anton Hansson8dab0a62019-03-28 15:45:40 +00001126ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001127ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001128VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001129 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
1130endif
1131endif
1132
Anton Hansson72e36f02019-02-26 17:36:30 +00001133INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -07001134
1135ifndef BUILDING_VENDOR_BOOT_IMAGE
1136ifdef BOARD_KERNEL_BASE
1137 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1138endif
1139ifdef BOARD_KERNEL_PAGESIZE
1140 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1141endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001142ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07001143 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1144endif
1145else
1146# building vendor boot image, dtb/base/pagesize go there
1147ifdef GENERIC_KERNEL_CMDLINE
1148 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1149endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001150endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001151
Sami Tolvanen3303d902016-03-15 16:49:30 +00001152INTERNAL_MKBOOTIMG_VERSION_ARGS := \
1153 --os_version $(PLATFORM_VERSION) \
1154 --os_patch_level $(PLATFORM_SECURITY_PATCH)
1155
Chris Grossa784ef12019-04-22 11:09:57 -07001156# Define these only if we are building boot
1157ifdef BUILDING_BOOT_IMAGE
1158INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1159
The Android Open Source Project88b60792009-03-03 19:28:42 -08001160ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001161$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -04001162
1163else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
1164
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001165$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -04001166 $(call pretty,"Target boot image: $@")
1167 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001168 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001169 $(hide) $(AVBTOOL) add_hash_footer \
1170 --image $@ \
1171 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001172 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001173 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1174
1175.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001176bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -04001177 @echo "make $@: ignoring dependencies"
1178 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001179 $(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 -04001180 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001181 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001182 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001183 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -04001184 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1185
Anton Hansson8dab0a62019-03-28 15:45:40 +00001186else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -07001187
1188$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
1189 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001190 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Anton Hansson8dab0a62019-03-28 15:45:40 +00001191 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -07001192 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1193
1194.PHONY: bootimage-nodeps
1195bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
1196 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001197 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001198 $(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 -07001199 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1200
Anton Hansson8dab0a62019-03-28 15:45:40 +00001201else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -08001202
Tao Bao4b577412017-02-22 22:54:39 -08001203$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001204 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001205 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +00001206 $(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 -08001207 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1208
1209.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001210bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001211 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001212 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +00001213 $(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 -08001214 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
1215
1216else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001217
1218$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
1219 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +00001220 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001221 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -07001222
1223.PHONY: bootimage-nodeps
1224bootimage-nodeps: $(MKBOOTIMG)
1225 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +00001226 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001227 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -07001228
The Android Open Source Project88b60792009-03-03 19:28:42 -08001229endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -07001230endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001231
Tao Baob1a2e352018-08-14 16:17:12 -07001232else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001233ifdef BOARD_PREBUILT_BOOTIMAGE
1234ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1235# Remove when b/63676296 is resolved.
1236$(error Prebuilt bootimage is only supported for AB targets)
1237endif
Kiyoung Kim62e22312019-06-20 14:27:45 +09001238INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001239$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -07001240else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -07001241INSTALLED_BOOTIMAGE_TARGET :=
1242endif # BOARD_PREBUILT_BOOTIMAGE
1243endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -08001244
1245# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001246# vendor boot image
1247ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1248
1249ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1250 $(error vboot 1.0 does not support vendor_boot partition)
1251endif
1252
1253INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
1254 $(ALL_GENERATED_SOURCES) \
1255 $(ALL_DEFAULT_INSTALLED_MODULES))
1256
1257INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio.gz
1258$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(MINIGZIP)
1259 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(MINIGZIP) > $@
1260
1261ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1262 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1263endif
1264ifdef BOARD_KERNEL_BASE
1265 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1266endif
1267ifdef BOARD_KERNEL_PAGESIZE
1268 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1269endif
1270ifdef INTERNAL_KERNEL_CMDLINE
1271 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1272endif
1273
1274INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1275$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
1276ifeq ($(BOARD_AVB_ENABLE),true)
1277$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1278 $(call pretty,"Target vendor_boot image: $@")
1279 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
1280 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1281 $(AVBTOOL) add_hash_footer \
1282 --image $@ \
1283 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
1284 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1285 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1286else
1287$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1288 $(call pretty,"Target vendor_boot image: $@")
1289 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
1290 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1291endif
1292endif # BUILDING_VENDOR_BOOT_IMAGE
1293
1294# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001295# NOTICE files
1296#
Steve Blockd14d3b42012-03-01 11:34:41 +00001297# We are required to publish the licenses for all code under BSD, GPL and
1298# Apache licenses (and possibly other more exotic ones as well). We err on the
1299# side of caution, so the licenses for other third-party code are included here
1300# too.
1301#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001302# This needs to be before the systemimage rules, because it adds to
1303# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1304# go into the systemimage.
1305
Steve Block495e5852012-02-29 19:18:08 +00001306.PHONY: notice_files
1307
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001308# Create the rule to combine the files into text and html/xml forms
Chris Grossaad39b32019-06-13 09:43:26 -07001309# $(1) - xml_excluded_system_product_odm|xml_excluded_vendor_product_odm
1310# xml_product|xml_odm|xml_system_ext|xml_system|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001311# $(2) - Plain text output file
1312# $(3) - HTML/XML output file
1313# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001314# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001315# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001316# $(6) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -08001317#
1318# The algorithm here is that we go collect a hash for each of the notice
1319# files and write the names of the files that match that hash. Then
1320# to generate the real files, we go print out all of the files and their
1321# hashes.
1322#
1323# These rules are fairly complex, so they depend on this makefile so if
1324# it changes, they'll run again.
1325#
1326# TODO: We could clean this up so that we just record the locations of the
1327# original notice files instead of making rules to copy them somwehere.
1328# Then we could traverse that without quite as much bash drama.
1329define combine-notice-files
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001330$(2) $(3): PRIVATE_MESSAGE := $(4)
1331$(2) $(3): PRIVATE_DIR := $(5)
1332$(2) : $(3)
Colin Crossfdea8932017-12-06 14:38:40 -08001333$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
1334 build/make/tools/generate-notice-files.py --text-output $(2) \
Chris Grossaad39b32019-06-13 09:43:26 -07001335 $(if $(filter $(1),xml_excluded_vendor_product_odm),-e vendor -e product -e system_ext -e odm --xml-output, \
1336 $(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 +00001337 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001338 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001339 $(if $(filter $(1),xml_system),-i system --xml-output, \
1340 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
1341 --html-output)))))) $(3) \
Anton Hansson6d814982018-11-26 18:12:05 +00001342 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001343notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001344endef
1345
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001346# Notice file logic isn't relevant for TARGET_BUILD_APPS
1347ifndef TARGET_BUILD_APPS
1348
The Android Open Source Project88b60792009-03-03 19:28:42 -08001349# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1350# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1351# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001352target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001353tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001354tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001355kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1356winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
1357pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001358
Steven Morelandae69e572017-12-15 14:49:55 -08001359# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001360ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1361target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1362target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1363installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1364$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001365 $(target_notice_file_txt), \
1366 $(target_notice_file_html), \
1367 "Notices for files contained in the filesystem images in this directory:", \
1368 $(TARGET_OUT_NOTICE_FILES), \
1369 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001370$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1371 $(hide) $(MINIGZIP) -9 < $< > $@
1372$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1373 $(copy-file-to-target)
1374else
1375target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1376target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001377installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1378
1379target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1380target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1381target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1382installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001383
1384target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1385target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1386target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1387installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001388
Justin Yun6151e3f2019-06-25 15:58:13 +09001389target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1390target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1391target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1392installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001393
Chris Gross15d96552019-07-16 14:38:43 -07001394target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1395target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1396target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1397installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1398
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001399# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1400# being built. A notice xml file must depend on all modules that could potentially
1401# install a license file relevant to it.
1402license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)
1403# Phonys/fakes don't have notice files (though their deps might)
1404license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001405# testcases are not relevant to the system image.
1406license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001407license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001408license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1409license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001410license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001411license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001412license_modules_agg := $(license_modules_system) \
1413 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001414 $(license_modules_product) \
1415 $(license_modules_system_ext) \
1416 $(license_modules_odm)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001417license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001418
Chris Grossaad39b32019-06-13 09:43:26 -07001419# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1420# update its notice file, so include those notices in the system partition instead
1421ifdef BOARD_PREBUILT_VENDORIMAGE
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001422license_modules_system += $(license_modules_rest)
Chris Grossaad39b32019-06-13 09:43:26 -07001423system_xml_directories := xml_excluded_vendor_product_odm
1424system_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 -07001425else
1426license_modules_vendor += $(license_modules_rest)
1427system_xml_directories := xml_system
1428system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001429endif
1430
1431$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001432 $(target_notice_file_txt), \
1433 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001434 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001435 $(TARGET_OUT_NOTICE_FILES), \
Chris Grossaad39b32019-06-13 09:43:26 -07001436 $(license_modules_system)))
1437$(eval $(call combine-notice-files, xml_excluded_system_product_odm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001438 $(target_vendor_notice_file_txt), \
1439 $(target_vendor_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001440 "Notices for files contained in all filesystem images except system/system_ext/product/odm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001441 $(TARGET_OUT_NOTICE_FILES), \
1442 $(license_modules_vendor)))
Dario Freniadc972d2018-07-09 18:38:38 +01001443$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001444 $(target_product_notice_file_txt), \
1445 $(target_product_notice_file_xml), \
1446 "Notices for files contained in the product filesystem image in this directory:", \
1447 $(TARGET_OUT_NOTICE_FILES), \
1448 $(license_modules_product)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001449$(eval $(call combine-notice-files, xml_system_ext, \
1450 $(target_system_ext_notice_file_txt), \
1451 $(target_system_ext_notice_file_xml), \
1452 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001453 $(TARGET_OUT_NOTICE_FILES), \
Justin Yun6151e3f2019-06-25 15:58:13 +09001454 $(license_modules_system_ext)))
Chris Gross15d96552019-07-16 14:38:43 -07001455$(eval $(call combine-notice-files, xml_odm, \
1456 $(target_odm_notice_file_txt), \
1457 $(target_odm_notice_file_xml), \
1458 "Notices for files contained in the odm filesystem image in this directory:", \
1459 $(TARGET_OUT_NOTICE_FILES), \
1460 $(license_modules_odm)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001461
1462$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1463 $(hide) $(MINIGZIP) -9 < $< > $@
1464$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1465 $(hide) $(MINIGZIP) -9 < $< > $@
1466$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1467 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001468$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001469 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001470$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1471 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001472$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1473 $(copy-file-to-target)
1474$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1475 $(copy-file-to-target)
1476$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1477 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001478$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001479 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001480$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1481 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001482
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001483ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1484ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1485ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1486ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1487ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001488endif # PRODUCT_NOTICE_SPLIT
1489
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001490ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001491
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001492$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001493 $(tools_notice_file_txt), \
1494 $(tools_notice_file_html), \
1495 "Notices for files contained in the tools directory:", \
1496 $(HOST_OUT_NOTICE_FILES), \
1497 $(ALL_DEFAULT_INSTALLED_MODULES) \
1498 $(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001499
Ying Wang62c81f82013-08-22 20:02:03 -07001500endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001501
1502# The kernel isn't really a module, so to get its module file in there, we
1503# make the target NOTICE files depend on this particular file too, which will
1504# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001505$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001506
Dan Willemsen288bedf2019-05-28 15:36:47 -07001507$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001508
Doug Zongker8678df42009-06-15 14:30:14 -07001509
The Android Open Source Project88b60792009-03-03 19:28:42 -08001510# #################################################################
1511# Targets for user images
1512# #################################################################
1513
Ying Wang933abf12010-06-16 14:31:34 -07001514INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001515ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001516INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1517else
1518ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001519INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1520else
1521ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001522INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1523endif
1524endif
1525endif
1526
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001527# These options tell the recovery updater/installer how to mount the partitions writebale.
1528# <fstype>=<fstype_opts>[|<fstype_opts>]...
1529# fstype_opts := <opt>[,<opt>]...
1530# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001531# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1532DEFAULT_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 -07001533
Ying Wang542903a2010-11-17 15:40:38 -08001534ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1535 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1536endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001537ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1538 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1539endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001540ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1541 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1542endif
Tao Baodba635a2019-06-24 10:39:54 -07001543
1544INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001545 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001546 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001547 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001548
1549ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1550INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001551endif
1552
Justin Yun6151e3f2019-06-25 15:58:13 +09001553ifneq ($(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 -07001554INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1555endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001556
Anton Hansson8dab0a62019-03-28 15:45:40 +00001557ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001558INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001559ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001560INTERNAL_USERIMAGES_DEPS += $(FEC)
1561endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001562endif
1563
Tao Baodba635a2019-06-24 10:39:54 -07001564ifeq ($(BOARD_AVB_ENABLE),true)
1565INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1566endif
1567
1568# Get a colon-separated list of search paths.
1569INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1570
Alex Klyubin092c9022017-03-13 13:28:34 -07001571SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001572INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1573
Yifan Hongc5c01242018-11-09 10:27:23 -08001574ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001575
Anton Hansson8dab0a62019-03-28 15:45:40 +00001576ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001577 $(error vboot 1.0 doesn't support logical partition)
1578endif
1579
Yifan Hongc5c01242018-11-09 10:27:23 -08001580endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001581
Ying Wangbd93d422011-10-28 17:02:30 -07001582# $(1): the path of the output dictionary file
Justin Yun6151e3f2019-06-25 15:58:13 +09001583# $(2): a subset of "system vendor cache userdata product system_ext oem odm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001584# $(3): additional "key=value" pairs to append to the dictionary file.
1585define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001586$(if $(filter $(2),system),\
1587 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001588 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001589 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1590 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1591 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1592 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1593 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1594 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1595 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1596 $(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 +00001597 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1598 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001599 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001600 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001601)
Yifan Hong760d3c02018-05-30 11:16:46 -07001602$(if $(filter $(2),userdata),\
1603 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1604 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001605 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1606 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001607 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001608)
Yifan Hong760d3c02018-05-30 11:16:46 -07001609$(if $(filter $(2),cache),\
1610 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1611 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001612 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001613)
1614$(if $(filter $(2),vendor),\
1615 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1616 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1617 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1618 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1619 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1620 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1621 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1622 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1623 $(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 +00001624 $(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 -07001625 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001626 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001627)
1628$(if $(filter $(2),product),\
1629 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1630 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1631 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1632 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1633 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1634 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1635 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1636 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1637 $(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 +00001638 $(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 -07001639 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001640 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001641)
Justin Yun6151e3f2019-06-25 15:58:13 +09001642$(if $(filter $(2),system_ext),\
1643 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1644 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1645 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1646 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1647 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1648 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1649 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1650 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1651 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1652 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1653 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001654)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001655$(if $(filter $(2),odm),\
1656 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1657 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1658 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1659 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1660 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1661 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1662 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1663 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1664 $(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 +00001665 $(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 +08001666 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001667 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001668)
Yifan Hong760d3c02018-05-30 11:16:46 -07001669$(if $(filter $(2),oem),\
1670 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1671 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1672 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1673 $(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 -07001674 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001675)
Tao Bao3602eca2018-07-10 10:53:55 -07001676$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001677
Tao Bao3602eca2018-07-10 10:53:55 -07001678$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001679$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001680$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001681$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001682$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1683$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1684$(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 +00001685$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1686$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1687$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1688$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1689$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001690$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001691$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1692$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1693$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001694$(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 +00001695$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1696$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1697$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1698$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1699$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001700$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001701$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1702$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1703$(if $(BOARD_AVB_ENABLE),\
1704 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1705 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1706 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1707 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001708$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1709$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1710$(if $(BOARD_AVB_ENABLE),\
1711 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1712 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001713 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001714$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1715$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1716$(if $(BOARD_AVB_ENABLE),\
1717 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1718 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1719 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1720 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001721$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1722$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1723$(if $(BOARD_AVB_ENABLE),\
1724 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1725 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1726 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1727 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001728$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001729$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001730 $(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 +01001731$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001732 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1733 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1734 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1735 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001736$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1737$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1738$(if $(BOARD_AVB_ENABLE),\
1739 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1740 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1741 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1742 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001743$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1744 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001745$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001746 $(hide) echo "system_root_image=true" >> $(1))
1747$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001748$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1749 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001750$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1751endef
1752
1753# $(1): the path of the output dictionary file
1754# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001755PROP_DICTIONARY_IMAGES := oem
1756ifdef BUILDING_CACHE_IMAGE
1757 PROP_DICTIONARY_IMAGES += cache
1758endif
1759ifdef BUILDING_SYSTEM_IMAGE
1760 PROP_DICTIONARY_IMAGES += system
1761endif
1762ifdef BUILDING_USERDATA_IMAGE
1763 PROP_DICTIONARY_IMAGES += userdata
1764endif
1765ifdef BUILDING_VENDOR_IMAGE
1766 PROP_DICTIONARY_IMAGES += vendor
1767endif
1768ifdef BUILDING_PRODUCT_IMAGE
1769 PROP_DICTIONARY_IMAGES += product
1770endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001771ifdef BUILDING_SYSTEM_EXT_IMAGE
1772 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001773endif
1774ifdef BUILDING_ODM_IMAGE
1775 PROP_DICTIONARY_IMAGES += odm
1776endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001777define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001778 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001779endef
1780
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001781# $(1): the path of the input dictionary file, where each line has the format key=value
1782# $(2): the key to look up
1783define read-image-prop-dictionary
1784$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1785endef
1786
The Android Open Source Project88b60792009-03-03 19:28:42 -08001787# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001788# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001789
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001790# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001791ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001792
Ying Wang37526142015-03-10 12:02:57 -07001793INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1794 $(ALL_DEFAULT_INSTALLED_MODULES))
1795
Tao Bao10fc9492018-08-14 12:17:48 -07001796INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1797INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1798
1799# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1800# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1801# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1802# the call to FILELIST.
1803ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001804INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001805$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1806else
1807$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1808endif
1809
1810$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001811$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001812 @echo Installed file list: $@
1813 @mkdir -p $(dir $@)
1814 @rm -f $@
1815 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001816 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001817
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001818recovery_sepolicy := \
1819 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001820 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001821 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001822 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1823 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1824 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001825 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001826 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001827 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1828 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1829 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001830
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001831# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1832# SELinux files
1833IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1834
Doug Zongker4647f122009-07-02 09:00:54 -07001835recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1836recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Doug Zongker4647f122009-07-02 09:00:54 -07001837recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001838
Anton Hansson45a40da2019-01-18 14:06:34 +00001839# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1840# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1841# which get remapped to a bucket.
1842recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001843ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1844recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001845# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001846# ------160------240------320----------480------------640------
1847# mdpi hdpi xhdpi xxhdpi xxxhdpi
1848recovery_density := $(strip \
1849 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1850 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1851 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1852 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001853endif
1854
1855ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1856recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1857else
Doug Zongker25d55f82014-04-04 13:51:15 -07001858recovery_resources_common := $(recovery_resources_common)-xhdpi
1859endif
1860
Tao Baoe1e829e2018-08-29 20:36:00 -07001861# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1862# Note that the font selected here can be overridden for a particular device by putting a font.png
1863# in its private recovery resources.
1864ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001865recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1866else
1867recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1868endif
1869
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001870
1871# We will only generate the recovery background text images if the variable
1872# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1873# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1874# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1875# BoardConfig in order to use this feature.
1876ifeq ($(recovery_density),xxxhdpi)
1877TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1878else ifeq ($(recovery_density),xxhdpi)
1879TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1880endif
1881
1882ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1883# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1884ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1885 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1886else
1887 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1888endif
1889
1890
1891RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,PACKAGING,recovery_text_res)/installing_text.png
1892RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1893RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1894RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1895RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1896
xunchangcc57d312018-12-07 12:12:17 -08001897RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1898RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1899RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1900RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1901RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1902
1903generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001904 $(RECOVERY_INSTALLING_TEXT_FILE) \
1905 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1906 $(RECOVERY_ERASING_TEXT_FILE) \
1907 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001908 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1909 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1910 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1911 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1912 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1913 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001914
1915resource_dir := $(call include-path-for, recovery)/tools/recovery_l10n/res/
1916image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001917zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001918$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
1919$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,PACKAGING,recovery_font_files)
1920$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1921$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001922$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001923$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001924$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001925 recovery_installing \
1926 recovery_installing_security \
1927 recovery_erasing \
1928 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001929 recovery_no_command
1930$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001931 recovery_cancel_wipe_data \
1932 recovery_factory_data_reset \
1933 recovery_try_again \
1934 recovery_wipe_data_menu_header \
1935 recovery_wipe_data_confirmation
1936$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
1937$(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 -08001938 # Prepares the font directory.
1939 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1940 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001941 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001942 @rm -rf $(dir $@)
1943 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001944 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001945 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001946 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001947 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1948 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1949 --text_name $(text_name) \
1950 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1951 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001952 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001953 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001954else
1955RECOVERY_INSTALLING_TEXT_FILE :=
1956RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1957RECOVERY_ERASING_TEXT_FILE :=
1958RECOVERY_ERROR_TEXT_FILE :=
1959RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001960RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1961RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1962RECOVERY_TRY_AGAIN_TEXT_FILE :=
1963RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1964RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001965endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1966
Ying Wang9a175682015-08-06 11:47:47 -07001967ifndef TARGET_PRIVATE_RES_DIRS
1968TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1969endif
Doug Zongker4647f122009-07-02 09:00:54 -07001970recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001971 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001972recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001973
1974
Andrew Boiefa61ff02012-09-28 09:33:45 -07001975ifdef TARGET_RECOVERY_FSTAB
1976recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1977else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001978recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001979endif
Tao Baoc3c17532016-06-10 10:11:54 -07001980ifdef TARGET_RECOVERY_WIPE
1981recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001982else
Tao Baoc3c17532016-06-10 10:11:54 -07001983recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001984endif
Tao Bao8beab692015-07-22 12:33:18 -07001985
Tao Bao6d5d6232018-03-09 17:04:42 -08001986# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001987# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001988# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1989# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001990#
1991# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001992# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001993# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001994# b) We build a single image that contains boot and recovery both - no recovery image to install
1995# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001996# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001997# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001998# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1999# do bsdiff because boot and recovery will contain different number of entries
2000# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002001# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
2002# do bsdiff because boot and recovery will contain different number of entries
2003# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002004
Tom Cherry2929cad2018-09-20 11:04:37 -07002005ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002006 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07002007# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002008RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2009ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002010else
Tao Bao8beab692015-07-22 12:33:18 -07002011RECOVERY_RESOURCE_ZIP :=
2012endif
Doug Zongker4647f122009-07-02 09:00:54 -07002013
Tao Bao139c7272018-07-31 13:26:54 -07002014INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2015
2016$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002017 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2018 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2019 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2020 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2021 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2022 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2023 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2024 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2025
2026# Parses the given list of build variables and writes their values as build properties if defined.
2027# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2028# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2029# $(1): Map from the build variable names to property names
2030# $(2): Output file
2031define append-recovery-ui-properties
2032echo "#" >> $(2)
2033echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2034echo "#" >> $(2)
2035$(foreach prop,$(1), \
2036 $(eval _varname := $(call word-colon,1,$(prop))) \
2037 $(eval _propname := $(call word-colon,2,$(prop))) \
2038 $(eval _value := $($(_varname))) \
2039 $(if $(_value), \
2040 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2041endef
2042
2043$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00002044 $(INSTALLED_DEFAULT_PROP_TARGET) \
2045 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
2046 $(intermediate_system_build_prop) \
2047 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2048 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2049 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002050 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002051 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002052 $(hide) mkdir -p $(dir $@)
2053 $(hide) rm -f $@
2054 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) > $@
2055 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) >> $@
Tao Bao6eb1a992018-08-06 07:33:45 -07002056 $(hide) cat $(intermediate_system_build_prop) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002057 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002058 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002059 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002060 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002061 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2062
Steve Mucklee1b10862019-07-10 10:49:37 -07002063ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
2064 INTERNAL_RECOVERYIMAGE_ARGS := \
2065 --kernel $(recovery_kernel) --ramdisk $(recovery_ramdisk)
2066ifdef GENERIC_KERNEL_CMDLINE
2067 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
2068endif
2069else # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
2070 INTERNAL_RECOVERYIMAGE_ARGS := \
2071 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
2072 --kernel $(recovery_kernel) --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07002073# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002074ifdef INTERNAL_KERNEL_CMDLINE
2075 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07002076endif
2077ifdef BOARD_KERNEL_BASE
2078 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2079endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002080ifdef BOARD_KERNEL_PAGESIZE
2081 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2082endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002083ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002084ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2085 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2086else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002087 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2088endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002089endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002090ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2091 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2092endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002093ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2094 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2095endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002096endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Doug Zongker4647f122009-07-02 09:00:54 -07002097
Ying Wang747b9f12015-01-30 14:05:22 -08002098# $(1): output file
2099define build-recoveryimage-target
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002100 # Making recovery image
Ying Wang747b9f12015-01-30 14:05:22 -08002101 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao696bb332018-08-17 16:27:01 -07002102 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002103 # Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002104 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
Tao Bao696bb332018-08-17 16:27:01 -07002105 $(hide) rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08002106 # Modifying ramdisk contents...
Tom Cherry3871f0f2018-11-06 14:23:44 -08002107 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2108 $(hide) ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
Bowgo Tsaib5b3bc62017-09-25 17:50:41 +08002109 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2110 $(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 -07002111 $(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 -08002112 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2113 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2114 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
xunchangcc57d312018-12-07 12:12:17 -08002115 $(hide) $(foreach recovery_text_file,$(generated_recovery_text_files), \
2116 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
Ying Wang747b9f12015-01-30 14:05:22 -08002117 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07002118 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2119 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08002120 $(hide) $(foreach item,$(recovery_fstab), \
Tao Bao696bb332018-08-17 16:27:01 -07002121 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07002122 $(if $(strip $(recovery_wipe)), \
Tao Bao696bb332018-08-17 16:27:01 -07002123 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
Hung-ying Tyanf829b402017-05-01 21:56:26 +08002124 $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07002125 $(BOARD_RECOVERY_IMAGE_PREPARE)
Thierry Strudel74a81e62015-07-09 09:54:55 -07002126 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002127 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00002128 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
Jooyung Han72b65ab2019-05-23 19:48:13 +09002129 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002130 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002131 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002132 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2133 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002134 )\
2135 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002136 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2137 $(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 +08002138 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
2139 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
2140 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002141 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2142 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
2143 $(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),\
2144 $(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 -08002145endef
2146
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002147ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002148ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Ying Wangbd07ad02016-03-10 12:57:33 -08002149$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
2150endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002151ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Ying Wangbd07ad02016-03-10 12:57:33 -08002152$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
2153endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002154ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002155$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002156endif
Tao Baof4866c72018-08-22 14:35:09 -07002157ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002158ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2159$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2160else
Tao Baof4866c72018-08-22 14:35:09 -07002161$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2162endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002163endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002164ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2165$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2166endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002167ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2168$(INSTALLED_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2169endif
Tao Baof4866c72018-08-22 14:35:09 -07002170
Jiyong Parkce3e34f2018-05-24 14:24:50 +09002171$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Anton Hansson6d814982018-11-26 18:12:05 +00002172 $(INTERNAL_ROOT_FILES) \
2173 $(INSTALLED_RAMDISK_TARGET) \
2174 $(INTERNAL_RECOVERYIMAGE_FILES) \
Tom Cherry89eea962019-11-04 10:41:51 -08002175 $(recovery_sepolicy) $(recovery_kernel) \
Anton Hansson6d814982018-11-26 18:12:05 +00002176 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2177 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2178 $(recovery_resource_deps) \
Colin Cross4f60e362019-06-05 11:53:43 -07002179 $(recovery_fstab)
Tao Baof4866c72018-08-22 14:35:09 -07002180 $(call pretty,"Target boot image from recovery: $@")
2181 $(call build-recoveryimage-target, $@)
Daniel Mentz4d6017d2019-12-19 20:48:43 -08002182$(INSTALLED_BOOTIMAGE_TARGET): .KATI_IMPLICIT_OUTPUTS += $(recovery_ramdisk)
Tao Baof4866c72018-08-22 14:35:09 -07002183endif # BOARD_USES_RECOVERY_AS_BOOT
2184
2185ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002186ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2187$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2188else
Tao Baof4866c72018-08-22 14:35:09 -07002189$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002190endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002191endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002192ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2193$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_RECOVERY_ACPIO)
2194endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002195ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2196$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
2197endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002198
Jiyong Parkce3e34f2018-05-24 14:24:50 +09002199$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Anton Hansson6d814982018-11-26 18:12:05 +00002200 $(INTERNAL_ROOT_FILES) \
2201 $(INSTALLED_RAMDISK_TARGET) \
2202 $(INSTALLED_BOOTIMAGE_TARGET) \
2203 $(INTERNAL_RECOVERYIMAGE_FILES) \
Tom Cherry89eea962019-11-04 10:41:51 -08002204 $(recovery_sepolicy) $(recovery_kernel) \
Anton Hansson6d814982018-11-26 18:12:05 +00002205 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2206 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
2207 $(recovery_resource_deps) \
Colin Cross4f60e362019-06-05 11:53:43 -07002208 $(recovery_fstab)
Tao Baof4866c72018-08-22 14:35:09 -07002209 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07002210
Tao Bao4594d0e2015-12-22 09:47:46 -08002211ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002212$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002213 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002214 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2215 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002216endif
Doug Zongker56588872012-08-20 15:38:58 -07002217
Ying Wang747b9f12015-01-30 14:05:22 -08002218.PHONY: recoveryimage-nodeps
2219recoveryimage-nodeps:
2220 @echo "make $@: ignoring dependencies"
2221 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
2222
Chris Grossa784ef12019-04-22 11:09:57 -07002223else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002224RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002225endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002226
2227.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002228recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002229
Jiyong Park03eb0612017-10-04 21:22:41 +09002230ifneq ($(BOARD_NAND_PAGE_SIZE),)
2231$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002232endif
2233
Jiyong Park03eb0612017-10-04 21:22:41 +09002234ifneq ($(BOARD_NAND_SPARE_SIZE),)
2235$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002236endif
2237
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002238ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002239# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002240# the debug ramdisk, which is the original ramdisk plus additional
2241# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2242# When /force_debuggable is present, /init will load userdebug sepolicy
2243# and property files to allow adb root, if the device is unlocked.
2244
2245ifdef BUILDING_RAMDISK_IMAGE
2246BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2247INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2248
2249INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2250 $(ALL_GENERATED_SOURCES) \
2251 $(ALL_DEFAULT_INSTALLED_MODULES))
2252
2253# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2254# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2255# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2256my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2257
2258INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2259INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2260$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2261$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2262
2263# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2264# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2265# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2266$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002267$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002268 echo Installed file list: $@
2269 mkdir -p $(dir $@)
2270 rm -f $@
2271 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002272 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002273
2274# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2275# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2276ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2277my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2278else
2279my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2280endif # BOARD_USES_RECOVERY_AS_BOOT
2281
2282$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2283$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002284
2285ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2286# 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 +08002287$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002288else
2289# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2290$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2291endif # BOARD_USES_RECOVERY_AS_BOOT
Bowgo Tsai0013f552019-03-20 17:59:52 +08002292$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(MINIGZIP)
2293 $(call pretty,"Target debug ram disk: $@")
2294 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2295 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002296 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002297 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2298
2299.PHONY: ramdisk_debug-nodeps
2300ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2301ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2302ramdisk_debug-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2303 echo "make $@: ignoring dependencies"
2304 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2305 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002306 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002307 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
2308
2309my_debug_ramdisk_sync_dir :=
2310my_debug_ramdisk_root_dir :=
2311
2312endif # BUILDING_RAMDISK_IMAGE
2313
2314# -----------------------------------------------------------------
2315# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2316#
2317# Note: it's intentional to skip signing for boot-debug.img, because it
2318# can only be used if the device is unlocked with verification error.
2319ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2320
2321INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2322
2323# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2324ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2325INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2326else
2327INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2328endif
2329
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002330# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2331# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2332# Using a test key to sign boot-debug.img to continue booting with the mismatched
2333# public key, if the device is unlocked.
2334ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002335$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002336endif
2337
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002338BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2339INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2340# $(1): the bootimage to sign
2341define test-key-sign-bootimage
2342$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
2343$(AVBTOOL) add_hash_footer \
2344 --image $(1) \
2345 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
2346 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2347 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
2348$(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
2349endef
2350
Bowgo Tsai0013f552019-03-20 17:59:52 +08002351# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2352$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2353 $(call pretty,"Target boot debug image: $@")
2354 $(MKBOOTIMG) $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002355 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002356
2357.PHONY: bootimage_debug-nodeps
2358bootimage_debug-nodeps: $(MKBOOTIMG)
2359 echo "make $@: ignoring dependencies"
2360 $(MKBOOTIMG) $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002361 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET)))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002362
2363endif # TARGET_NO_KERNEL
2364
Bowgo Tsai6a683672020-02-14 19:00:15 +08002365ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2366ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2367# -----------------------------------------------------------------
2368# vendor debug ramdisk
2369# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
2370INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio.gz
2371$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2372$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2373
2374INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2375 $(ALL_GENERATED_SOURCES) \
2376 $(ALL_DEFAULT_INSTALLED_MODULES))
2377
2378# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2379# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2380# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2381# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2382$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2383$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2384$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(MINIGZIP)
2385 $(call pretty,"Target vendor debug ram disk: $@")
2386 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2387 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2388 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2389 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2390 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
2391 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(MINIGZIP) > $@
2392
2393INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2394INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2395$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2396$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2397
2398# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2399# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2400$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2401$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2402 echo Installed file list: $@
2403 mkdir -p $(dir $@)
2404 rm -f $@
2405 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2406 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2407
2408# -----------------------------------------------------------------
2409# vendor_boot-debug.img.
2410INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2411
2412# The util to sign vendor_boot-debug.img with a test key.
2413BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2414INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2415# $(1): the vendor bootimage to sign
2416define test-key-sign-vendor-bootimage
2417$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2418$(AVBTOOL) add_hash_footer \
2419 --image $(1) \
2420 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2421 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2422 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2423$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2424endef
2425
2426ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2427$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2428endif
2429
2430# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2431$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2432 $(call pretty,"Target vendor_boot debug image: $@")
2433 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
2434 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2435 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2436
2437endif # BUILDING_RAMDISK_IMAGE
2438endif # BUILDING_VENDOR_BOOT_IMAGE
2439
Bowgo Tsai0013f552019-03-20 17:59:52 +08002440# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002441# The test harness ramdisk, which is based off debug_ramdisk, plus a
2442# few additional test-harness-specific properties in adb_debug.prop.
2443
2444ifdef BUILDING_RAMDISK_IMAGE
2445BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2446INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2447
2448# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2449# appends a few test harness specific properties into the adb_debug.prop.
2450TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2451TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2452
2453# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2454# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2455TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2456ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2457ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2458
2459# $(1): a list of key=value pairs for additional property assignments
2460# $(2): the target .prop file to append the properties from $(1)
2461define append-test-harness-props
2462 echo "#" >> $(2); \
2463 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2464 echo "#" >> $(2);
2465 $(foreach line,$(1), echo "$(line)" >> $(2);)
2466endef
2467
2468$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
2469$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(MINIGZIP)
2470 $(call pretty,"Target test harness ram disk: $@")
2471 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2472 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2473 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $@
2474
2475.PHONY: ramdisk_test_harness-nodeps
2476ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(MINIGZIP)
2477 echo "make $@: ignoring dependencies"
2478 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2479 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
2480 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(MINIGZIP) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2481
2482endif # BUILDING_RAMDISK_IMAGE
2483
2484# -----------------------------------------------------------------
2485# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2486#
2487# Note: it's intentional to skip signing for boot-test-harness.img, because it
2488# can only be used if the device is unlocked with verification error.
2489ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2490
2491INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2492
2493# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2494INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2495
2496# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2497# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2498# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2499# public key, if the device is unlocked.
2500ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2501$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2502endif
2503
2504# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2505$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2506 $(call pretty,"Target boot test harness image: $@")
2507 $(MKBOOTIMG) $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2508 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2509
2510.PHONY: bootimage_test_harness-nodeps
2511bootimage_test_harness-nodeps: $(MKBOOTIMG)
2512 echo "make $@: ignoring dependencies"
2513 $(MKBOOTIMG) $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
2514 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)))
2515
2516endif # TARGET_NO_KERNEL
2517endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2518
2519# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002520# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002521#
Ying Wang9c649a72012-08-08 15:27:00 -07002522# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2523PDK_FUSION_SYSIMG_FILES := \
2524 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2525 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002526
Dan Willemsen37a19862018-10-31 16:31:46 -07002527INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002528 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002529 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002530 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002531 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002532
Ying Wang82cceba2012-08-13 15:03:00 -07002533FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002534
2535# ASAN libraries in the system image - add dependency.
2536ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002537ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002538 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2539 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2540 endif
2541endif
2542
Tom Cherryd14b8952018-08-09 14:26:00 -07002543FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002544
Ying Wange5e8c5f2011-09-09 16:35:53 -07002545# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002546ifdef BUILDING_SYSTEM_IMAGE
2547
Ying Wange5e8c5f2011-09-09 16:35:53 -07002548# installed file list
2549# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2550# We put installed-files.txt ahead of image itself in the dependency graph
2551# so that we can get the size stat even if the build fails due to too large
2552# system image.
2553INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002554INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2555$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002556$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002557 @echo Installed file list: $@
2558 @mkdir -p $(dir $@)
2559 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002560 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002561 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002562
2563.PHONY: installed-file-list
2564installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002565
2566$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002567
2568systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002569 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002570BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2571
Ying Wang23898df2014-06-18 20:26:24 -07002572# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002573ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002574define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002575$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2576 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2577 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2578 exit 1; \
2579fi
Ying Wang23898df2014-06-18 20:26:24 -07002580$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2581endef
2582else
2583define create-system-vendor-symlink
2584endef
2585endif
2586
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002587# Create symlink /system/product to /product if necessary.
2588ifdef BOARD_USES_PRODUCTIMAGE
2589define create-system-product-symlink
2590$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2591 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2592 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2593 exit 1; \
2594fi
2595$(hide) ln -sf /product $(TARGET_OUT)/product
2596endef
2597else
2598define create-system-product-symlink
2599endef
2600endif
2601
Justin Yun6151e3f2019-06-25 15:58:13 +09002602# Create symlink /system/system_ext to /system_ext if necessary.
2603ifdef BOARD_USES_SYSTEM_EXTIMAGE
2604define create-system-system_ext-symlink
2605$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2606 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2607 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 +01002608 exit 1; \
2609fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002610$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002611endef
2612else
Justin Yun6151e3f2019-06-25 15:58:13 +09002613define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002614endef
2615endif
2616
The Android Open Source Project88b60792009-03-03 19:28:42 -08002617# $(1): output file
2618define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002619 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002620 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002621 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002622 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002623 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002624 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002625 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002626 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002627 $(BUILD_IMAGE) \
2628 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2629 || ( mkdir -p $${DIST_DIR}; \
2630 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2631 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002632endef
2633
Dan Willemsen6b72c732019-06-12 21:33:38 +00002634ifeq ($(BOARD_AVB_ENABLE),true)
2635$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2636endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002637$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002638 $(call build-systemimage-target,$@)
2639
Tao Baoe9d61b02018-08-20 21:09:07 -07002640INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002641SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002642
Tao Baoe9d61b02018-08-20 21:09:07 -07002643# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2644# compatibility, in case device-specific Makefiles still refer to the old name.
2645INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2646
Doug Zongker73ef8252009-07-23 15:12:53 -07002647# The system partition needs room for the recovery image as well. We
2648# now store the recovery image as a binary patch using the boot image
2649# as the source (since they are very similar). Generate the patch so
2650# we can see how big it's going to be, and include that in the system
2651# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002652ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002653ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002654ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002655ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002656diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2657else
2658diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2659endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002660intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2661RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002662$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2663$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002664 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2665 $(INSTALLED_BOOTIMAGE_TARGET) \
2666 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002667 @echo "Construct recovery from boot"
2668 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002669 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002670else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2671RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002672endif # BOARD_USES_FULL_RECOVERY_IMAGE
2673endif # INSTALLED_RECOVERYIMAGE_TARGET
2674endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002675
Tao Baoe9d61b02018-08-20 21:09:07 -07002676$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002677 @echo "Install system fs image: $@"
2678 $(copy-file-to-target)
Yifan Hong8c3dce02019-04-09 17:03:57 +00002679 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002680
Tao Baoe9d61b02018-08-20 21:09:07 -07002681systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002682
2683.PHONY: systemimage-nodeps snod
2684systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002685 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002686 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002687 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002688 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002689
Ying Wangacf01ec2012-02-24 11:05:48 -08002690ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
2691ifeq (true,$(WITH_DEXPREOPT))
2692$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
2693endif
2694endif
2695
Dan Willemsen67495202019-01-16 12:42:05 -08002696endif # BUILDING_SYSTEM_IMAGE
2697
Anton Hansson30e061b2018-11-12 13:36:46 +00002698.PHONY: sync syncsys
2699sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002700
Ying Wang3a61eeb2016-03-11 10:32:01 -08002701# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002702## platform.zip: system, plus other files to be used in PDK fusion build,
2703## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002704##
2705## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2706## The variable will be typically set from BoardConfig.mk.
2707## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002708ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002709pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002710 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002711pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002712 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002713pdk_classes_dex := $(strip \
2714 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002715 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002716
2717pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2718$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2719$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2720$(pdk_odex_config_mk) :
2721 @echo "PDK odex config makefile: $@"
2722 $(hide) mkdir -p $(dir $@)
2723 $(hide) echo "# Auto-generated. Do not modify." > $@
2724 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2725 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2726 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2727 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2728 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2729 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2730 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2731 )
2732 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002733 $(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 -08002734 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2735 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2736 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2737 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002738 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002739 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2740 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2741 )
2742
keunyoungc0178062013-07-22 14:54:58 -07002743PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002744INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002745
2746$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2747$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002748$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2749# dependencies for the other partitions are defined below after their file lists
2750# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002751$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002752 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002753 rm -f $@ $@.lst
2754 echo "-C $(PRODUCT_OUT)" >> $@.lst
2755 echo "-D $(TARGET_OUT)" >> $@.lst
2756 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2757 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002758ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002759 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002760endif
Dan Willemsen67495202019-01-16 12:42:05 -08002761ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002762 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002763endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002764ifdef BUILDING_SYSTEM_EXT_IMAGE
2765 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002766endif
Dan Willemsen67495202019-01-16 12:42:05 -08002767ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002768 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002769endif
Colin Crossc451a372013-12-18 19:36:44 -08002770ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002771 echo "-C $(OUT_DIR)" >> $@.lst
2772 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2773 if [ -e $$f ]; then \
2774 echo "-f $$f"; \
2775 fi \
2776 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002777endif
keunyoungc0178062013-07-22 14:54:58 -07002778ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002779 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002780endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002781 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002782 $(if $(PRIVATE_DEX_FILES),\
2783 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002784 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002785 touch $(PRODUCT_OUT)/pdk.mk
2786 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2787 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002788
2789.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002790platform: $(INSTALLED_PLATFORM_ZIP)
2791
2792.PHONY: platform-java
2793platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002794
2795# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002796ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2797$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002798endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002799
Colin Cross53c8f972018-09-28 16:19:42 -07002800endif # BUILD_PLATFORM_ZIP
2801
Ying Wang3a61eeb2016-03-11 10:32:01 -08002802# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002803# data partition image
2804INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002805 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002806
Dan Willemsen67495202019-01-16 12:42:05 -08002807ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002808userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002809 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002810BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2811
Ying Wangbd93d422011-10-28 17:02:30 -07002812define build-userdataimage-target
2813 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2814 @mkdir -p $(TARGET_OUT_DATA)
2815 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002816 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002817 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002818 $(BUILD_IMAGE) \
2819 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2820 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2821 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002822endef
2823
Joe Onorato64d85d02009-04-09 19:31:12 -07002824# We just build this directly to the install location.
2825INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002826INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2827 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002828 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002829$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002830 $(build-userdataimage-target)
2831
2832.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002833userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002834 $(build-userdataimage-target)
2835
Dan Willemsen67495202019-01-16 12:42:05 -08002836endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002837
Andreas Gampe039b5c72017-03-24 16:06:31 -07002838# ASAN libraries in the system image - build rule.
2839ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2840 $(TARGET_OUT_SHARED_LIBRARIES) \
2841 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2842 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2843 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002844# Extra options: Enforce the system user for the files to avoid having to change ownership.
2845ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002846# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2847# enough space.
2848$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002849 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 -07002850
The Android Open Source Project88b60792009-03-03 19:28:42 -08002851# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002852# partition table image
2853ifdef BOARD_BPT_INPUT_FILES
2854
2855BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002856BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002857
2858INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2859 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002860 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002861 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2862
2863ifdef BOARD_BPT_DISK_SIZE
2864INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2865endif
2866
2867define build-bptimage-target
2868 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2869 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2870endef
2871
2872INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002873$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2874 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2875
David Zeuthen25328622016-04-08 15:08:03 -04002876$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2877 $(build-bptimage-target)
2878
2879.PHONY: bptimage-nodeps
2880bptimage-nodeps:
2881 $(build-bptimage-target)
2882
2883endif # BOARD_BPT_INPUT_FILES
2884
2885# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002886# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002887ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002888INTERNAL_CACHEIMAGE_FILES := \
2889 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2890
2891cacheimage_intermediates := \
2892 $(call intermediates-dir-for,PACKAGING,cache)
2893BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2894
2895define build-cacheimage-target
2896 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2897 @mkdir -p $(TARGET_OUT_CACHE)
2898 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002899 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002900 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002901 $(BUILD_IMAGE) \
2902 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2903 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2904 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002905endef
2906
2907# We just build this directly to the install location.
2908INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002909$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002910 $(build-cacheimage-target)
2911
2912.PHONY: cacheimage-nodeps
2913cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2914 $(build-cacheimage-target)
2915
Dan Willemsen67495202019-01-16 12:42:05 -08002916else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002917# we need to ignore the broken cache link when doing the rsync
2918IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002919endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002920
David Zeuthen0eb10972016-09-28 17:55:27 -04002921# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002922# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002923ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002924ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002925# Marker file to identify that odex files are installed
2926INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2927ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2928$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2929 $(hide) touch $@
2930endif
2931
Alex Light4e358ab2016-06-16 14:47:10 -07002932INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2933 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2934 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002935 $(ALL_PDK_FUSION_FILES)) \
2936 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002937
Colin Cross6db5b0e2018-11-16 21:26:33 -08002938# system_other dex files are installed as a side-effect of installing system image files
2939INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2940
Alex Light4e358ab2016-06-16 14:47:10 -07002941INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002942INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2943$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002944$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002945 @echo Installed file list: $@
2946 @mkdir -p $(dir $@)
2947 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002948 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002949 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002950
Bowgo Tsai867ab662019-01-29 13:30:18 +08002951# Determines partition size for system_other.img.
2952ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2953ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2954INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2955endif
2956endif
2957
2958ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2959INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2960endif
2961
Alex Light4e358ab2016-06-16 14:47:10 -07002962systemotherimage_intermediates := \
2963 $(call intermediates-dir-for,PACKAGING,system_other)
2964BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2965
2966# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2967define build-systemotherimage-target
2968 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2969 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2970 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002971 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002972 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002973 $(BUILD_IMAGE) \
2974 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2975 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2976 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002977endef
2978
2979# We just build this directly to the install location.
2980INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002981ifneq (true,$(SANITIZE_LITE))
2982# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002983$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2984 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002985endif
Alex Light4e358ab2016-06-16 14:47:10 -07002986
2987.PHONY: systemotherimage-nodeps
2988systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2989 $(build-systemotherimage-target)
2990
Dan Willemsen67495202019-01-16 12:42:05 -08002991endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002992
2993
2994# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002995# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002996ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002997INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002998 $(filter $(TARGET_OUT_VENDOR)/%,\
2999 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08003000 $(ALL_PDK_FUSION_FILES)) \
3001 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07003002
3003# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
3004$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07003005
Ying Wang8da19e32015-09-15 14:22:12 -07003006INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07003007INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3008$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003009$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07003010 @echo Installed file list: $@
3011 @mkdir -p $(dir $@)
3012 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07003013 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003014 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07003015
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003016# Create symlink /vendor/odm to /odm if necessary.
3017ifdef BOARD_USES_ODMIMAGE
3018define create-vendor-odm-symlink
3019$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
3020 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
3021 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
3022 exit 1; \
3023fi
3024$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
3025endef
3026else
3027define create-vendor-odm-symlink
3028endef
3029endif
3030
Ying Wanga0febe52013-03-20 11:02:05 -07003031vendorimage_intermediates := \
3032 $(call intermediates-dir-for,PACKAGING,vendor)
3033BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003034define build-vendorimage-target
3035 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3036 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003037 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07003038 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003039 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003040 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003041 $(BUILD_IMAGE) \
3042 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3043 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
3044 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003045endef
3046
3047# We just build this directly to the install location.
3048INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003049$(INSTALLED_VENDORIMAGE_TARGET): \
3050 $(INTERNAL_USERIMAGES_DEPS) \
3051 $(INTERNAL_VENDORIMAGE_FILES) \
3052 $(INSTALLED_FILES_FILE_VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07003053 $(build-vendorimage-target)
3054
Steven Morelanda2e734d2017-03-07 12:10:09 -08003055.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003056vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003057 $(build-vendorimage-target)
3058
Colin Cross91a52272017-06-20 16:57:52 -07003059sync: $(INTERNAL_VENDORIMAGE_FILES)
3060
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003061else ifdef BOARD_PREBUILT_VENDORIMAGE
3062INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3063$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
3064endif
Ying Wanga0febe52013-03-20 11:02:05 -07003065
Ying Wang9f8e8db2011-11-04 11:37:01 -07003066# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003067# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003068ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003069INTERNAL_PRODUCTIMAGE_FILES := \
3070 $(filter $(TARGET_OUT_PRODUCT)/%,\
3071 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08003072 $(ALL_PDK_FUSION_FILES)) \
3073 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003074
3075# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
3076$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
3077
3078INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003079INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3080$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003081$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003082 @echo Installed file list: $@
3083 @mkdir -p $(dir $@)
3084 @rm -f $@
3085 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003086 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003087
3088productimage_intermediates := \
3089 $(call intermediates-dir-for,PACKAGING,product)
3090BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3091define build-productimage-target
3092 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3093 @mkdir -p $(TARGET_OUT_PRODUCT)
3094 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003095 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003096 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003097 $(BUILD_IMAGE) \
3098 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3099 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3100 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003101endef
3102
3103# We just build this directly to the install location.
3104INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003105$(INSTALLED_PRODUCTIMAGE_TARGET): \
3106 $(INTERNAL_USERIMAGES_DEPS) \
3107 $(INTERNAL_PRODUCTIMAGE_FILES) \
3108 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003109 $(build-productimage-target)
3110
3111.PHONY: productimage-nodeps pnod
3112productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3113 $(build-productimage-target)
3114
3115sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3116
3117else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3118INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3119$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3120endif
3121
3122# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003123# system_ext partition image
3124ifdef BUILDING_SYSTEM_EXT_IMAGE
3125INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3126 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01003127 $(ALL_DEFAULT_INSTALLED_MODULES)\
3128 $(ALL_PDK_FUSION_FILES)) \
3129 $(PDK_FUSION_SYMLINK_STAMP)
3130
Justin Yun6151e3f2019-06-25 15:58:13 +09003131# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
3132$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003133
Justin Yun6151e3f2019-06-25 15:58:13 +09003134INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3135INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3136$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3137$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003138 @echo Installed file list: $@
3139 @mkdir -p $(dir $@)
3140 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09003141 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003142 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003143
Justin Yun6151e3f2019-06-25 15:58:13 +09003144system_extimage_intermediates := \
3145 $(call intermediates-dir-for,PACKAGING,system_ext)
3146BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3147define build-system_extimage-target
3148 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3149 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3150 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3151 $(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 -07003152 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003153 $(BUILD_IMAGE) \
3154 $(TARGET_OUT_SYSTEM_EXT) \
3155 $(system_extimage_intermediates)/system_ext_image_info.txt \
3156 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3157 $(TARGET_OUT)
3158 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003159endef
3160
3161# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003162INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003163$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3164 $(INTERNAL_USERIMAGES_DEPS) \
3165 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3166 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003167 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003168
Justin Yun6151e3f2019-06-25 15:58:13 +09003169.PHONY: systemextimage-nodeps senod
3170systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3171 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003172
Justin Yun6151e3f2019-06-25 15:58:13 +09003173sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003174
Justin Yun6151e3f2019-06-25 15:58:13 +09003175else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3176INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3177$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003178endif
3179
3180# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003181# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003182ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003183INTERNAL_ODMIMAGE_FILES := \
3184 $(filter $(TARGET_OUT_ODM)/%,\
3185 $(ALL_DEFAULT_INSTALLED_MODULES)\
3186 $(ALL_PDK_FUSION_FILES)) \
3187 $(PDK_FUSION_SYMLINK_STAMP)
3188# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
3189$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
3190
3191INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3192INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3193$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003194$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003195 @echo Installed file list: $@
3196 @mkdir -p $(dir $@)
3197 @rm -f $@
3198 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003199 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003200
3201odmimage_intermediates := \
3202 $(call intermediates-dir-for,PACKAGING,odm)
3203BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3204define build-odmimage-target
3205 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3206 @mkdir -p $(TARGET_OUT_ODM)
3207 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3208 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003209 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003210 $(BUILD_IMAGE) \
3211 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3212 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3213 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003214endef
3215
3216# We just build this directly to the install location.
3217INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003218$(INSTALLED_ODMIMAGE_TARGET): \
3219 $(INTERNAL_USERIMAGES_DEPS) \
3220 $(INTERNAL_ODMIMAGE_FILES) \
3221 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003222 $(build-odmimage-target)
3223
3224.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003225odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003226 $(build-odmimage-target)
3227
3228sync: $(INTERNAL_ODMIMAGE_FILES)
3229
3230else ifdef BOARD_PREBUILT_ODMIMAGE
3231INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3232$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3233endif
3234
3235# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003236# dtbo image
3237ifdef BOARD_PREBUILT_DTBOIMAGE
3238INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3239
3240ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003241$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003242 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3243 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003244 --image $@ \
3245 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3246 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3247 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003248else
3249$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3250 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3251endif
3252
Tao Bao0da43472018-08-22 22:53:41 -07003253endif # BOARD_PREBUILT_DTBOIMAGE
3254
3255# Returns a list of image targets corresponding to the given list of partitions. For example, it
3256# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3257# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003258# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003259define images-for-partitions
3260$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3261endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003262
3263# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003264# vbmeta image
3265ifeq ($(BOARD_AVB_ENABLE),true)
3266
3267BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003268AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003269
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003270ifdef BOARD_AVB_KEY_PATH
3271$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3272else
3273# If key path isn't specified, use the 4096-bit test key.
3274BOARD_AVB_ALGORITHM := SHA256_RSA4096
3275BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3276endif
3277
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003278# AVB signing for system_other.img.
3279ifdef BUILDING_SYSTEM_OTHER_IMAGE
3280ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3281$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3282else
3283# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3284BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3285BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3286endif
3287
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003288$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3289 @echo Extracting system_other avb key: $@
3290 @rm -f $@
3291 @mkdir -p $(dir $@)
3292 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003293
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003294ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3295BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3296endif
3297
3298BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3299endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3300
Tao Bao744c4c72018-08-20 21:09:07 -07003301INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003302 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003303 $(BOARD_AVB_VBMETA_VENDOR)
3304
3305# Not allowing the same partition to appear in multiple groups.
3306ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003307 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003308endif
3309
cfig1aeef722019-09-20 22:45:06 +08003310# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3311# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3312# details.
3313ifneq ($(AB_OTA_UPDATER),true)
3314ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3315$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
3316 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for non-A/B devices. \
3317 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3318endif
3319endif
3320
Bowgo Tsai9b548012019-05-14 16:57:03 +08003321# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003322
3323BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003324 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003325 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003326 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3327
3328BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003329 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003330 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003331 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3332
Justin Yun6151e3f2019-06-25 15:58:13 +09003333BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003334 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003335 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3336 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003337
Bowgo Tsai9b548012019-05-14 16:57:03 +08003338BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003339 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003340 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3341
Tao Bao19b02fe2019-10-09 00:04:28 -07003342BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3343 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3344
3345BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3346 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3347
Bowgo Tsai9b548012019-05-14 16:57:03 +08003348BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003349 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003350 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3351
3352BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003353 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003354 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3355
Tao Bao19b02fe2019-10-09 00:04:28 -07003356BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3357 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3358
Bowgo Tsai9b548012019-05-14 16:57:03 +08003359# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003360ifdef BOOT_SECURITY_PATCH
3361BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3362 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3363endif
3364
3365ifdef VENDOR_SECURITY_PATCH
3366BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3367 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3368endif
3369
3370ifdef ODM_SECURITY_PATCH
3371BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3372 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3373endif
3374
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003375BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003376VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003377DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3378SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3379VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003380RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003381PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003382SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003383ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003384
Tao Bao0da43472018-08-22 22:53:41 -07003385# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003386# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003387define _check-and-set-avb-chain-args
3388$(eval part := $(1))
3389$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003390
3391$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3392$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3393$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3394$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3395$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3396$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3397$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3398$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3399
3400# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3401$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3402$(eval $(_signing_args) := \
3403 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3404
cfig1aeef722019-09-20 22:45:06 +08003405# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3406# partition descriptor for recovery partition into vbmeta.img.
3407$(if $(or $(filter true,$(AB_OTA_UPDATER)),$(filter-out recovery,$(part))),\
3408 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3409 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003410
Tao Bao744c4c72018-08-20 21:09:07 -07003411# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003412# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003413$(if $(filter $(part),$(part:vbmeta_%=%)),\
3414 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3415 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003416endef
3417
Tao Bao0da43472018-08-22 22:53:41 -07003418# Checks and sets the required build variables for an AVB partition. The partition will be
3419# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003420# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3421# VBMeta image.
Tao Bao0da43472018-08-22 22:53:41 -07003422# $(1): Partition name, e.g. boot or system.
3423define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003424$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003425$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003426 $(if $(_in_chained_vbmeta),\
3427 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003428 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003429 $(if $(_in_chained_vbmeta),,\
3430 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3431 --include_descriptors_from_image $(call images-for-partitions,$(1)))))
Tao Bao0da43472018-08-22 22:53:41 -07003432endef
3433
Tao Baob1a2e352018-08-14 16:17:12 -07003434ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003435$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003436endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003437
Steve Mucklee1b10862019-07-10 10:49:37 -07003438ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3439$(eval $(call check-and-set-avb-args,vendor_boot))
3440endif
3441
Tao Bao0da43472018-08-22 22:53:41 -07003442$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003443
3444ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003445$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003446endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003447
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003448ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003449$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003450endif
3451
Justin Yun6151e3f2019-06-25 15:58:13 +09003452ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3453$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003454endif
3455
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003456ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003457$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003458endif
3459
Yueyao Zhu211c9012017-04-27 00:34:50 -07003460ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003461$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003462endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003463
David Zeuthen8fecb282017-12-01 16:24:01 -05003464ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003465$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003466endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003467
David Anderson7709ab22018-10-15 14:41:34 -07003468# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3469ifdef BOARD_AVB_VBMETA_SYSTEM
3470$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003471endif
3472
3473ifdef BOARD_AVB_VBMETA_VENDOR
3474$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3475endif
3476
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003477# Add kernel cmdline descriptor for kernel to mount system.img as root with
3478# dm-verity. This works when system.img is either chained or not-chained:
3479# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3480# cmdline descriptor to system.img
3481# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3482# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003483ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003484ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003485BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003486endif
David Anderson8916a2a2018-09-18 15:46:59 -07003487endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003488
Tao Bao0da43472018-08-22 22:53:41 -07003489BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003490BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003491BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3492
3493ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003494# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003495BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003496endif
Tao Bao0da43472018-08-22 22:53:41 -07003497
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003498ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003499BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003500endif
3501
David Anderson7709ab22018-10-15 14:41:34 -07003502ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3503BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3504 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003505endif
3506
3507ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3508BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3509 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003510endif
3511
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003512# $(1): the directory to extract public keys to
3513define extract-avb-chain-public-keys
3514 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3515 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3516 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003517 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3518 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3519 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003520 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3521 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3522 --output $(1)/system.avbpubkey)
3523 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3524 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3525 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003526 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3527 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3528 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003529 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3530 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3531 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003532 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3533 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3534 --output $(1)/odm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003535 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3536 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3537 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003538 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3539 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3540 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003541 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3542 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3543 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003544 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3545 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3546 --output $(1)/vbmeta_vendor.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003547endef
3548
Tao Bao744c4c72018-08-20 21:09:07 -07003549# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3550# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003551# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003552# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3553# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003554# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003555# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003556# $(2): Output filename.
3557define build-chained-vbmeta-image
3558 $(call pretty,"Target chained vbmeta image: $@")
3559 $(hide) $(AVBTOOL) make_vbmeta_image \
3560 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3561 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3562 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3563 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3564 --output $@
3565endef
3566
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003567ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003568ifdef BOARD_AVB_VBMETA_SYSTEM
3569INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3570$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003571 $(AVBTOOL) \
3572 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3573 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003574 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003575endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003576endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003577
3578ifdef BOARD_AVB_VBMETA_VENDOR
3579INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3580$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003581 $(AVBTOOL) \
3582 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3583 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003584 $(call build-chained-vbmeta-image,vbmeta_vendor)
3585endif
3586
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003587define build-vbmetaimage-target
3588 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003589 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3590 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003591 $(hide) $(AVBTOOL) make_vbmeta_image \
3592 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003593 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003594 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3595 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003596 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003597endef
3598
Paul Trautrim4e143232019-08-13 16:30:57 +09003599ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003600INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003601$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3602 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3603
David Zeuthen8fecb282017-12-01 16:24:01 -05003604$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003605 $(AVBTOOL) \
3606 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003607 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003608 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3609 $(INSTALLED_VENDORIMAGE_TARGET) \
3610 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003611 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003612 $(INSTALLED_ODMIMAGE_TARGET) \
3613 $(INSTALLED_DTBOIMAGE_TARGET) \
3614 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3615 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3616 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3617 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3618 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3619 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003620 $(build-vbmetaimage-target)
3621
3622.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003623vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3624 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003625vbmetaimage-nodeps:
3626 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003627endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003628
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003629endif # BOARD_AVB_ENABLE
3630
3631# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003632# Check VINTF of build
3633
3634ifndef TARGET_BUILD_APPS
3635intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3636check_vintf_all_deps :=
3637
Yifan Hongaf9b0702020-01-21 12:46:57 -08003638# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3639# because they are only used for prebuilt images.
3640check_vintf_common_srcs_patterns := \
3641 $(TARGET_OUT)/etc/vintf/% \
3642 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3643 $(TARGET_OUT_ODM)/etc/vintf/% \
3644 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3645 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3646
3647check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3648 $(INTERNAL_SYSTEMIMAGE_FILES) \
3649 $(INTERNAL_VENDORIMAGE_FILES) \
3650 $(INTERNAL_ODMIMAGE_FILES) \
3651 $(INTERNAL_PRODUCTIMAGE_FILES) \
3652 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3653))
3654check_vintf_common_srcs_patterns :=
3655
3656check_vintf_has_system :=
3657check_vintf_has_vendor :=
3658
Yifan Hong605ea042020-01-14 21:36:00 +00003659# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003660check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3661ifneq ($(check_vintf_system_deps),)
3662check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003663check_vintf_system_log := $(intermediates)/check_vintf_system_log
3664check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003665$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003666 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3667check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003668endif # check_vintf_system_deps
3669check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003670
3671# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003672check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3673ifneq ($(check_vintf_vendor_deps),)
3674check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003675check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3676check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003677$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003678 @( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3679check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003680endif # check_vintf_vendor_deps
3681check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003682
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003683# -- Check VINTF compatibility of build.
3684# Skip partial builds; only check full builds. Only check if:
3685# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003686# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003687# - Building product / system_ext / odm images if board has product / system_ext / odm images
3688ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003689ifeq ($(check_vintf_has_system),true)
3690ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003691ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3692ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3693ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3694
3695check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3696check_vintf_all_deps += $(check_vintf_compatible_log)
3697
3698check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003699check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003700
3701# -- Kernel version and configurations.
3702ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3703
Yifan Hong605ea042020-01-14 21:36:00 +00003704BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3705BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3706
3707my_board_extracted_kernel :=
3708
3709# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3710# from INSTALLED_KERNEL_TARGET.
3711ifdef BOARD_KERNEL_CONFIG_FILE
3712ifdef BOARD_KERNEL_VERSION
3713$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3714 cp $< $@
3715$(BUILT_KERNEL_VERSION_FILE):
3716 echo $(BOARD_KERNEL_VERSION) > $@
3717
3718my_board_extracted_kernel := true
3719endif # BOARD_KERNEL_VERSION
3720endif # BOARD_KERNEL_CONFIG_FILE
3721
3722ifneq ($(my_board_extracted_kernel),true)
3723ifndef INSTALLED_KERNEL_TARGET
3724$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3725 is true. Information about the updated kernel cannot be built into OTA update package. \
3726 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3727 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3728 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3729 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3730 manually.)
3731else
3732
3733# Tools for decompression that is not in PATH.
3734# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3735# Algorithms that are in the script but not in this list will be found in PATH.
3736my_decompress_tools := \
3737 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3738
3739$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3740$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3741$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
3742$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(INSTALLED_KERNEL_TARGET)
3743 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(INSTALLED_KERNEL_TARGET) \
3744 --output-configs $@ \
3745 --output-version $(BUILT_KERNEL_VERSION_FILE)
3746
3747my_decompress_tools :=
3748
3749endif # my_board_extracted_kernel
3750my_board_extracted_kernel :=
3751
3752endif # INSTALLED_KERNEL_TARGET
3753
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003754check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3755check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3756
3757endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3758
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003759check_vintf_compatible_args += \
3760 --dirmap /system:$(TARGET_OUT) \
3761 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3762 --dirmap /odm:$(TARGET_OUT_ODM) \
3763 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3764 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3765
3766ifdef PRODUCT_SHIPPING_API_LEVEL
3767check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3768endif # PRODUCT_SHIPPING_API_LEVEL
3769
3770$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3771$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
3772$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3773 @echo -n -e 'Deps: \n ' > $@
3774 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3775 @echo -n -e 'Args: \n ' >> $@
3776 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
3777 @echo -n -e 'For empty SKU:' >> $@
3778 @( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) >> $@ 2>&1 ) || ( cat $@ && exit 1 )
3779 $(foreach sku,$(ODM_MANIFEST_SKUS), \
3780 echo "For SKU = $(sku):" >> $@; \
3781 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
3782 --property ro.boot.product.hardware.sku=$(sku) >> $@ 2>&1 ) || ( cat $@ && exit 1 ); )
3783
3784check_vintf_compatible_log :=
3785check_vintf_compatible_args :=
3786check_vintf_compatible_deps :=
3787
3788endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3789endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3790endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003791endif # check_vintf_has_vendor
3792endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003793endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3794
3795# Add all logs of VINTF checks to dist builds
3796droid_targets: $(check_vintf_all_deps)
3797$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3798
3799# Helper alias to check all VINTF of current build.
3800.PHONY: check-vintf-all
3801check-vintf-all: $(check_vintf_all_deps)
3802 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3803
Yifan Hongaf9b0702020-01-21 12:46:57 -08003804check_vintf_has_vendor :=
3805check_vintf_has_system :=
3806check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003807check_vintf_all_deps :=
3808intermediates :=
3809endif # !TARGET_BUILD_APPS
3810
3811# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003812# Check image sizes <= size of super partition
3813
3814ifeq (,$(TARGET_BUILD_APPS))
3815# Do not check for apps-only build
3816
3817ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003818
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003819# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003820# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003821define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003822 mkdir -p $(dir $(1))
3823 rm -f $(1)
3824 $(call dump-super-image-info, $(1))
3825 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3826 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003827 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003828endef
3829
Yifan Hong30910932019-10-25 20:36:55 -07003830check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3831droid_targets: $(check_all_partition_sizes_log)
3832$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003833
Yifan Hong30910932019-10-25 20:36:55 -07003834$(check_all_partition_sizes_log): \
3835 $(CHECK_PARTITION_SIZES) \
3836 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3837 $(call check-all-partition-sizes-target, \
3838 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3839 $@)
3840
3841.PHONY: check-all-partition-sizes
3842check-all-partition-sizes: $(check_all_partition_sizes_log)
3843
3844.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003845check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003846 $(call check-all-partition-sizes-target, \
3847 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003848
Yifan Hong2dae5722018-07-31 12:47:27 -07003849endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003850
3851endif # TARGET_BUILD_APPS
3852
3853# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003854# bring in the installer image generation defines if necessary
3855ifeq ($(TARGET_USE_DISKINSTALLER),true)
3856include bootable/diskinstaller/config.mk
3857endif
3858
3859# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003860# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003861
Ying Wangbd2d0242015-09-22 11:17:52 -07003862ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003863 build_ota_package := false
3864 build_otatools_package := false
3865else
Tao Bao9be20c72019-04-08 21:11:59 -07003866 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003867 build_ota_package := true
3868 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3869 build_ota_package := false
3870 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003871 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003872 build_ota_package := false
3873 endif
3874 ifeq ($(TARGET_PRODUCT),sdk)
3875 build_ota_package := false
3876 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003877 ifeq ($(TARGET_BUILD_PDK),true)
3878 build_ota_package := false
3879 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003880 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3881 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3882 build_ota_package := false
3883 endif
3884 ifeq ($(TARGET_NO_KERNEL),true)
3885 build_ota_package := false
3886 endif
3887 ifeq ($(recovery_fstab),)
3888 build_ota_package := false
3889 endif
3890 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003891
Tao Bao9be20c72019-04-08 21:11:59 -07003892 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003893 build_otatools_package := true
3894 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3895 build_otatools_package := false
3896 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003897endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003898
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003899ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003900
3901INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003902 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003903 add_img_to_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003904 append2simg \
3905 avbtool \
3906 blk_alloc_to_base_fs \
3907 boot_signer \
3908 brillo_update_payload \
3909 brotli \
3910 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003911 build_image \
3912 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003913 build_verity_metadata \
3914 build_verity_tree \
3915 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003916 check_ota_package_signature \
3917 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003918 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003919 checkvintf \
3920 delta_generator \
3921 e2fsck \
3922 e2fsdroid \
3923 fc_sort \
3924 fec \
3925 fs_config \
3926 generate_verity_key \
3927 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003928 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003929 imgdiff \
3930 libconscrypt_openjdk_jni \
3931 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003932 lpunpack \
Tao Bao96daeeb2019-05-01 21:17:13 -07003933 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07003934 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003935 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003936 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003937 mkbootfs \
3938 mkbootimg \
3939 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003940 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003941 mkf2fsuserimg.sh \
3942 mksquashfs \
3943 mksquashfsimage.sh \
3944 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003945 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003946 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003947 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003948 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003949 sign_apex \
3950 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003951 signapk \
3952 simg2img \
3953 sload_f2fs \
3954 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003955 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003956 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003957 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003958 verity_signer \
3959 verity_verifier \
3960 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003961
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003962# Additional tools to unpack and repack the apex file.
3963INTERNAL_OTATOOLS_MODULES += \
3964 apexer \
3965 deapexer \
3966 debugfs_static \
3967 merge_zips \
3968 resize2fs \
3969 soong_zip \
3970
Anton Hansson8dab0a62019-03-28 15:45:40 +00003971ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003972INTERNAL_OTATOOLS_MODULES += \
3973 futility \
3974 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003975endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003976
Tao Bao96daeeb2019-05-01 21:17:13 -07003977INTERNAL_OTATOOLS_FILES := \
3978 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003979
Ying Wang06898662010-06-17 17:52:18 -07003980.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003981otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003982
Tao Bao96daeeb2019-05-01 21:17:13 -07003983# For each module, recursively resolve its host shared library dependencies. Then we have a full
3984# list of modules whose installed files need to be packed.
3985INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3986 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3987 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003988
Tao Bao96daeeb2019-05-01 21:17:13 -07003989INTERNAL_OTATOOLS_PACKAGE_FILES := \
3990 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3991
3992INTERNAL_OTATOOLS_PACKAGE_FILES += \
3993 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3994 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003995
3996ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003997INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003998 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003999 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004000endif
4001ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004002INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004003 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4004 -name "atx_metadata.bin"))
4005endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004006ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004007INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004008 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004009endif
4010
Tao Bao96daeeb2019-05-01 21:17:13 -07004011INTERNAL_OTATOOLS_RELEASETOOLS := \
4012 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4013 \( -type f -o -type l \) -print))
4014
4015BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4016$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4017$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4018$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4019$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004020$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004021 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004022 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4023 mkdir -p $(dir $@)
4024 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4025 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004026 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004027 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004028
4029.PHONY: otatools-package
4030otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4031
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004032endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004033
The Android Open Source Project88b60792009-03-03 19:28:42 -08004034# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004035# misc_info.txt
4036
4037INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4038
4039ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4040# default to common dir for device vendor
4041tool_extensions := $(TARGET_DEVICE_DIR)/../common
4042else
4043tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4044endif
4045.KATI_READONLY := tool_extensions
4046
4047$(INSTALLED_MISC_INFO_TARGET):
4048 rm -f $@
4049 $(call pretty,"Target misc_info.txt: $@")
4050 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4051 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4052ifdef BOARD_FLASH_BLOCK_SIZE
4053 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4054endif
4055ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
4056 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $@
4057endif
4058ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4059 $(hide) echo "no_boot=true" >> $@
4060endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004061ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4062 echo "vendor_boot=true" >> $@
4063 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4064endif
Daniel Normane1e48082019-06-27 13:55:23 -07004065ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4066 $(hide) echo "no_recovery=true" >> $@
4067endif
4068ifdef BOARD_INCLUDE_RECOVERY_DTBO
4069 $(hide) echo "include_recovery_dtbo=true" >> $@
4070endif
4071ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4072 $(hide) echo "include_recovery_acpio=true" >> $@
4073endif
4074ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4075 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4076endif
4077ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4078 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4079 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4080else
4081 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4082endif
4083 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4084 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4085ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4086 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4087endif
4088 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
4089 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4090 $(hide) echo "multistage_support=1" >> $@
4091 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4092ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4093 $(hide) echo "build_generic_ota_package=true" >> $@
4094endif
4095ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4096 # OTA scripts are only interested in fingerprint related properties
4097 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4098endif
4099ifneq (,$(filter address, $(SANITIZE_TARGET)))
4100 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4101 $(hide) echo "userdata_img_with_data=true" >> $@
4102endif
4103ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4104 $(hide) echo "full_recovery_image=true" >> $@
4105endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004106ifdef BOARD_USES_VENDORIMAGE
4107 $(hide) echo "board_uses_vendorimage=true" >> $@
4108endif
Daniel Normane1e48082019-06-27 13:55:23 -07004109ifeq ($(BOARD_AVB_ENABLE),true)
4110 $(hide) echo "avb_enable=true" >> $@
4111 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4112 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4113 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4114 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4115ifdef BOARD_AVB_BOOT_KEY_PATH
4116 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4117 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4118 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4119endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004120 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4121ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4122 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4123 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4124 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4125endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004126 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4127ifdef BOARD_AVB_RECOVERY_KEY_PATH
4128 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4129 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4130 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4131endif # BOARD_AVB_RECOVERY_KEY_PATH
4132ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4133 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4134 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4135 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4136 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4137 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4138endif # BOARD_AVB_VBMETA_SYSTEM
4139ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4140 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4141 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4142 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4143 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4144 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4145endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4146endif # BOARD_AVB_ENABLE
4147ifdef BOARD_BPT_INPUT_FILES
4148 $(hide) echo "board_bpt_enable=true" >> $@
4149 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4150 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4151endif
4152ifdef BOARD_BPT_DISK_SIZE
4153 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4154endif
4155 $(call generate-userimage-prop-dictionary, $@)
4156ifeq ($(AB_OTA_UPDATER),true)
4157 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4158 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4159 $(hide) echo "ab_update=true" >> $@
4160endif
4161ifdef BOARD_PREBUILT_DTBOIMAGE
4162 $(hide) echo "has_dtbo=true" >> $@
4163ifeq ($(BOARD_AVB_ENABLE),true)
4164 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4165 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4166ifdef BOARD_AVB_DTBO_KEY_PATH
4167 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4168 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4169 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4170endif # BOARD_AVB_DTBO_KEY_PATH
4171endif # BOARD_AVB_ENABLE
4172endif # BOARD_PREBUILT_DTBOIMAGE
4173 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004174 @# VINTF checks
4175ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4176 $(hide) echo "vintf_enforce=true" >> $@
4177endif
4178ifdef ODM_MANIFEST_SKUS
4179 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4180endif
Daniel Normane1e48082019-06-27 13:55:23 -07004181
4182.PHONY: misc_info
4183misc_info: $(INSTALLED_MISC_INFO_TARGET)
4184
4185droidcore: $(INSTALLED_MISC_INFO_TARGET)
4186
4187# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004188# A zip of the directories that map to the target filesystem.
4189# This zip can be used to create an OTA package or filesystem image
4190# as a post-build step.
4191#
4192name := $(TARGET_PRODUCT)
4193ifeq ($(TARGET_BUILD_TYPE),debug)
4194 name := $(name)_debug
4195endif
4196name := $(name)-target_files-$(FILE_NAME_TAG)
4197
4198intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4199BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4200$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4201$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004202 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004203
4204# $(1): Directory to copy
4205# $(2): Location to copy it to
4206# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4207define package_files-copy-root
4208 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4209 mkdir -p $(2) && \
4210 $(ACP) -rd $(strip $(1))/* $(2); \
4211 fi
4212endef
4213
Tao Baoa04fca32015-11-30 12:22:24 -08004214built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004215
4216# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004217ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004218built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07004219 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
4220endif
4221
The Android Open Source Project88b60792009-03-03 19:28:42 -08004222$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4223
Dan Willemsen653bea92017-03-21 15:47:37 -07004224tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004225$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004226
Sen Jiang4438fd92016-03-07 16:51:01 -08004227ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004228updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08004229else
Steve Fung48e49f52015-10-01 23:53:31 -07004230# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004231updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004232endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004233$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004234
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004235# If we are using recovery as boot, output recovery files to BOOT/.
4236ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4237$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4238else
4239$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4240endif
4241
Dan Willemsen653bea92017-03-21 15:47:37 -07004242ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004243 ifdef OSRELEASED_DIRECTORY
4244 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4245 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4246 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4247 endif
Tao Baoa835f382019-07-18 15:55:30 -07004248
4249 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4250 # additionally include radio or bootloader partitions).
4251 ifeq ($(AB_OTA_PARTITIONS),)
4252 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4253 endif
4254endif
4255
4256ifneq ($(AB_OTA_PARTITIONS),)
4257 ifneq ($(AB_OTA_UPDATER),true)
4258 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4259 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004260endif
4261
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004262# Run fs_config while creating the target files package
4263# $1: root directory
4264# $2: add prefix
4265define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004266(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 -08004267endef
4268
Yifan Hong60bfcc42019-11-01 11:39:45 -07004269# Filter out vendor from the list for AOSP targets.
4270# $(1): list
4271define filter-out-missing-vendor
4272$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4273endef
4274
4275# Information related to dynamic partitions and virtual A/B. This information
4276# is needed for building the super image (see dump-super-image-info) and
4277# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004278# $(1): file
4279define dump-dynamic-partitions-info
4280 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4281 echo "use_dynamic_partitions=true" >> $(1))
4282 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4283 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004284 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4285 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4286 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004287 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4288 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004289 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4290 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4291 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4292 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4293 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4294 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004295 echo "dynamic_partition_list=$(call filter-out-missing-vendor, $(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004296 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4297 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4298 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4299 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4300 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Yifan Hong60bfcc42019-11-01 11:39:45 -07004301 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 -07004302 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4303 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004304 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4305 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004306 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4307 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004308 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4309 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4310 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4311 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4312 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4313 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4314 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4315 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004316 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4317 echo "virtual_ab=true" >> $(1))
4318 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4319 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004320endef
4321
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004322# By conditionally including the dependency of the target files package on the
4323# full system image deps, we speed up builds that do not build the system
4324# image.
4325ifdef BUILDING_SYSTEM_IMAGE
4326$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4327endif
4328
Isaac Chen9e09d472019-07-05 17:30:41 +08004329ifeq ($(BUILD_QEMU_IMAGES),true)
4330MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4331$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4332endif
4333
The Android Open Source Project88b60792009-03-03 19:28:42 -08004334# Depending on the various images guarantees that the underlying
4335# directories are up-to-date.
4336$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004337 $(INSTALLED_RAMDISK_TARGET) \
4338 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004339 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004340 $(INSTALLED_RADIOIMAGE_TARGET) \
4341 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004342 $(INSTALLED_USERDATAIMAGE_TARGET) \
4343 $(INSTALLED_CACHEIMAGE_TARGET) \
4344 $(INSTALLED_VENDORIMAGE_TARGET) \
4345 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004346 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004347 $(INSTALLED_VBMETAIMAGE_TARGET) \
4348 $(INSTALLED_ODMIMAGE_TARGET) \
4349 $(INSTALLED_DTBOIMAGE_TARGET) \
4350 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4351 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4352 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004353 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004354 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4355 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004356 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004357 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004358 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4359 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4360 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004361 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004362 $(PRODUCT_ODM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004363 $(LPMAKE) \
4364 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004365 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004366 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004367 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004368 $(SOONG_ZIP) \
4369 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004370 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004371 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004372 $(BUILT_KERNEL_CONFIGS_FILE) \
4373 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004374 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004375 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004376 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004377 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004378 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004379 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004380 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004381 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004382ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004383 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004384 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004385 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004386 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004387ifdef INSTALLED_KERNEL_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004388 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004389endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004390ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4391 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
4392else # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
The Android Open Source Project88b60792009-03-03 19:28:42 -08004393ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004394 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004395endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004396ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004397ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004398 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004399else
Steve Mucklee1b10862019-07-10 10:49:37 -07004400 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004401endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004402endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004403ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004404 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004405endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004406ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004407 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004408endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004409ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004410 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004411endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004412ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004413 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004414endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004415ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004416 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004417endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004418endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004419endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004420 @# Components of the boot image
4421 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004422 $(hide) mkdir -p $(zip_root)/ROOT
4423 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004424 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004425 @# If we are using recovery as boot, this is already done when processing recovery.
4426ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004427ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004428 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004429 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004430endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004431ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004432 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004433endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004434ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004435ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004436 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004437endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004438ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004439 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004440endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004441 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004442ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004443 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004444endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004445ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004446 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004447endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004448else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4449 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4450endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4451endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004452 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4453 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004454 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004455ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4456 mkdir -p $(zip_root)/VENDOR_BOOT
4457 $(call package_files-copy-root, \
4458 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4459ifdef INSTALLED_DTBIMAGE_TARGET
4460 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4461endif
4462ifdef BOARD_KERNEL_BASE
4463 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4464endif
4465ifdef BOARD_KERNEL_PAGESIZE
4466 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4467endif
4468 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4469endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004470ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004471 @# Contents of the system image
4472 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004473 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004474endif
4475ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004476 @# Contents of the data image
4477 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004478 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004479endif
4480ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004481 @# Contents of the vendor image
4482 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004483 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004484endif
Dan Willemsen67495202019-01-16 12:42:05 -08004485ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004486 @# Contents of the product image
4487 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004488 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004489endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004490ifdef BUILDING_SYSTEM_EXT_IMAGE
4491 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004492 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004493 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004494endif
Dan Willemsen67495202019-01-16 12:42:05 -08004495ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004496 @# Contents of the odm image
4497 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004498 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004499endif
Dan Willemsen67495202019-01-16 12:42:05 -08004500ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004501 @# Contents of the system_other image
4502 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004503 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004504endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004505 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004506 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004507 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07004508ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004509ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004510 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004511 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004512endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004513endif
Doug Zongker8678df42009-06-15 14:30:14 -07004514 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004515 @# build them.
4516 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004517 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004518 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004519ifneq ($(tool_extension),)
4520 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4521endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004522 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004523 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004524 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004525ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4526 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4527 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004528endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004529ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4530 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4531 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004532endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004533ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4534 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4535 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004536endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004537ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4538 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4539 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004540endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004541ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4542 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4543 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004544endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004545ifneq ($(AB_OTA_UPDATER),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004546ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004547 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004548 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004549endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004550endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004551ifeq ($(AB_OTA_UPDATER),true)
4552 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004553 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004554 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004555 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4556 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004557 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4558 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4559 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004560ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004561 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4562 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4563 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004564endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004565endif
Steve Fungdfbab492015-09-24 18:12:33 -07004566ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004567 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004568 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004569endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004570ifdef BOARD_PREBUILT_VENDORIMAGE
4571 $(hide) mkdir -p $(zip_root)/IMAGES
4572 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4573endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004574ifdef BOARD_PREBUILT_PRODUCTIMAGE
4575 $(hide) mkdir -p $(zip_root)/IMAGES
4576 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4577endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004578ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004579 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004580 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004581endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004582ifdef BOARD_PREBUILT_BOOTIMAGE
4583 $(hide) mkdir -p $(zip_root)/IMAGES
4584 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4585endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004586ifdef BOARD_PREBUILT_ODMIMAGE
4587 $(hide) mkdir -p $(zip_root)/IMAGES
4588 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4589endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004590ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004591 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4592 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004593endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07004594 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4595 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4596 @# INSTALLED_RADIOIMAGE_TARGET.
4597 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4598 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004599 @# Run fs_config on all the system, vendor, boot ramdisk,
4600 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004601ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004602 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004603endif
4604ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004605 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4606endif
Dan Willemsen67495202019-01-16 12:42:05 -08004607ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004608 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4609endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004610ifdef BUILDING_SYSTEM_EXT_IMAGE
4611 $(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 +01004612endif
Dan Willemsen67495202019-01-16 12:42:05 -08004613ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004614 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4615endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004616 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004617 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004618ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004619 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004620 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004621endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004622ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4623 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4624endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004625ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4626 @# 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 -08004627 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4628endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004629ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4630 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4631endif
Dan Willemsen67495202019-01-16 12:42:05 -08004632ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004633 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4634endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004635 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004636ifdef BUILT_KERNEL_CONFIGS_FILE
4637 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4638endif
4639ifdef BUILT_KERNEL_VERSION_FILE
4640 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4641endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004642 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4643ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4644 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4645endif
Tao Baocbd6d492019-10-07 22:46:02 -07004646 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4647 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004648ifeq ($(BUILD_QEMU_IMAGES),true)
4649 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4650 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4651endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004652 @# Zip everything up, preserving symlinks and placing META/ files first to
4653 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004654 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004655 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004656 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004657
Ying Wanga0febe52013-03-20 11:02:05 -07004658.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004659target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4660
Ying Wang4709d7c2014-04-14 17:25:43 -07004661ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4662$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4663endif
Doug Zongker367910f2009-06-15 18:56:51 -07004664
Dan Albert4d323332016-10-14 13:23:06 -07004665# -----------------------------------------------------------------
4666# NDK Sysroot Package
4667NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004668$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004669 @echo Package NDK sysroot...
4670 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4671
4672$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4673
Ying Wang09c4b682015-08-11 11:24:19 -07004674ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004675# -----------------------------------------------------------------
4676# OTA update package
4677
Yifan Hong50e79542018-11-08 17:44:12 -08004678# $(1): output file
4679# $(2): additional args
4680define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004681PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004682 $(OTA_FROM_TARGET_FILES) \
4683 --verbose \
4684 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4685 --path $(HOST_OUT) \
4686 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4687 $(2) \
4688 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004689endef
4690
Doug Zongker8678df42009-06-15 14:30:14 -07004691name := $(TARGET_PRODUCT)
4692ifeq ($(TARGET_BUILD_TYPE),debug)
4693 name := $(name)_debug
4694endif
4695name := $(name)-ota-$(FILE_NAME_TAG)
4696
4697INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004698INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4699
Doug Zongker8678df42009-06-15 14:30:14 -07004700$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004701$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004702$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004703 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004704 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004705
4706.PHONY: otapackage
4707otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4708
Tao Bao519d1822018-12-27 12:47:23 -08004709ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004710name := $(TARGET_PRODUCT)
4711ifeq ($(TARGET_BUILD_TYPE),debug)
4712 name := $(name)_debug
4713endif
4714name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4715
4716INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004717$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004718$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4719 $(BUILT_TARGET_FILES_PACKAGE) \
4720 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004721 @echo "Package OTA (retrofit dynamic partitions): $@"
4722 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4723
4724.PHONY: otardppackage
4725
4726otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4727
Tao Bao519d1822018-12-27 12:47:23 -08004728endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004729
Ying Wang09c4b682015-08-11 11:24:19 -07004730endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004731
Ying Wang09a00a62010-10-20 14:01:09 -07004732# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004733# A zip of the appcompat directory containing logs
4734APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4735# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4736ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004737$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004738 $(INSTALLED_RAMDISK_TARGET) \
4739 $(INSTALLED_BOOTIMAGE_TARGET) \
4740 $(INSTALLED_USERDATAIMAGE_TARGET) \
4741 $(INSTALLED_VENDORIMAGE_TARGET) \
4742 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004743 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004744endif
4745$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4746$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4747 @echo "appcompat logs: $@"
4748 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4749 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4750 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4751 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4752
Dario Frenid1011272018-07-23 20:20:15 +01004753# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004754# A zip of the symbols directory. Keep the full paths to make it
4755# more obvious where these files came from.
4756#
4757name := $(TARGET_PRODUCT)
4758ifeq ($(TARGET_BUILD_TYPE),debug)
4759 name := $(name)_debug
4760endif
4761name := $(name)-symbols-$(FILE_NAME_TAG)
4762
4763SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004764# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07004765ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004766$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004767 $(INSTALLED_RAMDISK_TARGET) \
4768 $(INSTALLED_BOOTIMAGE_TARGET) \
4769 $(INSTALLED_USERDATAIMAGE_TARGET) \
4770 $(INSTALLED_VENDORIMAGE_TARGET) \
4771 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004772 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004773 $(INSTALLED_ODMIMAGE_TARGET) \
4774 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004775endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004776$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4777$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004778 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004779 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4780 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004781 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004782 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004783# -----------------------------------------------------------------
4784# A zip of the coverage directory.
4785#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004786name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004787ifeq ($(TARGET_BUILD_TYPE),debug)
4788name := $(name)_debug
4789endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004790COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
4791ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07004792$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004793 $(INSTALLED_RAMDISK_TARGET) \
4794 $(INSTALLED_BOOTIMAGE_TARGET) \
4795 $(INSTALLED_USERDATAIMAGE_TARGET) \
4796 $(INSTALLED_VENDORIMAGE_TARGET) \
4797 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004798 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004799 $(INSTALLED_ODMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004800endif
4801$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4802$(COVERAGE_ZIP): $(SOONG_ZIP)
4803 @echo "Package coverage: $@"
4804 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4805 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4806 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4807 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004808
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004809#------------------------------------------------------------------
4810# Export the LLVM profile data tool and dependencies for Clang coverage processing
4811#
4812ifeq (true,$(CLANG_COVERAGE))
4813 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4814 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4815 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4816 $(PROFDATA_ZIP): $(SOONG_ZIP)
4817 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4818
4819 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4820endif
4821
The Android Open Source Project88b60792009-03-03 19:28:42 -08004822# -----------------------------------------------------------------
4823# A zip of the Android Apps. Not keeping full path so that we don't
4824# include product names when distributing
4825#
4826name := $(TARGET_PRODUCT)
4827ifeq ($(TARGET_BUILD_TYPE),debug)
4828 name := $(name)_debug
4829endif
4830name := $(name)-apps-$(FILE_NAME_TAG)
4831
4832APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004833$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004834 @echo "Package apps: $@"
4835 $(hide) rm -rf $@
4836 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004837 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4838 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004839 echo "No apps to zip up. Generating empty apps archive." ; \
4840 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004841 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004842 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004843 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004844
Ying Wangbc415dd2012-08-15 12:22:44 -07004845ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004846#------------------------------------------------------------------
4847# An archive of classes for use in generating code-coverage reports
4848# These are the uninstrumented versions of any classes that were
4849# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004850# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004851
Colin Crossa6bc3a82017-09-27 14:28:41 -07004852JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004853$(JACOCO_REPORT_CLASSES_ALL) :
4854 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004855 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4856 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004857
Ying Wangbc415dd2012-08-15 12:22:44 -07004858endif # EMMA_INSTRUMENT=true
4859
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004860
Ying Wangae9115a2013-08-22 20:52:47 -07004861#------------------------------------------------------------------
4862# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004863#
Ying Wangc62c92c2013-08-28 18:38:25 -07004864PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004865# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
4866ifndef TARGET_BUILD_APPS
4867$(PROGUARD_DICT_ZIP): \
4868 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4869 $(INSTALLED_RAMDISK_TARGET) \
4870 $(INSTALLED_BOOTIMAGE_TARGET) \
4871 $(INSTALLED_USERDATAIMAGE_TARGET) \
4872 $(INSTALLED_VENDORIMAGE_TARGET) \
4873 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4874 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4875 $(INSTALLED_ODMIMAGE_TARGET) \
4876 $(updater_dep)
4877endif
4878$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4879$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004880 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004881 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4882 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4883 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4884 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004885
Tao Bao48a2feb2019-06-28 11:00:05 -07004886
4887ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4888
4889# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4890# $(1): output file
4891define dump-super-image-info
4892 $(call dump-dynamic-partitions-info,$(1))
4893 $(if $(filter true,$(AB_OTA_UPDATER)), \
4894 echo "ab_update=true" >> $(1))
4895endef
4896
4897endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4898
The Android Open Source Project88b60792009-03-03 19:28:42 -08004899# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004900# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004901
4902ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4903
4904# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4905ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4906
4907ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004908
4909# For real devices and for dist builds, build super image from target files to an intermediate directory.
4910INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4911$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4912$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4913 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004914 PATH=$(dir $(LPMAKE)):$$PATH \
4915 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004916
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004917# Skip packing it in dist package because it is in update package.
4918ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004919$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004920endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004921
4922.PHONY: superimage_dist
4923superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07004924
4925endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07004926endif # BOARD_SUPER_PARTITION_SIZE != ""
4927endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004928
Yifan Hongacd862a2019-04-16 15:44:30 -07004929# -----------------------------------------------------------------
4930# super partition image for development
4931
4932ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4933ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4934ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
4935
4936# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
4937# $(1): built image path
4938# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
4939define build-superimage-target
4940 mkdir -p $(dir $(2))
4941 rm -rf $(2)
4942 $(call dump-super-image-info,$(2))
4943 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4944 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09004945 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
4946 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07004947 mkdir -p $(dir $(1))
4948 PATH=$(dir $(LPMAKE)):$$PATH \
4949 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
4950endef
4951
4952INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
4953INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
4954 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
4955
changho.shina8f9f112019-10-15 13:26:19 +09004956ifdef BUILDING_SYSTEM_OTHER_IMAGE
4957ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
4958INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
4959endif
4960endif
4961
Yifan Hongacd862a2019-04-16 15:44:30 -07004962# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
4963# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
4964# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
4965# virtual devices.
4966ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
4967$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4968 $(call pretty,"Target super fs image for debug: $@")
4969 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08004970 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004971
4972droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
4973
4974# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
4975.PHONY: superimage
4976superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08004977
4978$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004979endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
4980
4981# Build $(PRODUCT_OUT)/super.img without dependencies.
4982.PHONY: superimage-nodeps supernod
4983superimage-nodeps supernod: intermediates :=
4984superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4985 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
4986 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
4987 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
4988
4989endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
4990endif # BOARD_SUPER_PARTITION_SIZE != ""
4991endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
4992
4993# -----------------------------------------------------------------
4994# super empty image
4995
Tao Bao48a2feb2019-06-28 11:00:05 -07004996ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004997ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004998
Yifan Hong8b79d162018-11-29 12:32:00 -08004999INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5000$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5001$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5002 $(call pretty,"Target empty super fs image: $@")
5003 mkdir -p $(intermediates)
5004 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005005 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005006 PATH=$(dir $(LPMAKE)):$$PATH \
5007 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005008
5009$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5010
Yifan Hong2b891ac2018-11-29 12:06:31 -08005011endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005012endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005013
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005014
5015# -----------------------------------------------------------------
5016# The update package
5017
5018name := $(TARGET_PRODUCT)
5019ifeq ($(TARGET_BUILD_TYPE),debug)
5020 name := $(name)_debug
5021endif
5022name := $(name)-img-$(FILE_NAME_TAG)
5023
5024INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5025
Tao Bao57f8ed62019-08-14 23:08:18 -07005026$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5027 $(call pretty,"Package: $@")
5028 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5029 $(IMG_FROM_TARGET_FILES) \
5030 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5031 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005032
5033.PHONY: updatepackage
5034updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005035$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005036
5037
Yifan Hong2b891ac2018-11-29 12:06:31 -08005038# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005039# dalvik something
5040.PHONY: dalvikfiles
5041dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5042
Bo Huf0d50bb2017-08-01 19:02:09 +00005043ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005044MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005045MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005046SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005047
5048ifdef INSTALLED_SYSTEMIMAGE_TARGET
5049INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005050INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5051$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5052 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5053 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005054$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005055 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5056 @echo Create system-qemu.img now
5057 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005058 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005059
5060systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5061droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005062endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005063ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005064INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005065$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005066 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005067 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005068
5069vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5070droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5071endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005072ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005073INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005074$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005075 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005076 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005077
5078productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5079droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5080endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005081ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5082INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5083$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5084 @echo Create system_ext-qemu.img
5085 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005086
Justin Yun6151e3f2019-06-25 15:58:13 +09005087systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5088droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005089endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005090ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005091INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5092$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5093 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005094 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005095
5096odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5097droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5098endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005099
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005100QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005101$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5102 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005103 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005104 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5105 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005106
5107systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5108droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005109
Bo Huf0d50bb2017-08-01 19:02:09 +00005110endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005111# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005112# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005113ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005114INTERNAL_EMULATOR_PACKAGE_FILES += \
5115 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005116 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005117 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005118 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5119 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005120
5121name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5122
5123INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5124
Ying Wang5d887702015-11-04 10:06:25 -08005125$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005126 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005127 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005128
Ying Wang7d8c5352012-07-26 10:15:21 -07005129endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005130# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005131# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005132# The pdk package (Platform Development Kit)
5133
Keun young Park7fc7aad2012-02-27 15:49:23 -08005134#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5135# include development/pdk/Pdk.mk
5136#endif
5137
The Android Open Source Project88b60792009-03-03 19:28:42 -08005138
5139# -----------------------------------------------------------------
5140# The SDK
5141
The Android Open Source Project88b60792009-03-03 19:28:42 -08005142# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005143sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005144
5145# Build a name that looks like:
5146#
5147# linux-x86 --> android-sdk_12345_linux-x86
5148# darwin-x86 --> android-sdk_12345_mac-x86
5149# windows-x86 --> android-sdk_12345_windows
5150#
5151sdk_name := android-sdk_$(FILE_NAME_TAG)
5152ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005153 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005154else
Joe Onorato03fbe402009-04-13 08:31:16 -07005155 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005156endif
5157ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005158 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005159endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005160sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005161
5162sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5163
5164ATREE_FILES :=
5165-include $(sdk_dep_file)
5166
5167# if we don't have a real list, then use "everything"
5168ifeq ($(strip $(ATREE_FILES)),)
5169ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005170 $(ALL_DEFAULT_INSTALLED_MODULES) \
5171 $(INSTALLED_RAMDISK_TARGET) \
5172 $(ALL_DOCS) \
Nan Zhangcb0a6882018-08-07 15:26:32 -07005173 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api-stubs-docs_annotations.zip \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005174 $(ALL_SDK_FILES)
5175endif
5176
5177atree_dir := development/build
5178
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005179
The Android Open Source Project88b60792009-03-03 19:28:42 -08005180sdk_atree_files := \
5181 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005182 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005183
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005184# development/build/sdk-android-<abi>.atree is used to differentiate
5185# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5186# files like the kernel image. We use TARGET_CPU_ABI because we don't
5187# have a better way to distinguish between CPU models.
5188ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5189 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5190endif
5191
Anton Hansson8dab0a62019-03-28 15:45:40 +00005192ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5193sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005194else
5195sdk_atree_files += $(atree_dir)/sdk.atree
5196endif
5197
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005198include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005199
The Android Open Source Project88b60792009-03-03 19:28:42 -08005200deps := \
5201 $(target_notice_file_txt) \
5202 $(tools_notice_file_txt) \
5203 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005204 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005205 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005206 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005207 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005208 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005209 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005210 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005211 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005212 $(INSTALLED_USERDATAIMAGE_TARGET) \
5213 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005214 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005215 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005216 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005217 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005218 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005219 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005220 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005221
5222INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5223$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5224$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5225$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5226$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5227
5228# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5229#
5230#SDK_GNU_ERROR := true
5231
Ying Wang5d887702015-11-04 10:06:25 -08005232$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005233 @echo "Package SDK: $@"
5234 $(hide) rm -rf $(PRIVATE_DIR) $@
5235 $(hide) for f in $(target_gnu_MODULES); do \
5236 if [ -f $$f ]; then \
5237 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5238 including GNU target $$f >&2; \
5239 FAIL=$(SDK_GNU_ERROR); \
5240 fi; \
5241 done; \
5242 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005243 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005244 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005245 ATREE_STRIP="$(HOST_STRIP) -x" \
5246 $(HOST_OUT_EXECUTABLES)/atree \
5247 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5248 -m $(PRIVATE_DEP_FILE) \
5249 -I . \
5250 -I $(PRODUCT_OUT) \
5251 -I $(HOST_OUT) \
5252 -I $(TARGET_COMMON_OUT_ROOT) \
5253 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5254 -v "OUT_DIR=$(OUT_DIR)" \
5255 -v "HOST_OUT=$(HOST_OUT)" \
5256 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5257 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5258 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5259 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5260 -o $(PRIVATE_DIR) && \
5261 cp -f $(target_notice_file_txt) \
5262 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5263 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5264 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5265 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5266 chmod -R ug+rwX $(PRIVATE_DIR) && \
5267 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005268 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5269
Raphael3d224a02010-04-16 17:50:09 -07005270
5271# Is a Windows SDK requested? If so, we need some definitions from here
5272# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005273MAIN_SDK_NAME := $(sdk_name)
5274MAIN_SDK_DIR := $(sdk_dir)
5275MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005276ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005277include $(TOPDIR)development/build/tools/windows_sdk.mk
5278endif
5279
The Android Open Source Project88b60792009-03-03 19:28:42 -08005280# -----------------------------------------------------------------
5281# Findbugs
5282INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5283INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5284$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5285 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005286 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005287 > $@
5288$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5289 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005290 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005291 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005292
5293# -----------------------------------------------------------------
5294# Findbugs
5295
5296# -----------------------------------------------------------------
5297# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005298ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005299include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005300-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005301-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005302-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005303# Also the project-specific tasks
5304-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5305-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005306-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005307# Also add test specifc tasks
5308include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005309include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005310endif
Raphaelc4d47312011-02-15 16:09:36 -08005311
Ying Wang67132ba2015-10-28 16:42:39 -07005312include $(BUILD_SYSTEM)/product-graph.mk
5313
Raphaelc4d47312011-02-15 16:09:36 -08005314# -----------------------------------------------------------------
5315# Create SDK repository packages. Must be done after tasks/* since
5316# we need the addon rules defined.
5317ifneq ($(sdk_repo_goal),)
5318include $(TOPDIR)development/build/tools/sdk_repo.mk
5319endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005320
5321# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005322# Soong generates the list of all shared libraries that are depended on by fuzz
5323# targets. It saves this list as a source:destination pair to
5324# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5325# build of the unstripped shared library, and the destination is the
5326# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5327# where fuzz target shared libraries are to be "reinstalled". The
5328# copy-many-files below generates the rules to copy the unstripped shared
5329# libraries to the device or host "reinstallation" directory. These rules are
5330# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5331# a dependency on each shared library that it needs to be "reinstalled".
5332FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5333
5334# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005335# The rule to build all fuzz targets, and package them.
5336# Note: The packages are created in Soong, and in a perfect world,
5337# we'd be able to create the phony rule there. But, if we want to
5338# have dist goals for the fuzz target, we need to have the PHONY
5339# target defined in make. MakeVarsContext.DistForGoal doesn't take
5340# into account that a PHONY rule create by Soong won't be available
5341# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005342# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005343# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005344.PHONY: haiku
5345haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5346$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005347
5348# -----------------------------------------------------------------
5349# The makefile for haiku line coverage.
5350include $(BUILD_SYSTEM)/line_coverage.mk