blob: 3073f9166a26ee8245f566be0b97dabb16d7b8c7 [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))), \
39 $(eval $(call copy-one-file,$(_src),$(_fulldest))))) \
Ying Wang462d26b2010-11-02 21:31:47 -070040 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070041 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080042
43# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
44$(file >$(PRODUCT_OUT)/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
45ifdef dist_goal
46$(file >$(DIST_DIR)/logs/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
47endif
48
49product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070050unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070051unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080052
53# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080054# Returns the max allowed size for an image suitable for hash verification
55# (e.g., boot.img, recovery.img, etc).
56# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
57# $(1): partition size to flash the image
58define get-hash-image-max-size
59$(if $(1), \
60 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
61 $(eval _hash_meta_size := 69632), \
62 $(eval _hash_meta_size := 0)) \
63 $(1)-$(_hash_meta_size))
64endef
65
66# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -080067# Define rules to copy headers defined in copy_headers.mk
68# If more than one makefile declared a header, print a warning,
69# then copy the last one defined. This matches the previous make
70# behavior.
71$(foreach dest,$(ALL_COPIED_HEADERS), \
72 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
73 $(eval _src := $(word $(words $(_srcs)),$(_srcs))) \
74 $(if $(call streq,$(_src),$(_srcs)),, \
75 $(warning Duplicate header copy: $(dest)) \
76 $(warning Defined in: $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
77 $(eval $(call copy-one-header,$(_src),$(dest))))
78all_copied_headers: $(ALL_COPIED_HEADERS)
79
80# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -080081# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070082ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080083gen := $(OUT_DOCS)/index.html
84ALL_DOCS += $(gen)
85$(gen): frameworks/base/docs/docs-redirect-index.html
86 @mkdir -p $(dir $@)
87 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070088endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080089
Dan Albert303e6032017-10-04 10:20:20 -070090ndk_doxygen_out := $(OUT_NDK_DOCS)
91ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
92ndk_docs_src_dir := frameworks/native/docs
93ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
94ifneq ($(wildcard $(ndk_docs_src_dir)),)
95ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
96 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
97$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
98 @mkdir -p $(ndk_doxygen_out)
99 @echo "Generating NDK docs to $(ndk_doxygen_out)"
100 @( cat $(ndk_doxyfile); \
101 echo "INPUT=$(ndk_headers)"; \
102 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
103 ) | doxygen -
104
105# Note: Not a part of the docs target because we don't have doxygen available.
106# You can run this target locally if you have doxygen installed.
107ndk-docs: $(ndk_doxygen_out)/index.html
108.PHONY: ndk-docs
109endif
110
The Android Open Source Project88b60792009-03-03 19:28:42 -0800111# -----------------------------------------------------------------
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900112# property_overrides_split_enabled
113property_overrides_split_enabled :=
114ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
115 property_overrides_split_enabled := true
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900116endif
117
118# -----------------------------------------------------------------
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900119# FINAL_VENDOR_DEFAULT_PROPERTIES will be installed in vendor/default.prop if
120# property_overrides_split_enabled is true. Otherwise it will be installed in
121# ROOT/default.prop.
122ifdef BOARD_VNDK_VERSION
123 ifeq ($(BOARD_VNDK_VERSION),current)
124 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
125 else
126 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(BOARD_VNDK_VERSION)
127 endif
128else
129 FINAL_VENDOR_DEFAULT_PROPERTIES :=
130endif
131FINAL_VENDOR_DEFAULT_PROPERTIES += \
132 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
133FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
134 $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
135
136# -----------------------------------------------------------------
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800137# prop.default
138ifdef property_overrides_split_enabled
139INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800140INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
141ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
142$(INSTALLED_DEFAULT_PROP_OLD_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800143else
144# legacy path
The Android Open Source Project88b60792009-03-03 19:28:42 -0800145INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800146endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800147ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900148FINAL_DEFAULT_PROPERTIES := \
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900149 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) \
150 $(call collapse-pairs, $(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900151ifndef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900152 FINAL_DEFAULT_PROPERTIES += \
Jaekyun Seokc227ce72018-02-08 07:19:55 +0900153 $(call collapse-pairs, $(FINAL_VENDOR_DEFAULT_PROPERTIES))
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900154endif
Jaekyun Seok294286d2017-01-20 13:17:12 +0900155FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
156 $(FINAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800157
Andres Moralesb8876e12015-05-06 20:44:22 -0700158intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
159
160$(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800161 @echo Target buildinfo: $@
162 @mkdir -p $(dir $@)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800163 @rm -f $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800164 $(hide) echo "#" > $@; \
165 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
166 echo "#" >> $@;
Jaekyun Seok294286d2017-01-20 13:17:12 +0900167 $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700168 echo "$(line)" >> $@;)
Andres Moralesb8876e12015-05-06 20:44:22 -0700169 $(hide) echo "#" >> $@; \
170 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
171 echo "#" >> $@;
Dan Willemsen014719f2015-08-17 20:44:29 -0700172 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
173 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Cross73021682015-07-21 12:54:17 -0700174 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Colin Crossfdea8932017-12-06 14:38:40 -0800175 $(hide) build/make/tools/post_process_props.py $@
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800176ifdef property_overrides_split_enabled
177 $(hide) mkdir -p $(TARGET_ROOT_OUT)
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800178 $(hide) ln -sf system/etc/prop.default $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800179endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800180
181# -----------------------------------------------------------------
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900182# vendor default.prop
183INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900184ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900185INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
186ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
187
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900188$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
189 @echo Target buildinfo: $@
190 @mkdir -p $(dir $@)
191 $(hide) echo "#" > $@; \
192 echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
193 echo "#" >> $@;
194 $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
195 echo "$(line)" >> $@;)
Colin Crossfdea8932017-12-06 14:38:40 -0800196 $(hide) build/make/tools/post_process_props.py $@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900197
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900198endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900199
200# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800201# build.prop
202INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
203ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900204FINAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -0700205 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
Jaekyun Seok294286d2017-01-20 13:17:12 +0900206FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
207 $(FINAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800208
209# A list of arbitrary tags describing the build configuration.
210# Force ":=" so we can use +=
211BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
212ifeq ($(TARGET_BUILD_TYPE),debug)
213 BUILD_VERSION_TAGS += debug
214endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700215# The "test-keys" tag marks builds signed with the old test keys,
216# which are available in the SDK. "dev-keys" marks builds signed with
217# non-default dev keys (usually private keys from a vendor directory).
218# Both of these tags will be removed and replaced with "release-keys"
219# when the target-files is signed in a post-build step.
220ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700221BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700222else
Doug Zongkera8608a72013-07-23 11:51:04 -0700223BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700224endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700225BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800226BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
227
228# A human-readable string that descibes this build in detail.
Colin Crossf37b4552015-07-16 17:15:19 -0700229build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS)
Andres Moralesb8876e12015-05-06 20:44:22 -0700230$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800231
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700232# 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 -0800233ifeq (,$(strip $(BUILD_FINGERPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800234 ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
235 BF_BUILD_NUMBER := $(USER)$$($(DATE_FROM_FILE) +%m%d%H%M)
Ying Wang50367cc2014-06-12 18:42:53 -0700236 else
Nan Zhang0abdb582018-02-20 17:00:39 -0800237 BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE))
Ying Wang50367cc2014-06-12 18:42:53 -0700238 endif
239 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 -0800240endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800241# unset it for safety.
242BF_BUILD_NUMBER :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800243
Nan Zhang0abdb582018-02-20 17:00:39 -0800244BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt
245ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE) && grep " " $(BUILD_FINGERPRINT_FILE)))
246 $(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))")
247endif
248BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE))
249# unset it for safety.
250BUILD_FINGERPRINT :=
Colin Crossf37b4552015-07-16 17:15:19 -0700251
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700252# The string used to uniquely identify the system build; used by the OTA server.
253# This purposefully excludes any product-specific variables.
254ifeq (,$(strip $(BUILD_THUMBPRINT)))
Nan Zhang0abdb582018-02-20 17:00:39 -0800255 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700256endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800257
258BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt
259ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE)))
260 $(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))")
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700261endif
Nan Zhang0abdb582018-02-20 17:00:39 -0800262BUILD_THUMBPRINT_FROM_FILE := $$(cat $(BUILD_THUMBPRINT_FILE))
263# unset it for safety.
264BUILD_THUMBPRINT :=
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700265
Ying Wange24e17a2014-10-07 18:42:11 -0700266KNOWN_OEM_THUMBPRINT_PROPERTIES := \
267 ro.product.brand \
268 ro.product.name \
269 ro.product.device
270OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
271 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))
272
Sriram Raman7b641242009-03-24 22:40:59 -0700273# Display parameters shown under Settings -> About Phone
274ifeq ($(TARGET_BUILD_VARIANT),user)
275 # User builds should show:
276 # release build number or branch.buld_number non-release builds
277
278 # Dev. branches should have DISPLAY_BUILD_NUMBER set
Colin Cross63fe36a2017-02-21 17:23:02 -0800279 ifeq (true,$(DISPLAY_BUILD_NUMBER))
Colin Crossf37b4552015-07-16 17:15:19 -0700280 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700281 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700282 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700283 endif
284else
285 # Non-user builds should show detailed build information
286 BUILD_DISPLAY_ID := $(build_desc)
287endif
288
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000289# Accepts a whitespace separated list of product locales such as
290# (en_US en_AU en_GB...) and returns the first locale in the list with
291# underscores replaced with hyphens. In the example above, this will
292# return "en-US".
293define get-default-product-locale
294$(strip $(subst _,-, $(firstword $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800295endef
296
Colin Crossfdea8932017-12-06 14:38:40 -0800297BUILDINFO_SH := build/make/tools/buildinfo.sh
298VENDOR_BUILDINFO_SH := build/make/tools/vendor_buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700299
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700300# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test
301# harness to distinguish builds. Only add _asan for a sanitized build
302# if it isn't already a part of the flavor (via a dedicated lunch
303# config for example).
Ying Wang21ec03d2015-10-28 18:45:03 -0700304TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
Ivan Lozano0f71db32017-08-14 07:57:37 -0700305ifneq (, $(filter address, $(SANITIZE_TARGET)))
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700306ifeq (,$(findstring _asan,$(TARGET_BUILD_FLAVOR)))
Ying Wang21ec03d2015-10-28 18:45:03 -0700307TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
308endif
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700309endif
Ying Wang21ec03d2015-10-28 18:45:03 -0700310
Andrew Boiefa61ff02012-09-28 09:33:45 -0700311ifdef TARGET_SYSTEM_PROP
312system_prop_file := $(TARGET_SYSTEM_PROP)
313else
314system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
315endif
Jaekyun Seokf9af5fa2017-10-25 12:08:32 +0900316$(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 -0800317 @echo Target buildinfo: $@
318 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700319 $(hide) echo > $@
320ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
321 $(hide) echo "#" >> $@; \
322 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700323 echo "#" >> $@;
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700324 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
325 echo "import /oem/oem.prop $(prop)" >> $@;)
326endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800327 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Ying Wang21ec03d2015-10-28 18:45:03 -0700328 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800329 TARGET_DEVICE="$(TARGET_DEVICE)" \
330 PRODUCT_NAME="$(TARGET_PRODUCT)" \
331 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000332 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700333 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800334 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
335 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
336 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
337 BUILD_ID="$(BUILD_ID)" \
338 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
Dan Willemsenccc933e2015-08-11 15:25:12 -0700339 DATE="$(DATE_FROM_FILE)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700340 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
Daniel Rosenberg59156a62015-06-29 17:20:43 -0700341 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
Tao Bao532fdf42015-11-11 10:22:48 -0800342 AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
Dianne Hackborne593e5c2015-08-12 16:11:20 -0700344 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
345 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800346 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Adam Powellbdd5e8e2015-05-21 13:49:05 -0700347 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700348 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
Dianne Hackborn6ee3c432014-04-24 16:19:14 -0700349 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800350 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700351 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
Nan Zhang0abdb582018-02-20 17:00:39 -0800352 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT_FROM_FILE)") \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000353 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100354 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
355 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700356 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800357 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800358 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700359 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200360 $(hide) $(foreach file,$(system_prop_file), \
361 if [ -f "$(file)" ]; then \
362 echo "#" >> $@; \
363 echo Target buildinfo from: "$(file)"; \
364 echo "# from $(file)" >> $@; \
365 echo "#" >> $@; \
366 cat $(file) >> $@; \
367 fi;)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900368 $(if $(FINAL_BUILD_PROPERTIES), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800369 $(hide) echo >> $@; \
370 echo "#" >> $@; \
371 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
372 echo "#" >> $@; )
Jaekyun Seok294286d2017-01-20 13:17:12 +0900373 $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700374 echo "$(line)" >> $@;)
Andres Morales085a0ce2015-02-06 10:12:55 -0800375 $(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 -0800376 $(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 -0800377
378build_desc :=
379
Andres Moralesb8876e12015-05-06 20:44:22 -0700380ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
381INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
382else
383INSTALLED_RECOVERYIMAGE_TARGET :=
384endif
385
386$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) $(INSTALLED_RECOVERYIMAGE_TARGET)
387 @echo "Target build info: $@"
Steven Morelandec082652017-10-22 02:11:47 -0700388 $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@
Andres Moralesb8876e12015-05-06 20:44:22 -0700389ifdef INSTALLED_RECOVERYIMAGE_TARGET
390 $(hide) echo ro.expect.recovery_id=`cat $(RECOVERYIMAGE_ID_FILE)` >> $@
391endif
392
The Android Open Source Project88b60792009-03-03 19:28:42 -0800393# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700394# vendor build.prop
395#
Alex Naidis47e24e92016-01-10 14:18:54 +0000396# For verifying that the vendor build is what we think it is
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700397INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
398ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900399
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900400ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900401FINAL_VENDOR_BUILD_PROPERTIES += \
402 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
403FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
404 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900405endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900406
Steven Morelandec082652017-10-22 02:11:47 -0700407$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(VENDOR_BUILDINFO_SH) $(intermediate_system_build_prop)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700408 @echo Target vendor buildinfo: $@
409 @mkdir -p $(dir $@)
410 $(hide) echo > $@
Sandeep Patil127f5012017-10-23 19:47:43 -0700411 $(hide) grep 'ro.product.first_api_level' $(intermediate_system_build_prop) >> $@ || true
Dan Willemsenccc933e2015-08-11 15:25:12 -0700412 $(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
413 $(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Crossf37b4552015-07-16 17:15:19 -0700414 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Isaac Chen8d11feb2018-01-31 14:27:37 +0800415 $(hide) echo ro.vendor.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
416 $(hide) echo ro.vendor.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
417 $(hide) echo ro.vendor.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Ryan Campbell63fc0e62017-10-02 12:29:41 -0700418 $(hide) TARGET_DEVICE="$(TARGET_DEVICE)" \
419 PRODUCT_NAME="$(TARGET_PRODUCT)" \
420 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
421 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
422 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
423 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900424 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
425 bash $(VENDOR_BUILDINFO_SH) >> $@
Jaekyun Seokf9af5fa2017-10-25 12:08:32 +0900426ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900427 $(hide) echo "#" >> $@; \
428 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
429 echo "#" >> $@;
430 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
431 echo "$(line)" >> $@;)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900432endif # property_overrides_split_enabled
Ivan Podogovd5726322018-03-29 15:22:33 +0100433 $(hide) build/make/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_PROPERTY_BLACKLIST)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700434
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900435# -----------------------------------------------------------------
436# product build.prop
437INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
438ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
439
440FINAL_PRODUCT_PROPERTIES += \
441 $(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES))
442FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \
443 $(FINAL_PRODUCT_PROPERTIES),=)
444
445$(INSTALLED_PRODUCT_BUILD_PROP_TARGET):
446 @echo Target product buildinfo: $@
447 @mkdir -p $(dir $@)
448 $(hide) echo > $@
449ifdef BOARD_USES_PRODUCTIMAGE
450 $(hide) echo ro.product.build.date=`$(DATE_FROM_FILE)`>>$@
451 $(hide) echo ro.product.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
452 $(hide) echo ro.product.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
453endif # BOARD_USES_PRODUCTIMAGE
454 $(hide) echo "#" >> $@; \
455 echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \
456 echo "#" >> $@;
457 $(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \
458 echo "$(line)" >> $@;)
459 $(hide) build/make/tools/post_process_props.py $@
460
Andres Morales9c820f82015-01-13 15:30:34 -0800461# ----------------------------------------------------------------
Andres Morales9c820f82015-01-13 15:30:34 -0800462
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700463# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800464# sdk-build.prop
465#
466# There are certain things in build.prop that we don't want to
467# ship with the sdk; remove them.
468
469# This must be a list of entire property keys followed by
470# "=" characters, without any internal spaces.
471sdk_build_prop_remove := \
472 ro.build.user= \
473 ro.build.host= \
474 ro.product.brand= \
475 ro.product.manufacturer= \
476 ro.product.device=
477# TODO: Remove this soon-to-be obsolete property
478sdk_build_prop_remove += ro.build.product=
479INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
480$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
481 @echo SDK buildinfo: $@
482 @mkdir -p $(dir $@)
483 $(hide) grep -v "$(subst $(space),\|,$(strip \
484 $(sdk_build_prop_remove)))" $< > $@.tmp
485 $(hide) for x in $(sdk_build_prop_remove); do \
486 echo "$$x"generic >> $@.tmp; done
487 $(hide) mv $@.tmp $@
488
489# -----------------------------------------------------------------
490# package stats
491PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
492PACKAGES_TO_STAT := \
493 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
494 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
495$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
496 @echo Package stats: $@
497 @mkdir -p $(dir $@)
498 $(hide) rm -f $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700499ifeq ($(PACKAGES_TO_STAT),)
500# Create empty package stats file if target builds no jar(s) or apk(s).
501 $(hide) touch $@
502else
Colin Crossfdea8932017-12-06 14:38:40 -0800503 $(hide) build/make/tools/dump-package-stats $^ > $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700504endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800505
506.PHONY: package-stats
507package-stats: $(PACKAGE_STATS_FILE)
508
509# -----------------------------------------------------------------
510# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700511# Use a macro to add newline to each echo command
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100512define _apkcerts_write_line
513$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $5
514$(if $(4), $(hide) echo -n ' compressed="$4"' >> $5)
515$(hide) echo '' >> $5
Ying Wangd9a88d52012-10-26 09:21:28 -0700516
517endef
518
The Android Open Source Project88b60792009-03-03 19:28:42 -0800519name := $(TARGET_PRODUCT)
520ifeq ($(TARGET_BUILD_TYPE),debug)
521 name := $(name)_debug
522endif
523name := $(name)-apkcerts-$(FILE_NAME_TAG)
524intermediates := \
525 $(call intermediates-dir-for,PACKAGING,apkcerts)
526APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800527# We don't need to really build all the modules.
528# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700529$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800530 @echo APK certs list: $@
531 @mkdir -p $(dir $@)
532 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700533 $(foreach p,$(PACKAGES),\
534 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100535 $(call _apkcerts_write_line,$(p),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$@),\
536 $(call _apkcerts_write_line,$(p),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700537 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700538 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800539
540.PHONY: apkcerts-list
541apkcerts-list: $(APKCERTS_FILE)
542
Ying Wang15e487a2011-02-15 10:56:18 -0800543ifneq (,$(TARGET_BUILD_APPS))
544 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
545endif
Ying Wangefb21682010-07-23 16:42:13 -0700546
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700548# build system stats
549BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
550$(BUILD_SYSTEM_STATS):
551 @rm -f $@
552 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
553 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
554$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700555
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700556# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700557# Modules ready to be converted to Soong, ordered by how many
558# modules depend on them.
559SOONG_CONV := $(sort $(SOONG_CONV))
560SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
561$(SOONG_CONV_DATA):
562 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800563 @$(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 -0700564
Colin Crossfdea8932017-12-06 14:38:40 -0800565SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700566SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
567$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
568 @rm -f $@
569 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
570$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
571
572# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800573# Modules use -Wno-error, or added default -Wall -Werror
574WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
575$(WALL_WERROR):
576 @rm -f $@
577 echo "# Modules using -Wno-error" >> $@
578 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 -0800579 echo "# Modules added default -Wall" >> $@
580 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
581
582$(call dist-for-goals,droidcore,$(WALL_WERROR))
583
584# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800585# Modules missing profile files
586PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
587$(PGO_PROFILE_MISSING):
588 @rm -f $@
589 echo "# Modules missing PGO profile files" >> $@
590 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
591
592$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
593
594# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700595# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700596# for future OTA packages installed by this system. Actual product
597# deliverables will be re-signed by hand. We expect this file to
598# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700599DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700600
601
Jeff Browne33ba4c2011-07-11 22:11:46 -0700602# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800603# if they don't do anything.
604.PHONY: systemimage
605systemimage:
606
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800607# -----------------------------------------------------------------
608
609.PHONY: event-log-tags
610
Joe Onoratob7510532010-07-14 10:22:54 -0700611# Produce an event logs tag file for everything we know about, in order
612# to properly allocate numbers. Then produce a file that's filtered
613# for what's going to be installed.
614
615all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
616
Colin Crossdc8f8e42012-04-12 13:25:54 -0700617event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
618
Joe Onoratob7510532010-07-14 10:22:54 -0700619# Include tags from all packages that we know about
620all_event_log_tags_src := \
621 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
622
Colin Crossdc8f8e42012-04-12 13:25:54 -0700623# PDK builds will already have a full list of tags that needs to get merged
624# in with the ones from source
625pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
626
627$(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 -0800628$(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 -0700629 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900630 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700631
Doug Zongkera34fa952011-02-23 12:17:29 -0800632# Include tags from all packages included in this product, plus all
633# tags that are part of the system (ie, not in a vendor/ or device/
634# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800635event_log_tags_src := \
636 $(sort $(foreach m,\
637 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
638 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800639 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
640 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800641
Colin Crossdc8f8e42012-04-12 13:25:54 -0700642$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700643$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800644$(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 -0800645 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900646 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800647
648event-log-tags: $(event_log_tags_file)
649
650ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
651
Joe Onoratob7510532010-07-14 10:22:54 -0700652
The Android Open Source Project88b60792009-03-03 19:28:42 -0800653# #################################################################
654# Targets for boot/OS images
655# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800656ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
657 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
658 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
659 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
660 else
661 INSTALLED_2NDBOOTLOADER_TARGET :=
662 endif
663else
664 INSTALLED_BOOTLOADER_MODULE :=
665 INSTALLED_2NDBOOTLOADER_TARGET :=
666endif # TARGET_NO_BOOTLOADER
667ifneq ($(strip $(TARGET_NO_KERNEL)),true)
668 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
669else
670 INSTALLED_KERNEL_TARGET :=
671endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800672
673# -----------------------------------------------------------------
674# the ramdisk
675INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800676 $(ALL_GENERATED_SOURCES) \
677 $(ALL_DEFAULT_INSTALLED_MODULES))
678
Joe Onorato64d85d02009-04-09 19:31:12 -0700679BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
680
681# We just build this directly to the install location.
682INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700683$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800684 $(call pretty,"Target ram disk: $@")
Thierry Strudel74a81e62015-07-09 09:54:55 -0700685 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800686
Ying Wangad7fd292013-08-08 16:34:29 -0700687.PHONY: ramdisk-nodeps
688ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
689 @echo "make $@: ignoring dependencies"
Thierry Strudel74a81e62015-07-09 09:54:55 -0700690 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800691
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700692INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
693
The Android Open Source Project88b60792009-03-03 19:28:42 -0800694ifneq ($(strip $(TARGET_NO_KERNEL)),true)
695
696# -----------------------------------------------------------------
697# the boot image, which is a collection of other images.
698INTERNAL_BOOTIMAGE_ARGS := \
699 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700700 --kernel $(INSTALLED_KERNEL_TARGET)
701
702ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
703INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
704endif
705
The Android Open Source Project88b60792009-03-03 19:28:42 -0800706INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
707
Dima Zavin1e0847c2009-05-07 19:43:08 -0700708ifdef BOARD_KERNEL_BASE
709 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
710endif
711
Ying Wangffff0022010-08-23 12:56:25 -0700712ifdef BOARD_KERNEL_PAGESIZE
713 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
714endif
715
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700716ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
717ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
718VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
719 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
720endif
721endif
722
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700723INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
724ifdef INTERNAL_KERNEL_CMDLINE
725INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700726endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700727
Sami Tolvanen3303d902016-03-15 16:49:30 +0000728INTERNAL_MKBOOTIMG_VERSION_ARGS := \
729 --os_version $(PLATFORM_VERSION) \
730 --os_patch_level $(PLATFORM_SECURITY_PATCH)
731
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800732# BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true.
733ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
734ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
735 $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.)
736endif
737endif
738
739# We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true.
740ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800741ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800742$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400743
744else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
745
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800746$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400747 $(call pretty,"Target boot image: $@")
748 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800749 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400750 $(hide) $(AVBTOOL) add_hash_footer \
751 --image $@ \
752 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800753 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400754 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
755
756.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800757bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400758 @echo "make $@: ignoring dependencies"
759 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800760 $(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 -0400761 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800762 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400763 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800764 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400765 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
766
767else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700768
769$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
770 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000771 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800772 $(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 -0700773 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
774
775.PHONY: bootimage-nodeps
776bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
777 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000778 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800779 $(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 -0700780 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
781
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100782else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800783
Tao Bao4b577412017-02-22 22:54:39 -0800784$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800785 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000786 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700787 $(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 -0800788 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
789
790.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800791bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800792 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000793 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700794 $(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 -0800795 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
796
797else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800798
799$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
800 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000801 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700802 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700803
804.PHONY: bootimage-nodeps
805bootimage-nodeps: $(MKBOOTIMG)
806 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000807 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700808 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700809
The Android Open Source Project88b60792009-03-03 19:28:42 -0800810endif # TARGET_BOOTIMAGE_USE_EXT2
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800811endif # BOARD_USES_RECOVERY_AS_BOOT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812
813else # TARGET_NO_KERNEL
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700814ifdef BOARD_PREBUILT_BOOTIMAGE
815ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
816# Remove when b/63676296 is resolved.
817$(error Prebuilt bootimage is only supported for AB targets)
818endif
819$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
820else
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700821INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800822# HACK: The top-level targets depend on the bootimage. Not all targets
823# can produce a bootimage, though, and emulator targets need the ramdisk
824# instead. Fake it out by calling the ramdisk the bootimage.
825# TODO: make the emulator use bootimages, and make mkbootimg accept
826# kernel-less inputs.
827INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
828endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700829endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800830
831# -----------------------------------------------------------------
832# NOTICE files
833#
Steve Blockd14d3b42012-03-01 11:34:41 +0000834# We are required to publish the licenses for all code under BSD, GPL and
835# Apache licenses (and possibly other more exotic ones as well). We err on the
836# side of caution, so the licenses for other third-party code are included here
837# too.
838#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800839# This needs to be before the systemimage rules, because it adds to
840# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
841# go into the systemimage.
842
Steve Block495e5852012-02-29 19:18:08 +0000843.PHONY: notice_files
844
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900845# Create the rule to combine the files into text and html/xml forms
846# $(1) - xml_excluded_vendor|xml_vendor|html
847# $(2) - Plain text output file
848# $(3) - HTML/XML output file
849# $(4) - File title
850# $(5) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800851# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900852# $(6) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800853#
854# The algorithm here is that we go collect a hash for each of the notice
855# files and write the names of the files that match that hash. Then
856# to generate the real files, we go print out all of the files and their
857# hashes.
858#
859# These rules are fairly complex, so they depend on this makefile so if
860# it changes, they'll run again.
861#
862# TODO: We could clean this up so that we just record the locations of the
863# original notice files instead of making rules to copy them somwehere.
864# Then we could traverse that without quite as much bash drama.
865define combine-notice-files
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900866$(2) $(3): PRIVATE_MESSAGE := $(4)
867$(2) $(3): PRIVATE_DIR := $(5)
868$(2) : $(3)
Colin Crossfdea8932017-12-06 14:38:40 -0800869$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
870 build/make/tools/generate-notice-files.py --text-output $(2) \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900871 $(if $(filter $(1),xml_excluded_vendor),-e vendor --xml-output, \
872 $(if $(filter $(1),xml_vendor),-i vendor --xml-output, \
873 --html-output)) $(3) \
874 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
875notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800876endef
877
878# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
879# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
880# the src subdirectory.
881
Steve Block495e5852012-02-29 19:18:08 +0000882target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900883target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
884target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
885installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000886tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800887tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
888
Steven Morelandae69e572017-12-15 14:49:55 -0800889# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
890ifeq ($(PRODUCT_NOTICE_SPLIT),true)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900891target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
892target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
893installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
894
895target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
896target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
897target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
898installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
899endif
900
Ying Wang62c81f82013-08-22 20:02:03 -0700901ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Josh Gao4d9268e2017-02-23 13:17:46 -0800903winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
Ying Wang4534d812012-04-09 17:04:12 -0700904pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800905
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900906ifdef target_vendor_notice_file_xml_gz
907$(eval $(call combine-notice-files, xml_excluded_vendor, \
Steve Block495e5852012-02-29 19:18:08 +0000908 $(target_notice_file_txt), \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900909 $(target_notice_file_html_or_xml), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800910 "Notices for files contained in the filesystem images in this directory:", \
911 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700912 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900913$(eval $(call combine-notice-files, xml_vendor, \
914 $(target_vendor_notice_file_txt), \
915 $(target_vendor_notice_file_xml), \
916 "Notices for files contained in the vendor filesystem image in this directory:", \
917 $(TARGET_OUT_NOTICE_FILES), \
918 $(target_notice_file_html_or_xml)))
919else
920$(eval $(call combine-notice-files, html, \
921 $(target_notice_file_txt), \
922 $(target_notice_file_html_or_xml), \
923 "Notices for files contained in the filesystem images in this directory:", \
924 $(TARGET_OUT_NOTICE_FILES), \
925 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
926endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800927
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900928$(eval $(call combine-notice-files, html, \
Steve Block495e5852012-02-29 19:18:08 +0000929 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930 $(tools_notice_file_html), \
931 "Notices for files contained in the tools directory:", \
932 $(HOST_OUT_NOTICE_FILES), \
Josh Gao4d9268e2017-02-23 13:17:46 -0800933 $(ALL_DEFAULT_INSTALLED_MODULES) \
934 $(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800935
936# Install the html file at /system/etc/NOTICE.html.gz.
937# This is not ideal, but this is very late in the game, after a lot of
938# the module processing has already been done -- in fact, we used the
939# fact that all that has been done to get the list of modules that we
940# need notice files for.
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900941$(target_notice_file_html_or_xml_gz): $(target_notice_file_html_or_xml) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700942 $(hide) $(MINIGZIP) -9 < $< > $@
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900943$(installed_notice_html_or_xml_gz): $(target_notice_file_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800944 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700945
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900946ifdef target_vendor_notice_file_xml_gz
947# Install the vendor html file at /vendor/etc/NOTICE.xml.gz.
948$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
949 $(hide) $(MINIGZIP) -9 < $< > $@
950$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
951 $(copy-file-to-target)
952endif
953
Joe Onorato7b2845a2009-04-30 13:52:50 -0700954# if we've been run my mm, mmm, etc, don't reinstall this every time
955ifeq ($(ONE_SHOT_MAKEFILE),)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900956 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
957 ifdef target_vendor_notice_file_xml_gz
958 ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
959 endif
Joe Onorato7b2845a2009-04-30 13:52:50 -0700960endif
Ying Wang62c81f82013-08-22 20:02:03 -0700961endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800962
963# The kernel isn't really a module, so to get its module file in there, we
964# make the target NOTICE files depend on this particular file too, which will
965# then be in the right directory for the find in combine-notice-files to work.
966$(kernel_notice_file): \
Lee Campbellb463fcd2015-11-08 16:28:15 -0800967 $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800968 | $(ACP)
969 @echo Copying: $@
970 $(hide) mkdir -p $(dir $@)
971 $(hide) $(ACP) $< $@
972
Josh Gao4d9268e2017-02-23 13:17:46 -0800973$(winpthreads_notice_file): \
974 $(BUILD_SYSTEM)/WINPTHREADS_COPYING \
975 | $(ACP)
976 @echo Copying: $@
977 $(hide) mkdir -p $(dir $@)
978 $(hide) $(ACP) $< $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800979
Doug Zongker8678df42009-06-15 14:30:14 -0700980# -----------------------------------------------------------------
981# Build a keystore with the authorized keys in it, used to verify the
982# authenticity of downloaded OTA packages.
983#
984# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
985# before the rules that use that variable to build the image.
Dan Willemsenb589ae42015-10-29 21:26:18 +0000986ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
987$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Dan Willemsen48a621c2015-10-29 16:33:05 -0700988$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME)
Doug Zongker8678df42009-06-15 14:30:14 -0700989 $(hide) rm -f $@
990 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -0700991 $(hide) zip -qjX $@ $<
992 $(remove-timestamps-from-package)
Doug Zongker8678df42009-06-15 14:30:14 -0700993
Alex Deymocec578c2017-03-28 20:48:18 -0700994# Carry the public key for update_engine if it's a non-IoT target that
Tao Bao38812d62016-01-20 20:58:20 -0800995# uses the AB updater. We use the same key as otacerts but in RSA public key
996# format.
997ifeq ($(AB_OTA_UPDATER),true)
Alex Deymocec578c2017-03-28 20:48:18 -0700998ifneq ($(PRODUCT_IOT),true)
Tao Bao23c3db92016-01-21 14:28:50 -0800999ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
1000$(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Tao Bao38812d62016-01-20 20:58:20 -08001001 $(hide) rm -f $@
1002 $(hide) mkdir -p $(dir $@)
1003 $(hide) openssl x509 -pubkey -noout -in $< > $@
Alex Deymoc6ebe9f2016-08-03 20:52:54 -07001004
1005ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem
1006$(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem: $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
1007 $(hide) cp -f $< $@
Tao Bao38812d62016-01-20 20:58:20 -08001008endif
1009endif
1010
Doug Zongker8678df42009-06-15 14:30:14 -07001011.PHONY: otacerts
1012otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
1013
1014
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015# #################################################################
1016# Targets for user images
1017# #################################################################
1018
Ying Wang933abf12010-06-16 14:31:34 -07001019INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001020ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001021INTERNAL_USERIMAGES_USE_EXT := true
1022INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1023else
1024ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
1025INTERNAL_USERIMAGES_USE_EXT := true
1026INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1027else
1028ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
1029INTERNAL_USERIMAGES_USE_EXT := true
1030INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1031endif
1032endif
1033endif
1034
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001035# These options tell the recovery updater/installer how to mount the partitions writebale.
1036# <fstype>=<fstype_opts>[|<fstype_opts>]...
1037# fstype_opts := <opt>[,<opt>]...
1038# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001039# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1040DEFAULT_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 -07001041
Ying Wang542903a2010-11-17 15:40:38 -08001042ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1043 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1044endif
1045
Colin Cross0a7b2c52010-05-07 02:23:59 -07001046ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001047INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
1048INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
1049ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1050INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
1051endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001052endif
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001053
Chris Friesdf0387d2017-06-21 15:51:46 -05001054ifeq ($(BOARD_AVB_ENABLE),true)
1055INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1056endif
1057
Todd Poynorb2a555e2015-12-15 18:00:14 -08001058ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1059 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1060endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001061ifneq ($(filter $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),)
Mohamad Ayyash353265b2015-06-24 15:42:19 -07001062INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001063endif
1064
Ying Wang178ef922011-10-31 18:13:30 -07001065INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001066
Colin Cross8a30f722014-04-28 16:27:32 -07001067ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001068INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001069ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC))
1070INTERNAL_USERIMAGES_DEPS += $(FEC)
1071endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001072endif
1073
Alex Klyubin092c9022017-03-13 13:28:34 -07001074SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001075INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1076
Mohamad Ayyashf8765552016-03-02 21:07:23 -08001077INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS)
1078
Jin Qianabcec5e2017-03-10 16:53:45 -08001079ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
1080INTERNAL_USERIMAGES_DEPS += $(MKE2FS_CONF)
1081endif
1082
Ying Wangbd93d422011-10-28 17:02:30 -07001083# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -08001084# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -07001085define generate-userimage-prop-dictionary
Vikram Dattu29e88b82016-12-16 09:45:19 +01001086$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Ying Wangbd93d422011-10-28 17:02:30 -07001087$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
1088$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Mohamad Ayyash68946952015-03-03 12:30:37 -08001089$(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -07001090$(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Patrick Tjin3f5f9932018-03-23 11:36:43 -07001091$(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -08001092$(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
Jin Qianfde9f792018-01-22 13:15:46 -08001093$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
Simon Wilsonf86e7ee2015-06-17 12:35:15 -07001094$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1095$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
Mohamad Ayyashdfec8152016-05-24 12:59:30 -07001096$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
Mohamad Ayyash1b6d3482016-06-15 15:53:07 -07001097$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Mohamad Ayyash1868a602016-04-22 17:22:07 -07001098$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
Julius D'souza001c6762017-05-03 13:43:27 -07001099$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM)" >> $(1))
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001100$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001101$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Connor O'Briene9ee68d2017-01-05 16:48:14 -08001102$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1103$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001104$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1105$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -07001106$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -07001107$(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Patrick Tjin3f5f9932018-03-23 11:36:43 -07001108$(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -07001109$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -08001110$(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
Patrick Tjine11aa502016-02-09 15:40:38 -08001111$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1112$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
Mohamad Ayyashdfec8152016-05-24 12:59:30 -07001113$(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
Mohamad Ayyash1b6d3482016-06-15 15:53:07 -07001114$(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Mohamad Ayyash1868a602016-04-22 17:22:07 -07001115$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001116$(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1117$(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Patrick Tjin3f5f9932018-03-23 11:36:43 -07001118$(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001119$(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1120$(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1121$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1122$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1123$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1124$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_squashfs_disable_4k_align=$(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1125$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "product_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH)" >> $(1))
Ying Wangb8888432014-03-11 17:13:27 -07001126$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -08001127$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -07001128$(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Patrick Tjin3f5f9932018-03-23 11:36:43 -07001129$(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001130$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001131$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001132$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +01001133$(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 -07001134$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
Paul Lawrencea37b2bb2014-11-13 17:54:30 -08001135$(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 +02001136$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001137$(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 +08001138$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -07001139$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1140$(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 +09001141$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -07001142$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1143$(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 -07001144$(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 -08001145$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -07001146$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001147$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001148$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1149$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1150$(if $(BOARD_AVB_ENABLE),\
1151 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1152 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1153 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1154 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
1155$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1156$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1157$(if $(BOARD_AVB_ENABLE),\
1158 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1159 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1160 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1161 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001162$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1163$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1164$(if $(BOARD_AVB_ENABLE),\
1165 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1166 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1167 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1168 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001169$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1170 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001171$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
1172 $(hide) echo "system_root_image=true" >> $(1);\
1173 echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1))
Ying Wang6a42a252013-02-27 13:54:02 -08001174$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -07001175endef
1176
Xu Chao2b04bf42017-07-06 14:34:31 +08001177# $(1): modules list
1178# $(2): output dir
1179# $(3): mount point
1180# $(4): staging dir
1181# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
1182define build-image-kernel-modules
1183 $(hide) rm -rf $(2)/lib/modules
1184 $(hide) mkdir -p $(2)/lib/modules
1185 $(hide) cp $(1) $(2)/lib/modules/
1186 $(hide) rm -rf $(4)
1187 $(hide) mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules
1188 $(hide) cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules
1189 $(hide) $(DEPMOD) -b $(4) 0.0
1190 $(hide) sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules/modules.dep
1191 $(hide) cp $(4)/lib/modules/0.0/modules.alias $(2)/lib/modules
1192endef
1193
The Android Open Source Project88b60792009-03-03 19:28:42 -08001194# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001195# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001196
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001197# Recovery image exists if we are building recovery, or building recovery as boot.
1198ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Doug Zongker4647f122009-07-02 09:00:54 -07001199
Ying Wang37526142015-03-10 12:02:57 -07001200INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1201 $(ALL_DEFAULT_INSTALLED_MODULES))
1202
Doug Zongker4647f122009-07-02 09:00:54 -07001203recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001204recovery_sepolicy := \
1205 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001206 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Bowgo Tsai09f88a62018-02-05 17:32:20 +08001207 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001208 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai09f88a62018-02-05 17:32:20 +08001209 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts
1210
Bowgo Tsai99671252017-11-30 22:15:17 +08001211ifdef BOARD_ODM_SEPOLICY_DIRS
1212recovery_sepolicy += \
1213 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
1214 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts
1215endif
1216
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001217# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1218# SELinux files
1219IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1220
Doug Zongker4647f122009-07-02 09:00:54 -07001221recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1222recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001223recovery_build_props := $(intermediate_system_build_prop)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +09001224ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001225recovery_build_props += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
1226endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001227ifdef BOARD_USES_PRODUCTIMAGE
1228recovery_build_props += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
1229endif
Doug Zongker4647f122009-07-02 09:00:54 -07001230recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001231
Doug Zongker8eaeea92014-05-12 15:32:20 -07001232# Set recovery_density to the density bucket of the device.
1233recovery_density := unknown
1234ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
1235# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
1236recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
Doug Zongker25d55f82014-04-04 13:51:15 -07001237else
Adam Lesinski83ee6d72014-12-02 16:13:09 -08001238# Otherwise, use the default medium density.
1239recovery_densities := mdpi
Doug Zongker8eaeea92014-05-12 15:32:20 -07001240endif
1241
1242ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1243recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1244else
Doug Zongker25d55f82014-04-04 13:51:15 -07001245recovery_resources_common := $(recovery_resources_common)-xhdpi
1246endif
1247
Doug Zongker8eaeea92014-05-12 15:32:20 -07001248# Select the 18x32 font on high-density devices (xhdpi and up); and
1249# the 12x22 font on other devices. Note that the font selected here
1250# can be overridden for a particular device by putting a font.png in
1251# its private recovery resources.
1252
Tao Baoabbc9112015-04-08 14:14:43 -07001253ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001254recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1255else
1256recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1257endif
1258
Ying Wang9a175682015-08-06 11:47:47 -07001259ifndef TARGET_PRIVATE_RES_DIRS
1260TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1261endif
Doug Zongker4647f122009-07-02 09:00:54 -07001262recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001263 $(TARGET_PRIVATE_RES_DIRS) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -07001264ifdef TARGET_RECOVERY_FSTAB
1265recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1266else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001267recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001268endif
Tao Baoc3c17532016-06-10 10:11:54 -07001269ifdef TARGET_RECOVERY_WIPE
1270recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001271else
Tao Baoc3c17532016-06-10 10:11:54 -07001272recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001273endif
Tao Bao8beab692015-07-22 12:33:18 -07001274
Tao Bao6d5d6232018-03-09 17:04:42 -08001275# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001276# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001277# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1278# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001279#
1280# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001281# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001282# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001283# b) We build a single image that contains boot and recovery both - no recovery image to install
1284# (BOARD_USES_RECOVERY_AS_BOOT = true);
1285# c) We build the root into system image - not needing the resource file as we do bsdiff
1286# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001287# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1288# do bsdiff because boot and recovery will contain different number of entries
1289# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Tao Bao6d5d6232018-03-09 17:04:42 -08001290# Note that condition b) implies condition c), because of the earlier check in this file:
1291# "BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true" (not vice
1292# versa though).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001293
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001294ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) \
1295 $(BOARD_INCLUDE_RECOVERY_DTBO)))
Doug Zongker56588872012-08-20 15:38:58 -07001296# Named '.dat' so we don't attempt to use imgdiff for patching it.
1297RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Tao Bao8beab692015-07-22 12:33:18 -07001298else
Tao Bao8beab692015-07-22 12:33:18 -07001299RECOVERY_RESOURCE_ZIP :=
1300endif
Doug Zongker4647f122009-07-02 09:00:54 -07001301
Doug Zongker4647f122009-07-02 09:00:54 -07001302INTERNAL_RECOVERYIMAGE_ARGS := \
1303 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
1304 --kernel $(recovery_kernel) \
1305 --ramdisk $(recovery_ramdisk)
1306
1307# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001308ifdef INTERNAL_KERNEL_CMDLINE
1309 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001310endif
1311ifdef BOARD_KERNEL_BASE
1312 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1313endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001314ifdef BOARD_KERNEL_PAGESIZE
1315 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1316endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001317ifdef BOARD_INCLUDE_RECOVERY_DTBO
1318 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1319endif
Doug Zongker4647f122009-07-02 09:00:54 -07001320
1321# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -07001322# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -07001323# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -07001324OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -07001325
1326# Generate a file containing the keys that will be read by the
1327# recovery binary.
1328RECOVERY_INSTALL_OTA_KEYS := \
1329 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
1330DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
1331$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -07001332$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -08001333$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
1334 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -07001335 @rm -rf $@
1336 @mkdir -p $(dir $@)
Colin Cross0851df82017-06-30 13:55:38 -07001337 $(JAVA) -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -07001338
Andres Moralesb8876e12015-05-06 20:44:22 -07001339RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id
Howard Chen1756f8d2017-02-22 17:27:10 +08001340
Ying Wang747b9f12015-01-30 14:05:22 -08001341# $(1): output file
1342define build-recoveryimage-target
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001343 # Making recovery image
Ying Wang747b9f12015-01-30 14:05:22 -08001344 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao3f56a332016-01-12 11:34:58 -08001345 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001346 # Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001347 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1348 $(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001349 # Copy adbd from system/bin to recovery/root/sbin
1350 $(hide) cp -f $(TARGET_OUT_EXECUTABLES)/adbd $(TARGET_RECOVERY_ROOT_OUT)/sbin/adbd
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001351 # Modifying ramdisk contents...
Howard Chen1756f8d2017-02-22 17:27:10 +08001352 $(if $(BOARD_RECOVERY_KERNEL_MODULES), \
1353 $(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 +08001354 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1355 $(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 -08001356 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
Ying Wang36b039a2015-04-02 12:48:32 -07001357 $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist.
Ying Wang747b9f12015-01-30 14:05:22 -08001358 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1359 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1360 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1361 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07001362 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1363 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08001364 $(hide) $(foreach item,$(recovery_fstab), \
1365 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07001366 $(if $(strip $(recovery_wipe)), \
1367 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe)
Ying Wang747b9f12015-01-30 14:05:22 -08001368 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001369 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) \
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001370 > $(TARGET_RECOVERY_ROOT_OUT)/prop.default
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001371 $(if $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET), \
1372 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001373 >> $(TARGET_RECOVERY_ROOT_OUT)/prop.default)
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001374 $(hide) cat $(recovery_build_props) \
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001375 >> $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1376 $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07001377 $(BOARD_RECOVERY_IMAGE_PREPARE)
Tao Baobe46a542015-07-30 14:34:01 -07001378 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \
1379 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \
1380 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/system; \
1381 ln -sf /system_root/system $(TARGET_RECOVERY_ROOT_OUT)/system) # Mount the system_root_image to /system_root and symlink /system.
Thierry Strudel74a81e62015-07-09 09:54:55 -07001382 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Tao Baod95e9fd2015-03-29 23:07:41 -07001383 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001384 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
1385 $(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 +01001386 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001387 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1388 $(BOOT_SIGNER) /boot $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1389 $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
1390 )\
1391 )
Tao Baod95e9fd2015-03-29 23:07:41 -07001392 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Furquan Shaikhe8c21222015-08-07 11:58:05 -07001393 $(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 +08001394 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
1395 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
1396 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001397 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1398 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
1399 $(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),\
1400 $(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 -08001401endef
1402
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001403ADBD := $(TARGET_OUT_EXECUTABLES)/adbd
1404
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001405ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Ying Wangbd07ad02016-03-10 12:57:33 -08001406ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER))
1407$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
1408endif
1409ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1410$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
1411endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001412ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001413$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001414endif
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001415$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) $(ADBD) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001416 $(INSTALLED_RAMDISK_TARGET) \
1417 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001418 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001419 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001420 $(recovery_build_props) $(recovery_resource_deps) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001421 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001422 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001423 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1424 $(BOARD_RECOVERY_KERNEL_MODULES) \
1425 $(DEPMOD)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001426 $(call pretty,"Target boot image from recovery: $@")
1427 $(call build-recoveryimage-target, $@)
1428endif
1429
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001430$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) $(ADBD) \
Doug Zongker4647f122009-07-02 09:00:54 -07001431 $(INSTALLED_RAMDISK_TARGET) \
1432 $(INSTALLED_BOOTIMAGE_TARGET) \
Ying Wang37526142015-03-10 12:02:57 -07001433 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001434 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Doug Zongker4647f122009-07-02 09:00:54 -07001435 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001436 $(recovery_build_props) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001437 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001438 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001439 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1440 $(BOARD_RECOVERY_KERNEL_MODULES) \
1441 $(DEPMOD)
Ying Wang747b9f12015-01-30 14:05:22 -08001442 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07001443
Tao Bao4594d0e2015-12-22 09:47:46 -08001444ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001445$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001446 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001447 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1448 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001449endif
Doug Zongker56588872012-08-20 15:38:58 -07001450
Ying Wang747b9f12015-01-30 14:05:22 -08001451.PHONY: recoveryimage-nodeps
1452recoveryimage-nodeps:
1453 @echo "make $@: ignoring dependencies"
1454 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1455
Tao Bao8beab692015-07-22 12:33:18 -07001456else # INSTALLED_RECOVERYIMAGE_TARGET not defined
Doug Zongker56588872012-08-20 15:38:58 -07001457RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -07001458endif
1459
1460.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001461recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001462
Jiyong Park03eb0612017-10-04 21:22:41 +09001463ifneq ($(BOARD_NAND_PAGE_SIZE),)
1464$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001465endif
1466
Jiyong Park03eb0612017-10-04 21:22:41 +09001467ifneq ($(BOARD_NAND_SPARE_SIZE),)
1468$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001469endif
1470
Doug Zongker4647f122009-07-02 09:00:54 -07001471# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07001472# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08001473#
Ying Wang9c649a72012-08-08 15:27:00 -07001474# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
1475PDK_FUSION_SYSIMG_FILES := \
1476 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
1477 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001478
1479INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07001480 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07001481 $(ALL_DEFAULT_INSTALLED_MODULES) \
1482 $(PDK_FUSION_SYSIMG_FILES) \
Dan Willemsen0663f682018-03-06 14:07:21 -08001483 $(RECOVERY_RESOURCE_ZIP)) \
1484 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wang160b6702012-03-13 18:58:27 -07001485
Ying Wang82cceba2012-08-13 15:03:00 -07001486FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07001487
1488# ASAN libraries in the system image - add dependency.
1489ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
1490ifneq (,$(SANITIZE_TARGET))
1491 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
1492 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
1493 endif
1494endif
1495
Ying Wange5e8c5f2011-09-09 16:35:53 -07001496# -----------------------------------------------------------------
1497# installed file list
1498# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
1499# We put installed-files.txt ahead of image itself in the dependency graph
1500# so that we can get the size stat even if the build fails due to too large
1501# system image.
1502INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001503$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001504 @echo Installed file list: $@
1505 @mkdir -p $(dir $@)
1506 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001507 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001508 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07001509
1510.PHONY: installed-file-list
1511installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08001512
1513$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07001514
1515systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001516 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001517BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
1518
Ying Wang23898df2014-06-18 20:26:24 -07001519# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07001520ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07001521define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07001522$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
1523 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
1524 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
1525 exit 1; \
1526fi
Ying Wang23898df2014-06-18 20:26:24 -07001527$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
1528endef
1529else
1530define create-system-vendor-symlink
1531endef
1532endif
1533
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001534# Create symlink /system/product to /product if necessary.
1535ifdef BOARD_USES_PRODUCTIMAGE
1536define create-system-product-symlink
1537$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
1538 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
1539 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
1540 exit 1; \
1541fi
1542$(hide) ln -sf /product $(TARGET_OUT)/product
1543endef
1544else
1545define create-system-product-symlink
1546endef
1547endif
1548
The Android Open Source Project88b60792009-03-03 19:28:42 -08001549# $(1): output file
1550define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07001551 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07001552 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001553 $(call create-system-product-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07001554 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -07001555 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07001556 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001557 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001558 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001559 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
Ying Wang45ff36e2014-08-13 12:36:05 -07001560 || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\
1561 du -sm $(TARGET_OUT) 1>&2;\
Tao Baoc7a6f1e2015-06-23 11:16:05 -07001562 if [ "$(INTERNAL_USERIMAGES_EXT_VARIANT)" == "ext4" ]; then \
1563 maxsize=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE); \
Tao Baoc7a6f1e2015-06-23 11:16:05 -07001564 echo "The max is $$(( maxsize / 1048576 )) MB." 1>&2 ;\
1565 else \
1566 echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\
1567 fi; \
Ying Wangebe63fb2014-08-19 12:21:35 -07001568 mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
Ying Wang45ff36e2014-08-13 12:36:05 -07001569 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08001570endef
1571
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001572$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001573 $(call build-systemimage-target,$@)
1574
The Android Open Source Project88b60792009-03-03 19:28:42 -08001575INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07001576SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001577
Doug Zongker73ef8252009-07-23 15:12:53 -07001578# The system partition needs room for the recovery image as well. We
1579# now store the recovery image as a binary patch using the boot image
1580# as the source (since they are very similar). Generate the patch so
1581# we can see how big it's going to be, and include that in the system
1582# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -07001583ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07001584ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001585ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08001586diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
1587else
1588diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
1589endif
Doug Zongker73ef8252009-07-23 15:12:53 -07001590intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
1591RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08001592$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
1593$(RECOVERY_FROM_BOOT_PATCH): \
1594 $(INSTALLED_RECOVERYIMAGE_TARGET) \
1595 $(INSTALLED_BOOTIMAGE_TARGET) \
1596 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07001597 @echo "Construct recovery from boot"
1598 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08001599 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07001600else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
1601RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
1602endif
Sriram Raman1e96ac82009-07-24 13:52:32 -07001603endif
1604
Doug Zongker73ef8252009-07-23 15:12:53 -07001605
Dan Willemsen7f016152016-02-29 17:52:39 -08001606$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001607 @echo "Install system fs image: $@"
1608 $(copy-file-to-target)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001609 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001610
1611systemimage: $(INSTALLED_SYSTEMIMAGE)
1612
1613.PHONY: systemimage-nodeps snod
1614systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07001615 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001616 @echo "make $@: ignoring dependencies"
1617 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001618 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001619
Ying Wangacf01ec2012-02-24 11:05:48 -08001620ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
1621ifeq (true,$(WITH_DEXPREOPT))
1622$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
1623endif
1624endif
1625
Colin Cross91a52272017-06-20 16:57:52 -07001626.PHONY: sync
1627sync: $(INTERNAL_SYSTEMIMAGE_FILES)
1628
The Android Open Source Project88b60792009-03-03 19:28:42 -08001629#######
1630## system tarball
1631define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -07001632 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
1633 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001634 $(call create-system-product-symlink)
Ying Wang23898df2014-06-18 20:26:24 -07001635 $(MKTARBALL) $(FS_GET_STATS) \
1636 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001637 $(INSTALLED_SYSTEMTARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001638endef
1639
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001640ifndef SYSTEM_TARBALL_FORMAT
1641 SYSTEM_TARBALL_FORMAT := bz2
1642endif
1643
The Android Open Source Project88b60792009-03-03 19:28:42 -08001644system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001645INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001646$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
1647$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
1648 $(build-systemtarball-target)
1649
1650.PHONY: systemtarball-nodeps
1651systemtarball-nodeps: $(FS_GET_STATS) \
1652 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
1653 $(build-systemtarball-target)
1654
1655.PHONY: stnod
1656stnod: systemtarball-nodeps
1657
Ying Wang3a61eeb2016-03-11 10:32:01 -08001658# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07001659## platform.zip: system, plus other files to be used in PDK fusion build,
1660## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07001661##
1662## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
1663## The variable will be typically set from BoardConfig.mk.
1664## Files under out dir will be rejected to prevent possible conflicts with other rules.
Ying Wang3a61eeb2016-03-11 10:32:01 -08001665pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
1666 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
1667pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
1668 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
1669pdk_classes_dex := $(strip \
1670 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
1671 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk))
1672
1673pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
1674$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
1675$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
1676$(pdk_odex_config_mk) :
1677 @echo "PDK odex config makefile: $@"
1678 $(hide) mkdir -p $(dir $@)
1679 $(hide) echo "# Auto-generated. Do not modify." > $@
1680 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
1681 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
1682 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
1683 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
1684 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
1685 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
1686 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
1687 )
1688 $(foreach m,$(PRIVATE_APPS),\
1689 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\
1690 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
1691 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
1692 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
1693 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07001694 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08001695 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
1696 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
1697 )
1698
keunyoungc0178062013-07-22 14:54:58 -07001699PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07001700INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08001701
1702$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
1703$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
1704$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk)
Keun young Park816b9fd2012-05-16 10:32:41 -07001705 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07001706 $(hide) rm -f $@
Dan Willemsen48a621c2015-10-29 16:33:05 -07001707 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wang4534d812012-04-09 17:04:12 -07001708 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07001709 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
1710 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Ying Wangcff38622014-07-16 17:46:35 -07001711ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
Dan Willemsen48a621c2015-10-29 16:33:05 -07001712 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wangcff38622014-07-16 17:46:35 -07001713 $(TARGET_COPY_OUT_VENDOR)
1714endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001715ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
1716 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
1717 $(TARGET_COPY_OUT_PRODUCT)
1718endif
Colin Crossc451a372013-12-18 19:36:44 -08001719ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001720 $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07001721endif
keunyoungc0178062013-07-22 14:54:58 -07001722ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001723 $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
keunyoungc0178062013-07-22 14:54:58 -07001724endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08001725 @# Add dex-preopt files and config.
1726 $(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES)))
Dan Willemsen0663f682018-03-06 14:07:21 -08001727 $(hide) touch $(PRODUCT_OUT)/pdk.mk
1728 $(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG) $(PRODUCT_OUT)/pdk.mk
Ying Wang4c289e52012-03-30 13:52:54 -07001729
1730.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07001731platform: $(INSTALLED_PLATFORM_ZIP)
1732
1733.PHONY: platform-java
1734platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07001735
1736# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07001737ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
1738$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07001739endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001740
Ying Wang3a61eeb2016-03-11 10:32:01 -08001741# -----------------------------------------------------------------
Bruce Beare52aac202010-06-04 15:24:49 -07001742## boot tarball
1743define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07001744 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07001745 $(hide) mkdir -p $(PRODUCT_OUT)/boot
1746 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001747 $(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
Bruce Beare52aac202010-06-04 15:24:49 -07001748 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
1749 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001750 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
Bruce Beare52aac202010-06-04 15:24:49 -07001751endef
1752
1753ifndef BOOT_TARBALL_FORMAT
1754 BOOT_TARBALL_FORMAT := bz2
1755endif
1756
1757boot_tar := $(PRODUCT_OUT)/boot.tar
1758INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
1759$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
1760$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
1761 $(build-boottarball-target)
1762
1763.PHONY: boottarball-nodeps btnod
1764boottarball-nodeps btnod: $(FS_GET_STATS) \
1765 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
1766 $(build-boottarball-target)
1767
1768
The Android Open Source Project88b60792009-03-03 19:28:42 -08001769# -----------------------------------------------------------------
1770# data partition image
1771INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001772 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001773
Ying Wangd7321d32013-03-15 10:32:29 -07001774# Don't build userdata.img if it's extfs but no partition size
1775skip_userdata.img :=
1776ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1777ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1778skip_userdata.img := true
1779endif
1780endif
1781
1782ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001783userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001784 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001785BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1786
Ying Wangbd93d422011-10-28 17:02:30 -07001787define build-userdataimage-target
1788 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1789 @mkdir -p $(TARGET_OUT_DATA)
1790 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001791 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001792 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001793 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001794 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001795 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07001796endef
1797
Joe Onorato64d85d02009-04-09 19:31:12 -07001798# We just build this directly to the install location.
1799INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07001800INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
1801 $(INTERNAL_USERIMAGES_DEPS) \
1802 $(INTERNAL_USERDATAIMAGE_FILES) \
1803 $(BUILD_IMAGE_SRCS)
1804$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001805 $(build-userdataimage-target)
1806
1807.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001808userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001809 $(build-userdataimage-target)
1810
Ying Wangd7321d32013-03-15 10:32:29 -07001811endif # not skip_userdata.img
1812skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001813
Andreas Gampe039b5c72017-03-24 16:06:31 -07001814# ASAN libraries in the system image - build rule.
1815ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
1816 $(TARGET_OUT_SHARED_LIBRARIES) \
1817 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
1818 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
1819 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07001820# Extra options: Enforce the system user for the files to avoid having to change ownership.
1821ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07001822# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
1823# enough space.
1824$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07001825 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 -07001826
The Android Open Source Project88b60792009-03-03 19:28:42 -08001827#######
1828## data partition tarball
1829define build-userdatatarball-target
1830 $(call pretty,"Target userdata fs tarball: " \
1831 "$(INSTALLED_USERDATATARBALL_TARGET)")
1832 $(MKTARBALL) $(FS_GET_STATS) \
1833 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001834 $(INSTALLED_USERDATATARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001835endef
1836
1837userdata_tar := $(PRODUCT_OUT)/userdata.tar
1838INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1839$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1840$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1841 $(build-userdatatarball-target)
1842
Dan Willemsen69af2e42016-08-16 16:36:05 -07001843$(call dist-for-goals,userdatatarball,$(INSTALLED_USERDATATARBALL_TARGET))
1844
The Android Open Source Project88b60792009-03-03 19:28:42 -08001845.PHONY: userdatatarball-nodeps
1846userdatatarball-nodeps: $(FS_GET_STATS)
1847 $(build-userdatatarball-target)
1848
1849
The Android Open Source Project88b60792009-03-03 19:28:42 -08001850# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04001851# partition table image
1852ifdef BOARD_BPT_INPUT_FILES
1853
1854BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001855BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04001856
1857INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
1858 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001859 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04001860 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
1861
1862ifdef BOARD_BPT_DISK_SIZE
1863INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
1864endif
1865
1866define build-bptimage-target
1867 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
1868 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
1869endef
1870
1871INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001872$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
1873 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
1874
David Zeuthen25328622016-04-08 15:08:03 -04001875$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
1876 $(build-bptimage-target)
1877
1878.PHONY: bptimage-nodeps
1879bptimage-nodeps:
1880 $(build-bptimage-target)
1881
1882endif # BOARD_BPT_INPUT_FILES
1883
1884# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001885# cache partition image
1886ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1887INTERNAL_CACHEIMAGE_FILES := \
1888 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1889
1890cacheimage_intermediates := \
1891 $(call intermediates-dir-for,PACKAGING,cache)
1892BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1893
1894define build-cacheimage-target
1895 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1896 @mkdir -p $(TARGET_OUT_CACHE)
1897 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001898 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001899 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001900 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001901 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001902 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001903endef
1904
1905# We just build this directly to the install location.
1906INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001907$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) $(BUILD_IMAGE_SRCS)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001908 $(build-cacheimage-target)
1909
1910.PHONY: cacheimage-nodeps
1911cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1912 $(build-cacheimage-target)
1913
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07001914else # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1915# we need to ignore the broken cache link when doing the rsync
1916IGNORE_CACHE_LINK := --exclude=cache
Ying Wang9f8e8db2011-11-04 11:37:01 -07001917endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1918
David Zeuthen0eb10972016-09-28 17:55:27 -04001919# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07001920# system_other partition image
1921ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
1922BOARD_USES_SYSTEM_OTHER := true
1923
1924# Marker file to identify that odex files are installed
1925INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
1926ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
1927$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
1928 $(hide) touch $@
1929endif
1930
1931ifdef BOARD_USES_SYSTEM_OTHER
1932INTERNAL_SYSTEMOTHERIMAGE_FILES := \
1933 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
1934 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08001935 $(ALL_PDK_FUSION_FILES)) \
1936 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07001937
1938INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001939$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST)
Alex Light4e358ab2016-06-16 14:47:10 -07001940 @echo Installed file list: $@
1941 @mkdir -p $(dir $@)
1942 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001943 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001944 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07001945
1946systemotherimage_intermediates := \
1947 $(call intermediates-dir-for,PACKAGING,system_other)
1948BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
1949
1950# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
1951define build-systemotherimage-target
1952 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
1953 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
1954 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
1955 $(call generate-userimage-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt, skip_fsck=true)
1956 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001957 build/make/tools/releasetools/build_image.py \
Alex Light4e358ab2016-06-16 14:47:10 -07001958 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
1959 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
1960endef
1961
1962# We just build this directly to the install location.
1963INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07001964ifneq (true,$(SANITIZE_LITE))
1965# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07001966$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
1967 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07001968endif
Alex Light4e358ab2016-06-16 14:47:10 -07001969
1970.PHONY: systemotherimage-nodeps
1971systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1972 $(build-systemotherimage-target)
1973
1974endif # BOARD_USES_SYSTEM_OTHER
1975
1976
1977# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07001978# vendor partition image
1979ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1980INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07001981 $(filter $(TARGET_OUT_VENDOR)/%,\
1982 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08001983 $(ALL_PDK_FUSION_FILES)) \
1984 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07001985
1986# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
1987$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07001988
Ying Wang8da19e32015-09-15 14:22:12 -07001989INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001990$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST)
Ying Wang8da19e32015-09-15 14:22:12 -07001991 @echo Installed file list: $@
1992 @mkdir -p $(dir $@)
1993 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001994 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001995 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07001996
Ying Wanga0febe52013-03-20 11:02:05 -07001997vendorimage_intermediates := \
1998 $(call intermediates-dir-for,PACKAGING,vendor)
1999BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002000define build-vendorimage-target
2001 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2002 @mkdir -p $(TARGET_OUT_VENDOR)
2003 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
2004 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
Howard Chen1756f8d2017-02-22 17:27:10 +08002005 $(if $(BOARD_VENDOR_KERNEL_MODULES), \
2006 $(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 -07002007 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08002008 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07002009 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07002010 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002011endef
2012
2013# We just build this directly to the install location.
2014INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Howard Chen1756f8d2017-02-22 17:27:10 +08002015$(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 -07002016 $(build-vendorimage-target)
2017
Steven Morelanda2e734d2017-03-07 12:10:09 -08002018.PHONY: vendorimage-nodeps vnod
2019vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD)
Ying Wanga0febe52013-03-20 11:02:05 -07002020 $(build-vendorimage-target)
2021
Colin Cross91a52272017-06-20 16:57:52 -07002022sync: $(INTERNAL_VENDORIMAGE_FILES)
2023
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002024else ifdef BOARD_PREBUILT_VENDORIMAGE
2025INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2026$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2027endif
Ying Wanga0febe52013-03-20 11:02:05 -07002028
Ying Wang9f8e8db2011-11-04 11:37:01 -07002029# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002030# product partition image
2031ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2032INTERNAL_PRODUCTIMAGE_FILES := \
2033 $(filter $(TARGET_OUT_PRODUCT)/%,\
2034 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002035 $(ALL_PDK_FUSION_FILES)) \
2036 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002037
2038# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2039$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2040
2041INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
2042$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST)
2043 @echo Installed file list: $@
2044 @mkdir -p $(dir $@)
2045 @rm -f $@
2046 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
2047 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
2048
2049productimage_intermediates := \
2050 $(call intermediates-dir-for,PACKAGING,product)
2051BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2052define build-productimage-target
2053 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2054 @mkdir -p $(TARGET_OUT_PRODUCT)
2055 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
2056 $(call generate-userimage-prop-dictionary, $(productimage_intermediates)/product_image_info.txt, skip_fsck=true)
2057 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
2058 ./build/tools/releasetools/build_image.py \
2059 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2060 $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
2061endef
2062
2063# We just build this directly to the install location.
2064INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
2065$(INSTALLED_PRODUCTIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT) $(BUILD_IMAGE_SRCS)
2066 $(build-productimage-target)
2067
2068.PHONY: productimage-nodeps pnod
2069productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2070 $(build-productimage-target)
2071
2072sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2073
2074else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2075INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2076$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2077endif
2078
2079# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07002080# dtbo image
2081ifdef BOARD_PREBUILT_DTBOIMAGE
2082INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
2083
2084ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002085$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002086 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2087 $(AVBTOOL) add_hash_footer \
2088 --image $@ \
2089 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002090 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
Yueyao Zhu211c9012017-04-27 00:34:50 -07002091 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
2092else
2093$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2094 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2095endif
2096
2097endif
2098
2099# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002100# vbmeta image
2101ifeq ($(BOARD_AVB_ENABLE),true)
2102
2103BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002104AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002105
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002106ifdef BOARD_AVB_KEY_PATH
2107$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
2108else
2109# If key path isn't specified, use the 4096-bit test key.
2110BOARD_AVB_ALGORITHM := SHA256_RSA4096
2111BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
2112endif
2113
2114INTERNAL_AVB_SIGNING_ARGS := \
2115 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
2116
2117BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
2118DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
2119SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
2120VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05002121RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002122PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002123
2124# Check and set required build variables for a chain partition.
2125# $(1): the partition to enable AVB chain, e.g., BOOT or SYSTEM.
2126define check-and-set-avb-chain-args
2127$(eval PART := $(1))
Bowgo Tsaie615afd2017-06-20 17:38:21 +08002128$(eval part=$(call to-lower,$(PART)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002129
2130$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
2131$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
2132$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
2133$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
2134$(if $($(_key_path)),,$(error $(_key_path) is not defined))
2135$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
2136$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
2137$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
2138
2139# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
2140$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
2141$(eval $(_signing_args) := \
2142 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
2143
2144$(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2145 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey)
2146
2147# Set rollback_index via footer args
2148$(eval _footer_args := $(PART)_FOOTER_ARGS)
2149$(eval $($(_footer_args)) += --rollback_index $($(_rollback_index)))
2150endef
2151
2152ifdef BOARD_AVB_BOOT_KEY_PATH
2153$(eval $(call check-and-set-avb-chain-args,BOOT))
2154else
2155INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2156 --include_descriptors_from_image $(INSTALLED_BOOTIMAGE_TARGET)
2157endif
2158
2159ifdef BOARD_AVB_SYSTEM_KEY_PATH
2160$(eval $(call check-and-set-avb-chain-args,SYSTEM))
2161else
2162INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2163 --include_descriptors_from_image $(INSTALLED_SYSTEMIMAGE)
2164endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002165
2166ifdef INSTALLED_VENDORIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002167ifdef BOARD_AVB_VENDOR_KEY_PATH
2168$(eval $(call check-and-set-avb-chain-args,VENDOR))
2169else
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002170INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2171 --include_descriptors_from_image $(INSTALLED_VENDORIMAGE_TARGET)
2172endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002173endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002174
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002175ifdef INSTALLED_PRODUCTIMAGE_TARGET
2176ifdef BOARD_AVB_PRODUCT_KEY_PATH
2177$(eval $(call check-and-set-avb-chain-args,PRODUCT))
2178else
2179INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2180 --include_descriptors_from_image $(INSTALLED_PRODUCTIMAGE_TARGET)
2181endif
2182endif
2183
Yueyao Zhu211c9012017-04-27 00:34:50 -07002184ifdef INSTALLED_DTBOIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002185ifdef BOARD_AVB_DTBO_KEY_PATH
2186$(eval $(call check-and-set-avb-chain-args,DTBO))
2187else
Yueyao Zhu211c9012017-04-27 00:34:50 -07002188INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
Tao Baoc633ed02017-05-30 21:46:33 -07002189 --include_descriptors_from_image $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002190endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002191endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07002192
David Zeuthen8fecb282017-12-01 16:24:01 -05002193ifdef INSTALLED_RECOVERYIMAGE_TARGET
2194ifdef BOARD_AVB_RECOVERY_KEY_PATH
2195$(eval $(call check-and-set-avb-chain-args,RECOVERY))
2196else
2197INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2198 --include_descriptors_from_image $(INSTALLED_RECOVERYIMAGE_TARGET)
2199endif
2200endif
2201
Bowgo Tsai9e95bea2017-06-30 12:12:15 +08002202BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
Bowgo Tsai53cf9992017-06-13 11:27:06 +08002203
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002204# Add kernel cmdline descriptor for kernel to mount system.img as root with
2205# dm-verity. This works when system.img is either chained or not-chained:
2206# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
2207# cmdline descriptor to system.img
2208# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
2209# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08002210ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002211BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08002212endif
2213
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002214ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002215BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002216endif
2217
2218ifndef BOARD_BOOTIMAGE_PARTITION_SIZE
2219 $(error BOARD_BOOTIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
2220endif
2221
2222ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
2223 $(error BOARD_SYSTEMIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
2224endif
2225
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002226# $(1): the directory to extract public keys to
2227define extract-avb-chain-public-keys
2228 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
2229 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
2230 --output $(1)/boot.avbpubkey)
2231 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
2232 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
2233 --output $(1)/system.avbpubkey)
2234 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
2235 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
2236 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002237 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
2238 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
2239 --output $(1)/product.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002240 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
2241 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
2242 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05002243 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
2244 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
2245 --output $(1)/recovery.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002246endef
2247
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002248define build-vbmetaimage-target
2249 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002250 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
2251 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002252 $(hide) $(AVBTOOL) make_vbmeta_image \
2253 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
2254 $(INTERNAL_AVB_SIGNING_ARGS) \
2255 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
2256 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002257 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002258endef
2259
2260INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
David Zeuthen8fecb282017-12-01 16:24:01 -05002261$(INSTALLED_VBMETAIMAGE_TARGET): \
2262 $(AVBTOOL) \
2263 $(INSTALLED_BOOTIMAGE_TARGET) \
2264 $(INSTALLED_SYSTEMIMAGE) \
2265 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002266 $(INSTALLED_PRODUCTIMAGE_TARGET) \
David Zeuthen8fecb282017-12-01 16:24:01 -05002267 $(INSTALLED_DTBOIMAGE_TARGET) \
2268 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2269 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002270 $(build-vbmetaimage-target)
2271
2272.PHONY: vbmetaimage-nodeps
2273vbmetaimage-nodeps:
2274 $(build-vbmetaimage-target)
2275
Bowgo Tsai9afc0d52017-07-27 21:22:14 +08002276else ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE))
2277BUILT_DISABLED_VBMETAIMAGE := $(PRODUCT_OUT)/vbmeta.img
2278
2279INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_DISABLED_VBMETAIMAGE)
2280$(INSTALLED_VBMETAIMAGE_TARGET): $(AVBTOOL)
2281 $(hide) $(AVBTOOL) make_vbmeta_image \
2282 --flag 2 --padding_size 4096 --output $@
2283
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002284endif # BOARD_AVB_ENABLE
2285
2286# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08002287# bring in the installer image generation defines if necessary
2288ifeq ($(TARGET_USE_DISKINSTALLER),true)
2289include bootable/diskinstaller/config.mk
2290endif
2291
2292# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07002293# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08002294
Ying Wangbd2d0242015-09-22 11:17:52 -07002295build_ota_package := true
2296ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
2297build_ota_package := false
2298endif
2299ifeq ($(BUILD_OS),darwin)
2300build_ota_package := false
2301endif
2302ifneq ($(strip $(SANITIZE_TARGET)),)
2303build_ota_package := false
2304endif
2305ifeq ($(TARGET_PRODUCT),sdk)
2306build_ota_package := false
2307endif
2308ifneq ($(filter generic%,$(TARGET_DEVICE)),)
2309build_ota_package := false
2310endif
2311ifeq ($(TARGET_NO_KERNEL),true)
2312build_ota_package := false
2313endif
2314ifeq ($(recovery_fstab),)
2315build_ota_package := false
2316endif
Colin Cross481cc5a2016-02-04 15:09:23 -08002317ifeq ($(TARGET_BUILD_PDK),true)
2318build_ota_package := false
2319endif
Ying Wangbd2d0242015-09-22 11:17:52 -07002320
2321ifeq ($(build_ota_package),true)
Ying Wang09c4b682015-08-11 11:24:19 -07002322OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
2323 $(HOST_OUT_EXECUTABLES)/aapt \
Michael Schwartz6473e752017-11-08 11:45:14 -08002324 $(HOST_OUT_EXECUTABLES)/checkvintf \
Ying Wangc45a47b2015-04-08 12:24:37 -07002325 $(HOST_OUT_EXECUTABLES)/mkbootfs \
2326 $(HOST_OUT_EXECUTABLES)/mkbootimg \
2327 $(HOST_OUT_EXECUTABLES)/fs_config \
2328 $(HOST_OUT_EXECUTABLES)/zipalign \
2329 $(HOST_OUT_EXECUTABLES)/bsdiff \
2330 $(HOST_OUT_EXECUTABLES)/imgdiff \
2331 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
2332 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
2333 $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
Tao Baoe8ef8f702017-05-17 11:41:50 -07002334 $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar \
Tao Baobcc31092017-01-06 14:24:18 -08002335 $(HOST_OUT_EXECUTABLES)/mke2fs \
2336 $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh \
2337 $(HOST_OUT_EXECUTABLES)/e2fsdroid \
Tao Baocffaf732016-04-14 12:11:36 -07002338 $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \
2339 $(HOST_OUT_EXECUTABLES)/mksquashfs \
2340 $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \
2341 $(HOST_OUT_EXECUTABLES)/make_f2fs \
Jaegeuk Kim2ea1eba2017-11-28 19:21:28 -08002342 $(HOST_OUT_EXECUTABLES)/sload_f2fs \
Ying Wangc45a47b2015-04-08 12:24:37 -07002343 $(HOST_OUT_EXECUTABLES)/simg2img \
2344 $(HOST_OUT_EXECUTABLES)/e2fsck \
Baligh Uddinc8bef142017-12-18 10:40:57 -08002345 $(HOST_OUT_EXECUTABLES)/generate_verity_key \
Ying Wangc45a47b2015-04-08 12:24:37 -07002346 $(HOST_OUT_EXECUTABLES)/verity_signer \
Tao Bao7f02f342016-11-18 17:04:24 -08002347 $(HOST_OUT_EXECUTABLES)/verity_verifier \
Ying Wangc45a47b2015-04-08 12:24:37 -07002348 $(HOST_OUT_EXECUTABLES)/append2simg \
Mohamad Ayyash353265b2015-06-24 15:42:19 -07002349 $(HOST_OUT_EXECUTABLES)/img2simg \
Sami Tolvanenf99b5312015-05-20 07:30:57 +01002350 $(HOST_OUT_EXECUTABLES)/boot_signer \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002351 $(HOST_OUT_EXECUTABLES)/fec \
Tao Bao6d8a8cc2016-01-19 14:47:17 -08002352 $(HOST_OUT_EXECUTABLES)/brillo_update_payload \
2353 $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \
Tao Baof54216f2016-03-29 15:12:37 -07002354 $(HOST_OUT_EXECUTABLES)/delta_generator \
Tao Bao3cba3742017-05-16 16:27:25 -07002355 $(AVBTOOL) \
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002356 $(BLK_ALLOC_TO_BASE_FS) \
Tao Baob4ec6d72018-03-15 23:21:28 -07002357 $(BROTLI) \
2358 $(BUILD_VERITY_METADATA) \
2359 $(BUILD_VERITY_TREE)
Tao Bao5e04c382017-02-22 16:38:19 -08002360
2361ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
2362OTATOOLS += \
Tao Bao69ad1502017-02-23 11:03:45 -08002363 $(FUTILITY) \
2364 $(VBOOT_SIGNER)
Tao Bao5e04c382017-02-22 16:38:19 -08002365endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08002366
Ying Wangc45a47b2015-04-08 12:24:37 -07002367# Shared libraries.
Ying Wang09c4b682015-08-11 11:24:19 -07002368OTATOOLS += \
Mark Salyzync506e742015-04-13 09:01:24 -07002369 $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
2370 $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \
2371 $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02002372 $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \
Baligh Uddinc8bef142017-12-18 10:40:57 -08002373 $(HOST_LIBRARY_PATH)/libcrypto_utils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02002374 $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08002375 $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \
2376 $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \
2377 $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \
2378 $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \
Baligh Uddinb24470e2017-01-30 12:41:31 -08002379 $(HOST_LIBRARY_PATH)/libext2_misc$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08002380 $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \
2381 $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \
Alex Klyubin9667b182015-12-10 13:38:50 -08002382 $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002383 $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \
2384 $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \
2385 $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002386 $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \
2387 $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \
Dan Willemsen8c2b6bb2016-07-22 23:16:30 +00002388 $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \
Tao Baofdd26932016-02-11 09:50:41 -08002389 $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002390 $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \
Johan Redestig8f800df2016-03-24 13:57:03 +01002391 $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \
Tao Bao138986b2017-01-26 08:16:57 -08002392 $(HOST_LIBRARY_PATH)/libsparse-host$(HOST_SHLIB_SUFFIX) \
Vikram Dattu8be44672016-12-16 16:33:03 +01002393 $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) \
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002394 $(HOST_LIBRARY_PATH)/libpcre2$(HOST_SHLIB_SUFFIX) \
2395 $(HOST_LIBRARY_PATH)/libbrotli$(HOST_SHLIB_SUFFIX)
2396
The Android Open Source Project88b60792009-03-03 19:28:42 -08002397
Ying Wang06898662010-06-17 17:52:18 -07002398.PHONY: otatools
2399otatools: $(OTATOOLS)
2400
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002401BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
Ying Wang62925a92015-04-08 16:37:34 -07002402$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002403
Tao Baoe8ef8f702017-05-17 11:41:50 -07002404OTATOOLS_DEPS := \
Tao Baoe8ef8f702017-05-17 11:41:50 -07002405 system/extras/ext4_utils/mke2fs.conf \
Bryan Henry97f21ac2018-04-26 11:25:23 -07002406 external/avb/test/data/atx_metadata.bin \
2407 external/avb/test/data/testkey_atx_psk.pem \
Tao Bao3cba3742017-05-16 16:27:25 -07002408 external/avb/test/data/testkey_rsa4096.pem \
Dan Willemsenbe0b6ce2018-02-05 22:41:10 -08002409 $(sort $(shell find system/update_engine/scripts -name \*.pyc -prune -o -type f -print)) \
2410 $(sort $(shell find build/target/product/security -type f -name \*.x509.pem -o -name \*.pk8 -o \
2411 -name verity_key)) \
2412 $(sort $(shell find device $(wildcard vendor) -type f -name \*.pk8 -o -name verifiedboot\* -o \
2413 -name \*.x509.pem -o -name oem\*.prop))
Tao Baoe8ef8f702017-05-17 11:41:50 -07002414
2415OTATOOLS_RELEASETOOLS := \
Dan Willemsenbe0b6ce2018-02-05 22:41:10 -08002416 $(sort $(shell find build/make/tools/releasetools -name \*.pyc -prune -o -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07002417
2418ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
2419OTATOOLS_DEPS += \
Dan Willemsenbe0b6ce2018-02-05 22:41:10 -08002420 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07002421endif
2422
2423$(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) $(OTATOOLS_DEPS) $(OTATOOLS_RELEASETOOLS) | $(ACP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002424 @echo "Package OTA tools: $@"
2425 $(hide) rm -rf $@ $(zip_root)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002426 $(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools
Ying Wangc45a47b2015-04-08 12:24:37 -07002427 $(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
Colin Crossfdea8932017-12-06 14:38:40 -08002428 $(hide) $(ACP) -r -d -p build/make/tools/releasetools/* $(zip_root)/releasetools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002429 $(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
Dan Willemsen48a621c2015-10-29 16:33:05 -07002430 $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002431 $(hide) echo $(OTATOOLS_DEPS) | xargs zip -qryX $(abspath $@)>/dev/null || true
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002432
2433.PHONY: otatools-package
2434otatools-package: $(BUILT_OTATOOLS_PACKAGE)
2435
Ying Wangbd2d0242015-09-22 11:17:52 -07002436endif # build_ota_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002437
The Android Open Source Project88b60792009-03-03 19:28:42 -08002438# -----------------------------------------------------------------
2439# A zip of the directories that map to the target filesystem.
2440# This zip can be used to create an OTA package or filesystem image
2441# as a post-build step.
2442#
2443name := $(TARGET_PRODUCT)
2444ifeq ($(TARGET_BUILD_TYPE),debug)
2445 name := $(name)_debug
2446endif
2447name := $(name)-target_files-$(FILE_NAME_TAG)
2448
2449intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
2450BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
2451$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
2452$(BUILT_TARGET_FILES_PACKAGE): \
2453 zip_root := $(intermediates)/$(name)
2454
2455# $(1): Directory to copy
2456# $(2): Location to copy it to
2457# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
2458define package_files-copy-root
2459 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
2460 mkdir -p $(2) && \
2461 $(ACP) -rd $(strip $(1))/* $(2); \
2462 fi
2463endef
2464
Tao Baoa04fca32015-11-30 12:22:24 -08002465built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07002466
2467# We can't build static executables when SANITIZE_TARGET=address
Ivan Krasin74b32b82015-09-18 11:54:43 -07002468ifeq ($(strip $(SANITIZE_TARGET)),)
Ying Wange6e544e2015-06-22 18:35:35 -07002469built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07002470 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
2471endif
2472
The Android Open Source Project88b60792009-03-03 19:28:42 -08002473$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
2474
Doug Zongkerb1134dd2009-06-17 17:09:40 -07002475$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08002476$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07002477
Doug Zongkerc18736b2009-09-30 09:20:32 -07002478ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
2479# default to common dir for device vendor
Dan Willemsen653bea92017-03-21 15:47:37 -07002480tool_extensions := $(TARGET_DEVICE_DIR)/../common
Doug Zongkerc18736b2009-09-30 09:20:32 -07002481else
Dan Willemsen653bea92017-03-21 15:47:37 -07002482tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
Doug Zongkerc18736b2009-09-30 09:20:32 -07002483endif
Dan Willemsen653bea92017-03-21 15:47:37 -07002484tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
2485$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSIONS := $(tool_extensions)
2486$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07002487
Sen Jiang4438fd92016-03-07 16:51:01 -08002488ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08002489updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08002490else
Steve Fung48e49f52015-10-01 23:53:31 -07002491# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002492updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07002493endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002494$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07002495
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002496# If we are using recovery as boot, output recovery files to BOOT/.
2497ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2498$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
2499else
2500$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
2501endif
2502
Dan Willemsen653bea92017-03-21 15:47:37 -07002503ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07002504 ifdef OSRELEASED_DIRECTORY
2505 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
2506 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
2507 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
2508 endif
2509endif
2510
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002511# Run fs_config while creating the target files package
2512# $1: root directory
2513# $2: add prefix
2514define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08002515(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 -08002516endef
2517
The Android Open Source Project88b60792009-03-03 19:28:42 -08002518# Depending on the various images guarantees that the underlying
2519# directories are up-to-date.
2520$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002521 $(INSTALLED_BOOTIMAGE_TARGET) \
2522 $(INSTALLED_RADIOIMAGE_TARGET) \
2523 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002524 $(FULL_SYSTEMIMAGE_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002525 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002526 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07002527 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002528 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Bowgo Tsai6a749792017-09-01 22:55:44 +08002529 $(INSTALLED_VBMETAIMAGE_TARGET) \
Yueyao Zhu211c9012017-04-27 00:34:50 -07002530 $(INSTALLED_DTBOIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002531 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002532 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Dan Willemsen653bea92017-03-21 15:47:37 -07002533 $(INSTALLED_KERNEL_TARGET) \
2534 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2535 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
2536 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002537 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07002538 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002539 $(APKCERTS_FILE) \
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002540 $(SOONG_ZIP) \
Doug Zongker283e2a12010-03-15 17:52:32 -07002541 $(HOST_OUT_EXECUTABLES)/fs_config \
Dan Willemsend79a08f2017-03-23 22:09:06 -07002542 $(HOST_OUT_EXECUTABLES)/imgdiff \
2543 $(HOST_OUT_EXECUTABLES)/bsdiff \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002544 $(BUILD_IMAGE_SRCS) \
Steven Moreland3629aa72018-04-04 15:41:05 -07002545 $(HOST_OUT_EXECUTABLES)/assemble_vintf \
Steven Moreland915f3512018-01-25 10:44:47 -08002546 $(BUILT_VENDOR_MANIFEST) \
2547 $(BUILT_VENDOR_MATRIX) \
Ying Wang5d887702015-11-04 10:06:25 -08002548 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002549 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07002550 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002551 $(call create-system-product-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002552 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002553 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002554ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002555 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002556 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002557 $(hide) $(call package_files-copy-root, \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002558 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002559ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002560 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08002561endif
2562ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002563 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08002564endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002565ifdef BOARD_INCLUDE_RECOVERY_DTBO
2566 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
2567endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002568ifdef INTERNAL_KERNEL_CMDLINE
2569 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08002570endif
Doug Zongker38a649f2009-06-17 09:07:09 -07002571ifdef BOARD_KERNEL_BASE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002572 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07002573endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002574ifdef BOARD_KERNEL_PAGESIZE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002575 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07002576endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002577endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08002578 @# Components of the boot image
2579 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07002580ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
2581 $(hide) mkdir -p $(zip_root)/ROOT
2582 $(hide) $(call package_files-copy-root, \
2583 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
2584else
The Android Open Source Project88b60792009-03-03 19:28:42 -08002585 $(hide) $(call package_files-copy-root, \
2586 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07002587endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002588 @# If we are using recovery as boot, this is already done when processing recovery.
2589ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002590ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002591 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08002592endif
2593ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002594 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08002595endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002596ifdef INTERNAL_KERNEL_CMDLINE
2597 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08002598endif
Doug Zongker38a649f2009-06-17 09:07:09 -07002599ifdef BOARD_KERNEL_BASE
2600 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
2601endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002602ifdef BOARD_KERNEL_PAGESIZE
2603 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
2604endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002605endif # BOARD_USES_RECOVERY_AS_BOOT
Doug Zongkere01100c2009-06-19 17:12:18 -07002606 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
2607 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07002608 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002609 @# Contents of the system image
2610 $(hide) $(call package_files-copy-root, \
2611 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
2612 @# Contents of the data image
2613 $(hide) $(call package_files-copy-root, \
2614 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07002615ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2616 @# Contents of the vendor image
2617 $(hide) $(call package_files-copy-root, \
2618 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
2619endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002620ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2621 @# Contents of the product image
2622 $(hide) $(call package_files-copy-root, \
2623 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
2624endif
Alex Light4e358ab2016-06-16 14:47:10 -07002625ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
2626 @# Contents of the system_other image
2627 $(hide) $(call package_files-copy-root, \
2628 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
2629endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002630 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07002631 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07002632 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07002633ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08002634ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07002635 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07002636 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07002637endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08002638endif
Doug Zongker8678df42009-06-15 14:30:14 -07002639 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08002640 @# build them.
2641 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07002642 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
2643ifneq ($(tool_extension),)
2644 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
2645endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07002646 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07002647 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Doug Zongker37974732010-09-16 17:44:38 -07002648 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08002649 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002650ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07002651 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002652endif
2653ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08002654 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002655endif
Tao Baodb45efa2015-10-27 19:25:18 -07002656ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
2657 $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
2658endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002659ifdef BOARD_INCLUDE_RECOVERY_DTBO
2660 $(hide) echo "include_recovery_dtbo=true" >> $(zip_root)/META/misc_info.txt
2661endif
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002662ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08002663 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002664endif
JP Abgrall6ea5bd62014-10-22 20:01:22 -07002665ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
2666 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
2667 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
2668else
2669 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
2670endif
Dan Willemsen653bea92017-03-21 15:47:37 -07002671 $(hide) echo "tool_extensions=$(PRIVATE_TOOL_EXTENSIONS)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07002672 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07002673ifdef PRODUCT_EXTRA_RECOVERY_KEYS
2674 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08002675endif
Jianxun Zhang09849492013-04-17 15:19:19 -07002676 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Sami Tolvanen3303d902016-03-15 16:49:30 +00002677 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08002678 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Tao Bao8fad03e2017-03-01 14:36:26 -08002679 $(hide) echo "blockimgdiff_versions=3,4" >> $(zip_root)/META/misc_info.txt
Ying Wange24e17a2014-10-07 18:42:11 -07002680ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
Jeff Sharkey26e1a282014-03-21 16:20:05 -07002681 # OTA scripts are only interested in fingerprint related properties
Ying Wange24e17a2014-10-07 18:42:11 -07002682 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
Vineeta Srivastava27262112014-09-18 14:34:00 -07002683endif
Tao Baof54216f2016-03-29 15:12:37 -07002684ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07002685 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07002686 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH))
2687endif
2688ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07002689 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07002690 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH))
2691endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002692ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH),)
2693 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH) \
2694 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH))
2695endif
Ivan Krasin74b32b82015-09-18 11:54:43 -07002696ifneq ($(strip $(SANITIZE_TARGET)),)
Ying Wang2a048392015-06-25 13:56:53 -07002697 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
2698 $(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt
2699endif
Tao Bao8beab692015-07-22 12:33:18 -07002700ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
2701 $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
2702endif
David Zeuthen0eb10972016-09-28 17:55:27 -04002703ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002704 $(hide) echo "avb_enable=true" >> $(zip_root)/META/misc_info.txt
2705 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2706 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2707 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
2708 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2709ifdef BOARD_AVB_BOOT_KEY_PATH
2710 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2711 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2712 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
2713endif # BOARD_AVB_BOOT_KEY_PATH
David Zeuthen8fecb282017-12-01 16:24:01 -05002714 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2715ifdef BOARD_AVB_RECOVERY_KEY_PATH
2716 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2717 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2718 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
2719endif # BOARD_AVB_RECOVERY_KEY_PATH
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002720endif # BOARD_AVB_ENABLE
David Zeuthen25328622016-04-08 15:08:03 -04002721ifdef BOARD_BPT_INPUT_FILES
2722 $(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt
2723 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $(zip_root)/META/misc_info.txt
2724 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $(zip_root)/META/misc_info.txt
2725endif
2726ifdef BOARD_BPT_DISK_SIZE
2727 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $(zip_root)/META/misc_info.txt
2728endif
Ying Wangbd93d422011-10-28 17:02:30 -07002729 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Tao Baocbc6dc22015-08-18 18:03:56 -07002730ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Per Astrandcab66992015-03-25 14:06:30 +01002731 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08002732 build/make/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07002733endif
Alex Deymo70067ac2015-09-29 19:05:37 -07002734ifeq ($(AB_OTA_UPDATER),true)
2735 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07002736 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07002737 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07002738 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
2739 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08002740 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
2741 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
2742 done
Steve Fung4044b382015-11-05 02:04:04 -08002743 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
2744 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002745 $(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07002746ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07002747 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
2748 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
2749 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07002750endif
Alex Deymo70067ac2015-09-29 19:05:37 -07002751endif
Steve Fungdfbab492015-09-24 18:12:33 -07002752ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07002753 @# If breakpad symbols have been generated, add them to the zip.
Steve Fungdfbab492015-09-24 18:12:33 -07002754 $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
2755endif
Bowgo Tsai6a749792017-09-01 22:55:44 +08002756# BOARD_BUILD_DISABLED_VBMETAIMAGE is used to build a special vbmeta.img
2757# that disables AVB verification. The content is fixed and we can just copy
2758# it to $(zip_root)/IMAGES without passing some info into misc_info.txt for
2759# regeneration.
2760ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE))
2761 $(hide) mkdir -p $(zip_root)/IMAGES
2762 $(hide) cp $(INSTALLED_VBMETAIMAGE_TARGET) $(zip_root)/IMAGES/
2763endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002764ifdef BOARD_PREBUILT_VENDORIMAGE
2765 $(hide) mkdir -p $(zip_root)/IMAGES
2766 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
2767endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002768ifdef BOARD_PREBUILT_PRODUCTIMAGE
2769 $(hide) mkdir -p $(zip_root)/IMAGES
2770 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
2771endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07002772ifdef BOARD_PREBUILT_BOOTIMAGE
2773 $(hide) mkdir -p $(zip_root)/IMAGES
2774 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
2775endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07002776ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07002777 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
2778 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
2779 $(hide) echo "has_dtbo=true" >> $(zip_root)/META/misc_info.txt
2780ifeq ($(BOARD_AVB_ENABLE),true)
2781 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002782 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2783ifdef BOARD_AVB_DTBO_KEY_PATH
2784 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2785 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2786 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" \
Tao Baoc633ed02017-05-30 21:46:33 -07002787 >> $(zip_root)/META/misc_info.txt
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002788endif # BOARD_AVB_DTBO_KEY_PATH
2789endif # BOARD_AVB_ENABLE
2790endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07002791 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
2792 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
2793 @# INSTALLED_RADIOIMAGE_TARGET.
2794 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
2795 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002796 @# Run fs_config on all the system, vendor, boot ramdisk,
2797 @# and recovery ramdisk files in the zip, and save the output
2798 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
2799ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2800 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
2801endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002802ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2803 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
2804endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002805ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Tao Baoda01b212018-02-28 21:20:08 -08002806 @# When using BOARD_BUILD_SYSTEM_ROOT_IMAGE, ROOT always contains the files for the root under
2807 @# normal boot. BOOT/RAMDISK exists only if additionally using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002808 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08002809ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002810 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08002811endif
2812else # BOARD_BUILD_SYSTEM_ROOT_IMAGE != true
2813 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
2814endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002815ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
2816 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
2817endif
2818ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
2819 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
2820endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002821 @# Metadata for compatibility verification.
Yifan Hong35b34ef2017-05-15 18:00:37 -07002822 $(hide) cp $(BUILT_SYSTEM_COMPATIBILITY_MATRIX) $(zip_root)/META/system_matrix.xml
Steven Moreland3629aa72018-04-04 15:41:05 -07002823 $(hide) $(HOST_OUT_EXECUTABLES)/assemble_vintf \
2824 -i $(BUILT_SYSTEM_MANIFEST) $$(find $(zip_root)/SYSTEM/etc/vintf/manifest -type f -name "*.xml" | \
2825 sed "s/^/-i /" | tr '\n' ' ') \
2826 -o $(zip_root)/META/system_manifest.xml
Yifan Hongaa212212017-04-14 00:00:46 -07002827ifdef BUILT_VENDOR_MANIFEST
Steven Moreland3629aa72018-04-04 15:41:05 -07002828 $(hide) $(HOST_OUT_EXECUTABLES)/assemble_vintf \
2829 -i $(BUILT_VENDOR_MANIFEST) $$(find $(zip_root)/VENDOR/etc/vintf/manifest -type f -name "*.xml" | \
2830 sed "s/^/-i /" | tr '\n' ' ') \
2831 -o $(zip_root)/META/vendor_manifest.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002832endif
Yifan Hongaa212212017-04-14 00:00:46 -07002833ifdef BUILT_VENDOR_MATRIX
2834 $(hide) cp $(BUILT_VENDOR_MATRIX) $(zip_root)/META/vendor_matrix.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002835endif
2836
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002837 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08002838 build/make/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root)
Alex Deymo92cfd6f2016-01-26 18:47:44 -08002839 @# Zip everything up, preserving symlinks and placing META/ files first to
2840 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002841 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07002842 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002843 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07002844
Ying Wanga0febe52013-03-20 11:02:05 -07002845.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08002846target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
2847
Ying Wang4709d7c2014-04-14 17:25:43 -07002848ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
2849$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
2850endif
Doug Zongker367910f2009-06-15 18:56:51 -07002851
Dan Albert4d323332016-10-14 13:23:06 -07002852# -----------------------------------------------------------------
2853# NDK Sysroot Package
2854NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
2855$(NDK_SYSROOT_TARGET): ndk
2856 @echo Package NDK sysroot...
2857 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
2858
2859$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
2860
Ying Wang09c4b682015-08-11 11:24:19 -07002861ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07002862# -----------------------------------------------------------------
2863# OTA update package
2864
Doug Zongker8678df42009-06-15 14:30:14 -07002865name := $(TARGET_PRODUCT)
2866ifeq ($(TARGET_BUILD_TYPE),debug)
2867 name := $(name)_debug
2868endif
2869name := $(name)-ota-$(FILE_NAME_TAG)
2870
2871INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2872
2873$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
2874
Tao Baoe53c6e72017-04-19 15:54:22 -07002875ifeq ($(AB_OTA_UPDATER),true)
2876$(INTERNAL_OTA_PACKAGE_TARGET): $(BRILLO_UPDATE_PAYLOAD)
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002877else
Alex Deymob10e07a2017-11-09 23:53:42 +01002878$(INTERNAL_OTA_PACKAGE_TARGET): $(BROTLI)
Tao Baoe53c6e72017-04-19 15:54:22 -07002879endif
2880
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002881$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
Colin Crossfdea8932017-12-06 14:38:40 -08002882 build/make/tools/releasetools/ota_from_target_files
Doug Zongker8678df42009-06-15 14:30:14 -07002883 @echo "Package OTA: $@"
Ying Wang9d252e12015-02-09 17:20:06 -08002884 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08002885 build/make/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08002886 --block \
Dan Willemsencea5cd22017-03-21 14:44:27 -07002887 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
Doug Zongker602a84e2009-06-18 08:35:12 -07002888 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05002889 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07002890 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05002891 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07002892
2893.PHONY: otapackage
2894otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
2895
Ying Wang09c4b682015-08-11 11:24:19 -07002896endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07002897
Ying Wang09a00a62010-10-20 14:01:09 -07002898# -----------------------------------------------------------------
2899# The update package
2900
2901name := $(TARGET_PRODUCT)
2902ifeq ($(TARGET_BUILD_TYPE),debug)
2903 name := $(name)_debug
2904endif
2905name := $(name)-img-$(FILE_NAME_TAG)
2906
2907INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2908
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002909$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(ZIP2ZIP)
Ying Wang09a00a62010-10-20 14:01:09 -07002910 @echo "Package: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002911 $(hide) $(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
2912 OTA/android-info.txt:android-info.txt "IMAGES/*.img:."
Ying Wang09a00a62010-10-20 14:01:09 -07002913
2914.PHONY: updatepackage
2915updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
2916
The Android Open Source Project88b60792009-03-03 19:28:42 -08002917# -----------------------------------------------------------------
2918# A zip of the symbols directory. Keep the full paths to make it
2919# more obvious where these files came from.
2920#
2921name := $(TARGET_PRODUCT)
2922ifeq ($(TARGET_BUILD_TYPE),debug)
2923 name := $(name)_debug
2924endif
2925name := $(name)-symbols-$(FILE_NAME_TAG)
2926
2927SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07002928# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07002929ifndef TARGET_BUILD_APPS
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002930$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) \
2931 $(INSTALLED_BOOTIMAGE_TARGET) \
2932 $(INSTALLED_USERDATAIMAGE_TARGET) \
2933 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002934 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002935 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07002936endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002937$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
2938$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002939 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002940 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
2941 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
2942 $(hide) find $(TARGET_OUT_UNSTRIPPED) | sort >$(PRIVATE_LIST_FILE)
Dan Willemsen6cf21a72017-01-30 20:42:28 -08002943 $(hide) $(SOONG_ZIP) -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07002944# -----------------------------------------------------------------
2945# A zip of the coverage directory.
2946#
2947name := $(TARGET_PRODUCT)
2948ifeq ($(TARGET_BUILD_TYPE),debug)
2949name := $(name)_debug
2950endif
2951name := $(name)-coverage-$(FILE_NAME_TAG)
2952COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
2953ifndef TARGET_BUILD_APPS
2954$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE) \
2955 $(INSTALLED_BOOTIMAGE_TARGET) \
2956 $(INSTALLED_USERDATAIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002957 $(INSTALLED_VENDORIMAGE_TARGET) \
2958 $(INSTALLED_PRODUCTIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07002959endif
2960$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
2961$(COVERAGE_ZIP): $(SOONG_ZIP)
2962 @echo "Package coverage: $@"
2963 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
2964 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
2965 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
2966 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002967
2968# -----------------------------------------------------------------
2969# A zip of the Android Apps. Not keeping full path so that we don't
2970# include product names when distributing
2971#
2972name := $(TARGET_PRODUCT)
2973ifeq ($(TARGET_BUILD_TYPE),debug)
2974 name := $(name)_debug
2975endif
2976name := $(name)-apps-$(FILE_NAME_TAG)
2977
2978APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Ying Wang5d887702015-11-04 10:06:25 -08002979$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002980 @echo "Package apps: $@"
2981 $(hide) rm -rf $@
2982 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07002983 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
2984 if [ -z "$$apps_to_zip" ]; then \
2985 echo "No apps to zip up. Generating empty apps archive." ; \
2986 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
2987 else \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002988 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07002989 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07002990
Ying Wangbc415dd2012-08-15 12:22:44 -07002991ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07002992#------------------------------------------------------------------
2993# An archive of classes for use in generating code-coverage reports
2994# These are the uninstrumented versions of any classes that were
2995# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07002996# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07002997
Colin Crossa6bc3a82017-09-27 14:28:41 -07002998JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07002999$(JACOCO_REPORT_CLASSES_ALL) :
3000 @echo "Collecting uninstrumented classes"
3001 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" | \
3002 zip -@ -0 -q -X $@
3003# Meaning of these options:
3004# -@ scan stdin for file paths to add to the zip
3005# -0 don't do any compression
3006# -q supress most output
3007# -X skip storing extended file attributes
3008
Ying Wangbc415dd2012-08-15 12:22:44 -07003009endif # EMMA_INSTRUMENT=true
3010
Jeff Gastonaaae43c2017-04-11 16:36:46 -07003011
Ying Wangae9115a2013-08-22 20:52:47 -07003012#------------------------------------------------------------------
3013# A zip of Proguard obfuscation dictionary files.
3014# Only for apps_only build.
3015#
3016ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07003017PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07003018# the dependency will be set up later in build/make/core/main.mk.
Ying Wangae9115a2013-08-22 20:52:47 -07003019$(PROGUARD_DICT_ZIP) :
3020 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossa6bc3a82017-09-27 14:28:41 -07003021 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
Ying Wangae9115a2013-08-22 20:52:47 -07003022 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08003023 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
Dan Willemsen48a621c2015-10-29 16:33:05 -07003024 zip -qX $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07003025 else \
Ying Wangdcd90832015-02-26 09:36:27 -08003026 touch $(dir $@)/zipdummy; \
3027 (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \
3028 zip -qd $@ zipdummy; \
3029 rm $(dir $@)/zipdummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07003030 fi
3031
3032endif # TARGET_BUILD_APPS
3033
The Android Open Source Project88b60792009-03-03 19:28:42 -08003034# -----------------------------------------------------------------
3035# dalvik something
3036.PHONY: dalvikfiles
3037dalvikfiles: $(INTERNAL_DALVIK_MODULES)
3038
Bo Huf0d50bb2017-08-01 19:02:09 +00003039ifeq ($(BUILD_QEMU_IMAGES),true)
3040INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
3041MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
3042SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
3043$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_SYSTEMIMAGE) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3044 @echo Create system-qemu.img
3045 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/system.img)
3046
3047systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
3048droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
3049ifeq ($(BOARD_USES_VENDORIMAGE),true)
3050INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
3051$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3052 @echo Create vendor-qemu.img
3053 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/vendor.img)
3054
3055vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
3056droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
3057endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003058ifeq ($(BOARD_USES_PRODUCTIMAGE),true)
3059INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
3060$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3061 @echo Create product-qemu.img
3062 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/product.img)
3063
3064productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
3065droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
3066endif
Bo Huf0d50bb2017-08-01 19:02:09 +00003067endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003068# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003069# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07003070ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003071INTERNAL_EMULATOR_PACKAGE_FILES += \
3072 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08003073 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003074 $(INSTALLED_RAMDISK_TARGET) \
3075 $(INSTALLED_SYSTEMIMAGE) \
3076 $(INSTALLED_USERDATAIMAGE_TARGET)
3077
3078name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
3079
3080INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
3081
Ying Wang5d887702015-11-04 10:06:25 -08003082$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003083 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07003084 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003085
Ying Wang7d8c5352012-07-26 10:15:21 -07003086endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003087# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08003088# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08003089# The pdk package (Platform Development Kit)
3090
Keun young Park7fc7aad2012-02-27 15:49:23 -08003091#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
3092# include development/pdk/Pdk.mk
3093#endif
3094
The Android Open Source Project88b60792009-03-03 19:28:42 -08003095
3096# -----------------------------------------------------------------
3097# The SDK
3098
The Android Open Source Project88b60792009-03-03 19:28:42 -08003099# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07003100sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003101
3102# Build a name that looks like:
3103#
3104# linux-x86 --> android-sdk_12345_linux-x86
3105# darwin-x86 --> android-sdk_12345_mac-x86
3106# windows-x86 --> android-sdk_12345_windows
3107#
3108sdk_name := android-sdk_$(FILE_NAME_TAG)
3109ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07003110 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08003111else
Joe Onorato03fbe402009-04-13 08:31:16 -07003112 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003113endif
3114ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07003115 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003116endif
Joe Onorato03fbe402009-04-13 08:31:16 -07003117sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003118
3119sdk_dep_file := $(sdk_dir)/sdk_deps.mk
3120
3121ATREE_FILES :=
3122-include $(sdk_dep_file)
3123
3124# if we don't have a real list, then use "everything"
3125ifeq ($(strip $(ATREE_FILES)),)
3126ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003127 $(ALL_DEFAULT_INSTALLED_MODULES) \
3128 $(INSTALLED_RAMDISK_TARGET) \
3129 $(ALL_DOCS) \
3130 $(ALL_SDK_FILES)
3131endif
3132
3133atree_dir := development/build
3134
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01003135
The Android Open Source Project88b60792009-03-03 19:28:42 -08003136sdk_atree_files := \
3137 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07003138 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08003139
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02003140# development/build/sdk-android-<abi>.atree is used to differentiate
3141# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
3142# files like the kernel image. We use TARGET_CPU_ABI because we don't
3143# have a better way to distinguish between CPU models.
3144ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
3145 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
3146endif
3147
Griff Hazen433febb2014-02-28 08:45:59 -08003148ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
3149sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
3150else
3151sdk_atree_files += $(atree_dir)/sdk.atree
3152endif
3153
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003154include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07003155
The Android Open Source Project88b60792009-03-03 19:28:42 -08003156deps := \
3157 $(target_notice_file_txt) \
3158 $(tools_notice_file_txt) \
3159 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07003160 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07003161 $(COVERAGE_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07003162 $(INSTALLED_SYSTEMIMAGE) \
Bo Huf0d50bb2017-08-01 19:02:09 +00003163 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu18d18682017-08-14 14:52:20 -07003164 $(INSTALLED_QEMU_VENDORIMAGE) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07003165 $(INSTALLED_USERDATAIMAGE_TARGET) \
3166 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003167 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07003168 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003169 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08003170 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003171 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07003172 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003173 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003174
3175INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
3176$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
3177$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
3178$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
3179$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
3180
3181# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
3182#
3183#SDK_GNU_ERROR := true
3184
Ying Wang5d887702015-11-04 10:06:25 -08003185$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003186 @echo "Package SDK: $@"
3187 $(hide) rm -rf $(PRIVATE_DIR) $@
3188 $(hide) for f in $(target_gnu_MODULES); do \
3189 if [ -f $$f ]; then \
3190 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
3191 including GNU target $$f >&2; \
3192 FAIL=$(SDK_GNU_ERROR); \
3193 fi; \
3194 done; \
3195 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07003196 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08003197 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07003198 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003199 $(HOST_OUT_EXECUTABLES)/atree \
3200 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
3201 -m $(PRIVATE_DEP_FILE) \
3202 -I . \
3203 -I $(PRODUCT_OUT) \
3204 -I $(HOST_OUT) \
3205 -I $(TARGET_COMMON_OUT_ROOT) \
3206 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08003207 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08003208 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08003209 -v "TARGET_ARCH=$(TARGET_ARCH)" \
3210 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02003211 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003212 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003213 -o $(PRIVATE_DIR) && \
3214 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07003215 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07003216 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003217 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08003218 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003219 chmod -R ug+rwX $(PRIVATE_DIR) && \
Dan Willemsen48a621c2015-10-29 16:33:05 -07003220 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003221 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
3222
Raphael3d224a02010-04-16 17:50:09 -07003223
3224# Is a Windows SDK requested? If so, we need some definitions from here
3225# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08003226MAIN_SDK_NAME := $(sdk_name)
3227MAIN_SDK_DIR := $(sdk_dir)
3228MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08003229ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07003230include $(TOPDIR)development/build/tools/windows_sdk.mk
3231endif
3232
The Android Open Source Project88b60792009-03-03 19:28:42 -08003233# -----------------------------------------------------------------
3234# Findbugs
3235INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
3236INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
3237$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
3238 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09003239 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003240 > $@
3241$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
3242 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09003243 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07003244 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08003245
3246# -----------------------------------------------------------------
3247# Findbugs
3248
3249# -----------------------------------------------------------------
3250# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07003251ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003252include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01003253-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07003254-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07003255-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07003256# Also the project-specific tasks
3257-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
3258-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07003259-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07003260# Also add test specifc tasks
3261include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07003262include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07003263endif
Raphaelc4d47312011-02-15 16:09:36 -08003264
Ying Wang67132ba2015-10-28 16:42:39 -07003265include $(BUILD_SYSTEM)/product-graph.mk
3266
Raphaelc4d47312011-02-15 16:09:36 -08003267# -----------------------------------------------------------------
3268# Create SDK repository packages. Must be done after tasks/* since
3269# we need the addon rules defined.
3270ifneq ($(sdk_repo_goal),)
3271include $(TOPDIR)development/build/tools/sdk_repo.mk
3272endif
Jayant Chowdhary67e0cc52018-02-23 16:50:39 -08003273
3274#------------------------------------------------------------------
3275# Find lsdump paths
3276FIND_LSDUMPS_FILE := $(PRODUCT_OUT)/lsdump_paths.txt
3277$(FIND_LSDUMPS_FILE) : $(LSDUMP_PATHS)
3278 $(hide) rm -rf $@ && echo "$^" > $@