blob: fd409479e7a21fd018efff082242b3865db148bc [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 \
19 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)))
Ying Wang68864102011-09-29 13:23:25 -070020endef
Ying Wang619fccf2012-09-05 18:08:29 -070021# filter out the duplicate <source file>:<dest file> pairs.
22unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080023$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070024 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
25 $(eval unique_product_copy_files_pairs += $(cf))))
26unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080027product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070028$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070029 $(eval _src := $(call word-colon,1,$(cf))) \
30 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070031 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080032 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080033 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070034 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070035 $(if $(filter %.xml,$(_dest)),\
36 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010037 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
38 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070039 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
40 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
41 $(eval $(call copy-one-file,$(_src),$(_fulldest)))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070042 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080043
44# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
45$(file >$(PRODUCT_OUT)/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
46ifdef dist_goal
47$(file >$(DIST_DIR)/logs/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
48endif
49
50product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070051unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070052unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080053
54# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080055# Returns the max allowed size for an image suitable for hash verification
56# (e.g., boot.img, recovery.img, etc).
57# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
58# $(1): partition size to flash the image
59define get-hash-image-max-size
60$(if $(1), \
61 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
62 $(eval _hash_meta_size := 69632), \
63 $(eval _hash_meta_size := 0)) \
64 $(1)-$(_hash_meta_size))
65endef
66
67# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -080068# Define rules to copy headers defined in copy_headers.mk
69# If more than one makefile declared a header, print a warning,
70# then copy the last one defined. This matches the previous make
71# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -070072has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -080073$(foreach dest,$(ALL_COPIED_HEADERS), \
74 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
75 $(eval _src := $(word $(words $(_srcs)),$(_srcs))) \
76 $(if $(call streq,$(_src),$(_srcs)),, \
77 $(warning Duplicate header copy: $(dest)) \
Dan Willemsen7f9bd562018-08-15 14:28:01 -070078 $(warning Defined in: $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)) \
79 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -080080 $(eval $(call copy-one-header,$(_src),$(dest))))
81all_copied_headers: $(ALL_COPIED_HEADERS)
82
Dan Willemsen7f9bd562018-08-15 14:28:01 -070083ifdef has_dup_copy_headers
84 has_dup_copy_headers :=
85 ifneq ($(BUILD_BROKEN_DUP_COPY_HEADERS),true)
86 $(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)
87 endif
88endif
89
Dan Willemsen6f60f022016-02-23 13:40:07 -080090# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -080091# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070092ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080093gen := $(OUT_DOCS)/index.html
94ALL_DOCS += $(gen)
95$(gen): frameworks/base/docs/docs-redirect-index.html
96 @mkdir -p $(dir $@)
97 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070098endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080099
Dan Albert303e6032017-10-04 10:20:20 -0700100ndk_doxygen_out := $(OUT_NDK_DOCS)
101ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
102ndk_docs_src_dir := frameworks/native/docs
103ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
104ifneq ($(wildcard $(ndk_docs_src_dir)),)
105ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
106 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
107$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
108 @mkdir -p $(ndk_doxygen_out)
109 @echo "Generating NDK docs to $(ndk_doxygen_out)"
110 @( cat $(ndk_doxyfile); \
111 echo "INPUT=$(ndk_headers)"; \
112 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
113 ) | doxygen -
114
115# Note: Not a part of the docs target because we don't have doxygen available.
116# You can run this target locally if you have doxygen installed.
117ndk-docs: $(ndk_doxygen_out)/index.html
118.PHONY: ndk-docs
119endif
120
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121# -----------------------------------------------------------------
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900122# property_overrides_split_enabled
123property_overrides_split_enabled :=
124ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
125 property_overrides_split_enabled := true
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900126endif
127
128# -----------------------------------------------------------------
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900129# FINAL_VENDOR_DEFAULT_PROPERTIES will be installed in vendor/default.prop if
130# property_overrides_split_enabled is true. Otherwise it will be installed in
131# ROOT/default.prop.
132ifdef BOARD_VNDK_VERSION
133 ifeq ($(BOARD_VNDK_VERSION),current)
134 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
135 else
136 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(BOARD_VNDK_VERSION)
137 endif
Logan Chiend73b94c2018-05-04 19:33:17 +0800138 ifdef BOARD_VNDK_RUNTIME_DISABLE
139 FINAL_VENDOR_DEFAULT_PROPERTIES += ro.vndk.lite=true
140 endif
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900141else
Logan Chiend73b94c2018-05-04 19:33:17 +0800142 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
143 FINAL_VENDOR_DEFAULT_PROPERTIES += ro.vndk.lite=true
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900144endif
145FINAL_VENDOR_DEFAULT_PROPERTIES += \
146 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
147FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
148 $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
149
150# -----------------------------------------------------------------
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800151# prop.default
152ifdef property_overrides_split_enabled
153INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800154INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
155ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
156$(INSTALLED_DEFAULT_PROP_OLD_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800157else
158# legacy path
The Android Open Source Project88b60792009-03-03 19:28:42 -0800159INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800160endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800161ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900162FINAL_DEFAULT_PROPERTIES := \
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900163 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) \
164 $(call collapse-pairs, $(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900165ifndef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900166 FINAL_DEFAULT_PROPERTIES += \
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900167 $(call collapse-pairs, $(FINAL_VENDOR_DEFAULT_PROPERTIES))
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900168endif
Jaekyun Seok294286d2017-01-20 13:17:12 +0900169FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
170 $(FINAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800171
Andres Moralesb8876e12015-05-06 20:44:22 -0700172intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
173
174$(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800175 @echo Target buildinfo: $@
176 @mkdir -p $(dir $@)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800177 @rm -f $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800178 $(hide) echo "#" > $@; \
179 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
180 echo "#" >> $@;
Jaekyun Seok294286d2017-01-20 13:17:12 +0900181 $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700182 echo "$(line)" >> $@;)
Andres Moralesb8876e12015-05-06 20:44:22 -0700183 $(hide) echo "#" >> $@; \
184 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
185 echo "#" >> $@;
Dan Willemsen014719f2015-08-17 20:44:29 -0700186 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
187 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Cross73021682015-07-21 12:54:17 -0700188 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Colin Crossfdea8932017-12-06 14:38:40 -0800189 $(hide) build/make/tools/post_process_props.py $@
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800190ifdef property_overrides_split_enabled
191 $(hide) mkdir -p $(TARGET_ROOT_OUT)
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800192 $(hide) ln -sf system/etc/prop.default $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800193endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800194
195# -----------------------------------------------------------------
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900196# vendor default.prop
197INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900198ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900199INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
200ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
201
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900202$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
203 @echo Target buildinfo: $@
204 @mkdir -p $(dir $@)
205 $(hide) echo "#" > $@; \
206 echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
207 echo "#" >> $@;
208 $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
209 echo "$(line)" >> $@;)
Colin Crossfdea8932017-12-06 14:38:40 -0800210 $(hide) build/make/tools/post_process_props.py $@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900211
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900212endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900213
214# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800215# build.prop
216INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
217ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900218FINAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -0700219 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
Jaekyun Seok294286d2017-01-20 13:17:12 +0900220FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
221 $(FINAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800222
223# A list of arbitrary tags describing the build configuration.
224# Force ":=" so we can use +=
225BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
226ifeq ($(TARGET_BUILD_TYPE),debug)
227 BUILD_VERSION_TAGS += debug
228endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700229# The "test-keys" tag marks builds signed with the old test keys,
230# which are available in the SDK. "dev-keys" marks builds signed with
231# non-default dev keys (usually private keys from a vendor directory).
232# Both of these tags will be removed and replaced with "release-keys"
233# when the target-files is signed in a post-build step.
234ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700235BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700236else
Doug Zongkera8608a72013-07-23 11:51:04 -0700237BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700238endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700239BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800240BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
241
242# A human-readable string that descibes this build in detail.
Colin Crossf37b4552015-07-16 17:15:19 -0700243build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS)
Andres Moralesb8876e12015-05-06 20:44:22 -0700244$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800245
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700246# 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 -0800247ifeq (,$(strip $(BUILD_FINGERPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800248 ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
249 BF_BUILD_NUMBER := $(USER)$$($(DATE_FROM_FILE) +%m%d%H%M)
Ying Wang50367cc2014-06-12 18:42:53 -0700250 else
Nan Zhang0abdb582018-02-20 17:00:39 -0800251 BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE))
Ying Wang50367cc2014-06-12 18:42:53 -0700252 endif
253 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 -0800254endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800255# unset it for safety.
256BF_BUILD_NUMBER :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800257
Nan Zhang0abdb582018-02-20 17:00:39 -0800258BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt
259ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE) && grep " " $(BUILD_FINGERPRINT_FILE)))
260 $(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))")
261endif
262BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE))
263# unset it for safety.
264BUILD_FINGERPRINT :=
Colin Crossf37b4552015-07-16 17:15:19 -0700265
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700266# The string used to uniquely identify the system build; used by the OTA server.
267# This purposefully excludes any product-specific variables.
268ifeq (,$(strip $(BUILD_THUMBPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800269 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700270endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800271
272BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt
273ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE)))
274 $(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))")
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700275endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800276BUILD_THUMBPRINT_FROM_FILE := $$(cat $(BUILD_THUMBPRINT_FILE))
277# unset it for safety.
278BUILD_THUMBPRINT :=
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700279
Ying Wange24e17a2014-10-07 18:42:11 -0700280KNOWN_OEM_THUMBPRINT_PROPERTIES := \
281 ro.product.brand \
282 ro.product.name \
283 ro.product.device
284OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
285 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))
286
Sriram Raman7b641242009-03-24 22:40:59 -0700287# Display parameters shown under Settings -> About Phone
288ifeq ($(TARGET_BUILD_VARIANT),user)
289 # User builds should show:
290 # release build number or branch.buld_number non-release builds
291
292 # Dev. branches should have DISPLAY_BUILD_NUMBER set
Colin Cross63fe36a2017-02-21 17:23:02 -0800293 ifeq (true,$(DISPLAY_BUILD_NUMBER))
Colin Crossf37b4552015-07-16 17:15:19 -0700294 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700295 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700296 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700297 endif
298else
299 # Non-user builds should show detailed build information
300 BUILD_DISPLAY_ID := $(build_desc)
301endif
302
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000303# Accepts a whitespace separated list of product locales such as
304# (en_US en_AU en_GB...) and returns the first locale in the list with
305# underscores replaced with hyphens. In the example above, this will
306# return "en-US".
307define get-default-product-locale
308$(strip $(subst _,-, $(firstword $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800309endef
310
Colin Crossfdea8932017-12-06 14:38:40 -0800311BUILDINFO_SH := build/make/tools/buildinfo.sh
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800312DEVICE_BUILDINFO_SH := build/make/tools/device_buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700313
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700314# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test
315# harness to distinguish builds. Only add _asan for a sanitized build
316# if it isn't already a part of the flavor (via a dedicated lunch
317# config for example).
Ying Wang21ec03d2015-10-28 18:45:03 -0700318TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
Ivan Lozano0f71db32017-08-14 07:57:37 -0700319ifneq (, $(filter address, $(SANITIZE_TARGET)))
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700320ifeq (,$(findstring _asan,$(TARGET_BUILD_FLAVOR)))
Ying Wang21ec03d2015-10-28 18:45:03 -0700321TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
322endif
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700323endif
Ying Wang21ec03d2015-10-28 18:45:03 -0700324
Andrew Boiefa61ff02012-09-28 09:33:45 -0700325ifdef TARGET_SYSTEM_PROP
326system_prop_file := $(TARGET_SYSTEM_PROP)
327else
328system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
329endif
Jaekyun Seokf9af5fa2017-10-25 12:08:32 +0900330$(intermediate_system_build_prop): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800331 @echo Target buildinfo: $@
332 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700333 $(hide) echo > $@
334ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
335 $(hide) echo "#" >> $@; \
336 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700337 echo "#" >> $@;
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700338 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
339 echo "import /oem/oem.prop $(prop)" >> $@;)
340endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800341 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Ying Wang21ec03d2015-10-28 18:45:03 -0700342 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343 TARGET_DEVICE="$(TARGET_DEVICE)" \
344 PRODUCT_NAME="$(TARGET_PRODUCT)" \
345 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000346 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700347 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800348 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
349 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
350 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
351 BUILD_ID="$(BUILD_ID)" \
352 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
Dan Willemsenccc933e2015-08-11 15:25:12 -0700353 DATE="$(DATE_FROM_FILE)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700354 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
Daniel Rosenberg59156a62015-06-29 17:20:43 -0700355 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
Tao Bao532fdf42015-11-11 10:22:48 -0800356 AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800357 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
Dianne Hackborne593e5c2015-08-12 16:11:20 -0700358 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
359 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800360 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Adam Powellbdd5e8e2015-05-21 13:49:05 -0700361 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700362 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
Dianne Hackborn6ee3c432014-04-24 16:19:14 -0700363 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
Przemyslaw Szczepaniake5540152017-12-05 10:27:52 +0000364 PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION="$(PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800365 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700366 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
Nan Zhang0abdb582018-02-20 17:00:39 -0800367 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT_FROM_FILE)") \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000368 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100369 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
370 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700371 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800372 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800373 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700374 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200375 $(hide) $(foreach file,$(system_prop_file), \
376 if [ -f "$(file)" ]; then \
377 echo "#" >> $@; \
378 echo Target buildinfo from: "$(file)"; \
379 echo "# from $(file)" >> $@; \
380 echo "#" >> $@; \
381 cat $(file) >> $@; \
382 fi;)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900383 $(if $(FINAL_BUILD_PROPERTIES), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800384 $(hide) echo >> $@; \
385 echo "#" >> $@; \
386 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
387 echo "#" >> $@; )
Jaekyun Seok294286d2017-01-20 13:17:12 +0900388 $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700389 echo "$(line)" >> $@;)
Andres Morales085a0ce2015-02-06 10:12:55 -0800390 $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@
Colin Crossfdea8932017-12-06 14:38:40 -0800391 $(hide) build/make/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800392
393build_desc :=
394
Andres Moralesb8876e12015-05-06 20:44:22 -0700395ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
396INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
397else
398INSTALLED_RECOVERYIMAGE_TARGET :=
399endif
400
401$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) $(INSTALLED_RECOVERYIMAGE_TARGET)
402 @echo "Target build info: $@"
Steven Morelandec082652017-10-22 02:11:47 -0700403 $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@
Andres Moralesb8876e12015-05-06 20:44:22 -0700404ifdef INSTALLED_RECOVERYIMAGE_TARGET
405 $(hide) echo ro.expect.recovery_id=`cat $(RECOVERYIMAGE_ID_FILE)` >> $@
406endif
407
The Android Open Source Project88b60792009-03-03 19:28:42 -0800408# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700409# vendor build.prop
410#
Alex Naidis47e24e92016-01-10 14:18:54 +0000411# For verifying that the vendor build is what we think it is
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700412INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
413ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900414
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900415ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900416FINAL_VENDOR_BUILD_PROPERTIES += \
417 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
418FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
419 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900420endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900421
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800422$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(DEVICE_BUILDINFO_SH) $(intermediate_system_build_prop)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700423 @echo Target vendor buildinfo: $@
424 @mkdir -p $(dir $@)
425 $(hide) echo > $@
Sandeep Patil127f5012017-10-23 19:47:43 -0700426 $(hide) grep 'ro.product.first_api_level' $(intermediate_system_build_prop) >> $@ || true
Dan Willemsenccc933e2015-08-11 15:25:12 -0700427 $(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
428 $(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Crossf37b4552015-07-16 17:15:19 -0700429 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Max Biresa1749982018-03-28 15:48:13 -0700430 $(hide) echo ro.vendor.build.security_patch="$(VENDOR_SECURITY_PATCH)">>$@
Isaac Chen8d11feb2018-01-31 14:27:37 +0800431 $(hide) echo ro.vendor.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
432 $(hide) echo ro.vendor.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
433 $(hide) echo ro.vendor.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Hung-ying Tyanc565f5c2018-07-26 17:11:52 +0800434 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
435 BUILD_ID="$(BUILD_ID)" \
436 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
437 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
438 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
439 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
440 TARGET_DEVICE="$(TARGET_DEVICE)" \
Ryan Campbell63fc0e62017-10-02 12:29:41 -0700441 PRODUCT_NAME="$(TARGET_PRODUCT)" \
442 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
443 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
444 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
445 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900446 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800447 bash $(DEVICE_BUILDINFO_SH) "vendor" >> $@
Jaekyun Seokf9af5fa2017-10-25 12:08:32 +0900448ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900449 $(hide) echo "#" >> $@; \
450 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
451 echo "#" >> $@;
452 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
453 echo "$(line)" >> $@;)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900454endif # property_overrides_split_enabled
Ivan Podogovd5726322018-03-29 15:22:33 +0100455 $(hide) build/make/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_PROPERTY_BLACKLIST)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700456
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900457# -----------------------------------------------------------------
458# product build.prop
459INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
460ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
461
462FINAL_PRODUCT_PROPERTIES += \
Yifan Hongaf9e7f02018-07-27 13:11:50 -0700463 $(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES) $(ADDITIONAL_PRODUCT_PROPERTIES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900464FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \
465 $(FINAL_PRODUCT_PROPERTIES),=)
466
467$(INSTALLED_PRODUCT_BUILD_PROP_TARGET):
468 @echo Target product buildinfo: $@
469 @mkdir -p $(dir $@)
470 $(hide) echo > $@
471ifdef BOARD_USES_PRODUCTIMAGE
472 $(hide) echo ro.product.build.date=`$(DATE_FROM_FILE)`>>$@
473 $(hide) echo ro.product.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
474 $(hide) echo ro.product.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
475endif # BOARD_USES_PRODUCTIMAGE
476 $(hide) echo "#" >> $@; \
477 echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \
478 echo "#" >> $@;
479 $(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \
480 echo "$(line)" >> $@;)
481 $(hide) build/make/tools/post_process_props.py $@
482
Andres Morales9c820f82015-01-13 15:30:34 -0800483# ----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800484# odm build.prop
485INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/build.prop
486ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_ODM_BUILD_PROP_TARGET)
487
488FINAL_ODM_BUILD_PROPERTIES += \
489 $(call collapse-pairs, $(PRODUCT_ODM_PROPERTIES))
490FINAL_ODM_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
491 $(FINAL_ODM_BUILD_PROPERTIES),=)
492
493$(INSTALLED_ODM_BUILD_PROP_TARGET): $(DEVICE_BUILDINFO_SH)
494 @echo Target odm buildinfo: $@
495 @mkdir -p $(dir $@)
496 $(hide) echo > $@
497 $(hide) echo ro.odm.build.date=`$(DATE_FROM_FILE)`>>$@
498 $(hide) echo ro.odm.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
499 $(hide) echo ro.odm.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
500 $(hide) echo ro.odm.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
501 $(hide) echo ro.odm.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
502 $(hide) echo ro.odm.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
503 $(hide) TARGET_DEVICE="$(TARGET_DEVICE)" \
504 PRODUCT_NAME="$(TARGET_PRODUCT)" \
505 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
506 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
507 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
508 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
509 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
510 bash $(DEVICE_BUILDINFO_SH) "odm" >> $@
511 $(hide) echo "#" >> $@; \
512 echo "# ADDITIONAL ODM BUILD PROPERTIES" >> $@; \
513 echo "#" >> $@;
514 $(hide) $(foreach line,$(FINAL_ODM_BUILD_PROPERTIES), \
515 echo "$(line)" >> $@;)
516 $(hide) build/make/tools/post_process_props.py $@
Andres Morales9c820f82015-01-13 15:30:34 -0800517
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700518# -----------------------------------------------------------------
Dario Freni924af7d2018-08-17 00:56:14 +0100519# product_services build.prop
Dario Freni5f681e12018-05-29 13:09:01 +0100520INSTALLED_PRODUCT_SERVICES_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT_SERVICES)/build.prop
521ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SERVICES_BUILD_PROP_TARGET)
522
523FINAL_PRODUCT_SERVICES_PROPERTIES += \
524 $(call collapse-pairs, $(PRODUCT_PRODUCT_SERVICES_PROPERTIES))
525FINAL_PRODUCT_SERVICES_PROPERTIES := $(call uniq-pairs-by-first-component, \
526 $(FINAL_PRODUCT_SERVICES_PROPERTIES),=)
527
528$(INSTALLED_PRODUCT_SERVICES_BUILD_PROP_TARGET):
Dario Freni924af7d2018-08-17 00:56:14 +0100529 @echo Target product_services buildinfo: $@
Dario Freni5f681e12018-05-29 13:09:01 +0100530 @mkdir -p $(dir $@)
531 $(hide) echo > $@
532ifdef BOARD_USES_PRODUCT_SERVICESIMAGE
Yifan Hongebc041a2018-07-26 16:02:52 -0700533 $(hide) echo ro.product_services.build.date=`$(DATE_FROM_FILE)`>>$@
534 $(hide) echo ro.product_services.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
535 $(hide) echo ro.product_services.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Dario Freni5f681e12018-05-29 13:09:01 +0100536endif # BOARD_USES_PRODUCT_SERVICESIMAGE
537 $(hide) echo "#" >> $@; \
538 echo "# ADDITIONAL PRODUCT_SERVICES PROPERTIES" >> $@; \
539 echo "#" >> $@;
540 $(hide) $(foreach line,$(FINAL_PRODUCT_SERVICES_PROPERTIES), \
541 echo "$(line)" >> $@;)
542 $(hide) build/make/tools/post_process_props.py $@
543
544# ----------------------------------------------------------------
545
546# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547# sdk-build.prop
548#
549# There are certain things in build.prop that we don't want to
550# ship with the sdk; remove them.
551
552# This must be a list of entire property keys followed by
553# "=" characters, without any internal spaces.
554sdk_build_prop_remove := \
555 ro.build.user= \
556 ro.build.host= \
557 ro.product.brand= \
558 ro.product.manufacturer= \
559 ro.product.device=
560# TODO: Remove this soon-to-be obsolete property
561sdk_build_prop_remove += ro.build.product=
562INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
563$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
564 @echo SDK buildinfo: $@
565 @mkdir -p $(dir $@)
566 $(hide) grep -v "$(subst $(space),\|,$(strip \
567 $(sdk_build_prop_remove)))" $< > $@.tmp
568 $(hide) for x in $(sdk_build_prop_remove); do \
569 echo "$$x"generic >> $@.tmp; done
570 $(hide) mv $@.tmp $@
571
572# -----------------------------------------------------------------
573# package stats
574PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
575PACKAGES_TO_STAT := \
576 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
577 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
578$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
579 @echo Package stats: $@
580 @mkdir -p $(dir $@)
581 $(hide) rm -f $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700582ifeq ($(PACKAGES_TO_STAT),)
583# Create empty package stats file if target builds no jar(s) or apk(s).
584 $(hide) touch $@
585else
Colin Crossfdea8932017-12-06 14:38:40 -0800586 $(hide) build/make/tools/dump-package-stats $^ > $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700587endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800588
589.PHONY: package-stats
590package-stats: $(PACKAGE_STATS_FILE)
591
592# -----------------------------------------------------------------
593# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700594# Use a macro to add newline to each echo command
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100595define _apkcerts_write_line
596$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $5
597$(if $(4), $(hide) echo -n ' compressed="$4"' >> $5)
598$(hide) echo '' >> $5
Ying Wangd9a88d52012-10-26 09:21:28 -0700599
600endef
601
The Android Open Source Project88b60792009-03-03 19:28:42 -0800602name := $(TARGET_PRODUCT)
603ifeq ($(TARGET_BUILD_TYPE),debug)
604 name := $(name)_debug
605endif
606name := $(name)-apkcerts-$(FILE_NAME_TAG)
607intermediates := \
608 $(call intermediates-dir-for,PACKAGING,apkcerts)
609APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800610# We don't need to really build all the modules.
611# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700612$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800613 @echo APK certs list: $@
614 @mkdir -p $(dir $@)
615 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700616 $(foreach p,$(PACKAGES),\
617 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100618 $(call _apkcerts_write_line,$(p),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$@),\
619 $(call _apkcerts_write_line,$(p),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700620 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700621 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800622
623.PHONY: apkcerts-list
624apkcerts-list: $(APKCERTS_FILE)
625
Ying Wang15e487a2011-02-15 10:56:18 -0800626ifneq (,$(TARGET_BUILD_APPS))
627 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
628endif
Ying Wangefb21682010-07-23 16:42:13 -0700629
The Android Open Source Project88b60792009-03-03 19:28:42 -0800630# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700631# build system stats
632BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
633$(BUILD_SYSTEM_STATS):
634 @rm -f $@
635 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
636 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
637$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700638
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700639# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700640# Modules ready to be converted to Soong, ordered by how many
641# modules depend on them.
642SOONG_CONV := $(sort $(SOONG_CONV))
643SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
644$(SOONG_CONV_DATA):
645 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800646 @$(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 -0700647
Colin Crossfdea8932017-12-06 14:38:40 -0800648SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700649SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
650$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
651 @rm -f $@
652 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
653$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
654
655# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800656# Modules use -Wno-error, or added default -Wall -Werror
657WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
658$(WALL_WERROR):
659 @rm -f $@
660 echo "# Modules using -Wno-error" >> $@
661 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 -0800662 echo "# Modules added default -Wall" >> $@
663 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
664
665$(call dist-for-goals,droidcore,$(WALL_WERROR))
666
667# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800668# Modules missing profile files
669PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
670$(PGO_PROFILE_MISSING):
671 @rm -f $@
672 echo "# Modules missing PGO profile files" >> $@
673 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
674
675$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
676
677# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700678# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700679# for future OTA packages installed by this system. Actual product
680# deliverables will be re-signed by hand. We expect this file to
681# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700682DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700683
684
Jeff Browne33ba4c2011-07-11 22:11:46 -0700685# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800686# if they don't do anything.
687.PHONY: systemimage
688systemimage:
689
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800690# -----------------------------------------------------------------
691
692.PHONY: event-log-tags
693
Joe Onoratob7510532010-07-14 10:22:54 -0700694# Produce an event logs tag file for everything we know about, in order
695# to properly allocate numbers. Then produce a file that's filtered
696# for what's going to be installed.
697
698all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
699
Colin Crossdc8f8e42012-04-12 13:25:54 -0700700event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
701
Joe Onoratob7510532010-07-14 10:22:54 -0700702# Include tags from all packages that we know about
703all_event_log_tags_src := \
704 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
705
Colin Crossdc8f8e42012-04-12 13:25:54 -0700706# PDK builds will already have a full list of tags that needs to get merged
707# in with the ones from source
708pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
709
710$(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 -0800711$(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 -0700712 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900713 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700714
Doug Zongkera34fa952011-02-23 12:17:29 -0800715# Include tags from all packages included in this product, plus all
716# tags that are part of the system (ie, not in a vendor/ or device/
717# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800718event_log_tags_src := \
719 $(sort $(foreach m,\
720 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
721 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800722 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
723 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800724
Colin Crossdc8f8e42012-04-12 13:25:54 -0700725$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700726$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800727$(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 -0800728 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900729 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800730
731event-log-tags: $(event_log_tags_file)
732
733ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
734
Joe Onoratob7510532010-07-14 10:22:54 -0700735
The Android Open Source Project88b60792009-03-03 19:28:42 -0800736# #################################################################
737# Targets for boot/OS images
738# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800739ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
740 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
741 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
742 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
743 else
744 INSTALLED_2NDBOOTLOADER_TARGET :=
745 endif
746else
747 INSTALLED_BOOTLOADER_MODULE :=
748 INSTALLED_2NDBOOTLOADER_TARGET :=
749endif # TARGET_NO_BOOTLOADER
750ifneq ($(strip $(TARGET_NO_KERNEL)),true)
751 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
752else
753 INSTALLED_KERNEL_TARGET :=
754endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800755
756# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700757# the root dir
758INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800759 $(ALL_GENERATED_SOURCES) \
760 $(ALL_DEFAULT_INSTALLED_MODULES))
761
Luis Hector Chavezff489932018-07-03 15:41:40 -0700762INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
763INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
764$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700765$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700766 @echo Installed file list: $@
767 @mkdir -p $(dir $@)
768 @rm -f $@
769 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
770 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
771
772$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
773
Tom Cherryd14b8952018-08-09 14:26:00 -0700774# -----------------------------------------------------------------
775# the ramdisk
776INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
777 $(ALL_GENERATED_SOURCES) \
778 $(ALL_DEFAULT_INSTALLED_MODULES))
779
780INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
781INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
782$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
783$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST)
784 @echo Installed file list: $@
785 @mkdir -p $(dir $@)
786 @rm -f $@
787 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
788 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
789
790$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700791BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
792
793# We just build this directly to the install location.
794INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Tom Cherryd14b8952018-08-09 14:26:00 -0700795$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800796 $(call pretty,"Target ram disk: $@")
Tom Cherryd14b8952018-08-09 14:26:00 -0700797 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800798
Ying Wangad7fd292013-08-08 16:34:29 -0700799.PHONY: ramdisk-nodeps
800ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
801 @echo "make $@: ignoring dependencies"
Tom Cherryd14b8952018-08-09 14:26:00 -0700802 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800803
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700804INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
805
The Android Open Source Project88b60792009-03-03 19:28:42 -0800806ifneq ($(strip $(TARGET_NO_KERNEL)),true)
807
808# -----------------------------------------------------------------
809# the boot image, which is a collection of other images.
810INTERNAL_BOOTIMAGE_ARGS := \
811 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700812 --kernel $(INSTALLED_KERNEL_TARGET)
813
814ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
815INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
816endif
817
The Android Open Source Project88b60792009-03-03 19:28:42 -0800818INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
819
Dima Zavin1e0847c2009-05-07 19:43:08 -0700820ifdef BOARD_KERNEL_BASE
821 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
822endif
823
Ying Wangffff0022010-08-23 12:56:25 -0700824ifdef BOARD_KERNEL_PAGESIZE
825 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
826endif
827
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700828ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
829ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
830VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
831 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
832endif
833endif
834
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700835INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
836ifdef INTERNAL_KERNEL_CMDLINE
837INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700838endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700839
Sami Tolvanen3303d902016-03-15 16:49:30 +0000840INTERNAL_MKBOOTIMG_VERSION_ARGS := \
841 --os_version $(PLATFORM_VERSION) \
842 --os_patch_level $(PLATFORM_SECURITY_PATCH)
843
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800844# BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true.
845ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
846ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
847 $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.)
848endif
849endif
850
851# We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true.
852ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800853ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800854$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400855
856else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
857
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800858$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400859 $(call pretty,"Target boot image: $@")
860 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800861 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400862 $(hide) $(AVBTOOL) add_hash_footer \
863 --image $@ \
864 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800865 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400866 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
867
868.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800869bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400870 @echo "make $@: ignoring dependencies"
871 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800872 $(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 -0400873 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800874 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400875 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800876 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400877 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
878
879else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700880
881$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
882 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000883 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800884 $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -0700885 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
886
887.PHONY: bootimage-nodeps
888bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
889 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000890 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800891 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET)
Geremy Condra740b6632014-07-08 20:07:41 -0700892 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
893
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100894else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800895
Tao Bao4b577412017-02-22 22:54:39 -0800896$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800897 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000898 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700899 $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@
David Riley17be3d32015-03-03 08:54:11 -0800900 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
901
902.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800903bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800904 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000905 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700906 $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
David Riley17be3d32015-03-03 08:54:11 -0800907 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
908
909else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800910
911$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
912 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000913 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700914 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700915
916.PHONY: bootimage-nodeps
917bootimage-nodeps: $(MKBOOTIMG)
918 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000919 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700920 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700921
The Android Open Source Project88b60792009-03-03 19:28:42 -0800922endif # TARGET_BOOTIMAGE_USE_EXT2
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800923endif # BOARD_USES_RECOVERY_AS_BOOT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800924
Tao Baob1a2e352018-08-14 16:17:12 -0700925else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700926ifdef BOARD_PREBUILT_BOOTIMAGE
927ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
928# Remove when b/63676296 is resolved.
929$(error Prebuilt bootimage is only supported for AB targets)
930endif
931$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700932else # BOARD_PREBUILT_BOOTIMAGE not defined
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700933INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
Tao Baob1a2e352018-08-14 16:17:12 -0700934INSTALLED_BOOTIMAGE_TARGET :=
935endif # BOARD_PREBUILT_BOOTIMAGE
936endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800937
938# -----------------------------------------------------------------
939# NOTICE files
940#
Steve Blockd14d3b42012-03-01 11:34:41 +0000941# We are required to publish the licenses for all code under BSD, GPL and
942# Apache licenses (and possibly other more exotic ones as well). We err on the
943# side of caution, so the licenses for other third-party code are included here
944# too.
945#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800946# This needs to be before the systemimage rules, because it adds to
947# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
948# go into the systemimage.
949
Steve Block495e5852012-02-29 19:18:08 +0000950.PHONY: notice_files
951
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900952# Create the rule to combine the files into text and html/xml forms
Dario Freniadc972d2018-07-09 18:38:38 +0100953# $(1) - xml_excluded_vendor_product|xml_vendor|xml_product|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900954# $(2) - Plain text output file
955# $(3) - HTML/XML output file
956# $(4) - File title
957# $(5) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800958# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900959# $(6) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800960#
961# The algorithm here is that we go collect a hash for each of the notice
962# files and write the names of the files that match that hash. Then
963# to generate the real files, we go print out all of the files and their
964# hashes.
965#
966# These rules are fairly complex, so they depend on this makefile so if
967# it changes, they'll run again.
968#
969# TODO: We could clean this up so that we just record the locations of the
970# original notice files instead of making rules to copy them somwehere.
971# Then we could traverse that without quite as much bash drama.
972define combine-notice-files
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900973$(2) $(3): PRIVATE_MESSAGE := $(4)
974$(2) $(3): PRIVATE_DIR := $(5)
975$(2) : $(3)
Colin Crossfdea8932017-12-06 14:38:40 -0800976$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
977 build/make/tools/generate-notice-files.py --text-output $(2) \
Dario Freniadc972d2018-07-09 18:38:38 +0100978 $(if $(filter $(1),xml_excluded_vendor_product),-e vendor$(comma)product --xml-output, \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900979 $(if $(filter $(1),xml_vendor),-i vendor --xml-output, \
Dario Freniadc972d2018-07-09 18:38:38 +0100980 $(if $(filter $(1),xml_product),-i product --xml-output, \
981 --html-output))) $(3) \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900982 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
983notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800984endef
985
986# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
987# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
988# the src subdirectory.
989
Steve Block495e5852012-02-29 19:18:08 +0000990target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900991target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
992target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
993installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000994tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800995tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
996
Steven Morelandae69e572017-12-15 14:49:55 -0800997# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
998ifeq ($(PRODUCT_NOTICE_SPLIT),true)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900999target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1000target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
1001installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1002
1003target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1004target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1005target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1006installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001007
1008target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1009target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1010target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1011installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001012endif
1013
Ying Wang62c81f82013-08-22 20:02:03 -07001014ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Josh Gao4d9268e2017-02-23 13:17:46 -08001016winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
Ying Wang4534d812012-04-09 17:04:12 -07001017pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001018
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001019ifdef target_vendor_notice_file_xml_gz
Dario Freniadc972d2018-07-09 18:38:38 +01001020$(eval $(call combine-notice-files, xml_excluded_vendor_product, \
Steve Block495e5852012-02-29 19:18:08 +00001021 $(target_notice_file_txt), \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001022 $(target_notice_file_html_or_xml), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001023 "Notices for files contained in the filesystem images in this directory:", \
1024 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -07001025 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001026$(eval $(call combine-notice-files, xml_vendor, \
1027 $(target_vendor_notice_file_txt), \
1028 $(target_vendor_notice_file_xml), \
1029 "Notices for files contained in the vendor filesystem image in this directory:", \
1030 $(TARGET_OUT_NOTICE_FILES), \
1031 $(target_notice_file_html_or_xml)))
Dario Freniadc972d2018-07-09 18:38:38 +01001032ifdef target_product_notice_file_txt
1033$(eval $(call combine-notice-files, xml_product, \
1034 $(target_product_notice_file_txt), \
1035 $(target_product_notice_file_xml), \
1036 "Notices for files contained in the product filesystem image in this directory:", \
1037 $(TARGET_OUT_NOTICE_FILES), \
1038 $(target_notice_file_html_or_xml)))
1039endif
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001040else
1041$(eval $(call combine-notice-files, html, \
1042 $(target_notice_file_txt), \
1043 $(target_notice_file_html_or_xml), \
1044 "Notices for files contained in the filesystem images in this directory:", \
1045 $(TARGET_OUT_NOTICE_FILES), \
1046 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
1047endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001048
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001049$(eval $(call combine-notice-files, html, \
Steve Block495e5852012-02-29 19:18:08 +00001050 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001051 $(tools_notice_file_html), \
1052 "Notices for files contained in the tools directory:", \
1053 $(HOST_OUT_NOTICE_FILES), \
Josh Gao4d9268e2017-02-23 13:17:46 -08001054 $(ALL_DEFAULT_INSTALLED_MODULES) \
1055 $(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001056
1057# Install the html file at /system/etc/NOTICE.html.gz.
1058# This is not ideal, but this is very late in the game, after a lot of
1059# the module processing has already been done -- in fact, we used the
1060# fact that all that has been done to get the list of modules that we
1061# need notice files for.
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001062$(target_notice_file_html_or_xml_gz): $(target_notice_file_html_or_xml) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -07001063 $(hide) $(MINIGZIP) -9 < $< > $@
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001064$(installed_notice_html_or_xml_gz): $(target_notice_file_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001065 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -07001066
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001067ifdef target_vendor_notice_file_xml_gz
1068# Install the vendor html file at /vendor/etc/NOTICE.xml.gz.
1069$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1070 $(hide) $(MINIGZIP) -9 < $< > $@
1071$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1072 $(copy-file-to-target)
1073endif
1074
Dario Freniadc972d2018-07-09 18:38:38 +01001075ifdef target_product_notice_file_xml_gz
1076# Install the product html file at /product/etc/NOTICE.xml.gz.
1077$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1078 $(hide) $(MINIGZIP) -9 < $< > $@
1079$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1080 $(copy-file-to-target)
1081endif
1082
Joe Onorato7b2845a2009-04-30 13:52:50 -07001083# if we've been run my mm, mmm, etc, don't reinstall this every time
1084ifeq ($(ONE_SHOT_MAKEFILE),)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001085 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1086 ifdef target_vendor_notice_file_xml_gz
1087 ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1088 endif
Dario Freniadc972d2018-07-09 18:38:38 +01001089 ifdef target_product_notice_file_xml_gz
1090 ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1091 endif
Joe Onorato7b2845a2009-04-30 13:52:50 -07001092endif
Ying Wang62c81f82013-08-22 20:02:03 -07001093endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001094
1095# The kernel isn't really a module, so to get its module file in there, we
1096# make the target NOTICE files depend on this particular file too, which will
1097# then be in the right directory for the find in combine-notice-files to work.
1098$(kernel_notice_file): \
Lee Campbellb463fcd2015-11-08 16:28:15 -08001099 $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001100 | $(ACP)
1101 @echo Copying: $@
1102 $(hide) mkdir -p $(dir $@)
1103 $(hide) $(ACP) $< $@
1104
Josh Gao4d9268e2017-02-23 13:17:46 -08001105$(winpthreads_notice_file): \
1106 $(BUILD_SYSTEM)/WINPTHREADS_COPYING \
1107 | $(ACP)
1108 @echo Copying: $@
1109 $(hide) mkdir -p $(dir $@)
1110 $(hide) $(ACP) $< $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001111
Doug Zongker8678df42009-06-15 14:30:14 -07001112# -----------------------------------------------------------------
1113# Build a keystore with the authorized keys in it, used to verify the
1114# authenticity of downloaded OTA packages.
1115#
1116# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
1117# before the rules that use that variable to build the image.
Dan Willemsenb589ae42015-10-29 21:26:18 +00001118ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
1119$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001120$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME)
Doug Zongker8678df42009-06-15 14:30:14 -07001121 $(hide) rm -f $@
1122 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001123 $(hide) zip -qjX $@ $<
1124 $(remove-timestamps-from-package)
Doug Zongker8678df42009-06-15 14:30:14 -07001125
Alex Deymocec578c2017-03-28 20:48:18 -07001126# Carry the public key for update_engine if it's a non-IoT target that
Tao Bao38812d62016-01-20 20:58:20 -08001127# uses the AB updater. We use the same key as otacerts but in RSA public key
1128# format.
1129ifeq ($(AB_OTA_UPDATER),true)
Alex Deymocec578c2017-03-28 20:48:18 -07001130ifneq ($(PRODUCT_IOT),true)
Tao Bao23c3db92016-01-21 14:28:50 -08001131ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
1132$(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Tao Bao38812d62016-01-20 20:58:20 -08001133 $(hide) rm -f $@
1134 $(hide) mkdir -p $(dir $@)
1135 $(hide) openssl x509 -pubkey -noout -in $< > $@
Alex Deymoc6ebe9f2016-08-03 20:52:54 -07001136
Tao Bao696bb332018-08-17 16:27:01 -07001137ALL_DEFAULT_INSTALLED_MODULES += \
1138 $(TARGET_RECOVERY_ROOT_OUT)/system/etc/update_engine/update-payload-key.pub.pem
1139$(TARGET_RECOVERY_ROOT_OUT)/system/etc/update_engine/update-payload-key.pub.pem: \
1140 $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
Alex Deymoc6ebe9f2016-08-03 20:52:54 -07001141 $(hide) cp -f $< $@
Tao Bao38812d62016-01-20 20:58:20 -08001142endif
1143endif
1144
Doug Zongker8678df42009-06-15 14:30:14 -07001145.PHONY: otacerts
1146otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
1147
1148
The Android Open Source Project88b60792009-03-03 19:28:42 -08001149# #################################################################
1150# Targets for user images
1151# #################################################################
1152
Ying Wang933abf12010-06-16 14:31:34 -07001153INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001154ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001155INTERNAL_USERIMAGES_USE_EXT := true
1156INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1157else
1158ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
1159INTERNAL_USERIMAGES_USE_EXT := true
1160INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1161else
1162ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
1163INTERNAL_USERIMAGES_USE_EXT := true
1164INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1165endif
1166endif
1167endif
1168
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001169# These options tell the recovery updater/installer how to mount the partitions writebale.
1170# <fstype>=<fstype_opts>[|<fstype_opts>]...
1171# fstype_opts := <opt>[,<opt>]...
1172# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001173# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1174DEFAULT_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 -07001175
Ying Wang542903a2010-11-17 15:40:38 -08001176ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1177 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1178endif
1179
Colin Cross0a7b2c52010-05-07 02:23:59 -07001180ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001181INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
1182INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
1183ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1184INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
1185endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001186endif
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001187
Chris Friesdf0387d2017-06-21 15:51:46 -05001188ifeq ($(BOARD_AVB_ENABLE),true)
1189INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1190endif
1191
Todd Poynorb2a555e2015-12-15 18:00:14 -08001192ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1193 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1194endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001195ifneq ($(filter $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) $(BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE) $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),)
Mohamad Ayyash353265b2015-06-24 15:42:19 -07001196INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001197endif
1198
Ying Wang178ef922011-10-31 18:13:30 -07001199INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001200
Colin Cross8a30f722014-04-28 16:27:32 -07001201ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001202INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001203ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC))
1204INTERNAL_USERIMAGES_DEPS += $(FEC)
1205endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001206endif
1207
Alex Klyubin092c9022017-03-13 13:28:34 -07001208SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001209INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1210
Mohamad Ayyashf8765552016-03-02 21:07:23 -08001211INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS)
1212
Jin Qianabcec5e2017-03-10 16:53:45 -08001213ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
1214INTERNAL_USERIMAGES_DEPS += $(MKE2FS_CONF)
1215endif
1216
Yifan Honga42e5f92018-07-31 13:30:38 -07001217ifeq (true,$(PRODUCT_USE_LOGICAL_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001218
1219ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
1220 $(error vboot 1.0 doesn't support logical partition)
1221endif
1222
1223# TODO(b/80195851): Should not define BOARD_AVB_SYSTEM_KEY_PATH without
1224# BOARD_AVB_SYSTEM_DETACHED_VBMETA.
1225
Yifan Honga42e5f92018-07-31 13:30:38 -07001226endif # PRODUCT_USE_LOGICAL_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001227
Ying Wangbd93d422011-10-28 17:02:30 -07001228# $(1): the path of the output dictionary file
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001229# $(2): a subset of "system vendor cache userdata product product_services oem odm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001230# $(3): additional "key=value" pairs to append to the dictionary file.
1231define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001232$(if $(filter $(2),system),\
1233 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
1234 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1235 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1236 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1237 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1238 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1239 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1240 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1241 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1242 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1243 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001244 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001245)
Yifan Hong760d3c02018-05-30 11:16:46 -07001246$(if $(filter $(2),userdata),\
1247 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1248 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
1249)
Yifan Hong760d3c02018-05-30 11:16:46 -07001250$(if $(filter $(2),cache),\
1251 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1252 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
1253)
1254$(if $(filter $(2),vendor),\
1255 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1256 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1257 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1258 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1259 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1260 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1261 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1262 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1263 $(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1264 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
Yifan Hong749062d2018-06-19 16:23:16 -07001265 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001266)
1267$(if $(filter $(2),product),\
1268 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1269 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1270 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1271 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1272 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1273 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1274 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1275 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1276 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_squashfs_disable_4k_align=$(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1277 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "product_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH)" >> $(1))
Yifan Hong56a6c3b2018-07-20 15:19:34 -07001278 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001279)
Yifan Hongebc041a2018-07-26 16:02:52 -07001280$(if $(filter $(2),product_services),\
1281 $(if $(BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_services_fs_type=$(BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1282 $(if $(BOARD_PRODUCT_SERVICESIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_services_extfs_inode_count=$(BOARD_PRODUCT_SERVICESIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1283 $(if $(BOARD_PRODUCT_SERVICESIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_services_extfs_rsv_pct=$(BOARD_PRODUCT_SERVICESIMAGE_EXTFS_RSV_PCT)" >> $(1))
1284 $(if $(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE),$(hide) echo "product_services_size=$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE)" >> $(1))
1285 $(if $(BOARD_PRODUCT_SERVICESIMAGE_JOURNAL_SIZE),$(hide) echo "product_services_journal_size=$(BOARD_PRODUCT_SERVICESIMAGE_JOURNAL_SIZE)" >> $(1))
1286 $(if $(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_services_squashfs_compressor=$(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1287 $(if $(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_services_squashfs_compressor_opt=$(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1288 $(if $(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_services_squashfs_block_size=$(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1289 $(if $(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_services_squashfs_disable_4k_align=$(BOARD_PRODUCT_SERVICESIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1290 $(if $(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_services_reserved_size=$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001291)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001292$(if $(filter $(2),odm),\
1293 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1294 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1295 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1296 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1297 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1298 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1299 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1300 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1301 $(if $(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_squashfs_disable_4k_align=$(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1302 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ODM_BASE_FS_PATH),$(hide) echo "odm_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ODM_BASE_FS_PATH)" >> $(1))
1303 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1304)
Yifan Hong760d3c02018-05-30 11:16:46 -07001305$(if $(filter $(2),oem),\
1306 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1307 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1308 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1309 $(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1310)
Tao Bao3602eca2018-07-10 10:53:55 -07001311$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001312
Tao Bao3602eca2018-07-10 10:53:55 -07001313$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001314$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001315$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001316$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1317$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1318$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001319$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +01001320$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -07001321$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
Paul Lawrencea37b2bb2014-11-13 17:54:30 -08001322$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
Claes Elgemarkec996042015-06-02 11:03:27 +02001323$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001324$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001325$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -07001326$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1327$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001328$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Yifan Hongebc041a2018-07-26 16:02:52 -07001329$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_SERVICES_VERITY_PARTITION),$(hide) echo "product_services_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_SERVICES_VERITY_PARTITION)" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -07001330$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1331$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
Furquan Shaikhe8c21222015-08-07 11:58:05 -07001332$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
Tao Bao9b524ef2017-02-23 11:03:45 -08001333$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -07001334$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001335$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001336$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1337$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1338$(if $(BOARD_AVB_ENABLE),\
1339 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1340 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1341 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1342 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
1343$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1344$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1345$(if $(BOARD_AVB_ENABLE),\
1346 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1347 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1348 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1349 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001350$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1351$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1352$(if $(BOARD_AVB_ENABLE),\
1353 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1354 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1355 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1356 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001357$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_services_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1358$(if $(BOARD_AVB_ENABLE),\
1359 $(hide) echo "avb_product_services_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_SERVICES_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001360$(if $(BOARD_AVB_ENABLE),\
1361 $(if $(BOARD_AVB_PRODUCT_SERVICES_KEY_PATH),\
Yifan Hongebc041a2018-07-26 16:02:52 -07001362 $(hide) echo "avb_product_services_key_path=$(BOARD_AVB_PRODUCT_SERVICES_KEY_PATH)" >> $(1)
1363 $(hide) echo "avb_product_services_algorithm=$(BOARD_AVB_PRODUCT_SERVICES_ALGORITHM)" >> $(1)
1364 $(hide) echo "avb_product_services_rollback_index_location=$(BOARD_AVB_PRODUCT_SERVICES_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001365$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1366$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1367$(if $(BOARD_AVB_ENABLE),\
1368 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1369 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1370 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1371 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001372$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1373 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001374$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001375 $(hide) echo "system_root_image=true" >> $(1))
1376$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Yifan Hong2dae5722018-07-31 12:47:27 -07001377$(if $(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),$(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001378$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1379endef
1380
1381# $(1): the path of the output dictionary file
1382# $(2): additional "key=value" pairs to append to the dictionary file.
1383define generate-userimage-prop-dictionary
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001384$(call generate-image-prop-dictionary,$(1),system vendor cache userdata product product_services oem odm,$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001385endef
1386
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001387# $(1): the path of the input dictionary file, where each line has the format key=value
1388# $(2): the key to look up
1389define read-image-prop-dictionary
1390$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1391endef
1392
Xu Chao2b04bf42017-07-06 14:34:31 +08001393# $(1): modules list
1394# $(2): output dir
1395# $(3): mount point
1396# $(4): staging dir
1397# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
1398define build-image-kernel-modules
1399 $(hide) rm -rf $(2)/lib/modules
1400 $(hide) mkdir -p $(2)/lib/modules
1401 $(hide) cp $(1) $(2)/lib/modules/
1402 $(hide) rm -rf $(4)
1403 $(hide) mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules
1404 $(hide) cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules
1405 $(hide) $(DEPMOD) -b $(4) 0.0
1406 $(hide) sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules/modules.dep
1407 $(hide) cp $(4)/lib/modules/0.0/modules.alias $(2)/lib/modules
1408endef
1409
The Android Open Source Project88b60792009-03-03 19:28:42 -08001410# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001411# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001412
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001413# Recovery image exists if we are building recovery, or building recovery as boot.
1414ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Doug Zongker4647f122009-07-02 09:00:54 -07001415
Ying Wang37526142015-03-10 12:02:57 -07001416INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1417 $(ALL_DEFAULT_INSTALLED_MODULES))
1418
Tao Bao10fc9492018-08-14 12:17:48 -07001419INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1420INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1421
1422# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1423# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1424# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1425# the call to FILELIST.
1426ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1427$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1428else
1429$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1430endif
1431
1432$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
1433$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST)
1434 @echo Installed file list: $@
1435 @mkdir -p $(dir $@)
1436 @rm -f $@
1437 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
1438 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
1439
Doug Zongker4647f122009-07-02 09:00:54 -07001440recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001441recovery_sepolicy := \
1442 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001443 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Bowgo Tsai09f88a62018-02-05 17:32:20 +08001444 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001445 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai09f88a62018-02-05 17:32:20 +08001446 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts
1447
Bowgo Tsai99671252017-11-30 22:15:17 +08001448ifdef BOARD_ODM_SEPOLICY_DIRS
1449recovery_sepolicy += \
1450 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
1451 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts
1452endif
1453
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001454# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1455# SELinux files
1456IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1457
Doug Zongker4647f122009-07-02 09:00:54 -07001458recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1459recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Doug Zongker4647f122009-07-02 09:00:54 -07001460recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001461
Doug Zongker8eaeea92014-05-12 15:32:20 -07001462# Set recovery_density to the density bucket of the device.
1463recovery_density := unknown
1464ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
1465# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
1466recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
Doug Zongker25d55f82014-04-04 13:51:15 -07001467else
Adam Lesinski83ee6d72014-12-02 16:13:09 -08001468# Otherwise, use the default medium density.
1469recovery_densities := mdpi
Doug Zongker8eaeea92014-05-12 15:32:20 -07001470endif
1471
1472ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1473recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1474else
Doug Zongker25d55f82014-04-04 13:51:15 -07001475recovery_resources_common := $(recovery_resources_common)-xhdpi
1476endif
1477
Doug Zongker8eaeea92014-05-12 15:32:20 -07001478# Select the 18x32 font on high-density devices (xhdpi and up); and
1479# the 12x22 font on other devices. Note that the font selected here
1480# can be overridden for a particular device by putting a font.png in
1481# its private recovery resources.
1482
Tao Baoabbc9112015-04-08 14:14:43 -07001483ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001484recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1485else
1486recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1487endif
1488
Ying Wang9a175682015-08-06 11:47:47 -07001489ifndef TARGET_PRIVATE_RES_DIRS
1490TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1491endif
Doug Zongker4647f122009-07-02 09:00:54 -07001492recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001493 $(TARGET_PRIVATE_RES_DIRS) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -07001494ifdef TARGET_RECOVERY_FSTAB
1495recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1496else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001497recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001498endif
Tao Baoc3c17532016-06-10 10:11:54 -07001499ifdef TARGET_RECOVERY_WIPE
1500recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001501else
Tao Baoc3c17532016-06-10 10:11:54 -07001502recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001503endif
Tao Bao8beab692015-07-22 12:33:18 -07001504
Tao Bao6d5d6232018-03-09 17:04:42 -08001505# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001506# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001507# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1508# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001509#
1510# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001511# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001512# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001513# b) We build a single image that contains boot and recovery both - no recovery image to install
1514# (BOARD_USES_RECOVERY_AS_BOOT = true);
1515# c) We build the root into system image - not needing the resource file as we do bsdiff
1516# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001517# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1518# do bsdiff because boot and recovery will contain different number of entries
1519# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Tao Bao6d5d6232018-03-09 17:04:42 -08001520# Note that condition b) implies condition c), because of the earlier check in this file:
1521# "BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true" (not vice
1522# versa though).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001523
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001524ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) \
1525 $(BOARD_INCLUDE_RECOVERY_DTBO)))
Doug Zongker56588872012-08-20 15:38:58 -07001526# Named '.dat' so we don't attempt to use imgdiff for patching it.
1527RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Tao Bao8beab692015-07-22 12:33:18 -07001528else
Tao Bao8beab692015-07-22 12:33:18 -07001529RECOVERY_RESOURCE_ZIP :=
1530endif
Doug Zongker4647f122009-07-02 09:00:54 -07001531
Tao Bao139c7272018-07-31 13:26:54 -07001532INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1533
1534$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
1535 TARGET_RECOVERY_DEFAULT_ROTATION:default_rotation \
1536 TARGET_RECOVERY_OVERSCAN_PERCENT:overscan_percent \
1537 TARGET_RECOVERY_PIXEL_FORMAT:pixel_format \
1538 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1539 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1540 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1541 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1542 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1543 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1544 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1545 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1546
1547# Parses the given list of build variables and writes their values as build properties if defined.
1548# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1549# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1550# $(1): Map from the build variable names to property names
1551# $(2): Output file
1552define append-recovery-ui-properties
1553echo "#" >> $(2)
1554echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1555echo "#" >> $(2)
1556$(foreach prop,$(1), \
1557 $(eval _varname := $(call word-colon,1,$(prop))) \
1558 $(eval _propname := $(call word-colon,2,$(prop))) \
1559 $(eval _value := $($(_varname))) \
1560 $(if $(_value), \
1561 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1562endef
1563
1564$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
1565 $(INSTALLED_DEFAULT_PROP_TARGET) \
1566 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
Tao Bao6eb1a992018-08-06 07:33:45 -07001567 $(intermediate_system_build_prop) \
Tao Bao139c7272018-07-31 13:26:54 -07001568 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001569 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
Tao Bao139c7272018-07-31 13:26:54 -07001570 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
1571 $(INSTALLED_PRODUCT_SERVICES_BUILD_PROP_TARGET)
1572 @echo "Target recovery buildinfo: $@
1573 $(hide) mkdir -p $(dir $@)
1574 $(hide) rm -f $@
1575 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) > $@
1576 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) >> $@
Tao Bao6eb1a992018-08-06 07:33:45 -07001577 $(hide) cat $(intermediate_system_build_prop) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001578 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001579 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001580 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
1581 $(hide) cat $(INSTALLED_PRODUCT_SERVICES_BUILD_PROP_TARGET) >> $@
1582 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1583
Doug Zongker4647f122009-07-02 09:00:54 -07001584INTERNAL_RECOVERYIMAGE_ARGS := \
1585 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
1586 --kernel $(recovery_kernel) \
1587 --ramdisk $(recovery_ramdisk)
1588
1589# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001590ifdef INTERNAL_KERNEL_CMDLINE
1591 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001592endif
1593ifdef BOARD_KERNEL_BASE
1594 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1595endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001596ifdef BOARD_KERNEL_PAGESIZE
1597 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1598endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001599ifdef BOARD_INCLUDE_RECOVERY_DTBO
1600 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1601endif
Doug Zongker4647f122009-07-02 09:00:54 -07001602
1603# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -07001604# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -07001605# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -07001606OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -07001607
1608# Generate a file containing the keys that will be read by the
1609# recovery binary.
1610RECOVERY_INSTALL_OTA_KEYS := \
1611 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
1612DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
1613$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -07001614$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -08001615$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
1616 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -07001617 @rm -rf $@
1618 @mkdir -p $(dir $@)
Colin Cross0851df82017-06-30 13:55:38 -07001619 $(JAVA) -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -07001620
Andres Moralesb8876e12015-05-06 20:44:22 -07001621RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id
Howard Chen1756f8d2017-02-22 17:27:10 +08001622
Ying Wang747b9f12015-01-30 14:05:22 -08001623# $(1): output file
1624define build-recoveryimage-target
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001625 # Making recovery image
Ying Wang747b9f12015-01-30 14:05:22 -08001626 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao696bb332018-08-17 16:27:01 -07001627 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001628 # Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001629 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
Tao Bao696bb332018-08-17 16:27:01 -07001630 $(hide) rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -07001631 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1632 $(hide) rsync -a $(TARGET_RAMDISK_OUT)/* $(TARGET_RECOVERY_ROOT_OUT)/)
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001633 # Modifying ramdisk contents...
Howard Chen1756f8d2017-02-22 17:27:10 +08001634 $(if $(BOARD_RECOVERY_KERNEL_MODULES), \
1635 $(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery)))
Bowgo Tsaib5b3bc62017-09-25 17:50:41 +08001636 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1637 $(hide) find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
Ying Wang747b9f12015-01-30 14:05:22 -08001638 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
Tao Baocf8853b2018-08-13 14:27:32 -07001639 $(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 -08001640 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1641 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1642 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1643 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07001644 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1645 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08001646 $(hide) $(foreach item,$(recovery_fstab), \
Tao Bao696bb332018-08-17 16:27:01 -07001647 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07001648 $(if $(strip $(recovery_wipe)), \
Tao Bao696bb332018-08-17 16:27:01 -07001649 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
Ying Wang747b9f12015-01-30 14:05:22 -08001650 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001651 $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07001652 $(BOARD_RECOVERY_IMAGE_PREPARE)
Thierry Strudel74a81e62015-07-09 09:54:55 -07001653 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Tao Baod95e9fd2015-03-29 23:07:41 -07001654 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001655 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
1656 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1) --id > $(RECOVERYIMAGE_ID_FILE))
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +01001657 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001658 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1659 $(BOOT_SIGNER) /boot $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1660 $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
1661 )\
1662 )
Tao Baod95e9fd2015-03-29 23:07:41 -07001663 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Furquan Shaikhe8c21222015-08-07 11:58:05 -07001664 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08001665 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
1666 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
1667 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001668 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1669 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
1670 $(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),\
1671 $(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 -08001672endef
1673
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001674ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Ying Wangbd07ad02016-03-10 12:57:33 -08001675ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER))
1676$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
1677endif
1678ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1679$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
1680endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001681ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001682$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001683endif
Tao Baof4866c72018-08-22 14:35:09 -07001684ifdef BOARD_INCLUDE_RECOVERY_DTBO
1685$(INSTALLED_BOOTIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
1686endif
1687
Jiyong Parkce3e34f2018-05-24 14:24:50 +09001688$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Tom Cherryd14b8952018-08-09 14:26:00 -07001689 $(INTERNAL_ROOT_FILES) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001690 $(INSTALLED_RAMDISK_TARGET) \
1691 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001692 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001693 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Tao Bao139c7272018-07-31 13:26:54 -07001694 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1695 $(recovery_resource_deps) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001696 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001697 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001698 $(BOARD_RECOVERY_KERNEL_MODULES) \
1699 $(DEPMOD)
Tao Baof4866c72018-08-22 14:35:09 -07001700 $(call pretty,"Target boot image from recovery: $@")
1701 $(call build-recoveryimage-target, $@)
1702endif # BOARD_USES_RECOVERY_AS_BOOT
1703
1704ifdef BOARD_INCLUDE_RECOVERY_DTBO
1705$(INSTALLED_RECOVERYIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001706endif
1707
Jiyong Parkce3e34f2018-05-24 14:24:50 +09001708$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
Tom Cherryd14b8952018-08-09 14:26:00 -07001709 $(INTERNAL_ROOT_FILES) \
Doug Zongker4647f122009-07-02 09:00:54 -07001710 $(INSTALLED_RAMDISK_TARGET) \
1711 $(INSTALLED_BOOTIMAGE_TARGET) \
Ying Wang37526142015-03-10 12:02:57 -07001712 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001713 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Doug Zongker4647f122009-07-02 09:00:54 -07001714 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Tao Bao139c7272018-07-31 13:26:54 -07001715 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1716 $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001717 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001718 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001719 $(BOARD_RECOVERY_KERNEL_MODULES) \
1720 $(DEPMOD)
Tao Baof4866c72018-08-22 14:35:09 -07001721 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07001722
Tao Bao4594d0e2015-12-22 09:47:46 -08001723ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001724$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001725 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001726 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1727 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001728endif
Doug Zongker56588872012-08-20 15:38:58 -07001729
Ying Wang747b9f12015-01-30 14:05:22 -08001730.PHONY: recoveryimage-nodeps
1731recoveryimage-nodeps:
1732 @echo "make $@: ignoring dependencies"
1733 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1734
Tao Bao8beab692015-07-22 12:33:18 -07001735else # INSTALLED_RECOVERYIMAGE_TARGET not defined
Doug Zongker56588872012-08-20 15:38:58 -07001736RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -07001737endif
1738
1739.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001740recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001741
Jiyong Park03eb0612017-10-04 21:22:41 +09001742ifneq ($(BOARD_NAND_PAGE_SIZE),)
1743$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001744endif
1745
Jiyong Park03eb0612017-10-04 21:22:41 +09001746ifneq ($(BOARD_NAND_SPARE_SIZE),)
1747$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001748endif
1749
Doug Zongker4647f122009-07-02 09:00:54 -07001750# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07001751# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08001752#
Ying Wang9c649a72012-08-08 15:27:00 -07001753# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
1754PDK_FUSION_SYSIMG_FILES := \
1755 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
1756 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001757
1758INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07001759 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07001760 $(ALL_DEFAULT_INSTALLED_MODULES) \
1761 $(PDK_FUSION_SYSIMG_FILES) \
Dan Willemsen0663f682018-03-06 14:07:21 -08001762 $(RECOVERY_RESOURCE_ZIP)) \
1763 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wang160b6702012-03-13 18:58:27 -07001764
Ying Wang82cceba2012-08-13 15:03:00 -07001765FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07001766
1767# ASAN libraries in the system image - add dependency.
1768ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07001769ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07001770 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
1771 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
1772 endif
1773endif
1774
Tom Cherryd14b8952018-08-09 14:26:00 -07001775FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07001776
Ying Wange5e8c5f2011-09-09 16:35:53 -07001777# -----------------------------------------------------------------
Steven Moreland627debe2018-05-01 09:54:21 -07001778# Final System VINTF manifest including fragments. This is not assembled
1779# on the device because it depends on everything in a given device
1780# image which defines a vintf_fragment.
1781
1782BUILT_ASSEMBLED_SYSTEM_MANIFEST := $(PRODUCT_OUT)/verified_assembled_system_manifest.xml
1783$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(HOST_OUT_EXECUTABLES)/assemble_vintf
1784$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(BUILT_VENDOR_MATRIX)
1785$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(BUILT_SYSTEM_MANIFEST)
1786$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(FULL_SYSTEMIMAGE_DEPS)
1787 @echo "Verifying system VINTF manifest."
1788 PRODUCT_ENFORCE_VINTF_MANIFEST=$(PRODUCT_ENFORCE_VINTF_MANIFEST) \
1789 $(HOST_OUT_EXECUTABLES)/assemble_vintf \
1790 -c $(BUILT_VENDOR_MATRIX) \
1791 -i $(BUILT_SYSTEM_MANIFEST) \
1792 $$([ -d $(TARGET_OUT)/etc/vintf/manifest ] && \
1793 find $(TARGET_OUT)/etc/vintf/manifest -type f -name "*.xml" | \
1794 sed "s/^/-i /" | tr '\n' ' ') -o $@
1795
1796# -----------------------------------------------------------------
Ying Wange5e8c5f2011-09-09 16:35:53 -07001797# installed file list
1798# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
1799# We put installed-files.txt ahead of image itself in the dependency graph
1800# so that we can get the size stat even if the build fails due to too large
1801# system image.
1802INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07001803INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
1804$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001805$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001806 @echo Installed file list: $@
1807 @mkdir -p $(dir $@)
1808 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001809 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001810 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07001811
1812.PHONY: installed-file-list
1813installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08001814
1815$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07001816
1817systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001818 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001819BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
1820
Ying Wang23898df2014-06-18 20:26:24 -07001821# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07001822ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07001823define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07001824$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
1825 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
1826 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
1827 exit 1; \
1828fi
Ying Wang23898df2014-06-18 20:26:24 -07001829$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
1830endef
1831else
1832define create-system-vendor-symlink
1833endef
1834endif
1835
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001836# Create symlink /system/product to /product if necessary.
1837ifdef BOARD_USES_PRODUCTIMAGE
1838define create-system-product-symlink
1839$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
1840 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
1841 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
1842 exit 1; \
1843fi
1844$(hide) ln -sf /product $(TARGET_OUT)/product
1845endef
1846else
1847define create-system-product-symlink
1848endef
1849endif
1850
Dario Freni924af7d2018-08-17 00:56:14 +01001851# Create symlink /system/product_services to /product_services if necessary.
Dario Freni5f681e12018-05-29 13:09:01 +01001852ifdef BOARD_USES_PRODUCT_SERVICESIMAGE
Dario Freni924af7d2018-08-17 00:56:14 +01001853define create-system-product_services-symlink
1854$(hide) if [ -d $(TARGET_OUT)/product_services ] && [ ! -h $(TARGET_OUT)/product_services ]; then \
1855 echo 'Non-symlink $(TARGET_OUT)/product_services detected!' 1>&2; \
1856 echo 'You cannot install files to $(TARGET_OUT)/product_services while building a separate product_services.img!' 1>&2; \
Dario Freni5f681e12018-05-29 13:09:01 +01001857 exit 1; \
1858fi
Dario Freni924af7d2018-08-17 00:56:14 +01001859$(hide) ln -sf /product_services $(TARGET_OUT)/product_services
Dario Freni5f681e12018-05-29 13:09:01 +01001860endef
1861else
Dario Freni924af7d2018-08-17 00:56:14 +01001862define create-system-product_services-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01001863endef
1864endif
1865
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001866# Create symlink /vendor/odm to /odm if necessary.
1867ifdef BOARD_USES_ODMIMAGE
1868define create-vendor-odm-symlink
1869$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
1870 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
1871 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
1872 exit 1; \
1873fi
1874$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
1875endef
1876else
1877define create-vendor-odm-symlink
1878endef
1879endif
1880
The Android Open Source Project88b60792009-03-03 19:28:42 -08001881# $(1): output file
1882define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07001883 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07001884 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001885 $(call create-system-product-symlink)
Dario Freni924af7d2018-08-17 00:56:14 +01001886 $(call create-system-product_services-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07001887 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07001888 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07001889 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001890 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001891 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001892 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001893 $(systemimage_intermediates)/generated_system_image_info.txt \
1894 || ( mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
Ying Wang45ff36e2014-08-13 12:36:05 -07001895 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08001896endef
1897
Steven Moreland627debe2018-05-01 09:54:21 -07001898$(BUILT_SYSTEMIMAGE): $(BUILT_ASSEMBLED_SYSTEM_MANIFEST)
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001899$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001900 $(call build-systemimage-target,$@)
1901
Tao Baoe9d61b02018-08-20 21:09:07 -07001902INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07001903SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001904
Tao Baoe9d61b02018-08-20 21:09:07 -07001905# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
1906# compatibility, in case device-specific Makefiles still refer to the old name.
1907INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
1908
Doug Zongker73ef8252009-07-23 15:12:53 -07001909# The system partition needs room for the recovery image as well. We
1910# now store the recovery image as a binary patch using the boot image
1911# as the source (since they are very similar). Generate the patch so
1912# we can see how big it's going to be, and include that in the system
1913# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07001914ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07001915ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07001916ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001917ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08001918diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
1919else
1920diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
1921endif
Doug Zongker73ef8252009-07-23 15:12:53 -07001922intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
1923RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08001924$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
1925$(RECOVERY_FROM_BOOT_PATCH): \
1926 $(INSTALLED_RECOVERYIMAGE_TARGET) \
1927 $(INSTALLED_BOOTIMAGE_TARGET) \
1928 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07001929 @echo "Construct recovery from boot"
1930 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08001931 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07001932else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
1933RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07001934endif # BOARD_USES_FULL_RECOVERY_IMAGE
1935endif # INSTALLED_RECOVERYIMAGE_TARGET
1936endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07001937
Tao Baoe9d61b02018-08-20 21:09:07 -07001938$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001939 @echo "Install system fs image: $@"
1940 $(copy-file-to-target)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001941 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),\
1942 $(call read-image-prop-dictionary,\
1943 $(systemimage_intermediates)/generated_system_image_info.txt,system_size))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001944
Tao Baoe9d61b02018-08-20 21:09:07 -07001945systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001946
1947.PHONY: systemimage-nodeps snod
1948systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07001949 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001950 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07001951 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
1952 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),\
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001953 $(call read-image-prop-dictionary,\
1954 $(systemimage_intermediates)/generated_system_image_info.txt,system_size))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001955
Ying Wangacf01ec2012-02-24 11:05:48 -08001956ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
1957ifeq (true,$(WITH_DEXPREOPT))
1958$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
1959endif
1960endif
1961
Colin Cross91a52272017-06-20 16:57:52 -07001962.PHONY: sync
1963sync: $(INTERNAL_SYSTEMIMAGE_FILES)
1964
The Android Open Source Project88b60792009-03-03 19:28:42 -08001965#######
1966## system tarball
1967define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -07001968 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
1969 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001970 $(call create-system-product-symlink)
Dario Freni924af7d2018-08-17 00:56:14 +01001971 $(call create-system-product_services-symlink)
Ying Wang23898df2014-06-18 20:26:24 -07001972 $(MKTARBALL) $(FS_GET_STATS) \
1973 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001974 $(INSTALLED_SYSTEMTARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001975endef
1976
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001977ifndef SYSTEM_TARBALL_FORMAT
1978 SYSTEM_TARBALL_FORMAT := bz2
1979endif
1980
The Android Open Source Project88b60792009-03-03 19:28:42 -08001981system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001982INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001983$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
1984$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
1985 $(build-systemtarball-target)
1986
1987.PHONY: systemtarball-nodeps
1988systemtarball-nodeps: $(FS_GET_STATS) \
1989 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
1990 $(build-systemtarball-target)
1991
1992.PHONY: stnod
1993stnod: systemtarball-nodeps
1994
Ying Wang3a61eeb2016-03-11 10:32:01 -08001995# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07001996## platform.zip: system, plus other files to be used in PDK fusion build,
1997## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07001998##
1999## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2000## The variable will be typically set from BoardConfig.mk.
2001## Files under out dir will be rejected to prevent possible conflicts with other rules.
Ying Wang3a61eeb2016-03-11 10:32:01 -08002002pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
2003 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
2004pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
2005 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
2006pdk_classes_dex := $(strip \
2007 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
2008 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk))
2009
2010pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2011$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2012$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2013$(pdk_odex_config_mk) :
2014 @echo "PDK odex config makefile: $@"
2015 $(hide) mkdir -p $(dir $@)
2016 $(hide) echo "# Auto-generated. Do not modify." > $@
2017 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2018 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2019 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2020 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2021 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2022 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2023 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2024 )
2025 $(foreach m,$(PRIVATE_APPS),\
2026 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\
2027 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2028 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2029 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2030 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002031 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002032 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2033 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2034 )
2035
keunyoungc0178062013-07-22 14:54:58 -07002036PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002037INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002038
2039$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2040$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
2041$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk)
Keun young Park816b9fd2012-05-16 10:32:41 -07002042 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07002043 $(hide) rm -f $@
Dan Willemsen48a621c2015-10-29 16:33:05 -07002044 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wang4534d812012-04-09 17:04:12 -07002045 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07002046 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
2047 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Ying Wangcff38622014-07-16 17:46:35 -07002048ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
Dan Willemsen48a621c2015-10-29 16:33:05 -07002049 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wangcff38622014-07-16 17:46:35 -07002050 $(TARGET_COPY_OUT_VENDOR)
2051endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002052ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2053 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
2054 $(TARGET_COPY_OUT_PRODUCT)
2055endif
Dario Freni5f681e12018-05-29 13:09:01 +01002056ifdef BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE
2057 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
2058 $(TARGET_COPY_OUT_PRODUCT_SERVICES)
2059endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002060ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
2061 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
2062 $(TARGET_COPY_OUT_ODM)
2063endif
Colin Crossc451a372013-12-18 19:36:44 -08002064ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002065 $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07002066endif
keunyoungc0178062013-07-22 14:54:58 -07002067ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002068 $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
keunyoungc0178062013-07-22 14:54:58 -07002069endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002070 @# Add dex-preopt files and config.
2071 $(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES)))
Dan Willemsen0663f682018-03-06 14:07:21 -08002072 $(hide) touch $(PRODUCT_OUT)/pdk.mk
2073 $(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG) $(PRODUCT_OUT)/pdk.mk
Ying Wang4c289e52012-03-30 13:52:54 -07002074
2075.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002076platform: $(INSTALLED_PLATFORM_ZIP)
2077
2078.PHONY: platform-java
2079platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002080
2081# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002082ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2083$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002084endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002085
Ying Wang3a61eeb2016-03-11 10:32:01 -08002086# -----------------------------------------------------------------
Bruce Beare52aac202010-06-04 15:24:49 -07002087## boot tarball
2088define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07002089 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07002090 $(hide) mkdir -p $(PRODUCT_OUT)/boot
2091 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002092 $(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
Bruce Beare52aac202010-06-04 15:24:49 -07002093 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
2094 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07002095 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
Bruce Beare52aac202010-06-04 15:24:49 -07002096endef
2097
2098ifndef BOOT_TARBALL_FORMAT
2099 BOOT_TARBALL_FORMAT := bz2
2100endif
2101
2102boot_tar := $(PRODUCT_OUT)/boot.tar
2103INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
2104$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
2105$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
2106 $(build-boottarball-target)
2107
2108.PHONY: boottarball-nodeps btnod
2109boottarball-nodeps btnod: $(FS_GET_STATS) \
2110 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
2111 $(build-boottarball-target)
2112
2113
The Android Open Source Project88b60792009-03-03 19:28:42 -08002114# -----------------------------------------------------------------
2115# data partition image
2116INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002117 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002118
Ying Wangd7321d32013-03-15 10:32:29 -07002119# Don't build userdata.img if it's extfs but no partition size
2120skip_userdata.img :=
2121ifdef INTERNAL_USERIMAGES_EXT_VARIANT
2122ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
2123skip_userdata.img := true
2124endif
2125endif
2126
2127ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07002128userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002129 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002130BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2131
Ying Wangbd93d422011-10-28 17:02:30 -07002132define build-userdataimage-target
2133 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2134 @mkdir -p $(TARGET_OUT_DATA)
2135 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002136 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07002137 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08002138 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07002139 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07002140 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002141endef
2142
Joe Onorato64d85d02009-04-09 19:31:12 -07002143# We just build this directly to the install location.
2144INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002145INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2146 $(INTERNAL_USERIMAGES_DEPS) \
2147 $(INTERNAL_USERDATAIMAGE_FILES) \
2148 $(BUILD_IMAGE_SRCS)
2149$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002150 $(build-userdataimage-target)
2151
2152.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002153userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002154 $(build-userdataimage-target)
2155
Ying Wangd7321d32013-03-15 10:32:29 -07002156endif # not skip_userdata.img
2157skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07002158
Andreas Gampe039b5c72017-03-24 16:06:31 -07002159# ASAN libraries in the system image - build rule.
2160ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2161 $(TARGET_OUT_SHARED_LIBRARIES) \
2162 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2163 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2164 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002165# Extra options: Enforce the system user for the files to avoid having to change ownership.
2166ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002167# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2168# enough space.
2169$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002170 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 -07002171
The Android Open Source Project88b60792009-03-03 19:28:42 -08002172#######
2173## data partition tarball
2174define build-userdatatarball-target
2175 $(call pretty,"Target userdata fs tarball: " \
2176 "$(INSTALLED_USERDATATARBALL_TARGET)")
2177 $(MKTARBALL) $(FS_GET_STATS) \
2178 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07002179 $(INSTALLED_USERDATATARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002180endef
2181
2182userdata_tar := $(PRODUCT_OUT)/userdata.tar
2183INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
2184$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
2185$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
2186 $(build-userdatatarball-target)
2187
Dan Willemsen69af2e42016-08-16 16:36:05 -07002188$(call dist-for-goals,userdatatarball,$(INSTALLED_USERDATATARBALL_TARGET))
2189
The Android Open Source Project88b60792009-03-03 19:28:42 -08002190.PHONY: userdatatarball-nodeps
2191userdatatarball-nodeps: $(FS_GET_STATS)
2192 $(build-userdatatarball-target)
2193
2194
The Android Open Source Project88b60792009-03-03 19:28:42 -08002195# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002196# partition table image
2197ifdef BOARD_BPT_INPUT_FILES
2198
2199BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002200BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002201
2202INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2203 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002204 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002205 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2206
2207ifdef BOARD_BPT_DISK_SIZE
2208INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2209endif
2210
2211define build-bptimage-target
2212 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2213 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2214endef
2215
2216INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002217$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2218 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2219
David Zeuthen25328622016-04-08 15:08:03 -04002220$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2221 $(build-bptimage-target)
2222
2223.PHONY: bptimage-nodeps
2224bptimage-nodeps:
2225 $(build-bptimage-target)
2226
2227endif # BOARD_BPT_INPUT_FILES
2228
2229# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002230# cache partition image
2231ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
2232INTERNAL_CACHEIMAGE_FILES := \
2233 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2234
2235cacheimage_intermediates := \
2236 $(call intermediates-dir-for,PACKAGING,cache)
2237BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2238
2239define build-cacheimage-target
2240 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2241 @mkdir -p $(TARGET_OUT_CACHE)
2242 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002243 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002244 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08002245 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07002246 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07002247 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002248endef
2249
2250# We just build this directly to the install location.
2251INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09002252$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) $(BUILD_IMAGE_SRCS)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002253 $(build-cacheimage-target)
2254
2255.PHONY: cacheimage-nodeps
2256cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2257 $(build-cacheimage-target)
2258
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002259else # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
2260# we need to ignore the broken cache link when doing the rsync
2261IGNORE_CACHE_LINK := --exclude=cache
Ying Wang9f8e8db2011-11-04 11:37:01 -07002262endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
2263
David Zeuthen0eb10972016-09-28 17:55:27 -04002264# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002265# system_other partition image
2266ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
2267BOARD_USES_SYSTEM_OTHER := true
2268
2269# Marker file to identify that odex files are installed
2270INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2271ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2272$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2273 $(hide) touch $@
2274endif
2275
2276ifdef BOARD_USES_SYSTEM_OTHER
2277INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2278 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2279 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002280 $(ALL_PDK_FUSION_FILES)) \
2281 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002282
2283INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002284INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2285$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002286$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST)
Alex Light4e358ab2016-06-16 14:47:10 -07002287 @echo Installed file list: $@
2288 @mkdir -p $(dir $@)
2289 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002290 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08002291 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002292
2293systemotherimage_intermediates := \
2294 $(call intermediates-dir-for,PACKAGING,system_other)
2295BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2296
2297# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2298define build-systemotherimage-target
2299 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2300 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2301 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002302 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Alex Light4e358ab2016-06-16 14:47:10 -07002303 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08002304 build/make/tools/releasetools/build_image.py \
Yifan Hongbbcba1e2018-06-18 16:32:35 -07002305 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)\
2306 $(systemotherimage_intermediates)/generated_system_other_image_info.txt
2307 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
2308 $(call read-image-prop-dictionary,\
2309 $(systemotherimage_intermediates)/generated_system_other_image_info.txt,system_size))
Alex Light4e358ab2016-06-16 14:47:10 -07002310endef
2311
2312# We just build this directly to the install location.
2313INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002314ifneq (true,$(SANITIZE_LITE))
2315# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002316$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2317 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002318endif
Alex Light4e358ab2016-06-16 14:47:10 -07002319
2320.PHONY: systemotherimage-nodeps
2321systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2322 $(build-systemotherimage-target)
2323
2324endif # BOARD_USES_SYSTEM_OTHER
2325
2326
2327# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002328# vendor partition image
2329ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2330INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002331 $(filter $(TARGET_OUT_VENDOR)/%,\
2332 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002333 $(ALL_PDK_FUSION_FILES)) \
2334 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07002335
Steven Moreland627debe2018-05-01 09:54:21 -07002336# Final Vendor VINTF manifest including fragments. This is not assembled
2337# on the device because it depends on everything in a given device
2338# image which defines a vintf_fragment.
2339ifdef BUILT_VENDOR_MANIFEST
2340BUILT_ASSEMBLED_VENDOR_MANIFEST := $(PRODUCT_OUT)/verified_assembled_vendor_manifest.xml
2341ifeq (true,$(strip $(PRODUCT_ENFORCE_VINTF_MANIFEST)))
2342ifdef DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE
2343# TODO(b/65028233): turn this on globally
2344$(BUILT_ASSEMBLED_VENDOR_MANIFEST): PRIVATE_SYSTEM_ASSEMBLE_VINTF_ENV_VARS := VINTF_ENFORCE_NO_UNUSED_HALS=true
2345endif # DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE
2346endif # PRODUCT_ENFORCE_VINTF_MANIFEST
2347$(BUILT_ASSEMBLED_VENDOR_MANIFEST): $(HOST_OUT_EXECUTABLES)/assemble_vintf
2348$(BUILT_ASSEMBLED_VENDOR_MANIFEST): $(BUILT_SYSTEM_MATRIX)
2349$(BUILT_ASSEMBLED_VENDOR_MANIFEST): $(BUILT_VENDOR_MANIFEST)
2350$(BUILT_ASSEMBLED_VENDOR_MANIFEST): $(INTERNAL_VENDORIMAGE_FILES)
2351 @echo "Verifying vendor VINTF manifest."
2352 PRODUCT_ENFORCE_VINTF_MANIFEST=$(PRODUCT_ENFORCE_VINTF_MANIFEST) \
2353 $(PRIVATE_SYSTEM_ASSEMBLE_VINTF_ENV_VARS) \
2354 $(HOST_OUT_EXECUTABLES)/assemble_vintf \
2355 -c $(BUILT_SYSTEM_MATRIX) \
2356 -i $(BUILT_VENDOR_MANIFEST) \
2357 $$([ -d $(TARGET_OUT_VENDOR)/etc/vintf/manifest ] && \
2358 find $(TARGET_OUT_VENDOR)/etc/vintf/manifest -type f -name "*.xml" | \
2359 sed "s/^/-i /" | tr '\n' ' ') -o $@
2360endif # BUILT_VENDOR_MANIFEST
2361
Ying Wangcff38622014-07-16 17:46:35 -07002362# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
2363$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07002364
Ying Wang8da19e32015-09-15 14:22:12 -07002365INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002366INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2367$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002368$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST)
Ying Wang8da19e32015-09-15 14:22:12 -07002369 @echo Installed file list: $@
2370 @mkdir -p $(dir $@)
2371 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002372 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08002373 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002374
Ying Wanga0febe52013-03-20 11:02:05 -07002375vendorimage_intermediates := \
2376 $(call intermediates-dir-for,PACKAGING,vendor)
2377BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002378define build-vendorimage-target
2379 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2380 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002381 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002382 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002383 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Howard Chen1756f8d2017-02-22 17:27:10 +08002384 $(if $(BOARD_VENDOR_KERNEL_MODULES), \
2385 $(call build-image-kernel-modules,$(BOARD_VENDOR_KERNEL_MODULES),$(TARGET_OUT_VENDOR),vendor/,$(call intermediates-dir-for,PACKAGING,depmod_vendor)))
Ying Wanga0febe52013-03-20 11:02:05 -07002386 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08002387 build/make/tools/releasetools/build_image.py \
Yifan Hong749062d2018-06-19 16:23:16 -07002388 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT) \
2389 $(vendorimage_intermediates)/generated_vendor_image_info.txt
2390 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),\
2391 $(call read-image-prop-dictionary,\
2392 $(vendorimage_intermediates)/generated_vendor_image_info.txt,vendor_size))
Ying Wanga0febe52013-03-20 11:02:05 -07002393endef
2394
2395# We just build this directly to the install location.
2396INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Steven Moreland627debe2018-05-01 09:54:21 -07002397ifdef BUILT_VENDOR_MANIFEST
2398$(INSTALLED_VENDORIMAGE_TARGET): $(BUILT_ASSEMBLED_VENDOR_MANIFEST)
2399endif
Howard Chen1756f8d2017-02-22 17:27:10 +08002400$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_VENDOR_KERNEL_MODULES)
Ying Wanga0febe52013-03-20 11:02:05 -07002401 $(build-vendorimage-target)
2402
Steven Morelanda2e734d2017-03-07 12:10:09 -08002403.PHONY: vendorimage-nodeps vnod
2404vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD)
Ying Wanga0febe52013-03-20 11:02:05 -07002405 $(build-vendorimage-target)
2406
Colin Cross91a52272017-06-20 16:57:52 -07002407sync: $(INTERNAL_VENDORIMAGE_FILES)
2408
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002409else ifdef BOARD_PREBUILT_VENDORIMAGE
2410INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2411$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2412endif
Ying Wanga0febe52013-03-20 11:02:05 -07002413
Ying Wang9f8e8db2011-11-04 11:37:01 -07002414# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002415# product partition image
2416ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2417INTERNAL_PRODUCTIMAGE_FILES := \
2418 $(filter $(TARGET_OUT_PRODUCT)/%,\
2419 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002420 $(ALL_PDK_FUSION_FILES)) \
2421 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002422
2423# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2424$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2425
2426INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002427INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2428$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002429$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST)
2430 @echo Installed file list: $@
2431 @mkdir -p $(dir $@)
2432 @rm -f $@
2433 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
2434 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
2435
2436productimage_intermediates := \
2437 $(call intermediates-dir-for,PACKAGING,product)
2438BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2439define build-productimage-target
2440 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2441 @mkdir -p $(TARGET_OUT_PRODUCT)
2442 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002443 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002444 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
2445 ./build/tools/releasetools/build_image.py \
Yifan Hong56a6c3b2018-07-20 15:19:34 -07002446 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT) \
2447 $(productimage_intermediates)/generated_product_image_info.txt
2448 $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),\
2449 $(call read-image-prop-dictionary,\
2450 $(productimage_intermediates)/generated_product_image_info.txt,product_size))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002451endef
2452
2453# We just build this directly to the install location.
2454INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
2455$(INSTALLED_PRODUCTIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT) $(BUILD_IMAGE_SRCS)
2456 $(build-productimage-target)
2457
2458.PHONY: productimage-nodeps pnod
2459productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2460 $(build-productimage-target)
2461
2462sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2463
2464else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2465INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2466$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2467endif
2468
2469# -----------------------------------------------------------------
Dario Freni924af7d2018-08-17 00:56:14 +01002470# product_services partition image
Dario Freni5f681e12018-05-29 13:09:01 +01002471ifdef BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE
2472INTERNAL_PRODUCT_SERVICESIMAGE_FILES := \
2473 $(filter $(TARGET_OUT_PRODUCT_SERVICES)/%,\
2474 $(ALL_DEFAULT_INSTALLED_MODULES)\
2475 $(ALL_PDK_FUSION_FILES)) \
2476 $(PDK_FUSION_SYMLINK_STAMP)
2477
2478# platform.zip depends on $(INTERNAL_PRODUCT_SERVICESIMAGE_FILES).
2479$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCT_SERVICESIMAGE_FILES)
2480
Dario Freni924af7d2018-08-17 00:56:14 +01002481INSTALLED_FILES_FILE_PRODUCT_SERVICES := $(PRODUCT_OUT)/installed-files-product_services.txt
Dario Freni5f681e12018-05-29 13:09:01 +01002482INSTALLED_FILES_JSON_PRODUCT_SERVICES := $(INSTALLED_FILES_FILE_PRODUCT_SERVICES:.txt=.json)
2483$(INSTALLED_FILES_FILE_PRODUCT_SERVICES): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT_SERVICES)
2484$(INSTALLED_FILES_FILE_PRODUCT_SERVICES) : $(INTERNAL_PRODUCT_SERVICESIMAGE_FILES) $(FILESLIST)
2485 @echo Installed file list: $@
2486 @mkdir -p $(dir $@)
2487 @rm -f $@
2488 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT_SERVICES) > $(@:.txt=.json)
2489 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
2490
Yifan Hongebc041a2018-07-26 16:02:52 -07002491product_servicesimage_intermediates := \
2492 $(call intermediates-dir-for,PACKAGING,product_services)
Dario Freni924af7d2018-08-17 00:56:14 +01002493BUILT_PRODUCT_SERVICESIMAGE_TARGET := $(PRODUCT_OUT)/product_services.img
2494define build-product_servicesimage-target
2495 $(call pretty,"Target product_services fs image: $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET)")
Dario Freni5f681e12018-05-29 13:09:01 +01002496 @mkdir -p $(TARGET_OUT_PRODUCT_SERVICES)
Yifan Hongebc041a2018-07-26 16:02:52 -07002497 @mkdir -p $(product_servicesimage_intermediates) && rm -rf $(product_servicesimage_intermediates)/product_services_image_info.txt
2498 $(call generate-image-prop-dictionary, $(product_servicesimage_intermediates)/product_services_image_info.txt,product_services, skip_fsck=true)
Dario Freni5f681e12018-05-29 13:09:01 +01002499 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
2500 ./build/tools/releasetools/build_image.py \
Yifan Hongebc041a2018-07-26 16:02:52 -07002501 $(TARGET_OUT_PRODUCT_SERVICES) $(product_servicesimage_intermediates)/product_services_image_info.txt $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) $(TARGET_OUT) \
2502 $(product_servicesimage_intermediates)/generated_product_services_image_info.txt
Yifan Hong9c35a022018-07-20 15:33:47 -07002503 $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),\
2504 $(call read-image-prop-dictionary,\
Yifan Hongebc041a2018-07-26 16:02:52 -07002505 $(product_servicesimage_intermediates)/generated_product_services_image_info.txt,product_services_size))
Dario Freni5f681e12018-05-29 13:09:01 +01002506endef
2507
2508# We just build this directly to the install location.
2509INSTALLED_PRODUCT_SERVICESIMAGE_TARGET := $(BUILT_PRODUCT_SERVICESIMAGE_TARGET)
2510$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCT_SERVICESIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT_SERVICES) $(BUILD_IMAGE_SRCS)
Dario Freni924af7d2018-08-17 00:56:14 +01002511 $(build-product_servicesimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002512
2513.PHONY: productservicesimage-nodeps psnod
2514productservicesimage-nodeps psnod: | $(INTERNAL_USERIMAGES_DEPS)
Dario Freni924af7d2018-08-17 00:56:14 +01002515 $(build-product_servicesimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002516
2517sync: $(INTERNAL_PRODUCT_SERVICESIMAGE_FILES)
2518
2519else ifdef BOARD_PREBUILT_PRODUCT_SERVICESIMAGE
Dario Freni924af7d2018-08-17 00:56:14 +01002520INSTALLED_PRODUCT_SERVICESIMAGE_TARGET := $(PRODUCT_OUT)/product_services.img
Dario Freni5f681e12018-05-29 13:09:01 +01002521$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCT_SERVICESIMAGE),$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET)))
2522endif
2523
2524# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002525# odm partition image
2526ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
2527INTERNAL_ODMIMAGE_FILES := \
2528 $(filter $(TARGET_OUT_ODM)/%,\
2529 $(ALL_DEFAULT_INSTALLED_MODULES)\
2530 $(ALL_PDK_FUSION_FILES)) \
2531 $(PDK_FUSION_SYMLINK_STAMP)
2532# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
2533$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
2534
2535INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2536INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2537$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
2538$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST)
2539 @echo Installed file list: $@
2540 @mkdir -p $(dir $@)
2541 @rm -f $@
2542 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
2543 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
2544
2545odmimage_intermediates := \
2546 $(call intermediates-dir-for,PACKAGING,odm)
2547BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2548define build-odmimage-target
2549 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2550 @mkdir -p $(TARGET_OUT_ODM)
2551 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2552 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
2553 $(if $(BOARD_ODM_KERNEL_MODULES), \
2554 $(call build-image-kernel-modules,$(BOARD_ODM_KERNEL_MODULES),$(TARGET_OUT_ODM),odm/,$(call intermediates-dir-for,PACKAGING,depmod_odm)))
2555 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
2556 ./build/tools/releasetools/build_image.py \
2557 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT) \
2558 $(odmimage_intermediates)/generated_odm_image_info.txt
2559 $(hide) $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),\
2560 $(call read-image-prop-dictionary,\
2561 $(odmimage_intermediates)/generated_odm_image_info.txt,odm_size))
2562endef
2563
2564# We just build this directly to the install location.
2565INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
2566$(INSTALLED_ODMIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_ODM_KERNEL_MODULES)
2567 $(build-odmimage-target)
2568
2569.PHONY: odmimage-nodeps onod
2570odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD)
2571 $(build-odmimage-target)
2572
2573sync: $(INTERNAL_ODMIMAGE_FILES)
2574
2575else ifdef BOARD_PREBUILT_ODMIMAGE
2576INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2577$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2578endif
2579
2580# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07002581# dtbo image
2582ifdef BOARD_PREBUILT_DTBOIMAGE
2583INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
2584
2585ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002586$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002587 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2588 $(AVBTOOL) add_hash_footer \
2589 --image $@ \
2590 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002591 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
Yueyao Zhu211c9012017-04-27 00:34:50 -07002592 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
2593else
2594$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2595 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2596endif
2597
2598endif
2599
2600# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002601# vbmeta image
2602ifeq ($(BOARD_AVB_ENABLE),true)
2603
2604BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002605AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002606
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002607ifdef BOARD_AVB_KEY_PATH
2608$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
2609else
2610# If key path isn't specified, use the 4096-bit test key.
2611BOARD_AVB_ALGORITHM := SHA256_RSA4096
2612BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
2613endif
2614
2615INTERNAL_AVB_SIGNING_ARGS := \
2616 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
2617
2618BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
2619DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
2620SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
2621VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05002622RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002623PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Dario Freni5f681e12018-05-29 13:09:01 +01002624PRODUCT_SERVICES_FOOTER_ARGS := BOARD_AVB_PRODUCT_SERVICES_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002625ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002626
2627# Check and set required build variables for a chain partition.
2628# $(1): the partition to enable AVB chain, e.g., BOOT or SYSTEM.
2629define check-and-set-avb-chain-args
2630$(eval PART := $(1))
Bowgo Tsaie615afd2017-06-20 17:38:21 +08002631$(eval part=$(call to-lower,$(PART)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002632
2633$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
2634$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
2635$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
2636$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
2637$(if $($(_key_path)),,$(error $(_key_path) is not defined))
2638$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
2639$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
2640$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
2641
2642# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
2643$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
2644$(eval $(_signing_args) := \
2645 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
2646
2647$(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2648 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey)
2649
2650# Set rollback_index via footer args
2651$(eval _footer_args := $(PART)_FOOTER_ARGS)
2652$(eval $($(_footer_args)) += --rollback_index $($(_rollback_index)))
2653endef
2654
Tao Baob1a2e352018-08-14 16:17:12 -07002655ifdef INSTALLED_BOOTIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002656ifdef BOARD_AVB_BOOT_KEY_PATH
2657$(eval $(call check-and-set-avb-chain-args,BOOT))
2658else
2659INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2660 --include_descriptors_from_image $(INSTALLED_BOOTIMAGE_TARGET)
2661endif
Tao Baob1a2e352018-08-14 16:17:12 -07002662endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002663
2664ifdef BOARD_AVB_SYSTEM_KEY_PATH
2665$(eval $(call check-and-set-avb-chain-args,SYSTEM))
2666else
2667INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
Tao Baoe9d61b02018-08-20 21:09:07 -07002668 --include_descriptors_from_image $(INSTALLED_SYSTEMIMAGE_TARGET)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002669endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002670
2671ifdef INSTALLED_VENDORIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002672ifdef BOARD_AVB_VENDOR_KEY_PATH
2673$(eval $(call check-and-set-avb-chain-args,VENDOR))
2674else
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002675INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2676 --include_descriptors_from_image $(INSTALLED_VENDORIMAGE_TARGET)
2677endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002678endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002679
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002680ifdef INSTALLED_PRODUCTIMAGE_TARGET
2681ifdef BOARD_AVB_PRODUCT_KEY_PATH
2682$(eval $(call check-and-set-avb-chain-args,PRODUCT))
2683else
2684INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2685 --include_descriptors_from_image $(INSTALLED_PRODUCTIMAGE_TARGET)
2686endif
2687endif
2688
Tao Baocee6d042018-08-22 23:39:03 -07002689ifdef INSTALLED_PRODUCT_SERVICESIMAGE_TARGET
2690ifdef BOARD_AVB_PRODUCT_SERVICES_KEY_PATH
2691$(eval $(call check-and-set-avb-chain-args,PRODUCT_SERVICES))
2692else
2693INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2694 --include_descriptors_from_image $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET)
2695endif
2696endif
2697
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002698ifdef INSTALLED_ODMIMAGE_TARGET
2699ifdef BOARD_AVB_ODM_KEY_PATH
2700$(eval $(call check-and-set-avb-chain-args,ODM))
2701else
2702INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2703 --include_descriptors_from_image $(INSTALLED_ODMIMAGE_TARGET)
2704endif
2705endif
2706
Yueyao Zhu211c9012017-04-27 00:34:50 -07002707ifdef INSTALLED_DTBOIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002708ifdef BOARD_AVB_DTBO_KEY_PATH
2709$(eval $(call check-and-set-avb-chain-args,DTBO))
2710else
Yueyao Zhu211c9012017-04-27 00:34:50 -07002711INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
Tao Baoc633ed02017-05-30 21:46:33 -07002712 --include_descriptors_from_image $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002713endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002714endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07002715
David Zeuthen8fecb282017-12-01 16:24:01 -05002716ifdef INSTALLED_RECOVERYIMAGE_TARGET
2717ifdef BOARD_AVB_RECOVERY_KEY_PATH
2718$(eval $(call check-and-set-avb-chain-args,RECOVERY))
2719else
2720INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2721 --include_descriptors_from_image $(INSTALLED_RECOVERYIMAGE_TARGET)
2722endif
2723endif
2724
Bowgo Tsai9e95bea2017-06-30 12:12:15 +08002725BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
Bowgo Tsai53cf9992017-06-13 11:27:06 +08002726
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002727# Add kernel cmdline descriptor for kernel to mount system.img as root with
2728# dm-verity. This works when system.img is either chained or not-chained:
2729# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
2730# cmdline descriptor to system.img
2731# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
2732# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08002733ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002734BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08002735endif
2736
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002737ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002738BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002739endif
2740
John Reck0588b432018-05-03 13:20:01 -07002741ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
2742BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
2743endif
2744
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002745ifndef BOARD_BOOTIMAGE_PARTITION_SIZE
2746 $(error BOARD_BOOTIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
2747endif
2748
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002749# $(1): the directory to extract public keys to
2750define extract-avb-chain-public-keys
2751 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
2752 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
2753 --output $(1)/boot.avbpubkey)
2754 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
2755 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
2756 --output $(1)/system.avbpubkey)
2757 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
2758 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
2759 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002760 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
2761 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
2762 --output $(1)/product.avbpubkey)
Dario Freni5f681e12018-05-29 13:09:01 +01002763 $(if $(BOARD_AVB_PRODUCT_SERVICES_KEY_PATH),\
2764 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_SERVICES_KEY_PATH) \
Dario Freni924af7d2018-08-17 00:56:14 +01002765 --output $(1)/product_services.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002766 $(if $(BOARD_AVB_ODM_KEY_PATH),\
2767 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
2768 --output $(1)/odm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002769 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
2770 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
2771 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05002772 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
2773 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
2774 --output $(1)/recovery.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002775endef
2776
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002777define build-vbmetaimage-target
2778 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002779 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
2780 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002781 $(hide) $(AVBTOOL) make_vbmeta_image \
2782 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
2783 $(INTERNAL_AVB_SIGNING_ARGS) \
2784 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
2785 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002786 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002787endef
2788
2789INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
David Zeuthen8fecb282017-12-01 16:24:01 -05002790$(INSTALLED_VBMETAIMAGE_TARGET): \
2791 $(AVBTOOL) \
2792 $(INSTALLED_BOOTIMAGE_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07002793 $(INSTALLED_SYSTEMIMAGE_TARGET) \
David Zeuthen8fecb282017-12-01 16:24:01 -05002794 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002795 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Dario Freni5f681e12018-05-29 13:09:01 +01002796 $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) \
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002797 $(INSTALLED_ODMIMAGE_TARGET) \
David Zeuthen8fecb282017-12-01 16:24:01 -05002798 $(INSTALLED_DTBOIMAGE_TARGET) \
2799 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2800 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002801 $(build-vbmetaimage-target)
2802
2803.PHONY: vbmetaimage-nodeps
2804vbmetaimage-nodeps:
2805 $(build-vbmetaimage-target)
2806
Bowgo Tsai9afc0d52017-07-27 21:22:14 +08002807else ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE))
2808BUILT_DISABLED_VBMETAIMAGE := $(PRODUCT_OUT)/vbmeta.img
2809
2810INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_DISABLED_VBMETAIMAGE)
2811$(INSTALLED_VBMETAIMAGE_TARGET): $(AVBTOOL)
2812 $(hide) $(AVBTOOL) make_vbmeta_image \
2813 --flag 2 --padding_size 4096 --output $@
2814
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002815endif # BOARD_AVB_ENABLE
2816
2817# -----------------------------------------------------------------
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002818# super partition image
2819
Tao Baoe9d61b02018-08-20 21:09:07 -07002820# Returns a list of image targets corresponding to the given list of partitions. For example, it
2821# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
2822# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
2823# (1): list of partitions like "system", "vendor" or "system product product_services".
2824define images-for-partitions
2825$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002826endef
2827
2828# (1): list of items like "system", "vendor", "product", "product_services"
2829# return: map each item into a command ( wrapped in $$() ) that reads the size
2830define read-size-of-partitions
2831$(foreach p,$(1),$(call read-image-prop-dictionary,$($(p)image_intermediates)/generated_$(p)_image_info.txt,$(p)_size))
2832endef
2833
Yifan Hong2dae5722018-07-31 12:47:27 -07002834ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002835
2836# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
2837ifdef BOARD_SUPER_PARTITION_SIZE
2838
2839INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
David Anderson433f8222018-08-13 13:01:14 -07002840INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
2841
Tao Baoe9d61b02018-08-20 21:09:07 -07002842$(INSTALLED_SUPERIMAGE_TARGET): $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002843
2844# For A/B devices, super partition always contains sub-partitions in the _a slot, because this
2845# image should only be used for bootstrapping / initializing the device. When flashing the image,
2846# bootloader fastboot should always mark _a slot as bootable.
2847ifeq ($(AB_OTA_UPDATER),true)
David Anderson433f8222018-08-13 13:01:14 -07002848$(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SUPERIMAGE_EMPTY_TARGET): PRIVATE_PARTITION_SUFFIX=_a
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002849endif # AB_OTA_UPDATER
2850
Yifan Hong251a02f2018-08-22 11:58:35 -07002851$(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(HOST_OUT_EXECUTABLES)/lpmake
2852
2853# $(1): output image path
2854# $(2): slot A suffix (_a or empty)
2855# $(3): include images or not (true or empty)
2856define build-superimage-target
2857 $(HOST_OUT_EXECUTABLES)/lpmake \
2858 $(if $(3), --sparse) \
2859 --metadata-size 65536 \
2860 --metadata-slots $(if $(2),2,1) \
2861 --device-size $(BOARD_SUPER_PARTITION_SIZE) \
2862 --output $(1) \
2863 $(foreach name,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
2864 --partition $(name)$(2):$$($(UUIDGEN) $(name)$(2)):readonly:$(if $(3),$(call read-size-of-partitions,$(name)),0) \
2865 $(if $(3), --image $(name)$(2)=$(call images-for-partitions,$(name))) \
Yifan Hongebba7842018-08-22 14:18:27 -07002866 $(if $(2), --partition $(name)_b:$$($(UUIDGEN) $(name)_b):readonly:0) \
Yifan Hong251a02f2018-08-22 11:58:35 -07002867 )
2868endef
2869
2870$(INSTALLED_SUPERIMAGE_TARGET):
2871 $(call pretty,"Target super fs image: $@")
2872 $(call build-superimage-target,$@,$(PRIVATE_PARTITION_SUFFIX),true)
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002873
2874$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_TARGET))
2875
Yifan Hong251a02f2018-08-22 11:58:35 -07002876$(INSTALLED_SUPERIMAGE_EMPTY_TARGET):
2877 $(call pretty,"Target empty super fs image: $@")
2878 $(call build-superimage-target,$@,$(PRIVATE_PARTITION_SUFFIX))
David Anderson433f8222018-08-13 13:01:14 -07002879
2880$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
2881
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002882endif # BOARD_SUPER_PARTITION_SIZE
Yifan Hong2dae5722018-07-31 12:47:27 -07002883endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002884
2885# -----------------------------------------------------------------
Yifan Hong17dd45d2018-07-20 16:45:57 -07002886# Check image sizes <= size of super partition
2887
2888ifeq (,$(TARGET_BUILD_APPS))
2889# Do not check for apps-only build
2890
Yifan Hong2dae5722018-07-31 12:47:27 -07002891ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong17dd45d2018-07-20 16:45:57 -07002892ifdef BOARD_SUPER_PARTITION_SIZE
2893ifdef BOARD_SUPER_PARTITION_PARTITION_LIST
2894
2895droid_targets: check_android_partition_sizes
2896
2897.PHONY: check_android_partition_sizes
2898
Yifan Hong17dd45d2018-07-20 16:45:57 -07002899# Add image dependencies so that generated_*_image_info.txt are written before checking.
Tao Baoe9d61b02018-08-20 21:09:07 -07002900check_android_partition_sizes: $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
Yifan Hong17dd45d2018-07-20 16:45:57 -07002901
2902check_android_partition_sizes:
Yifan Hong37c0c7c2018-07-24 17:45:08 -07002903 partition_size_list="$(call read-size-of-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))"; \
Yifan Hong17dd45d2018-07-20 16:45:57 -07002904 sum_sizes_expr=$$(sed -e 's/ /+/g' <<< "$${partition_size_list}"); \
2905 if [ $$(( $${sum_sizes_expr} )) -gt $(BOARD_SUPER_PARTITION_SIZE) ]; then \
2906 echo 'The sum of sizes of all logical partitions is larger than BOARD_SUPER_PARTITION_SIZE.'; \
2907 echo $${sum_sizes_expr} '==' $$(( $${sum_sizes_expr} )) '>' $(BOARD_SUPER_PARTITION_SIZE); \
2908 exit 1; \
2909 else \
2910 echo 'The sum of sizes of all logical partitions is within BOARD_SUPER_PARTITION_SIZE:' \
2911 $${sum_sizes_expr} '==' $$(( $${sum_sizes_expr} )) '<=' $(BOARD_SUPER_PARTITION_SIZE); \
2912 fi
2913
2914endif # BOARD_SUPER_PARTITION_PARTITION_LIST
2915endif # BOARD_SUPER_PARTITION_SIZE
Yifan Hong2dae5722018-07-31 12:47:27 -07002916endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07002917
2918endif # TARGET_BUILD_APPS
2919
2920# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08002921# bring in the installer image generation defines if necessary
2922ifeq ($(TARGET_USE_DISKINSTALLER),true)
2923include bootable/diskinstaller/config.mk
2924endif
2925
2926# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07002927# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08002928
Ying Wangbd2d0242015-09-22 11:17:52 -07002929build_ota_package := true
2930ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
2931build_ota_package := false
2932endif
2933ifeq ($(BUILD_OS),darwin)
2934build_ota_package := false
2935endif
2936ifneq ($(strip $(SANITIZE_TARGET)),)
2937build_ota_package := false
2938endif
2939ifeq ($(TARGET_PRODUCT),sdk)
2940build_ota_package := false
2941endif
2942ifneq ($(filter generic%,$(TARGET_DEVICE)),)
2943build_ota_package := false
2944endif
2945ifeq ($(TARGET_NO_KERNEL),true)
2946build_ota_package := false
2947endif
2948ifeq ($(recovery_fstab),)
2949build_ota_package := false
2950endif
Colin Cross481cc5a2016-02-04 15:09:23 -08002951ifeq ($(TARGET_BUILD_PDK),true)
2952build_ota_package := false
2953endif
Ying Wangbd2d0242015-09-22 11:17:52 -07002954
2955ifeq ($(build_ota_package),true)
Ying Wang09c4b682015-08-11 11:24:19 -07002956OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
2957 $(HOST_OUT_EXECUTABLES)/aapt \
Michael Schwartz6473e752017-11-08 11:45:14 -08002958 $(HOST_OUT_EXECUTABLES)/checkvintf \
Ying Wangc45a47b2015-04-08 12:24:37 -07002959 $(HOST_OUT_EXECUTABLES)/mkbootfs \
2960 $(HOST_OUT_EXECUTABLES)/mkbootimg \
2961 $(HOST_OUT_EXECUTABLES)/fs_config \
2962 $(HOST_OUT_EXECUTABLES)/zipalign \
2963 $(HOST_OUT_EXECUTABLES)/bsdiff \
2964 $(HOST_OUT_EXECUTABLES)/imgdiff \
2965 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
2966 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
2967 $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
Tao Baoe8ef8f702017-05-17 11:41:50 -07002968 $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar \
Tao Baobcc31092017-01-06 14:24:18 -08002969 $(HOST_OUT_EXECUTABLES)/mke2fs \
2970 $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh \
2971 $(HOST_OUT_EXECUTABLES)/e2fsdroid \
Tao Baocffaf732016-04-14 12:11:36 -07002972 $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \
2973 $(HOST_OUT_EXECUTABLES)/mksquashfs \
2974 $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \
2975 $(HOST_OUT_EXECUTABLES)/make_f2fs \
Jaegeuk Kim2ea1eba2017-11-28 19:21:28 -08002976 $(HOST_OUT_EXECUTABLES)/sload_f2fs \
Ying Wangc45a47b2015-04-08 12:24:37 -07002977 $(HOST_OUT_EXECUTABLES)/simg2img \
2978 $(HOST_OUT_EXECUTABLES)/e2fsck \
Baligh Uddinc8bef142017-12-18 10:40:57 -08002979 $(HOST_OUT_EXECUTABLES)/generate_verity_key \
Ying Wangc45a47b2015-04-08 12:24:37 -07002980 $(HOST_OUT_EXECUTABLES)/verity_signer \
Tao Bao7f02f342016-11-18 17:04:24 -08002981 $(HOST_OUT_EXECUTABLES)/verity_verifier \
Ying Wangc45a47b2015-04-08 12:24:37 -07002982 $(HOST_OUT_EXECUTABLES)/append2simg \
Mohamad Ayyash353265b2015-06-24 15:42:19 -07002983 $(HOST_OUT_EXECUTABLES)/img2simg \
Sami Tolvanenf99b5312015-05-20 07:30:57 +01002984 $(HOST_OUT_EXECUTABLES)/boot_signer \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002985 $(HOST_OUT_EXECUTABLES)/fec \
Tao Bao6d8a8cc2016-01-19 14:47:17 -08002986 $(HOST_OUT_EXECUTABLES)/brillo_update_payload \
2987 $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \
Tao Baof54216f2016-03-29 15:12:37 -07002988 $(HOST_OUT_EXECUTABLES)/delta_generator \
Tianjie Xuccbae482018-08-15 14:28:27 -07002989 $(HOST_OUT_EXECUTABLES)/care_map_generator \
Tao Bao3cba3742017-05-16 16:27:25 -07002990 $(AVBTOOL) \
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002991 $(BLK_ALLOC_TO_BASE_FS) \
Tao Baob4ec6d72018-03-15 23:21:28 -07002992 $(BROTLI) \
2993 $(BUILD_VERITY_METADATA) \
2994 $(BUILD_VERITY_TREE)
Tao Bao5e04c382017-02-22 16:38:19 -08002995
2996ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
2997OTATOOLS += \
Tao Bao69ad1502017-02-23 11:03:45 -08002998 $(FUTILITY) \
2999 $(VBOOT_SIGNER)
Tao Bao5e04c382017-02-22 16:38:19 -08003000endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003001
Ying Wangc45a47b2015-04-08 12:24:37 -07003002# Shared libraries.
Ying Wang09c4b682015-08-11 11:24:19 -07003003OTATOOLS += \
Mark Salyzync506e742015-04-13 09:01:24 -07003004 $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
3005 $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \
3006 $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02003007 $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \
Baligh Uddinc8bef142017-12-18 10:40:57 -08003008 $(HOST_LIBRARY_PATH)/libcrypto_utils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02003009 $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08003010 $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \
3011 $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \
3012 $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \
3013 $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \
Baligh Uddinb24470e2017-01-30 12:41:31 -08003014 $(HOST_LIBRARY_PATH)/libext2_misc$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08003015 $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \
3016 $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \
Alex Klyubin9667b182015-12-10 13:38:50 -08003017 $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08003018 $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \
3019 $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \
3020 $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08003021 $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \
3022 $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \
Dan Willemsen8c2b6bb2016-07-22 23:16:30 +00003023 $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \
Tao Baofdd26932016-02-11 09:50:41 -08003024 $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08003025 $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \
Johan Redestig8f800df2016-03-24 13:57:03 +01003026 $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \
Tao Bao138986b2017-01-26 08:16:57 -08003027 $(HOST_LIBRARY_PATH)/libsparse-host$(HOST_SHLIB_SUFFIX) \
Vikram Dattu8be44672016-12-16 16:33:03 +01003028 $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) \
Tianjie Xub0a29ad2017-07-06 15:13:59 -07003029 $(HOST_LIBRARY_PATH)/libpcre2$(HOST_SHLIB_SUFFIX) \
3030 $(HOST_LIBRARY_PATH)/libbrotli$(HOST_SHLIB_SUFFIX)
3031
The Android Open Source Project88b60792009-03-03 19:28:42 -08003032
Ying Wang06898662010-06-17 17:52:18 -07003033.PHONY: otatools
3034otatools: $(OTATOOLS)
3035
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003036BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
Ying Wang62925a92015-04-08 16:37:34 -07003037$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003038
Tao Baoe8ef8f702017-05-17 11:41:50 -07003039OTATOOLS_DEPS := \
Tao Baoe8ef8f702017-05-17 11:41:50 -07003040 system/extras/ext4_utils/mke2fs.conf \
Tao Bao2d0e5122018-05-23 09:23:28 -07003041 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3042 -name "atx_metadata.bin")) \
Dan Willemsen60c66442018-05-01 19:07:27 -07003043 $(sort $(shell find system/update_engine/scripts -name "*.pyc" -prune -o -type f -print)) \
3044 $(sort $(shell find build/target/product/security -type f -name "*.x509.pem" -o -name "*.pk8" -o \
Tao Bao5232f092018-02-10 04:03:32 +00003045 -name verity_key)) \
Dan Willemsen60c66442018-05-01 19:07:27 -07003046 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
3047 -name "*.x509.pem" -o -name "oem*.prop"))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003048
3049OTATOOLS_RELEASETOOLS := \
Dan Willemsen60c66442018-05-01 19:07:27 -07003050 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003051
3052ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
3053OTATOOLS_DEPS += \
Tao Bao5232f092018-02-10 04:03:32 +00003054 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003055endif
3056
3057$(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) $(OTATOOLS_DEPS) $(OTATOOLS_RELEASETOOLS) | $(ACP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003058 @echo "Package OTA tools: $@"
3059 $(hide) rm -rf $@ $(zip_root)
Tao Baoe8ef8f702017-05-17 11:41:50 -07003060 $(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools
Ying Wangc45a47b2015-04-08 12:24:37 -07003061 $(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
Colin Crossfdea8932017-12-06 14:38:40 -08003062 $(hide) $(ACP) -r -d -p build/make/tools/releasetools/* $(zip_root)/releasetools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003063 $(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
Dan Willemsen48a621c2015-10-29 16:33:05 -07003064 $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *)
Tao Baoe8ef8f702017-05-17 11:41:50 -07003065 $(hide) echo $(OTATOOLS_DEPS) | xargs zip -qryX $(abspath $@)>/dev/null || true
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003066
3067.PHONY: otatools-package
3068otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3069
Ying Wangbd2d0242015-09-22 11:17:52 -07003070endif # build_ota_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003071
The Android Open Source Project88b60792009-03-03 19:28:42 -08003072# -----------------------------------------------------------------
3073# A zip of the directories that map to the target filesystem.
3074# This zip can be used to create an OTA package or filesystem image
3075# as a post-build step.
3076#
3077name := $(TARGET_PRODUCT)
3078ifeq ($(TARGET_BUILD_TYPE),debug)
3079 name := $(name)_debug
3080endif
3081name := $(name)-target_files-$(FILE_NAME_TAG)
3082
3083intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
3084BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
3085$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
3086$(BUILT_TARGET_FILES_PACKAGE): \
3087 zip_root := $(intermediates)/$(name)
3088
3089# $(1): Directory to copy
3090# $(2): Location to copy it to
3091# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
3092define package_files-copy-root
3093 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
3094 mkdir -p $(2) && \
3095 $(ACP) -rd $(strip $(1))/* $(2); \
3096 fi
3097endef
3098
Tao Baoa04fca32015-11-30 12:22:24 -08003099built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07003100
3101# We can't build static executables when SANITIZE_TARGET=address
Ivan Krasin74b32b82015-09-18 11:54:43 -07003102ifeq ($(strip $(SANITIZE_TARGET)),)
Ying Wange6e544e2015-06-22 18:35:35 -07003103built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07003104 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
3105endif
3106
The Android Open Source Project88b60792009-03-03 19:28:42 -08003107$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
3108
Doug Zongkerb1134dd2009-06-17 17:09:40 -07003109$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08003110$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07003111
Doug Zongkerc18736b2009-09-30 09:20:32 -07003112ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3113# default to common dir for device vendor
Dan Willemsen653bea92017-03-21 15:47:37 -07003114tool_extensions := $(TARGET_DEVICE_DIR)/../common
Doug Zongkerc18736b2009-09-30 09:20:32 -07003115else
Dan Willemsen653bea92017-03-21 15:47:37 -07003116tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
Doug Zongkerc18736b2009-09-30 09:20:32 -07003117endif
Dan Willemsen653bea92017-03-21 15:47:37 -07003118tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
3119$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSIONS := $(tool_extensions)
3120$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07003121
Sen Jiang4438fd92016-03-07 16:51:01 -08003122ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08003123updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08003124else
Steve Fung48e49f52015-10-01 23:53:31 -07003125# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09003126updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07003127endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09003128$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07003129
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003130# If we are using recovery as boot, output recovery files to BOOT/.
3131ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
3132$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
3133else
3134$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
3135endif
3136
Dan Willemsen653bea92017-03-21 15:47:37 -07003137ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07003138 ifdef OSRELEASED_DIRECTORY
3139 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
3140 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
3141 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
3142 endif
3143endif
3144
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08003145# Run fs_config while creating the target files package
3146# $1: root directory
3147# $2: add prefix
3148define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08003149(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 -08003150endef
3151
The Android Open Source Project88b60792009-03-03 19:28:42 -08003152# Depending on the various images guarantees that the underlying
3153# directories are up-to-date.
3154$(BUILT_TARGET_FILES_PACKAGE): \
Tao Baob1a2e352018-08-14 16:17:12 -07003155 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003156 $(INSTALLED_BOOTIMAGE_TARGET) \
3157 $(INSTALLED_RADIOIMAGE_TARGET) \
3158 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07003159 $(FULL_SYSTEMIMAGE_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003160 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003161 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07003162 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003163 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Dario Freni5f681e12018-05-29 13:09:01 +01003164 $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) \
Bowgo Tsai6a749792017-09-01 22:55:44 +08003165 $(INSTALLED_VBMETAIMAGE_TARGET) \
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003166 $(INSTALLED_ODMIMAGE_TARGET) \
Yueyao Zhu211c9012017-04-27 00:34:50 -07003167 $(INSTALLED_DTBOIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07003168 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003169 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Dan Willemsen653bea92017-03-21 15:47:37 -07003170 $(INSTALLED_KERNEL_TARGET) \
3171 $(INSTALLED_2NDBOOTLOADER_TARGET) \
cfig28687402018-08-22 16:21:41 +08003172 $(BOARD_PREBUILT_DTBOIMAGE) \
Dan Willemsen653bea92017-03-21 15:47:37 -07003173 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
3174 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003175 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH) \
Dario Freni5f681e12018-05-29 13:09:01 +01003176 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_SERVICES_BASE_FS_PATH) \
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003177 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ODM_BASE_FS_PATH) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07003178 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003179 $(APKCERTS_FILE) \
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003180 $(SOONG_ZIP) \
Doug Zongker283e2a12010-03-15 17:52:32 -07003181 $(HOST_OUT_EXECUTABLES)/fs_config \
Dan Willemsend79a08f2017-03-23 22:09:06 -07003182 $(HOST_OUT_EXECUTABLES)/imgdiff \
3183 $(HOST_OUT_EXECUTABLES)/bsdiff \
Dan Willemsenaadd4992017-03-21 16:01:02 -07003184 $(BUILD_IMAGE_SRCS) \
Steven Moreland627debe2018-05-01 09:54:21 -07003185 $(BUILT_ASSEMBLED_SYSTEM_MANIFEST) \
3186 $(BUILT_ASSEMBLED_VENDOR_MANIFEST) \
3187 $(BUILT_SYSTEM_MATRIX) \
Steven Moreland915f3512018-01-25 10:44:47 -08003188 $(BUILT_VENDOR_MATRIX) \
Ying Wang5d887702015-11-04 10:06:25 -08003189 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003190 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07003191 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003192 $(call create-system-product-symlink)
Dario Freni924af7d2018-08-17 00:56:14 +01003193 $(call create-system-product_services-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003194 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003195 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003196 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003197ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003198 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003199 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003200 $(hide) $(call package_files-copy-root, \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003201 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003202ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07003203 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08003204endif
3205ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07003206 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08003207endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07003208ifdef BOARD_INCLUDE_RECOVERY_DTBO
cfig28687402018-08-22 16:21:41 +08003209 $(hide) cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07003210endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07003211ifdef INTERNAL_KERNEL_CMDLINE
3212 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08003213endif
Doug Zongker38a649f2009-06-17 09:07:09 -07003214ifdef BOARD_KERNEL_BASE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003215 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07003216endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07003217ifdef BOARD_KERNEL_PAGESIZE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003218 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07003219endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003220endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08003221 @# Components of the boot image
3222 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07003223 $(hide) mkdir -p $(zip_root)/ROOT
3224 $(hide) $(call package_files-copy-root, \
3225 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherryd14b8952018-08-09 14:26:00 -07003226ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003227 $(hide) $(call package_files-copy-root, \
Tom Cherryd14b8952018-08-09 14:26:00 -07003228 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07003229endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003230 @# If we are using recovery as boot, this is already done when processing recovery.
3231ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003232ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07003233 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08003234endif
3235ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07003236 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08003237endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07003238ifdef INTERNAL_KERNEL_CMDLINE
3239 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08003240endif
Doug Zongker38a649f2009-06-17 09:07:09 -07003241ifdef BOARD_KERNEL_BASE
3242 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
3243endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07003244ifdef BOARD_KERNEL_PAGESIZE
3245 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
3246endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003247endif # BOARD_USES_RECOVERY_AS_BOOT
Doug Zongkere01100c2009-06-19 17:12:18 -07003248 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
3249 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07003250 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003251 @# Contents of the system image
3252 $(hide) $(call package_files-copy-root, \
3253 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
3254 @# Contents of the data image
3255 $(hide) $(call package_files-copy-root, \
3256 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07003257ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
3258 @# Contents of the vendor image
3259 $(hide) $(call package_files-copy-root, \
3260 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
3261endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003262ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
3263 @# Contents of the product image
3264 $(hide) $(call package_files-copy-root, \
3265 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
3266endif
Dario Freni5f681e12018-05-29 13:09:01 +01003267ifdef BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE
Dario Freni924af7d2018-08-17 00:56:14 +01003268 @# Contents of the product_services image
Dario Freni5f681e12018-05-29 13:09:01 +01003269 $(hide) $(call package_files-copy-root, \
Yifan Hong35be6ca2018-08-17 21:01:25 +00003270 $(TARGET_OUT_PRODUCT_SERVICES),$(zip_root)/PRODUCT_SERVICES)
Dario Freni5f681e12018-05-29 13:09:01 +01003271endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003272ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
3273 @# Contents of the odm image
3274 $(hide) $(call package_files-copy-root, \
3275 $(TARGET_OUT_ODM),$(zip_root)/ODM)
3276endif
Alex Light4e358ab2016-06-16 14:47:10 -07003277ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
3278 @# Contents of the system_other image
3279 $(hide) $(call package_files-copy-root, \
3280 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
3281endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003282 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07003283 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07003284 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07003285ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08003286ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07003287 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07003288 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07003289endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08003290endif
Doug Zongker8678df42009-06-15 14:30:14 -07003291 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08003292 @# build them.
3293 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07003294 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
3295ifneq ($(tool_extension),)
3296 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
3297endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07003298 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07003299 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Doug Zongker37974732010-09-16 17:44:38 -07003300 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08003301 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07003302ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07003303 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07003304endif
3305ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08003306 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07003307endif
Tao Baodb45efa2015-10-27 19:25:18 -07003308ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3309 $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
3310endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07003311ifdef BOARD_INCLUDE_RECOVERY_DTBO
3312 $(hide) echo "include_recovery_dtbo=true" >> $(zip_root)/META/misc_info.txt
3313endif
Doug Zongkerb4c7d322010-07-01 15:30:11 -07003314ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08003315 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07003316endif
JP Abgrall6ea5bd62014-10-22 20:01:22 -07003317ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3318 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3319 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
3320else
3321 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
3322endif
Dan Willemsen653bea92017-03-21 15:47:37 -07003323 $(hide) echo "tool_extensions=$(PRIVATE_TOOL_EXTENSIONS)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07003324 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07003325ifdef PRODUCT_EXTRA_RECOVERY_KEYS
3326 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08003327endif
Jianxun Zhang09849492013-04-17 15:19:19 -07003328 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Sami Tolvanen3303d902016-03-15 16:49:30 +00003329 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08003330 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Tao Bao8fad03e2017-03-01 14:36:26 -08003331 $(hide) echo "blockimgdiff_versions=3,4" >> $(zip_root)/META/misc_info.txt
Ying Wange24e17a2014-10-07 18:42:11 -07003332ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
Jeff Sharkey26e1a282014-03-21 16:20:05 -07003333 # OTA scripts are only interested in fingerprint related properties
Ying Wange24e17a2014-10-07 18:42:11 -07003334 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
Vineeta Srivastava27262112014-09-18 14:34:00 -07003335endif
Tao Baof54216f2016-03-29 15:12:37 -07003336ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07003337 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07003338 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH))
3339endif
3340ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07003341 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07003342 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH))
3343endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003344ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH),)
3345 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH) \
3346 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH))
3347endif
Dario Freni5f681e12018-05-29 13:09:01 +01003348ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_SERVICES_BASE_FS_PATH),)
3349 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_SERVICES_BASE_FS_PATH) \
3350 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_SERVICES_BASE_FS_PATH))
3351endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003352ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ODM_BASE_FS_PATH),)
3353 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ODM_BASE_FS_PATH) \
3354 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ODM_BASE_FS_PATH))
3355endif
Ivan Krasin74b32b82015-09-18 11:54:43 -07003356ifneq ($(strip $(SANITIZE_TARGET)),)
Ying Wang2a048392015-06-25 13:56:53 -07003357 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
3358 $(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt
3359endif
Tao Bao8beab692015-07-22 12:33:18 -07003360ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
3361 $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
3362endif
David Zeuthen0eb10972016-09-28 17:55:27 -04003363ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003364 $(hide) echo "avb_enable=true" >> $(zip_root)/META/misc_info.txt
3365 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
3366 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
3367 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
3368 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
3369ifdef BOARD_AVB_BOOT_KEY_PATH
3370 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
3371 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
3372 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
3373endif # BOARD_AVB_BOOT_KEY_PATH
David Zeuthen8fecb282017-12-01 16:24:01 -05003374 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
3375ifdef BOARD_AVB_RECOVERY_KEY_PATH
3376 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
3377 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
3378 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
3379endif # BOARD_AVB_RECOVERY_KEY_PATH
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003380endif # BOARD_AVB_ENABLE
David Zeuthen25328622016-04-08 15:08:03 -04003381ifdef BOARD_BPT_INPUT_FILES
3382 $(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt
3383 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $(zip_root)/META/misc_info.txt
3384 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $(zip_root)/META/misc_info.txt
3385endif
3386ifdef BOARD_BPT_DISK_SIZE
3387 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $(zip_root)/META/misc_info.txt
3388endif
Ying Wangbd93d422011-10-28 17:02:30 -07003389 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Tao Baocbc6dc22015-08-18 18:03:56 -07003390ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Per Astrandcab66992015-03-25 14:06:30 +01003391 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08003392 build/make/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07003393endif
Alex Deymo70067ac2015-09-29 19:05:37 -07003394ifeq ($(AB_OTA_UPDATER),true)
3395 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07003396 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07003397 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07003398 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
3399 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08003400 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
3401 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
3402 done
Steve Fung4044b382015-11-05 02:04:04 -08003403 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
3404 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08003405 $(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07003406ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07003407 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
3408 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
3409 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07003410endif
Alex Deymo70067ac2015-09-29 19:05:37 -07003411endif
Steve Fungdfbab492015-09-24 18:12:33 -07003412ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07003413 @# If breakpad symbols have been generated, add them to the zip.
Steve Fungdfbab492015-09-24 18:12:33 -07003414 $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
3415endif
Bowgo Tsai6a749792017-09-01 22:55:44 +08003416# BOARD_BUILD_DISABLED_VBMETAIMAGE is used to build a special vbmeta.img
3417# that disables AVB verification. The content is fixed and we can just copy
3418# it to $(zip_root)/IMAGES without passing some info into misc_info.txt for
3419# regeneration.
3420ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE))
3421 $(hide) mkdir -p $(zip_root)/IMAGES
3422 $(hide) cp $(INSTALLED_VBMETAIMAGE_TARGET) $(zip_root)/IMAGES/
3423endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003424ifdef BOARD_PREBUILT_VENDORIMAGE
3425 $(hide) mkdir -p $(zip_root)/IMAGES
3426 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
3427endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003428ifdef BOARD_PREBUILT_PRODUCTIMAGE
3429 $(hide) mkdir -p $(zip_root)/IMAGES
3430 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
3431endif
Dario Freni5f681e12018-05-29 13:09:01 +01003432ifdef BOARD_PREBUILT_PRODUCT_SERVICESIMAGE
3433 $(hide) mkdir -p $(zip_root)/IMAGES
3434 $(hide) cp $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) $(zip_root)/IMAGES/
3435endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07003436ifdef BOARD_PREBUILT_BOOTIMAGE
3437 $(hide) mkdir -p $(zip_root)/IMAGES
3438 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
3439endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003440ifdef BOARD_PREBUILT_ODMIMAGE
3441 $(hide) mkdir -p $(zip_root)/IMAGES
3442 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
3443endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07003444ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07003445 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
3446 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
3447 $(hide) echo "has_dtbo=true" >> $(zip_root)/META/misc_info.txt
3448ifeq ($(BOARD_AVB_ENABLE),true)
3449 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003450 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
3451ifdef BOARD_AVB_DTBO_KEY_PATH
3452 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
3453 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
3454 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" \
Tao Baoc633ed02017-05-30 21:46:33 -07003455 >> $(zip_root)/META/misc_info.txt
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003456endif # BOARD_AVB_DTBO_KEY_PATH
3457endif # BOARD_AVB_ENABLE
3458endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07003459 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
3460 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
3461 @# INSTALLED_RADIOIMAGE_TARGET.
3462 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
3463 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08003464 @# Run fs_config on all the system, vendor, boot ramdisk,
3465 @# and recovery ramdisk files in the zip, and save the output
3466 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
3467ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
3468 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
3469endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003470ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
3471 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
3472endif
Dario Freni5f681e12018-05-29 13:09:01 +01003473ifdef BOARD_PRODUCT_SERVICESIMAGE_FILE_SYSTEM_TYPE
Dario Freni924af7d2018-08-17 00:56:14 +01003474 $(hide) $(call fs_config,$(zip_root)/PRODUCT_SERVICES,product_services/) > $(zip_root)/META/product_services_filesystem_config.txt
Dario Freni5f681e12018-05-29 13:09:01 +01003475endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003476ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
3477 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
3478endif
Tom Cherryd14b8952018-08-09 14:26:00 -07003479 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08003480 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tom Cherryd14b8952018-08-09 14:26:00 -07003481ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
3482 @# BOOT/RAMDISK exists only if additionally using BOARD_USES_RECOVERY_AS_BOOT.
Tao Baoda01b212018-02-28 21:20:08 -08003483ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08003484 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08003485endif
3486else # BOARD_BUILD_SYSTEM_ROOT_IMAGE != true
3487 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
3488endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08003489ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3490 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
3491endif
3492ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
3493 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
3494endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07003495 @# Metadata for compatibility verification.
Steven Moreland42a0afc2018-05-01 11:06:15 -07003496 $(hide) cp $(BUILT_SYSTEM_MATRIX) $(zip_root)/META/system_matrix.xml
Steven Moreland627debe2018-05-01 09:54:21 -07003497 $(hide) cp $(BUILT_ASSEMBLED_SYSTEM_MANIFEST) $(zip_root)/META/system_manifest.xml
3498ifdef BUILT_ASSEMBLED_VENDOR_MANIFEST
3499 $(hide) cp $(BUILT_ASSEMBLED_VENDOR_MANIFEST) $(zip_root)/META/vendor_manifest.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07003500endif
Yifan Hongaa212212017-04-14 00:00:46 -07003501ifdef BUILT_VENDOR_MATRIX
3502 $(hide) cp $(BUILT_VENDOR_MATRIX) $(zip_root)/META/vendor_matrix.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07003503endif
3504
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08003505 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08003506 build/make/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root)
Alex Deymo92cfd6f2016-01-26 18:47:44 -08003507 @# Zip everything up, preserving symlinks and placing META/ files first to
3508 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003509 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07003510 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003511 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07003512
Ying Wanga0febe52013-03-20 11:02:05 -07003513.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08003514target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
3515
Ying Wang4709d7c2014-04-14 17:25:43 -07003516ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
3517$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
3518endif
Doug Zongker367910f2009-06-15 18:56:51 -07003519
Dan Albert4d323332016-10-14 13:23:06 -07003520# -----------------------------------------------------------------
3521# NDK Sysroot Package
3522NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07003523$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07003524 @echo Package NDK sysroot...
3525 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
3526
3527$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
3528
Ying Wang09c4b682015-08-11 11:24:19 -07003529ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07003530# -----------------------------------------------------------------
3531# OTA update package
3532
Doug Zongker8678df42009-06-15 14:30:14 -07003533name := $(TARGET_PRODUCT)
3534ifeq ($(TARGET_BUILD_TYPE),debug)
3535 name := $(name)_debug
3536endif
3537name := $(name)-ota-$(FILE_NAME_TAG)
3538
3539INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
3540
3541$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
3542
Tao Baoe53c6e72017-04-19 15:54:22 -07003543ifeq ($(AB_OTA_UPDATER),true)
3544$(INTERNAL_OTA_PACKAGE_TARGET): $(BRILLO_UPDATE_PAYLOAD)
Tianjie Xub0a29ad2017-07-06 15:13:59 -07003545else
Alex Deymob10e07a2017-11-09 23:53:42 +01003546$(INTERNAL_OTA_PACKAGE_TARGET): $(BROTLI)
Tao Baoe53c6e72017-04-19 15:54:22 -07003547endif
3548
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09003549$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
Colin Crossfdea8932017-12-06 14:38:40 -08003550 build/make/tools/releasetools/ota_from_target_files
Doug Zongker8678df42009-06-15 14:30:14 -07003551 @echo "Package OTA: $@"
Ying Wang9d252e12015-02-09 17:20:06 -08003552 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08003553 build/make/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08003554 --block \
Dan Willemsencea5cd22017-03-21 14:44:27 -07003555 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
Doug Zongker602a84e2009-06-18 08:35:12 -07003556 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05003557 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07003558 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05003559 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07003560
3561.PHONY: otapackage
3562otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
3563
Ying Wang09c4b682015-08-11 11:24:19 -07003564endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07003565
Ying Wang09a00a62010-10-20 14:01:09 -07003566# -----------------------------------------------------------------
3567# The update package
3568
3569name := $(TARGET_PRODUCT)
3570ifeq ($(TARGET_BUILD_TYPE),debug)
3571 name := $(name)_debug
3572endif
3573name := $(name)-img-$(FILE_NAME_TAG)
3574
3575INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
3576
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003577$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(ZIP2ZIP)
Ying Wang09a00a62010-10-20 14:01:09 -07003578 @echo "Package: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003579 $(hide) $(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
3580 OTA/android-info.txt:android-info.txt "IMAGES/*.img:."
Ying Wang09a00a62010-10-20 14:01:09 -07003581
3582.PHONY: updatepackage
3583updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
3584
The Android Open Source Project88b60792009-03-03 19:28:42 -08003585# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01003586# A zip of the appcompat directory containing logs
3587APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
3588# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
3589ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07003590$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Tao Baob1a2e352018-08-14 16:17:12 -07003591 $(INSTALLED_RAMDISK_TARGET) \
Dario Frenid1011272018-07-23 20:20:15 +01003592 $(INSTALLED_BOOTIMAGE_TARGET) \
3593 $(INSTALLED_USERDATAIMAGE_TARGET) \
3594 $(INSTALLED_VENDORIMAGE_TARGET) \
3595 $(INSTALLED_PRODUCTIMAGE_TARGET) \
3596 $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET)
3597endif
3598$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
3599$(APPCOMPAT_ZIP): $(SOONG_ZIP)
3600 @echo "appcompat logs: $@"
3601 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
3602 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
3603 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
3604 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
3605
3606
3607# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003608# A zip of the symbols directory. Keep the full paths to make it
3609# more obvious where these files came from.
3610#
3611name := $(TARGET_PRODUCT)
3612ifeq ($(TARGET_BUILD_TYPE),debug)
3613 name := $(name)_debug
3614endif
3615name := $(name)-symbols-$(FILE_NAME_TAG)
3616
3617SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07003618# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07003619ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07003620$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Tao Baob1a2e352018-08-14 16:17:12 -07003621 $(INSTALLED_RAMDISK_TARGET) \
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09003622 $(INSTALLED_BOOTIMAGE_TARGET) \
3623 $(INSTALLED_USERDATAIMAGE_TARGET) \
3624 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003625 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Dario Freni5f681e12018-05-29 13:09:01 +01003626 $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) \
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003627 $(INSTALLED_ODMIMAGE_TARGET) \
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09003628 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07003629endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003630$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
3631$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003632 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07003633 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
3634 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
3635 $(hide) find $(TARGET_OUT_UNSTRIPPED) | sort >$(PRIVATE_LIST_FILE)
Dan Willemsen6cf21a72017-01-30 20:42:28 -08003636 $(hide) $(SOONG_ZIP) -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07003637# -----------------------------------------------------------------
3638# A zip of the coverage directory.
3639#
3640name := $(TARGET_PRODUCT)
3641ifeq ($(TARGET_BUILD_TYPE),debug)
3642name := $(name)_debug
3643endif
3644name := $(name)-coverage-$(FILE_NAME_TAG)
3645COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
3646ifndef TARGET_BUILD_APPS
Tao Baoe9d61b02018-08-20 21:09:07 -07003647$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Tao Baob1a2e352018-08-14 16:17:12 -07003648 $(INSTALLED_RAMDISK_TARGET) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07003649 $(INSTALLED_BOOTIMAGE_TARGET) \
3650 $(INSTALLED_USERDATAIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003651 $(INSTALLED_VENDORIMAGE_TARGET) \
Dario Freni5f681e12018-05-29 13:09:01 +01003652 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003653 $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) \
3654 $(INSTALLED_ODMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07003655endif
3656$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
3657$(COVERAGE_ZIP): $(SOONG_ZIP)
3658 @echo "Package coverage: $@"
3659 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
3660 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
3661 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
3662 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003663
3664# -----------------------------------------------------------------
3665# A zip of the Android Apps. Not keeping full path so that we don't
3666# include product names when distributing
3667#
3668name := $(TARGET_PRODUCT)
3669ifeq ($(TARGET_BUILD_TYPE),debug)
3670 name := $(name)_debug
3671endif
3672name := $(name)-apps-$(FILE_NAME_TAG)
3673
3674APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07003675$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003676 @echo "Package apps: $@"
3677 $(hide) rm -rf $@
3678 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07003679 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
3680 if [ -z "$$apps_to_zip" ]; then \
3681 echo "No apps to zip up. Generating empty apps archive." ; \
3682 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
3683 else \
Dan Willemsen48a621c2015-10-29 16:33:05 -07003684 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07003685 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07003686
Ying Wangbc415dd2012-08-15 12:22:44 -07003687ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07003688#------------------------------------------------------------------
3689# An archive of classes for use in generating code-coverage reports
3690# These are the uninstrumented versions of any classes that were
3691# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07003692# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07003693
Colin Crossa6bc3a82017-09-27 14:28:41 -07003694JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07003695$(JACOCO_REPORT_CLASSES_ALL) :
3696 @echo "Collecting uninstrumented classes"
3697 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" | \
3698 zip -@ -0 -q -X $@
3699# Meaning of these options:
3700# -@ scan stdin for file paths to add to the zip
3701# -0 don't do any compression
3702# -q supress most output
3703# -X skip storing extended file attributes
3704
Ying Wangbc415dd2012-08-15 12:22:44 -07003705endif # EMMA_INSTRUMENT=true
3706
Jeff Gastonaaae43c2017-04-11 16:36:46 -07003707
Ying Wangae9115a2013-08-22 20:52:47 -07003708#------------------------------------------------------------------
3709# A zip of Proguard obfuscation dictionary files.
3710# Only for apps_only build.
3711#
3712ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07003713PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07003714# the dependency will be set up later in build/make/core/main.mk.
Ying Wangae9115a2013-08-22 20:52:47 -07003715$(PROGUARD_DICT_ZIP) :
3716 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossa6bc3a82017-09-27 14:28:41 -07003717 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
Ying Wangae9115a2013-08-22 20:52:47 -07003718 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08003719 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
Dan Willemsen48a621c2015-10-29 16:33:05 -07003720 zip -qX $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07003721 else \
Ying Wangdcd90832015-02-26 09:36:27 -08003722 touch $(dir $@)/zipdummy; \
3723 (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \
3724 zip -qd $@ zipdummy; \
3725 rm $(dir $@)/zipdummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07003726 fi
3727
3728endif # TARGET_BUILD_APPS
3729
The Android Open Source Project88b60792009-03-03 19:28:42 -08003730# -----------------------------------------------------------------
3731# dalvik something
3732.PHONY: dalvikfiles
3733dalvikfiles: $(INTERNAL_DALVIK_MODULES)
3734
Bo Huf0d50bb2017-08-01 19:02:09 +00003735ifeq ($(BUILD_QEMU_IMAGES),true)
3736INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
3737MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
3738SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Tao Baoe9d61b02018-08-20 21:09:07 -07003739$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_SYSTEMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00003740 @echo Create system-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00003741 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/system.img)
Bo Huf0d50bb2017-08-01 19:02:09 +00003742
3743systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
3744droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
3745ifeq ($(BOARD_USES_VENDORIMAGE),true)
3746INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00003747$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00003748 @echo Create vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00003749 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/vendor.img)
Bo Huf0d50bb2017-08-01 19:02:09 +00003750
3751vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
3752droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
3753endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003754ifeq ($(BOARD_USES_PRODUCTIMAGE),true)
3755INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00003756$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003757 @echo Create product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00003758 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/product.img)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003759
3760productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
3761droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
3762endif
Dario Freni5f681e12018-05-29 13:09:01 +01003763ifeq ($(BOARD_USES_PRODUCT_SERVICESIMAGE),true)
Dario Freni924af7d2018-08-17 00:56:14 +01003764INSTALLED_QEMU_PRODUCT_SERVICESIMAGE := $(PRODUCT_OUT)/product_services-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00003765$(INSTALLED_QEMU_PRODUCT_SERVICESIMAGE): $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Dario Freni924af7d2018-08-17 00:56:14 +01003766 @echo Create product_services-qemu.img
3767 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/product_services.img)
Dario Freni5f681e12018-05-29 13:09:01 +01003768
3769productservicesimage: $(INSTALLED_QEMU_PRODUCT_SERVICESIMAGE)
3770droidcore: $(INSTALLED_QEMU_PRODUCT_SERVICESIMAGE)
3771endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003772ifeq ($(BOARD_USES_ODMIMAGE),true)
3773INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
3774$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3775 @echo Create odm-qemu.img
3776 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/odm.img)
3777
3778odmimage: $(INSTALLED_QEMU_ODMIMAGE)
3779droidcore: $(INSTALLED_QEMU_ODMIMAGE)
3780endif
Bo Huf0d50bb2017-08-01 19:02:09 +00003781endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003782# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003783# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07003784ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003785INTERNAL_EMULATOR_PACKAGE_FILES += \
3786 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08003787 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003788 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07003789 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3790 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003791
3792name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
3793
3794INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
3795
Ying Wang5d887702015-11-04 10:06:25 -08003796$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003797 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07003798 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003799
Ying Wang7d8c5352012-07-26 10:15:21 -07003800endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003801# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08003802# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08003803# The pdk package (Platform Development Kit)
3804
Keun young Park7fc7aad2012-02-27 15:49:23 -08003805#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
3806# include development/pdk/Pdk.mk
3807#endif
3808
The Android Open Source Project88b60792009-03-03 19:28:42 -08003809
3810# -----------------------------------------------------------------
3811# The SDK
3812
The Android Open Source Project88b60792009-03-03 19:28:42 -08003813# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07003814sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003815
3816# Build a name that looks like:
3817#
3818# linux-x86 --> android-sdk_12345_linux-x86
3819# darwin-x86 --> android-sdk_12345_mac-x86
3820# windows-x86 --> android-sdk_12345_windows
3821#
3822sdk_name := android-sdk_$(FILE_NAME_TAG)
3823ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07003824 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08003825else
Joe Onorato03fbe402009-04-13 08:31:16 -07003826 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003827endif
3828ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07003829 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003830endif
Joe Onorato03fbe402009-04-13 08:31:16 -07003831sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003832
3833sdk_dep_file := $(sdk_dir)/sdk_deps.mk
3834
3835ATREE_FILES :=
3836-include $(sdk_dep_file)
3837
3838# if we don't have a real list, then use "everything"
3839ifeq ($(strip $(ATREE_FILES)),)
3840ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003841 $(ALL_DEFAULT_INSTALLED_MODULES) \
3842 $(INSTALLED_RAMDISK_TARGET) \
3843 $(ALL_DOCS) \
Nan Zhangcb0a6882018-08-07 15:26:32 -07003844 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api-stubs-docs_annotations.zip \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003845 $(ALL_SDK_FILES)
3846endif
3847
3848atree_dir := development/build
3849
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01003850
The Android Open Source Project88b60792009-03-03 19:28:42 -08003851sdk_atree_files := \
3852 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07003853 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08003854
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02003855# development/build/sdk-android-<abi>.atree is used to differentiate
3856# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
3857# files like the kernel image. We use TARGET_CPU_ABI because we don't
3858# have a better way to distinguish between CPU models.
3859ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
3860 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
3861endif
3862
Griff Hazen433febb2014-02-28 08:45:59 -08003863ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
3864sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
3865else
3866sdk_atree_files += $(atree_dir)/sdk.atree
3867endif
3868
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003869include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07003870
The Android Open Source Project88b60792009-03-03 19:28:42 -08003871deps := \
3872 $(target_notice_file_txt) \
3873 $(tools_notice_file_txt) \
3874 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07003875 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07003876 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01003877 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07003878 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00003879 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu18d18682017-08-14 14:52:20 -07003880 $(INSTALLED_QEMU_VENDORIMAGE) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07003881 $(INSTALLED_USERDATAIMAGE_TARGET) \
3882 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003883 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07003884 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003885 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08003886 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003887 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07003888 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003889 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003890
3891INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
3892$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
3893$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
3894$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
3895$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
3896
3897# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
3898#
3899#SDK_GNU_ERROR := true
3900
Ying Wang5d887702015-11-04 10:06:25 -08003901$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003902 @echo "Package SDK: $@"
3903 $(hide) rm -rf $(PRIVATE_DIR) $@
3904 $(hide) for f in $(target_gnu_MODULES); do \
3905 if [ -f $$f ]; then \
3906 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
3907 including GNU target $$f >&2; \
3908 FAIL=$(SDK_GNU_ERROR); \
3909 fi; \
3910 done; \
3911 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07003912 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08003913 $(hide) ( \
Dan Willemsen6f57b282018-06-01 10:53:55 -07003914 ATREE_STRIP="$(HOST_STRIP) -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003915 $(HOST_OUT_EXECUTABLES)/atree \
3916 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
3917 -m $(PRIVATE_DEP_FILE) \
3918 -I . \
3919 -I $(PRODUCT_OUT) \
3920 -I $(HOST_OUT) \
3921 -I $(TARGET_COMMON_OUT_ROOT) \
3922 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08003923 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08003924 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08003925 -v "TARGET_ARCH=$(TARGET_ARCH)" \
3926 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02003927 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003928 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003929 -o $(PRIVATE_DIR) && \
3930 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07003931 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07003932 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003933 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08003934 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003935 chmod -R ug+rwX $(PRIVATE_DIR) && \
Dan Willemsen48a621c2015-10-29 16:33:05 -07003936 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003937 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
3938
Raphael3d224a02010-04-16 17:50:09 -07003939
3940# Is a Windows SDK requested? If so, we need some definitions from here
3941# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08003942MAIN_SDK_NAME := $(sdk_name)
3943MAIN_SDK_DIR := $(sdk_dir)
3944MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08003945ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07003946include $(TOPDIR)development/build/tools/windows_sdk.mk
3947endif
3948
The Android Open Source Project88b60792009-03-03 19:28:42 -08003949# -----------------------------------------------------------------
3950# Findbugs
3951INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
3952INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
3953$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
3954 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09003955 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003956 > $@
3957$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
3958 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09003959 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07003960 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08003961
3962# -----------------------------------------------------------------
3963# Findbugs
3964
3965# -----------------------------------------------------------------
3966# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07003967ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003968include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01003969-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07003970-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07003971-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07003972# Also the project-specific tasks
3973-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
3974-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07003975-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07003976# Also add test specifc tasks
3977include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07003978include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07003979endif
Raphaelc4d47312011-02-15 16:09:36 -08003980
Ying Wang67132ba2015-10-28 16:42:39 -07003981include $(BUILD_SYSTEM)/product-graph.mk
3982
Raphaelc4d47312011-02-15 16:09:36 -08003983# -----------------------------------------------------------------
3984# Create SDK repository packages. Must be done after tasks/* since
3985# we need the addon rules defined.
3986ifneq ($(sdk_repo_goal),)
3987include $(TOPDIR)development/build/tools/sdk_repo.mk
3988endif
Jayant Chowdhary67e0cc52018-02-23 16:50:39 -08003989
3990#------------------------------------------------------------------
3991# Find lsdump paths
3992FIND_LSDUMPS_FILE := $(PRODUCT_OUT)/lsdump_paths.txt
3993$(FIND_LSDUMPS_FILE) : $(LSDUMP_PATHS)
Yi-yo Chiangac0d49f2018-07-25 13:34:28 +08003994 $(hide) rm -rf $@ && echo "$^" | sed -e 's/ /\n/g' > $@