blob: a67a4110e158c7cc22f6cc5fef3d8c0f3371b97c [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# Pick a reasonable string to use to identify files.
Colin Cross63fe36a2017-02-21 17:23:02 -08008ifneq (,$(filter eng.%,$(BUILD_NUMBER)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08009 # BUILD_NUMBER has a timestamp in it, which means that
10 # it will change every time. Pick a stable value.
11 FILE_NAME_TAG := eng.$(USER)
12else
13 FILE_NAME_TAG := $(BUILD_NUMBER)
14endif
15
16# -----------------------------------------------------------------
17# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070018# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080019# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
20# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080021# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070022# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070023#$(1): the src:dest pair
24define check-product-copy-files
Ying Wangc6c21d02014-01-21 20:25:46 -080025$(if $(filter %.apk, $(call word-colon, 2, $(1))),$(error \
Ying Wang68864102011-09-29 13:23:25 -070026 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
27endef
Ying Wang619fccf2012-09-05 18:08:29 -070028# filter out the duplicate <source file>:<dest file> pairs.
29unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080030$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070031 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
32 $(eval unique_product_copy_files_pairs += $(cf))))
33unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080034product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070035$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070036 $(eval _src := $(call word-colon,1,$(cf))) \
37 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang68864102011-09-29 13:23:25 -070038 $(call check-product-copy-files,$(cf)) \
Ying Wang193010c2011-12-16 11:54:25 -080039 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080040 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070041 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070042 $(if $(filter %.xml,$(_dest)),\
43 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010044 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
45 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
46 $(eval $(call copy-one-file,$(_src),$(_fulldest))))) \
Ying Wang462d26b2010-11-02 21:31:47 -070047 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070048 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080049
50# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
51$(file >$(PRODUCT_OUT)/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
52ifdef dist_goal
53$(file >$(DIST_DIR)/logs/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
54endif
55
56product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070057unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070058unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080059
60# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080061# Returns the max allowed size for an image suitable for hash verification
62# (e.g., boot.img, recovery.img, etc).
63# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
64# $(1): partition size to flash the image
65define get-hash-image-max-size
66$(if $(1), \
67 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
68 $(eval _hash_meta_size := 69632), \
69 $(eval _hash_meta_size := 0)) \
70 $(1)-$(_hash_meta_size))
71endef
72
73# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -080074# Define rules to copy headers defined in copy_headers.mk
75# If more than one makefile declared a header, print a warning,
76# then copy the last one defined. This matches the previous make
77# behavior.
78$(foreach dest,$(ALL_COPIED_HEADERS), \
79 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
80 $(eval _src := $(word $(words $(_srcs)),$(_srcs))) \
81 $(if $(call streq,$(_src),$(_srcs)),, \
82 $(warning Duplicate header copy: $(dest)) \
83 $(warning Defined in: $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
84 $(eval $(call copy-one-header,$(_src),$(dest))))
85all_copied_headers: $(ALL_COPIED_HEADERS)
86
87# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -080088# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070089ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080090gen := $(OUT_DOCS)/index.html
91ALL_DOCS += $(gen)
92$(gen): frameworks/base/docs/docs-redirect-index.html
93 @mkdir -p $(dir $@)
94 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070095endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080096
Dan Albert303e6032017-10-04 10:20:20 -070097ndk_doxygen_out := $(OUT_NDK_DOCS)
98ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
99ndk_docs_src_dir := frameworks/native/docs
100ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
101ifneq ($(wildcard $(ndk_docs_src_dir)),)
102ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
103 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
104$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
105 @mkdir -p $(ndk_doxygen_out)
106 @echo "Generating NDK docs to $(ndk_doxygen_out)"
107 @( cat $(ndk_doxyfile); \
108 echo "INPUT=$(ndk_headers)"; \
109 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
110 ) | doxygen -
111
112# Note: Not a part of the docs target because we don't have doxygen available.
113# You can run this target locally if you have doxygen installed.
114ndk-docs: $(ndk_doxygen_out)/index.html
115.PHONY: ndk-docs
116endif
117
The Android Open Source Project88b60792009-03-03 19:28:42 -0800118# -----------------------------------------------------------------
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900119# property_overrides_split_enabled
120property_overrides_split_enabled :=
121ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
122 property_overrides_split_enabled := true
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900123endif
124
125# -----------------------------------------------------------------
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800126# prop.default
127ifdef property_overrides_split_enabled
128INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800129INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
130ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
131$(INSTALLED_DEFAULT_PROP_OLD_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800132else
133# legacy path
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800135endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900137FINAL_DEFAULT_PROPERTIES := \
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900138 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) \
139 $(call collapse-pairs, $(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900140ifndef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900141 FINAL_DEFAULT_PROPERTIES += \
142 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
143endif
Jaekyun Seok294286d2017-01-20 13:17:12 +0900144FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
145 $(FINAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800146
Andres Moralesb8876e12015-05-06 20:44:22 -0700147intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
148
149$(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800150 @echo Target buildinfo: $@
151 @mkdir -p $(dir $@)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800152 @rm -f $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800153 $(hide) echo "#" > $@; \
154 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
155 echo "#" >> $@;
Jaekyun Seok294286d2017-01-20 13:17:12 +0900156 $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700157 echo "$(line)" >> $@;)
Andres Moralesb8876e12015-05-06 20:44:22 -0700158 $(hide) echo "#" >> $@; \
159 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
160 echo "#" >> $@;
Dan Willemsen014719f2015-08-17 20:44:29 -0700161 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
162 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Cross73021682015-07-21 12:54:17 -0700163 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Colin Crossfdea8932017-12-06 14:38:40 -0800164 $(hide) build/make/tools/post_process_props.py $@
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800165ifdef property_overrides_split_enabled
166 $(hide) mkdir -p $(TARGET_ROOT_OUT)
Hung-ying Tyanb260f0d2017-07-13 17:04:10 +0800167 $(hide) ln -sf system/etc/prop.default $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
Hung-ying Tyanf829b402017-05-01 21:56:26 +0800168endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800169
170# -----------------------------------------------------------------
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900171# vendor default.prop
172INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900173ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900174INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
175ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
176
Sundong Ahn6d4fab12017-10-10 13:53:32 +0900177ifdef BOARD_VNDK_VERSION
Justin Yun2a233b32017-12-07 17:08:19 +0900178 ifeq ($(BOARD_VNDK_VERSION),current)
179 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
180 else
181 FINAL_VENDOR_DEFAULT_PROPERTIES := ro.vndk.version=$(BOARD_VNDK_VERSION)
182 endif
Sundong Ahn6d4fab12017-10-10 13:53:32 +0900183else
Justin Yun2a233b32017-12-07 17:08:19 +0900184 FINAL_VENDOR_DEFAULT_PROPERTIES :=
Sundong Ahn6d4fab12017-10-10 13:53:32 +0900185endif
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900186FINAL_VENDOR_DEFAULT_PROPERTIES += \
187 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
188FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
189 $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
190
191$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
192 @echo Target buildinfo: $@
193 @mkdir -p $(dir $@)
194 $(hide) echo "#" > $@; \
195 echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
196 echo "#" >> $@;
197 $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
198 echo "$(line)" >> $@;)
Colin Crossfdea8932017-12-06 14:38:40 -0800199 $(hide) build/make/tools/post_process_props.py $@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900200
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900201endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900202
203# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800204# build.prop
205INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
206ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900207FINAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -0700208 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
Jaekyun Seok294286d2017-01-20 13:17:12 +0900209FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
210 $(FINAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800211
212# A list of arbitrary tags describing the build configuration.
213# Force ":=" so we can use +=
214BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
215ifeq ($(TARGET_BUILD_TYPE),debug)
216 BUILD_VERSION_TAGS += debug
217endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700218# The "test-keys" tag marks builds signed with the old test keys,
219# which are available in the SDK. "dev-keys" marks builds signed with
220# non-default dev keys (usually private keys from a vendor directory).
221# Both of these tags will be removed and replaced with "release-keys"
222# when the target-files is signed in a post-build step.
223ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700224BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700225else
Doug Zongkera8608a72013-07-23 11:51:04 -0700226BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700227endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700228BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800229BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
230
231# A human-readable string that descibes this build in detail.
Colin Crossf37b4552015-07-16 17:15:19 -0700232build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS)
Andres Moralesb8876e12015-05-06 20:44:22 -0700233$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800234
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700235# 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 -0800236ifeq (,$(strip $(BUILD_FINGERPRINT)))
Ying Wang50367cc2014-06-12 18:42:53 -0700237 ifneq ($(filter eng.%,$(BUILD_NUMBER)),)
Tom Cherrya4af66e2017-10-18 10:46:36 -0700238 BF_BUILD_NUMBER := $(USER)$(shell $(DATE) +%m%d%H%M)
Ying Wang50367cc2014-06-12 18:42:53 -0700239 else
240 BF_BUILD_NUMBER := $(BUILD_NUMBER)
241 endif
242 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 -0800243endif
244ifneq ($(words $(BUILD_FINGERPRINT)),1)
245 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
246endif
247
Ying Wang06332732015-07-21 16:22:51 -0700248$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) > $(PRODUCT_OUT)/build_fingerprint.txt)
Colin Crossf37b4552015-07-16 17:15:19 -0700249BUILD_FINGERPRINT_FROM_FILE := $$(cat $(PRODUCT_OUT)/build_fingerprint.txt)
250
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700251# The string used to uniquely identify the system build; used by the OTA server.
252# This purposefully excludes any product-specific variables.
253ifeq (,$(strip $(BUILD_THUMBPRINT)))
254 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
255endif
256ifneq ($(words $(BUILD_THUMBPRINT)),1)
257 $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)")
258endif
259
Ying Wange24e17a2014-10-07 18:42:11 -0700260KNOWN_OEM_THUMBPRINT_PROPERTIES := \
261 ro.product.brand \
262 ro.product.name \
263 ro.product.device
264OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
265 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))
266
Sriram Raman7b641242009-03-24 22:40:59 -0700267# Display parameters shown under Settings -> About Phone
268ifeq ($(TARGET_BUILD_VARIANT),user)
269 # User builds should show:
270 # release build number or branch.buld_number non-release builds
271
272 # Dev. branches should have DISPLAY_BUILD_NUMBER set
Colin Cross63fe36a2017-02-21 17:23:02 -0800273 ifeq (true,$(DISPLAY_BUILD_NUMBER))
Colin Crossf37b4552015-07-16 17:15:19 -0700274 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700275 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700276 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700277 endif
278else
279 # Non-user builds should show detailed build information
280 BUILD_DISPLAY_ID := $(build_desc)
281endif
282
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000283# Accepts a whitespace separated list of product locales such as
284# (en_US en_AU en_GB...) and returns the first locale in the list with
285# underscores replaced with hyphens. In the example above, this will
286# return "en-US".
287define get-default-product-locale
288$(strip $(subst _,-, $(firstword $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800289endef
290
Colin Crossfdea8932017-12-06 14:38:40 -0800291BUILDINFO_SH := build/make/tools/buildinfo.sh
292VENDOR_BUILDINFO_SH := build/make/tools/vendor_buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700293
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700294# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test
295# harness to distinguish builds. Only add _asan for a sanitized build
296# if it isn't already a part of the flavor (via a dedicated lunch
297# config for example).
Ying Wang21ec03d2015-10-28 18:45:03 -0700298TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
Ivan Lozano0f71db32017-08-14 07:57:37 -0700299ifneq (, $(filter address, $(SANITIZE_TARGET)))
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700300ifeq (,$(findstring _asan,$(TARGET_BUILD_FLAVOR)))
Ying Wang21ec03d2015-10-28 18:45:03 -0700301TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
302endif
Vishwath Mohan9ebc2782017-05-09 09:54:49 -0700303endif
Ying Wang21ec03d2015-10-28 18:45:03 -0700304
Andrew Boiefa61ff02012-09-28 09:33:45 -0700305ifdef TARGET_SYSTEM_PROP
306system_prop_file := $(TARGET_SYSTEM_PROP)
307else
308system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
309endif
Jaekyun Seokf9af5fa2017-10-25 12:08:32 +0900310$(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 -0800311 @echo Target buildinfo: $@
312 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700313 $(hide) echo > $@
314ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
315 $(hide) echo "#" >> $@; \
316 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700317 echo "#" >> $@;
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700318 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
319 echo "import /oem/oem.prop $(prop)" >> $@;)
320endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800321 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Ying Wang21ec03d2015-10-28 18:45:03 -0700322 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323 TARGET_DEVICE="$(TARGET_DEVICE)" \
324 PRODUCT_NAME="$(TARGET_PRODUCT)" \
325 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000326 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700327 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800328 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
329 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
330 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
331 BUILD_ID="$(BUILD_ID)" \
332 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
Dan Willemsenccc933e2015-08-11 15:25:12 -0700333 DATE="$(DATE_FROM_FILE)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700334 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
Daniel Rosenberg59156a62015-06-29 17:20:43 -0700335 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
Tao Bao532fdf42015-11-11 10:22:48 -0800336 AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800337 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
Dianne Hackborne593e5c2015-08-12 16:11:20 -0700338 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
339 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800340 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Adam Powellbdd5e8e2015-05-21 13:49:05 -0700341 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700342 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
Dianne Hackborn6ee3c432014-04-24 16:19:14 -0700343 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
Przemyslaw Szczepaniake5540152017-12-05 10:27:52 +0000344 PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION="$(PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800345 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700346 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
Ying Wange24e17a2014-10-07 18:42:11 -0700347 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000348 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100349 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
350 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700351 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800352 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800353 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700354 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200355 $(hide) $(foreach file,$(system_prop_file), \
356 if [ -f "$(file)" ]; then \
357 echo "#" >> $@; \
358 echo Target buildinfo from: "$(file)"; \
359 echo "# from $(file)" >> $@; \
360 echo "#" >> $@; \
361 cat $(file) >> $@; \
362 fi;)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900363 $(if $(FINAL_BUILD_PROPERTIES), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800364 $(hide) echo >> $@; \
365 echo "#" >> $@; \
366 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
367 echo "#" >> $@; )
Jaekyun Seok294286d2017-01-20 13:17:12 +0900368 $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700369 echo "$(line)" >> $@;)
Andres Morales085a0ce2015-02-06 10:12:55 -0800370 $(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 -0800371 $(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 -0800372
373build_desc :=
374
Andres Moralesb8876e12015-05-06 20:44:22 -0700375ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
376INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
377else
378INSTALLED_RECOVERYIMAGE_TARGET :=
379endif
380
381$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) $(INSTALLED_RECOVERYIMAGE_TARGET)
382 @echo "Target build info: $@"
Steven Morelandec082652017-10-22 02:11:47 -0700383 $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@
Andres Moralesb8876e12015-05-06 20:44:22 -0700384ifdef INSTALLED_RECOVERYIMAGE_TARGET
385 $(hide) echo ro.expect.recovery_id=`cat $(RECOVERYIMAGE_ID_FILE)` >> $@
386endif
387
The Android Open Source Project88b60792009-03-03 19:28:42 -0800388# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700389# vendor build.prop
390#
Alex Naidis47e24e92016-01-10 14:18:54 +0000391# For verifying that the vendor build is what we think it is
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700392INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
393ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900394
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900395ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900396FINAL_VENDOR_BUILD_PROPERTIES += \
397 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
398FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
399 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900400endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900401
Steven Morelandec082652017-10-22 02:11:47 -0700402$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(VENDOR_BUILDINFO_SH) $(intermediate_system_build_prop)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700403 @echo Target vendor buildinfo: $@
404 @mkdir -p $(dir $@)
405 $(hide) echo > $@
Sandeep Patil127f5012017-10-23 19:47:43 -0700406 $(hide) grep 'ro.product.first_api_level' $(intermediate_system_build_prop) >> $@ || true
Dan Willemsenccc933e2015-08-11 15:25:12 -0700407 $(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
408 $(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Crossf37b4552015-07-16 17:15:19 -0700409 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Isaac Chen8d11feb2018-01-31 14:27:37 +0800410 $(hide) echo ro.vendor.product.cpu.abilist="$(TARGET_CPU_ABI_LIST)">>$@
411 $(hide) echo ro.vendor.product.cpu.abilist32="$(TARGET_CPU_ABI_LIST_32_BIT)">>$@
412 $(hide) echo ro.vendor.product.cpu.abilist64="$(TARGET_CPU_ABI_LIST_64_BIT)">>$@
Ryan Campbell63fc0e62017-10-02 12:29:41 -0700413 $(hide) TARGET_DEVICE="$(TARGET_DEVICE)" \
414 PRODUCT_NAME="$(TARGET_PRODUCT)" \
415 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
416 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
417 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
418 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900419 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
420 bash $(VENDOR_BUILDINFO_SH) >> $@
Jaekyun Seokf9af5fa2017-10-25 12:08:32 +0900421ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900422 $(hide) echo "#" >> $@; \
423 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
424 echo "#" >> $@;
425 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
426 echo "$(line)" >> $@;)
Colin Crossfdea8932017-12-06 14:38:40 -0800427 $(hide) build/make/tools/post_process_props.py $@
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900428endif # property_overrides_split_enabled
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700429
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900430# -----------------------------------------------------------------
431# product build.prop
432INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
433ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
434
435FINAL_PRODUCT_PROPERTIES += \
436 $(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES))
437FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \
438 $(FINAL_PRODUCT_PROPERTIES),=)
439
440$(INSTALLED_PRODUCT_BUILD_PROP_TARGET):
441 @echo Target product buildinfo: $@
442 @mkdir -p $(dir $@)
443 $(hide) echo > $@
444ifdef BOARD_USES_PRODUCTIMAGE
445 $(hide) echo ro.product.build.date=`$(DATE_FROM_FILE)`>>$@
446 $(hide) echo ro.product.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
447 $(hide) echo ro.product.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
448endif # BOARD_USES_PRODUCTIMAGE
449 $(hide) echo "#" >> $@; \
450 echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \
451 echo "#" >> $@;
452 $(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \
453 echo "$(line)" >> $@;)
454 $(hide) build/make/tools/post_process_props.py $@
455
Andres Morales9c820f82015-01-13 15:30:34 -0800456# ----------------------------------------------------------------
Andres Morales9c820f82015-01-13 15:30:34 -0800457
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700458# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800459# sdk-build.prop
460#
461# There are certain things in build.prop that we don't want to
462# ship with the sdk; remove them.
463
464# This must be a list of entire property keys followed by
465# "=" characters, without any internal spaces.
466sdk_build_prop_remove := \
467 ro.build.user= \
468 ro.build.host= \
469 ro.product.brand= \
470 ro.product.manufacturer= \
471 ro.product.device=
472# TODO: Remove this soon-to-be obsolete property
473sdk_build_prop_remove += ro.build.product=
474INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
475$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
476 @echo SDK buildinfo: $@
477 @mkdir -p $(dir $@)
478 $(hide) grep -v "$(subst $(space),\|,$(strip \
479 $(sdk_build_prop_remove)))" $< > $@.tmp
480 $(hide) for x in $(sdk_build_prop_remove); do \
481 echo "$$x"generic >> $@.tmp; done
482 $(hide) mv $@.tmp $@
483
484# -----------------------------------------------------------------
485# package stats
486PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
487PACKAGES_TO_STAT := \
488 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
489 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
490$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
491 @echo Package stats: $@
492 @mkdir -p $(dir $@)
493 $(hide) rm -f $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700494ifeq ($(PACKAGES_TO_STAT),)
495# Create empty package stats file if target builds no jar(s) or apk(s).
496 $(hide) touch $@
497else
Colin Crossfdea8932017-12-06 14:38:40 -0800498 $(hide) build/make/tools/dump-package-stats $^ > $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700499endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800500
501.PHONY: package-stats
502package-stats: $(PACKAGE_STATS_FILE)
503
504# -----------------------------------------------------------------
505# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700506# Use a macro to add newline to each echo command
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100507define _apkcerts_write_line
508$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $5
509$(if $(4), $(hide) echo -n ' compressed="$4"' >> $5)
510$(hide) echo '' >> $5
Ying Wangd9a88d52012-10-26 09:21:28 -0700511
512endef
513
The Android Open Source Project88b60792009-03-03 19:28:42 -0800514name := $(TARGET_PRODUCT)
515ifeq ($(TARGET_BUILD_TYPE),debug)
516 name := $(name)_debug
517endif
518name := $(name)-apkcerts-$(FILE_NAME_TAG)
519intermediates := \
520 $(call intermediates-dir-for,PACKAGING,apkcerts)
521APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800522# We don't need to really build all the modules.
523# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700524$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800525 @echo APK certs list: $@
526 @mkdir -p $(dir $@)
527 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700528 $(foreach p,$(PACKAGES),\
529 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100530 $(call _apkcerts_write_line,$(p),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$@),\
531 $(call _apkcerts_write_line,$(p),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700532 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700533 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800534
535.PHONY: apkcerts-list
536apkcerts-list: $(APKCERTS_FILE)
537
Ying Wang15e487a2011-02-15 10:56:18 -0800538ifneq (,$(TARGET_BUILD_APPS))
539 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
540endif
Ying Wangefb21682010-07-23 16:42:13 -0700541
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700543# build system stats
544BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
545$(BUILD_SYSTEM_STATS):
546 @rm -f $@
547 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
548 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
549$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700550
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700551# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700552# Modules ready to be converted to Soong, ordered by how many
553# modules depend on them.
554SOONG_CONV := $(sort $(SOONG_CONV))
555SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
556$(SOONG_CONV_DATA):
557 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800558 @$(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 -0700559
Colin Crossfdea8932017-12-06 14:38:40 -0800560SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700561SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
562$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
563 @rm -f $@
564 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
565$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
566
567# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800568# Modules use -Wno-error, or added default -Wall -Werror
569WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
570$(WALL_WERROR):
571 @rm -f $@
572 echo "# Modules using -Wno-error" >> $@
573 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 -0800574 echo "# Modules added default -Wall" >> $@
575 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
576
577$(call dist-for-goals,droidcore,$(WALL_WERROR))
578
579# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800580# Modules missing profile files
581PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
582$(PGO_PROFILE_MISSING):
583 @rm -f $@
584 echo "# Modules missing PGO profile files" >> $@
585 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
586
587$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
588
589# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700590# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700591# for future OTA packages installed by this system. Actual product
592# deliverables will be re-signed by hand. We expect this file to
593# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700594DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700595
596
Jeff Browne33ba4c2011-07-11 22:11:46 -0700597# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800598# if they don't do anything.
599.PHONY: systemimage
600systemimage:
601
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800602# -----------------------------------------------------------------
603
604.PHONY: event-log-tags
605
Joe Onoratob7510532010-07-14 10:22:54 -0700606# Produce an event logs tag file for everything we know about, in order
607# to properly allocate numbers. Then produce a file that's filtered
608# for what's going to be installed.
609
610all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
611
Colin Crossdc8f8e42012-04-12 13:25:54 -0700612event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
613
Joe Onoratob7510532010-07-14 10:22:54 -0700614# Include tags from all packages that we know about
615all_event_log_tags_src := \
616 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
617
Colin Crossdc8f8e42012-04-12 13:25:54 -0700618# PDK builds will already have a full list of tags that needs to get merged
619# in with the ones from source
620pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
621
622$(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 -0800623$(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 -0700624 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900625 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700626
Doug Zongkera34fa952011-02-23 12:17:29 -0800627# Include tags from all packages included in this product, plus all
628# tags that are part of the system (ie, not in a vendor/ or device/
629# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800630event_log_tags_src := \
631 $(sort $(foreach m,\
632 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
633 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800634 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
635 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800636
Colin Crossdc8f8e42012-04-12 13:25:54 -0700637$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700638$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800639$(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 -0800640 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900641 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800642
643event-log-tags: $(event_log_tags_file)
644
645ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
646
Joe Onoratob7510532010-07-14 10:22:54 -0700647
The Android Open Source Project88b60792009-03-03 19:28:42 -0800648# #################################################################
649# Targets for boot/OS images
650# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800651ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
652 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
653 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
654 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
655 else
656 INSTALLED_2NDBOOTLOADER_TARGET :=
657 endif
658else
659 INSTALLED_BOOTLOADER_MODULE :=
660 INSTALLED_2NDBOOTLOADER_TARGET :=
661endif # TARGET_NO_BOOTLOADER
662ifneq ($(strip $(TARGET_NO_KERNEL)),true)
663 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
664else
665 INSTALLED_KERNEL_TARGET :=
666endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800667
668# -----------------------------------------------------------------
669# the ramdisk
670INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800671 $(ALL_GENERATED_SOURCES) \
672 $(ALL_DEFAULT_INSTALLED_MODULES))
673
Joe Onorato64d85d02009-04-09 19:31:12 -0700674BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
675
676# We just build this directly to the install location.
677INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700678$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800679 $(call pretty,"Target ram disk: $@")
Thierry Strudel74a81e62015-07-09 09:54:55 -0700680 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800681
Ying Wangad7fd292013-08-08 16:34:29 -0700682.PHONY: ramdisk-nodeps
683ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
684 @echo "make $@: ignoring dependencies"
Thierry Strudel74a81e62015-07-09 09:54:55 -0700685 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800686
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700687INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
688
The Android Open Source Project88b60792009-03-03 19:28:42 -0800689ifneq ($(strip $(TARGET_NO_KERNEL)),true)
690
691# -----------------------------------------------------------------
692# the boot image, which is a collection of other images.
693INTERNAL_BOOTIMAGE_ARGS := \
694 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700695 --kernel $(INSTALLED_KERNEL_TARGET)
696
697ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
698INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
699endif
700
The Android Open Source Project88b60792009-03-03 19:28:42 -0800701INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
702
Dima Zavin1e0847c2009-05-07 19:43:08 -0700703ifdef BOARD_KERNEL_BASE
704 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
705endif
706
Ying Wangffff0022010-08-23 12:56:25 -0700707ifdef BOARD_KERNEL_PAGESIZE
708 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
709endif
710
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700711ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
712ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
713VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
714 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
715endif
716endif
717
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700718INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
719ifdef INTERNAL_KERNEL_CMDLINE
720INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700721endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700722
Sami Tolvanen3303d902016-03-15 16:49:30 +0000723INTERNAL_MKBOOTIMG_VERSION_ARGS := \
724 --os_version $(PLATFORM_VERSION) \
725 --os_patch_level $(PLATFORM_SECURITY_PATCH)
726
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800727# BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true.
728ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
729ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
730 $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.)
731endif
732endif
733
734# We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true.
735ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800736ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800737$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400738
739else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
740
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800741$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400742 $(call pretty,"Target boot image: $@")
743 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800744 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400745 $(hide) $(AVBTOOL) add_hash_footer \
746 --image $@ \
747 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800748 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400749 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
750
751.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800752bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400753 @echo "make $@: ignoring dependencies"
754 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800755 $(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 -0400756 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800757 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400758 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800759 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400760 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
761
762else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700763
764$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
765 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000766 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800767 $(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 -0700768 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
769
770.PHONY: bootimage-nodeps
771bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
772 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000773 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800774 $(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 -0700775 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
776
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100777else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800778
Tao Bao4b577412017-02-22 22:54:39 -0800779$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800780 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000781 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700782 $(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 -0800783 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
784
785.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800786bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800787 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000788 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700789 $(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 -0800790 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
791
792else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800793
794$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
795 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000796 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700797 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700798
799.PHONY: bootimage-nodeps
800bootimage-nodeps: $(MKBOOTIMG)
801 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000802 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700803 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700804
The Android Open Source Project88b60792009-03-03 19:28:42 -0800805endif # TARGET_BOOTIMAGE_USE_EXT2
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800806endif # BOARD_USES_RECOVERY_AS_BOOT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800807
808else # TARGET_NO_KERNEL
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700809ifdef BOARD_PREBUILT_BOOTIMAGE
810ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
811# Remove when b/63676296 is resolved.
812$(error Prebuilt bootimage is only supported for AB targets)
813endif
814$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
815else
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700816INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800817# HACK: The top-level targets depend on the bootimage. Not all targets
818# can produce a bootimage, though, and emulator targets need the ramdisk
819# instead. Fake it out by calling the ramdisk the bootimage.
820# TODO: make the emulator use bootimages, and make mkbootimg accept
821# kernel-less inputs.
822INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
823endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700824endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800825
826# -----------------------------------------------------------------
827# NOTICE files
828#
Steve Blockd14d3b42012-03-01 11:34:41 +0000829# We are required to publish the licenses for all code under BSD, GPL and
830# Apache licenses (and possibly other more exotic ones as well). We err on the
831# side of caution, so the licenses for other third-party code are included here
832# too.
833#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800834# This needs to be before the systemimage rules, because it adds to
835# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
836# go into the systemimage.
837
Steve Block495e5852012-02-29 19:18:08 +0000838.PHONY: notice_files
839
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900840# Create the rule to combine the files into text and html/xml forms
841# $(1) - xml_excluded_vendor|xml_vendor|html
842# $(2) - Plain text output file
843# $(3) - HTML/XML output file
844# $(4) - File title
845# $(5) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900847# $(6) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800848#
849# The algorithm here is that we go collect a hash for each of the notice
850# files and write the names of the files that match that hash. Then
851# to generate the real files, we go print out all of the files and their
852# hashes.
853#
854# These rules are fairly complex, so they depend on this makefile so if
855# it changes, they'll run again.
856#
857# TODO: We could clean this up so that we just record the locations of the
858# original notice files instead of making rules to copy them somwehere.
859# Then we could traverse that without quite as much bash drama.
860define combine-notice-files
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900861$(2) $(3): PRIVATE_MESSAGE := $(4)
862$(2) $(3): PRIVATE_DIR := $(5)
863$(2) : $(3)
Colin Crossfdea8932017-12-06 14:38:40 -0800864$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
865 build/make/tools/generate-notice-files.py --text-output $(2) \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900866 $(if $(filter $(1),xml_excluded_vendor),-e vendor --xml-output, \
867 $(if $(filter $(1),xml_vendor),-i vendor --xml-output, \
868 --html-output)) $(3) \
869 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
870notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800871endef
872
873# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
874# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
875# the src subdirectory.
876
Steve Block495e5852012-02-29 19:18:08 +0000877target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900878target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
879target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
880installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000881tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800882tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
883
Steven Morelandae69e572017-12-15 14:49:55 -0800884# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
885ifeq ($(PRODUCT_NOTICE_SPLIT),true)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900886target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
887target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
888installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
889
890target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
891target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
892target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
893installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
894endif
895
Ying Wang62c81f82013-08-22 20:02:03 -0700896ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800897kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Josh Gao4d9268e2017-02-23 13:17:46 -0800898winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
Ying Wang4534d812012-04-09 17:04:12 -0700899pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800900
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900901ifdef target_vendor_notice_file_xml_gz
902$(eval $(call combine-notice-files, xml_excluded_vendor, \
Steve Block495e5852012-02-29 19:18:08 +0000903 $(target_notice_file_txt), \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900904 $(target_notice_file_html_or_xml), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800905 "Notices for files contained in the filesystem images in this directory:", \
906 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700907 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900908$(eval $(call combine-notice-files, xml_vendor, \
909 $(target_vendor_notice_file_txt), \
910 $(target_vendor_notice_file_xml), \
911 "Notices for files contained in the vendor filesystem image in this directory:", \
912 $(TARGET_OUT_NOTICE_FILES), \
913 $(target_notice_file_html_or_xml)))
914else
915$(eval $(call combine-notice-files, html, \
916 $(target_notice_file_txt), \
917 $(target_notice_file_html_or_xml), \
918 "Notices for files contained in the filesystem images in this directory:", \
919 $(TARGET_OUT_NOTICE_FILES), \
920 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
921endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800922
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900923$(eval $(call combine-notice-files, html, \
Steve Block495e5852012-02-29 19:18:08 +0000924 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800925 $(tools_notice_file_html), \
926 "Notices for files contained in the tools directory:", \
927 $(HOST_OUT_NOTICE_FILES), \
Josh Gao4d9268e2017-02-23 13:17:46 -0800928 $(ALL_DEFAULT_INSTALLED_MODULES) \
929 $(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930
931# Install the html file at /system/etc/NOTICE.html.gz.
932# This is not ideal, but this is very late in the game, after a lot of
933# the module processing has already been done -- in fact, we used the
934# fact that all that has been done to get the list of modules that we
935# need notice files for.
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900936$(target_notice_file_html_or_xml_gz): $(target_notice_file_html_or_xml) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700937 $(hide) $(MINIGZIP) -9 < $< > $@
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900938$(installed_notice_html_or_xml_gz): $(target_notice_file_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800939 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700940
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900941ifdef target_vendor_notice_file_xml_gz
942# Install the vendor html file at /vendor/etc/NOTICE.xml.gz.
943$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
944 $(hide) $(MINIGZIP) -9 < $< > $@
945$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
946 $(copy-file-to-target)
947endif
948
Joe Onorato7b2845a2009-04-30 13:52:50 -0700949# if we've been run my mm, mmm, etc, don't reinstall this every time
950ifeq ($(ONE_SHOT_MAKEFILE),)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900951 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
952 ifdef target_vendor_notice_file_xml_gz
953 ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
954 endif
Joe Onorato7b2845a2009-04-30 13:52:50 -0700955endif
Ying Wang62c81f82013-08-22 20:02:03 -0700956endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800957
958# The kernel isn't really a module, so to get its module file in there, we
959# make the target NOTICE files depend on this particular file too, which will
960# then be in the right directory for the find in combine-notice-files to work.
961$(kernel_notice_file): \
Lee Campbellb463fcd2015-11-08 16:28:15 -0800962 $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800963 | $(ACP)
964 @echo Copying: $@
965 $(hide) mkdir -p $(dir $@)
966 $(hide) $(ACP) $< $@
967
Josh Gao4d9268e2017-02-23 13:17:46 -0800968$(winpthreads_notice_file): \
969 $(BUILD_SYSTEM)/WINPTHREADS_COPYING \
970 | $(ACP)
971 @echo Copying: $@
972 $(hide) mkdir -p $(dir $@)
973 $(hide) $(ACP) $< $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974
Doug Zongker8678df42009-06-15 14:30:14 -0700975# -----------------------------------------------------------------
976# Build a keystore with the authorized keys in it, used to verify the
977# authenticity of downloaded OTA packages.
978#
979# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
980# before the rules that use that variable to build the image.
Dan Willemsenb589ae42015-10-29 21:26:18 +0000981ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
982$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Dan Willemsen48a621c2015-10-29 16:33:05 -0700983$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME)
Doug Zongker8678df42009-06-15 14:30:14 -0700984 $(hide) rm -f $@
985 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -0700986 $(hide) zip -qjX $@ $<
987 $(remove-timestamps-from-package)
Doug Zongker8678df42009-06-15 14:30:14 -0700988
Alex Deymocec578c2017-03-28 20:48:18 -0700989# Carry the public key for update_engine if it's a non-IoT target that
Tao Bao38812d62016-01-20 20:58:20 -0800990# uses the AB updater. We use the same key as otacerts but in RSA public key
991# format.
992ifeq ($(AB_OTA_UPDATER),true)
Alex Deymocec578c2017-03-28 20:48:18 -0700993ifneq ($(PRODUCT_IOT),true)
Tao Bao23c3db92016-01-21 14:28:50 -0800994ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
995$(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Tao Bao38812d62016-01-20 20:58:20 -0800996 $(hide) rm -f $@
997 $(hide) mkdir -p $(dir $@)
998 $(hide) openssl x509 -pubkey -noout -in $< > $@
Alex Deymoc6ebe9f2016-08-03 20:52:54 -0700999
1000ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem
1001$(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem: $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
1002 $(hide) cp -f $< $@
Tao Bao38812d62016-01-20 20:58:20 -08001003endif
1004endif
1005
Doug Zongker8678df42009-06-15 14:30:14 -07001006.PHONY: otacerts
1007otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
1008
1009
The Android Open Source Project88b60792009-03-03 19:28:42 -08001010# #################################################################
1011# Targets for user images
1012# #################################################################
1013
Ying Wang933abf12010-06-16 14:31:34 -07001014INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001016INTERNAL_USERIMAGES_USE_EXT := true
1017INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1018else
1019ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
1020INTERNAL_USERIMAGES_USE_EXT := true
1021INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1022else
1023ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
1024INTERNAL_USERIMAGES_USE_EXT := true
1025INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1026endif
1027endif
1028endif
1029
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001030# These options tell the recovery updater/installer how to mount the partitions writebale.
1031# <fstype>=<fstype_opts>[|<fstype_opts>]...
1032# fstype_opts := <opt>[,<opt>]...
1033# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001034# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1035DEFAULT_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 -07001036
Ying Wang542903a2010-11-17 15:40:38 -08001037ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1038 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1039endif
1040
Colin Cross0a7b2c52010-05-07 02:23:59 -07001041ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001042INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
1043INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
1044ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1045INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
1046endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001047endif
JP Abgrall5bfed5a2014-06-16 14:17:40 -07001048
Chris Friesdf0387d2017-06-21 15:51:46 -05001049ifeq ($(BOARD_AVB_ENABLE),true)
1050INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1051endif
1052
Todd Poynorb2a555e2015-12-15 18:00:14 -08001053ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1054 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1055endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001056ifneq ($(filter $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),)
Mohamad Ayyash353265b2015-06-24 15:42:19 -07001057INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001058endif
1059
Ying Wang178ef922011-10-31 18:13:30 -07001060INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001061
Colin Cross8a30f722014-04-28 16:27:32 -07001062ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
Colin Cross477cf2b2014-04-16 18:49:56 -07001063INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001064ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC))
1065INTERNAL_USERIMAGES_DEPS += $(FEC)
1066endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001067endif
1068
Alex Klyubin092c9022017-03-13 13:28:34 -07001069SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001070INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1071
Mohamad Ayyashf8765552016-03-02 21:07:23 -08001072INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS)
1073
Jin Qianabcec5e2017-03-10 16:53:45 -08001074ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
1075INTERNAL_USERIMAGES_DEPS += $(MKE2FS_CONF)
1076endif
1077
Ying Wangbd93d422011-10-28 17:02:30 -07001078# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -08001079# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -07001080define generate-userimage-prop-dictionary
Vikram Dattu29e88b82016-12-16 09:45:19 +01001081$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Ying Wangbd93d422011-10-28 17:02:30 -07001082$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
1083$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Mohamad Ayyash68946952015-03-03 12:30:37 -08001084$(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -07001085$(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -08001086$(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
Jin Qianfde9f792018-01-22 13:15:46 -08001087$(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 -07001088$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1089$(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 -07001090$(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 -07001091$(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 -07001092$(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 -07001093$(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 -07001094$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001095$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Connor O'Briene9ee68d2017-01-05 16:48:14 -08001096$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1097$(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 -07001098$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1099$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -07001100$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -07001101$(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -07001102$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -08001103$(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
Patrick Tjine11aa502016-02-09 15:40:38 -08001104$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1105$(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 -07001106$(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 -07001107$(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 -07001108$(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 +09001109$(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1110$(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1111$(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1112$(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1113$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1114$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1115$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1116$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_squashfs_disable_4k_align=$(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1117$(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 -07001118$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -08001119$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -07001120$(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001121$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001122$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001123$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +01001124$(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 -07001125$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
Paul Lawrencea37b2bb2014-11-13 17:54:30 -08001126$(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 +02001127$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001128$(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 +08001129$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -07001130$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1131$(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 +09001132$(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 -07001133$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1134$(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 -07001135$(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 -08001136$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -07001137$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001138$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001139$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1140$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1141$(if $(BOARD_AVB_ENABLE),\
1142 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1143 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1144 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1145 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
1146$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1147$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1148$(if $(BOARD_AVB_ENABLE),\
1149 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1150 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1151 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1152 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001153$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1154$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1155$(if $(BOARD_AVB_ENABLE),\
1156 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1157 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1158 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1159 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001160$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1161 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001162$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
1163 $(hide) echo "system_root_image=true" >> $(1);\
1164 echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1))
Ying Wang6a42a252013-02-27 13:54:02 -08001165$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -07001166endef
1167
Xu Chao2b04bf42017-07-06 14:34:31 +08001168# $(1): modules list
1169# $(2): output dir
1170# $(3): mount point
1171# $(4): staging dir
1172# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
1173define build-image-kernel-modules
1174 $(hide) rm -rf $(2)/lib/modules
1175 $(hide) mkdir -p $(2)/lib/modules
1176 $(hide) cp $(1) $(2)/lib/modules/
1177 $(hide) rm -rf $(4)
1178 $(hide) mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules
1179 $(hide) cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules
1180 $(hide) $(DEPMOD) -b $(4) 0.0
1181 $(hide) sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules/modules.dep
1182 $(hide) cp $(4)/lib/modules/0.0/modules.alias $(2)/lib/modules
1183endef
1184
The Android Open Source Project88b60792009-03-03 19:28:42 -08001185# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001186# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001187
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001188# Recovery image exists if we are building recovery, or building recovery as boot.
1189ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Doug Zongker4647f122009-07-02 09:00:54 -07001190
Ying Wang37526142015-03-10 12:02:57 -07001191INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1192 $(ALL_DEFAULT_INSTALLED_MODULES))
1193
Doug Zongker4647f122009-07-02 09:00:54 -07001194recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001195recovery_sepolicy := \
1196 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001197 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Bowgo Tsai09f88a62018-02-05 17:32:20 +08001198 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001199 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai09f88a62018-02-05 17:32:20 +08001200 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts
1201
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001202# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1203# SELinux files
1204IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1205
Doug Zongker4647f122009-07-02 09:00:54 -07001206recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1207recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001208recovery_build_props := $(intermediate_system_build_prop)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +09001209ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001210recovery_build_props += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
1211endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001212ifdef BOARD_USES_PRODUCTIMAGE
1213recovery_build_props += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
1214endif
Doug Zongker4647f122009-07-02 09:00:54 -07001215recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001216
Doug Zongker8eaeea92014-05-12 15:32:20 -07001217# Set recovery_density to the density bucket of the device.
1218recovery_density := unknown
1219ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
1220# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
1221recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
Doug Zongker25d55f82014-04-04 13:51:15 -07001222else
Adam Lesinski83ee6d72014-12-02 16:13:09 -08001223# Otherwise, use the default medium density.
1224recovery_densities := mdpi
Doug Zongker8eaeea92014-05-12 15:32:20 -07001225endif
1226
1227ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1228recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1229else
Doug Zongker25d55f82014-04-04 13:51:15 -07001230recovery_resources_common := $(recovery_resources_common)-xhdpi
1231endif
1232
Doug Zongker8eaeea92014-05-12 15:32:20 -07001233# Select the 18x32 font on high-density devices (xhdpi and up); and
1234# the 12x22 font on other devices. Note that the font selected here
1235# can be overridden for a particular device by putting a font.png in
1236# its private recovery resources.
1237
Tao Baoabbc9112015-04-08 14:14:43 -07001238ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001239recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1240else
1241recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1242endif
1243
Ying Wang9a175682015-08-06 11:47:47 -07001244ifndef TARGET_PRIVATE_RES_DIRS
1245TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1246endif
Doug Zongker4647f122009-07-02 09:00:54 -07001247recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001248 $(TARGET_PRIVATE_RES_DIRS) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -07001249ifdef TARGET_RECOVERY_FSTAB
1250recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1251else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001252recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001253endif
Tao Baoc3c17532016-06-10 10:11:54 -07001254ifdef TARGET_RECOVERY_WIPE
1255recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001256else
Tao Baoc3c17532016-06-10 10:11:54 -07001257recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001258endif
Tao Bao8beab692015-07-22 12:33:18 -07001259
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001260# Prior to A/B update, we used to have:
1261# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
1262# recovery-resource.dat is needed only if we carry a patch of the boot and
1263# recovery images and invoke install-recovery.sh on the first boot post an
1264# OTA update.
1265#
1266# We no longer need that if one of the following conditions holds:
1267# a) We carry a full copy of the recovery image
1268# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
1269# b) We build a single image that contains boot and recovery both
1270# (BOARD_USES_RECOVERY_AS_BOOT = true).
1271
1272ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07001273# Named '.dat' so we don't attempt to use imgdiff for patching it.
1274RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Tao Bao8beab692015-07-22 12:33:18 -07001275else
Tao Bao8beab692015-07-22 12:33:18 -07001276RECOVERY_RESOURCE_ZIP :=
1277endif
Doug Zongker4647f122009-07-02 09:00:54 -07001278
Doug Zongker4647f122009-07-02 09:00:54 -07001279INTERNAL_RECOVERYIMAGE_ARGS := \
1280 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
1281 --kernel $(recovery_kernel) \
1282 --ramdisk $(recovery_ramdisk)
1283
1284# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001285ifdef INTERNAL_KERNEL_CMDLINE
1286 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001287endif
1288ifdef BOARD_KERNEL_BASE
1289 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1290endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001291ifdef BOARD_KERNEL_PAGESIZE
1292 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1293endif
Doug Zongker4647f122009-07-02 09:00:54 -07001294
1295# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -07001296# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -07001297# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -07001298OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -07001299
1300# Generate a file containing the keys that will be read by the
1301# recovery binary.
1302RECOVERY_INSTALL_OTA_KEYS := \
1303 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
1304DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
1305$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -07001306$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -08001307$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
1308 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -07001309 @rm -rf $@
1310 @mkdir -p $(dir $@)
Colin Cross0851df82017-06-30 13:55:38 -07001311 $(JAVA) -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -07001312
Andres Moralesb8876e12015-05-06 20:44:22 -07001313RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id
Howard Chen1756f8d2017-02-22 17:27:10 +08001314
Ying Wang747b9f12015-01-30 14:05:22 -08001315# $(1): output file
1316define build-recoveryimage-target
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001317 # Making recovery image
Ying Wang747b9f12015-01-30 14:05:22 -08001318 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao3f56a332016-01-12 11:34:58 -08001319 $(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 -08001320 # Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001321 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1322 $(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 +08001323 # Copy adbd from system/bin to recovery/root/sbin
1324 $(hide) cp -f $(TARGET_OUT_EXECUTABLES)/adbd $(TARGET_RECOVERY_ROOT_OUT)/sbin/adbd
Tomasz Wasilczyk29ec06b2017-11-15 10:34:01 -08001325 # Modifying ramdisk contents...
Howard Chen1756f8d2017-02-22 17:27:10 +08001326 $(if $(BOARD_RECOVERY_KERNEL_MODULES), \
1327 $(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 +08001328 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1329 $(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 -08001330 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
Ying Wang36b039a2015-04-02 12:48:32 -07001331 $(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 -08001332 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1333 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1334 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1335 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07001336 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1337 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08001338 $(hide) $(foreach item,$(recovery_fstab), \
1339 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07001340 $(if $(strip $(recovery_wipe)), \
1341 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe)
Ying Wang747b9f12015-01-30 14:05:22 -08001342 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001343 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) \
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001344 > $(TARGET_RECOVERY_ROOT_OUT)/prop.default
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001345 $(if $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET), \
1346 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001347 >> $(TARGET_RECOVERY_ROOT_OUT)/prop.default)
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001348 $(hide) cat $(recovery_build_props) \
Hung-ying Tyanf829b402017-05-01 21:56:26 +08001349 >> $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1350 $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07001351 $(BOARD_RECOVERY_IMAGE_PREPARE)
Tao Baobe46a542015-07-30 14:34:01 -07001352 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \
1353 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \
1354 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/system; \
1355 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 -07001356 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Tao Baod95e9fd2015-03-29 23:07:41 -07001357 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001358 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
1359 $(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 +01001360 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001361 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1362 $(BOOT_SIGNER) /boot $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1363 $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
1364 )\
1365 )
Tao Baod95e9fd2015-03-29 23:07:41 -07001366 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Furquan Shaikhe8c21222015-08-07 11:58:05 -07001367 $(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 +08001368 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
1369 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
1370 $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001371 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1372 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
1373 $(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),\
1374 $(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 -08001375endef
1376
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001377ADBD := $(TARGET_OUT_EXECUTABLES)/adbd
1378
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001379ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Ying Wangbd07ad02016-03-10 12:57:33 -08001380ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER))
1381$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
1382endif
1383ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1384$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
1385endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001386ifeq (true,$(BOARD_AVB_ENABLE))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001387$(INSTALLED_BOOTIMAGE_TARGET) : $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001388endif
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001389$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) $(ADBD) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001390 $(INSTALLED_RAMDISK_TARGET) \
1391 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001392 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001393 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001394 $(recovery_build_props) $(recovery_resource_deps) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001395 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001396 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001397 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1398 $(BOARD_RECOVERY_KERNEL_MODULES) \
1399 $(DEPMOD)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001400 $(call pretty,"Target boot image from recovery: $@")
1401 $(call build-recoveryimage-target, $@)
1402endif
1403
Bowgo Tsai9a05dca2017-07-28 20:22:05 +08001404$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) $(ADBD) \
Doug Zongker4647f122009-07-02 09:00:54 -07001405 $(INSTALLED_RAMDISK_TARGET) \
1406 $(INSTALLED_BOOTIMAGE_TARGET) \
Ying Wang37526142015-03-10 12:02:57 -07001407 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001408 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Doug Zongker4647f122009-07-02 09:00:54 -07001409 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001410 $(recovery_build_props) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001411 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001412 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001413 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1414 $(BOARD_RECOVERY_KERNEL_MODULES) \
1415 $(DEPMOD)
Ying Wang747b9f12015-01-30 14:05:22 -08001416 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07001417
Tao Bao4594d0e2015-12-22 09:47:46 -08001418ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001419$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001420 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001421 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1422 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001423endif
Doug Zongker56588872012-08-20 15:38:58 -07001424
Ying Wang747b9f12015-01-30 14:05:22 -08001425.PHONY: recoveryimage-nodeps
1426recoveryimage-nodeps:
1427 @echo "make $@: ignoring dependencies"
1428 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1429
Tao Bao8beab692015-07-22 12:33:18 -07001430else # INSTALLED_RECOVERYIMAGE_TARGET not defined
Doug Zongker56588872012-08-20 15:38:58 -07001431RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -07001432endif
1433
1434.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001435recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001436
Jiyong Park03eb0612017-10-04 21:22:41 +09001437ifneq ($(BOARD_NAND_PAGE_SIZE),)
1438$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001439endif
1440
Jiyong Park03eb0612017-10-04 21:22:41 +09001441ifneq ($(BOARD_NAND_SPARE_SIZE),)
1442$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001443endif
1444
Doug Zongker4647f122009-07-02 09:00:54 -07001445# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07001446# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08001447#
Ying Wang9c649a72012-08-08 15:27:00 -07001448# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
1449PDK_FUSION_SYSIMG_FILES := \
1450 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
1451 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001452
1453INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07001454 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07001455 $(ALL_DEFAULT_INSTALLED_MODULES) \
1456 $(PDK_FUSION_SYSIMG_FILES) \
1457 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -07001458
Ying Wang82cceba2012-08-13 15:03:00 -07001459FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07001460
1461# ASAN libraries in the system image - add dependency.
1462ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
1463ifneq (,$(SANITIZE_TARGET))
1464 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
1465 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
1466 endif
1467endif
1468
Ying Wange5e8c5f2011-09-09 16:35:53 -07001469# -----------------------------------------------------------------
1470# installed file list
1471# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
1472# We put installed-files.txt ahead of image itself in the dependency graph
1473# so that we can get the size stat even if the build fails due to too large
1474# system image.
1475INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001476$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001477 @echo Installed file list: $@
1478 @mkdir -p $(dir $@)
1479 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001480 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001481 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07001482
1483.PHONY: installed-file-list
1484installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08001485
1486$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07001487
1488systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001489 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001490BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
1491
Ying Wang23898df2014-06-18 20:26:24 -07001492# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07001493ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07001494define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07001495$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
1496 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
1497 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
1498 exit 1; \
1499fi
Ying Wang23898df2014-06-18 20:26:24 -07001500$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
1501endef
1502else
1503define create-system-vendor-symlink
1504endef
1505endif
1506
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001507# Create symlink /system/product to /product if necessary.
1508ifdef BOARD_USES_PRODUCTIMAGE
1509define create-system-product-symlink
1510$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
1511 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
1512 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
1513 exit 1; \
1514fi
1515$(hide) ln -sf /product $(TARGET_OUT)/product
1516endef
1517else
1518define create-system-product-symlink
1519endef
1520endif
1521
The Android Open Source Project88b60792009-03-03 19:28:42 -08001522# $(1): output file
1523define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07001524 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07001525 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001526 $(call create-system-product-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07001527 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -07001528 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07001529 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001530 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001531 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001532 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
Ying Wang45ff36e2014-08-13 12:36:05 -07001533 || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\
1534 du -sm $(TARGET_OUT) 1>&2;\
Tao Baoc7a6f1e2015-06-23 11:16:05 -07001535 if [ "$(INTERNAL_USERIMAGES_EXT_VARIANT)" == "ext4" ]; then \
1536 maxsize=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE); \
Tao Baoc7a6f1e2015-06-23 11:16:05 -07001537 echo "The max is $$(( maxsize / 1048576 )) MB." 1>&2 ;\
1538 else \
1539 echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\
1540 fi; \
Ying Wangebe63fb2014-08-19 12:21:35 -07001541 mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
Ying Wang45ff36e2014-08-13 12:36:05 -07001542 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08001543endef
1544
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001545$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001546 $(call build-systemimage-target,$@)
1547
The Android Open Source Project88b60792009-03-03 19:28:42 -08001548INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07001549SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001550
Doug Zongker73ef8252009-07-23 15:12:53 -07001551# The system partition needs room for the recovery image as well. We
1552# now store the recovery image as a binary patch using the boot image
1553# as the source (since they are very similar). Generate the patch so
1554# we can see how big it's going to be, and include that in the system
1555# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -07001556ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07001557ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Doug Zongker73ef8252009-07-23 15:12:53 -07001558intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
1559RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
1560$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
1561 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -07001562 $(HOST_OUT_EXECUTABLES)/imgdiff \
1563 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -07001564 @echo "Construct recovery from boot"
1565 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -07001566 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07001567else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
1568RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
1569endif
Sriram Raman1e96ac82009-07-24 13:52:32 -07001570endif
1571
Doug Zongker73ef8252009-07-23 15:12:53 -07001572
Dan Willemsen7f016152016-02-29 17:52:39 -08001573$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001574 @echo "Install system fs image: $@"
1575 $(copy-file-to-target)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001576 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001577
1578systemimage: $(INSTALLED_SYSTEMIMAGE)
1579
1580.PHONY: systemimage-nodeps snod
1581systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07001582 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001583 @echo "make $@: ignoring dependencies"
1584 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001585 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001586
Ying Wangacf01ec2012-02-24 11:05:48 -08001587ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
1588ifeq (true,$(WITH_DEXPREOPT))
1589$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
1590endif
1591endif
1592
Colin Cross91a52272017-06-20 16:57:52 -07001593.PHONY: sync
1594sync: $(INTERNAL_SYSTEMIMAGE_FILES)
1595
The Android Open Source Project88b60792009-03-03 19:28:42 -08001596#######
1597## system tarball
1598define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -07001599 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
1600 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001601 $(call create-system-product-symlink)
Ying Wang23898df2014-06-18 20:26:24 -07001602 $(MKTARBALL) $(FS_GET_STATS) \
1603 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001604 $(INSTALLED_SYSTEMTARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001605endef
1606
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001607ifndef SYSTEM_TARBALL_FORMAT
1608 SYSTEM_TARBALL_FORMAT := bz2
1609endif
1610
The Android Open Source Project88b60792009-03-03 19:28:42 -08001611system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001612INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001613$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
1614$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
1615 $(build-systemtarball-target)
1616
1617.PHONY: systemtarball-nodeps
1618systemtarball-nodeps: $(FS_GET_STATS) \
1619 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
1620 $(build-systemtarball-target)
1621
1622.PHONY: stnod
1623stnod: systemtarball-nodeps
1624
Ying Wang3a61eeb2016-03-11 10:32:01 -08001625# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07001626## platform.zip: system, plus other files to be used in PDK fusion build,
1627## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07001628##
1629## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
1630## The variable will be typically set from BoardConfig.mk.
1631## Files under out dir will be rejected to prevent possible conflicts with other rules.
Ying Wang3a61eeb2016-03-11 10:32:01 -08001632pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
1633 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
1634pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
1635 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
1636pdk_classes_dex := $(strip \
1637 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
1638 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk))
1639
1640pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
1641$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
1642$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
1643$(pdk_odex_config_mk) :
1644 @echo "PDK odex config makefile: $@"
1645 $(hide) mkdir -p $(dir $@)
1646 $(hide) echo "# Auto-generated. Do not modify." > $@
1647 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
1648 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
1649 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
1650 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
1651 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
1652 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
1653 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
1654 )
1655 $(foreach m,$(PRIVATE_APPS),\
1656 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\
1657 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
1658 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
1659 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
1660 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07001661 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08001662 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
1663 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
1664 )
1665
keunyoungc0178062013-07-22 14:54:58 -07001666PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07001667INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08001668
1669$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
1670$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
1671$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk)
Keun young Park816b9fd2012-05-16 10:32:41 -07001672 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07001673 $(hide) rm -f $@
Dan Willemsen48a621c2015-10-29 16:33:05 -07001674 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wang4534d812012-04-09 17:04:12 -07001675 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07001676 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
1677 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Ying Wangcff38622014-07-16 17:46:35 -07001678ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
Dan Willemsen48a621c2015-10-29 16:33:05 -07001679 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wangcff38622014-07-16 17:46:35 -07001680 $(TARGET_COPY_OUT_VENDOR)
1681endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001682ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
1683 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
1684 $(TARGET_COPY_OUT_PRODUCT)
1685endif
Colin Crossc451a372013-12-18 19:36:44 -08001686ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001687 $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07001688endif
keunyoungc0178062013-07-22 14:54:58 -07001689ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001690 $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
keunyoungc0178062013-07-22 14:54:58 -07001691endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08001692 @# Add dex-preopt files and config.
1693 $(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES)))
1694 $(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG)
Ying Wang4c289e52012-03-30 13:52:54 -07001695
1696.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07001697platform: $(INSTALLED_PLATFORM_ZIP)
1698
1699.PHONY: platform-java
1700platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07001701
1702# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07001703ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
1704$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07001705endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001706
Ying Wang3a61eeb2016-03-11 10:32:01 -08001707# -----------------------------------------------------------------
Bruce Beare52aac202010-06-04 15:24:49 -07001708## boot tarball
1709define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07001710 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07001711 $(hide) mkdir -p $(PRODUCT_OUT)/boot
1712 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001713 $(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
Bruce Beare52aac202010-06-04 15:24:49 -07001714 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
1715 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001716 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
Bruce Beare52aac202010-06-04 15:24:49 -07001717endef
1718
1719ifndef BOOT_TARBALL_FORMAT
1720 BOOT_TARBALL_FORMAT := bz2
1721endif
1722
1723boot_tar := $(PRODUCT_OUT)/boot.tar
1724INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
1725$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
1726$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
1727 $(build-boottarball-target)
1728
1729.PHONY: boottarball-nodeps btnod
1730boottarball-nodeps btnod: $(FS_GET_STATS) \
1731 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
1732 $(build-boottarball-target)
1733
1734
The Android Open Source Project88b60792009-03-03 19:28:42 -08001735# -----------------------------------------------------------------
1736# data partition image
1737INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001738 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001739
Ying Wangd7321d32013-03-15 10:32:29 -07001740# Don't build userdata.img if it's extfs but no partition size
1741skip_userdata.img :=
1742ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1743ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1744skip_userdata.img := true
1745endif
1746endif
1747
1748ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001749userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001750 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001751BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1752
Ying Wangbd93d422011-10-28 17:02:30 -07001753define build-userdataimage-target
1754 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1755 @mkdir -p $(TARGET_OUT_DATA)
1756 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001757 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001758 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001759 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001760 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001761 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07001762endef
1763
Joe Onorato64d85d02009-04-09 19:31:12 -07001764# We just build this directly to the install location.
1765INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07001766INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
1767 $(INTERNAL_USERIMAGES_DEPS) \
1768 $(INTERNAL_USERDATAIMAGE_FILES) \
1769 $(BUILD_IMAGE_SRCS)
1770$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001771 $(build-userdataimage-target)
1772
1773.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001774userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001775 $(build-userdataimage-target)
1776
Ying Wangd7321d32013-03-15 10:32:29 -07001777endif # not skip_userdata.img
1778skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001779
Andreas Gampe039b5c72017-03-24 16:06:31 -07001780# ASAN libraries in the system image - build rule.
1781ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
1782 $(TARGET_OUT_SHARED_LIBRARIES) \
1783 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
1784 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
1785 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07001786# Extra options: Enforce the system user for the files to avoid having to change ownership.
1787ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07001788# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
1789# enough space.
1790$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07001791 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 -07001792
The Android Open Source Project88b60792009-03-03 19:28:42 -08001793#######
1794## data partition tarball
1795define build-userdatatarball-target
1796 $(call pretty,"Target userdata fs tarball: " \
1797 "$(INSTALLED_USERDATATARBALL_TARGET)")
1798 $(MKTARBALL) $(FS_GET_STATS) \
1799 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001800 $(INSTALLED_USERDATATARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001801endef
1802
1803userdata_tar := $(PRODUCT_OUT)/userdata.tar
1804INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1805$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1806$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1807 $(build-userdatatarball-target)
1808
Dan Willemsen69af2e42016-08-16 16:36:05 -07001809$(call dist-for-goals,userdatatarball,$(INSTALLED_USERDATATARBALL_TARGET))
1810
The Android Open Source Project88b60792009-03-03 19:28:42 -08001811.PHONY: userdatatarball-nodeps
1812userdatatarball-nodeps: $(FS_GET_STATS)
1813 $(build-userdatatarball-target)
1814
1815
The Android Open Source Project88b60792009-03-03 19:28:42 -08001816# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04001817# partition table image
1818ifdef BOARD_BPT_INPUT_FILES
1819
1820BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001821BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04001822
1823INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
1824 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001825 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04001826 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
1827
1828ifdef BOARD_BPT_DISK_SIZE
1829INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
1830endif
1831
1832define build-bptimage-target
1833 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
1834 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
1835endef
1836
1837INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001838$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
1839 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
1840
David Zeuthen25328622016-04-08 15:08:03 -04001841$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
1842 $(build-bptimage-target)
1843
1844.PHONY: bptimage-nodeps
1845bptimage-nodeps:
1846 $(build-bptimage-target)
1847
1848endif # BOARD_BPT_INPUT_FILES
1849
1850# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001851# cache partition image
1852ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1853INTERNAL_CACHEIMAGE_FILES := \
1854 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1855
1856cacheimage_intermediates := \
1857 $(call intermediates-dir-for,PACKAGING,cache)
1858BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1859
1860define build-cacheimage-target
1861 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1862 @mkdir -p $(TARGET_OUT_CACHE)
1863 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001864 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001865 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001866 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001867 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001868 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001869endef
1870
1871# We just build this directly to the install location.
1872INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001873$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) $(BUILD_IMAGE_SRCS)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001874 $(build-cacheimage-target)
1875
1876.PHONY: cacheimage-nodeps
1877cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1878 $(build-cacheimage-target)
1879
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07001880else # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1881# we need to ignore the broken cache link when doing the rsync
1882IGNORE_CACHE_LINK := --exclude=cache
Ying Wang9f8e8db2011-11-04 11:37:01 -07001883endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1884
David Zeuthen0eb10972016-09-28 17:55:27 -04001885# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07001886# system_other partition image
1887ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
1888BOARD_USES_SYSTEM_OTHER := true
1889
1890# Marker file to identify that odex files are installed
1891INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
1892ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
1893$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
1894 $(hide) touch $@
1895endif
1896
1897ifdef BOARD_USES_SYSTEM_OTHER
1898INTERNAL_SYSTEMOTHERIMAGE_FILES := \
1899 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
1900 $(ALL_DEFAULT_INSTALLED_MODULES)\
1901 $(ALL_PDK_FUSION_FILES))
1902
1903INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001904$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST)
Alex Light4e358ab2016-06-16 14:47:10 -07001905 @echo Installed file list: $@
1906 @mkdir -p $(dir $@)
1907 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001908 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001909 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07001910
1911systemotherimage_intermediates := \
1912 $(call intermediates-dir-for,PACKAGING,system_other)
1913BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
1914
1915# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
1916define build-systemotherimage-target
1917 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
1918 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
1919 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
1920 $(call generate-userimage-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt, skip_fsck=true)
1921 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001922 build/make/tools/releasetools/build_image.py \
Alex Light4e358ab2016-06-16 14:47:10 -07001923 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
1924 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
1925endef
1926
1927# We just build this directly to the install location.
1928INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07001929ifneq (true,$(SANITIZE_LITE))
1930# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07001931$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
1932 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07001933endif
Alex Light4e358ab2016-06-16 14:47:10 -07001934
1935.PHONY: systemotherimage-nodeps
1936systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1937 $(build-systemotherimage-target)
1938
1939endif # BOARD_USES_SYSTEM_OTHER
1940
1941
1942# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07001943# vendor partition image
1944ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1945INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07001946 $(filter $(TARGET_OUT_VENDOR)/%,\
1947 $(ALL_DEFAULT_INSTALLED_MODULES)\
1948 $(ALL_PDK_FUSION_FILES))
1949
1950# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
1951$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07001952
Ying Wang8da19e32015-09-15 14:22:12 -07001953INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001954$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST)
Ying Wang8da19e32015-09-15 14:22:12 -07001955 @echo Installed file list: $@
1956 @mkdir -p $(dir $@)
1957 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07001958 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Colin Crossfdea8932017-12-06 14:38:40 -08001959 $(hide) build/make/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07001960
Ying Wanga0febe52013-03-20 11:02:05 -07001961vendorimage_intermediates := \
1962 $(call intermediates-dir-for,PACKAGING,vendor)
1963BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07001964define build-vendorimage-target
1965 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1966 @mkdir -p $(TARGET_OUT_VENDOR)
1967 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1968 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
Howard Chen1756f8d2017-02-22 17:27:10 +08001969 $(if $(BOARD_VENDOR_KERNEL_MODULES), \
1970 $(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 -07001971 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Colin Crossfdea8932017-12-06 14:38:40 -08001972 build/make/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001973 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001974 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07001975endef
1976
1977# We just build this directly to the install location.
1978INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Howard Chen1756f8d2017-02-22 17:27:10 +08001979$(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 -07001980 $(build-vendorimage-target)
1981
Steven Morelanda2e734d2017-03-07 12:10:09 -08001982.PHONY: vendorimage-nodeps vnod
1983vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD)
Ying Wanga0febe52013-03-20 11:02:05 -07001984 $(build-vendorimage-target)
1985
Colin Cross91a52272017-06-20 16:57:52 -07001986sync: $(INTERNAL_VENDORIMAGE_FILES)
1987
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07001988else ifdef BOARD_PREBUILT_VENDORIMAGE
1989INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1990$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
1991endif
Ying Wanga0febe52013-03-20 11:02:05 -07001992
Ying Wang9f8e8db2011-11-04 11:37:01 -07001993# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001994# product partition image
1995ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
1996INTERNAL_PRODUCTIMAGE_FILES := \
1997 $(filter $(TARGET_OUT_PRODUCT)/%,\
1998 $(ALL_DEFAULT_INSTALLED_MODULES)\
1999 $(ALL_PDK_FUSION_FILES))
2000
2001# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2002$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2003
2004INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
2005$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST)
2006 @echo Installed file list: $@
2007 @mkdir -p $(dir $@)
2008 @rm -f $@
2009 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
2010 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
2011
2012productimage_intermediates := \
2013 $(call intermediates-dir-for,PACKAGING,product)
2014BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2015define build-productimage-target
2016 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2017 @mkdir -p $(TARGET_OUT_PRODUCT)
2018 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
2019 $(call generate-userimage-prop-dictionary, $(productimage_intermediates)/product_image_info.txt, skip_fsck=true)
2020 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
2021 ./build/tools/releasetools/build_image.py \
2022 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2023 $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
2024endef
2025
2026# We just build this directly to the install location.
2027INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
2028$(INSTALLED_PRODUCTIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT) $(BUILD_IMAGE_SRCS)
2029 $(build-productimage-target)
2030
2031.PHONY: productimage-nodeps pnod
2032productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2033 $(build-productimage-target)
2034
2035sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2036
2037else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2038INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2039$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2040endif
2041
2042# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07002043# dtbo image
2044ifdef BOARD_PREBUILT_DTBOIMAGE
2045INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
2046
2047ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002048$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002049 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2050 $(AVBTOOL) add_hash_footer \
2051 --image $@ \
2052 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002053 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
Yueyao Zhu211c9012017-04-27 00:34:50 -07002054 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
2055else
2056$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
2057 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2058endif
2059
2060endif
2061
2062# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002063# vbmeta image
2064ifeq ($(BOARD_AVB_ENABLE),true)
2065
2066BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002067AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002068
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002069ifdef BOARD_AVB_KEY_PATH
2070$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
2071else
2072# If key path isn't specified, use the 4096-bit test key.
2073BOARD_AVB_ALGORITHM := SHA256_RSA4096
2074BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
2075endif
2076
2077INTERNAL_AVB_SIGNING_ARGS := \
2078 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
2079
2080BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
2081DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
2082SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
2083VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05002084RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002085PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002086
2087# Check and set required build variables for a chain partition.
2088# $(1): the partition to enable AVB chain, e.g., BOOT or SYSTEM.
2089define check-and-set-avb-chain-args
2090$(eval PART := $(1))
Bowgo Tsaie615afd2017-06-20 17:38:21 +08002091$(eval part=$(call to-lower,$(PART)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002092
2093$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
2094$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
2095$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
2096$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
2097$(if $($(_key_path)),,$(error $(_key_path) is not defined))
2098$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
2099$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
2100$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
2101
2102# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
2103$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
2104$(eval $(_signing_args) := \
2105 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
2106
2107$(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2108 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey)
2109
2110# Set rollback_index via footer args
2111$(eval _footer_args := $(PART)_FOOTER_ARGS)
2112$(eval $($(_footer_args)) += --rollback_index $($(_rollback_index)))
2113endef
2114
2115ifdef BOARD_AVB_BOOT_KEY_PATH
2116$(eval $(call check-and-set-avb-chain-args,BOOT))
2117else
2118INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2119 --include_descriptors_from_image $(INSTALLED_BOOTIMAGE_TARGET)
2120endif
2121
2122ifdef BOARD_AVB_SYSTEM_KEY_PATH
2123$(eval $(call check-and-set-avb-chain-args,SYSTEM))
2124else
2125INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2126 --include_descriptors_from_image $(INSTALLED_SYSTEMIMAGE)
2127endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002128
2129ifdef INSTALLED_VENDORIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002130ifdef BOARD_AVB_VENDOR_KEY_PATH
2131$(eval $(call check-and-set-avb-chain-args,VENDOR))
2132else
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002133INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2134 --include_descriptors_from_image $(INSTALLED_VENDORIMAGE_TARGET)
2135endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002136endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002137
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002138ifdef INSTALLED_PRODUCTIMAGE_TARGET
2139ifdef BOARD_AVB_PRODUCT_KEY_PATH
2140$(eval $(call check-and-set-avb-chain-args,PRODUCT))
2141else
2142INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2143 --include_descriptors_from_image $(INSTALLED_PRODUCTIMAGE_TARGET)
2144endif
2145endif
2146
Yueyao Zhu211c9012017-04-27 00:34:50 -07002147ifdef INSTALLED_DTBOIMAGE_TARGET
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002148ifdef BOARD_AVB_DTBO_KEY_PATH
2149$(eval $(call check-and-set-avb-chain-args,DTBO))
2150else
Yueyao Zhu211c9012017-04-27 00:34:50 -07002151INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
Tao Baoc633ed02017-05-30 21:46:33 -07002152 --include_descriptors_from_image $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002153endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002154endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07002155
David Zeuthen8fecb282017-12-01 16:24:01 -05002156ifdef INSTALLED_RECOVERYIMAGE_TARGET
2157ifdef BOARD_AVB_RECOVERY_KEY_PATH
2158$(eval $(call check-and-set-avb-chain-args,RECOVERY))
2159else
2160INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
2161 --include_descriptors_from_image $(INSTALLED_RECOVERYIMAGE_TARGET)
2162endif
2163endif
2164
Bowgo Tsai9e95bea2017-06-30 12:12:15 +08002165BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
Bowgo Tsai53cf9992017-06-13 11:27:06 +08002166
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002167# Add kernel cmdline descriptor for kernel to mount system.img as root with
2168# dm-verity. This works when system.img is either chained or not-chained:
2169# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
2170# cmdline descriptor to system.img
2171# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
2172# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08002173ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002174BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08002175endif
2176
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002177ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002178BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002179endif
2180
2181ifndef BOARD_BOOTIMAGE_PARTITION_SIZE
2182 $(error BOARD_BOOTIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
2183endif
2184
2185ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
2186 $(error BOARD_SYSTEMIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
2187endif
2188
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002189# $(1): the directory to extract public keys to
2190define extract-avb-chain-public-keys
2191 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
2192 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
2193 --output $(1)/boot.avbpubkey)
2194 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
2195 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
2196 --output $(1)/system.avbpubkey)
2197 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
2198 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
2199 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002200 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
2201 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
2202 --output $(1)/product.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002203 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
2204 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
2205 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05002206 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
2207 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
2208 --output $(1)/recovery.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002209endef
2210
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002211define build-vbmetaimage-target
2212 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002213 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
2214 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002215 $(hide) $(AVBTOOL) make_vbmeta_image \
2216 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
2217 $(INTERNAL_AVB_SIGNING_ARGS) \
2218 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
2219 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002220 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002221endef
2222
2223INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
David Zeuthen8fecb282017-12-01 16:24:01 -05002224$(INSTALLED_VBMETAIMAGE_TARGET): \
2225 $(AVBTOOL) \
2226 $(INSTALLED_BOOTIMAGE_TARGET) \
2227 $(INSTALLED_SYSTEMIMAGE) \
2228 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002229 $(INSTALLED_PRODUCTIMAGE_TARGET) \
David Zeuthen8fecb282017-12-01 16:24:01 -05002230 $(INSTALLED_DTBOIMAGE_TARGET) \
2231 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2232 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002233 $(build-vbmetaimage-target)
2234
2235.PHONY: vbmetaimage-nodeps
2236vbmetaimage-nodeps:
2237 $(build-vbmetaimage-target)
2238
Bowgo Tsai9afc0d52017-07-27 21:22:14 +08002239else ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE))
2240BUILT_DISABLED_VBMETAIMAGE := $(PRODUCT_OUT)/vbmeta.img
2241
2242INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_DISABLED_VBMETAIMAGE)
2243$(INSTALLED_VBMETAIMAGE_TARGET): $(AVBTOOL)
2244 $(hide) $(AVBTOOL) make_vbmeta_image \
2245 --flag 2 --padding_size 4096 --output $@
2246
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08002247endif # BOARD_AVB_ENABLE
2248
2249# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08002250# bring in the installer image generation defines if necessary
2251ifeq ($(TARGET_USE_DISKINSTALLER),true)
2252include bootable/diskinstaller/config.mk
2253endif
2254
2255# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07002256# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08002257
Ying Wangbd2d0242015-09-22 11:17:52 -07002258build_ota_package := true
2259ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
2260build_ota_package := false
2261endif
2262ifeq ($(BUILD_OS),darwin)
2263build_ota_package := false
2264endif
2265ifneq ($(strip $(SANITIZE_TARGET)),)
2266build_ota_package := false
2267endif
2268ifeq ($(TARGET_PRODUCT),sdk)
2269build_ota_package := false
2270endif
2271ifneq ($(filter generic%,$(TARGET_DEVICE)),)
2272build_ota_package := false
2273endif
2274ifeq ($(TARGET_NO_KERNEL),true)
2275build_ota_package := false
2276endif
2277ifeq ($(recovery_fstab),)
2278build_ota_package := false
2279endif
Colin Cross481cc5a2016-02-04 15:09:23 -08002280ifeq ($(TARGET_BUILD_PDK),true)
2281build_ota_package := false
2282endif
Ying Wangbd2d0242015-09-22 11:17:52 -07002283
2284ifeq ($(build_ota_package),true)
Ying Wang09c4b682015-08-11 11:24:19 -07002285OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
2286 $(HOST_OUT_EXECUTABLES)/aapt \
Michael Schwartz6473e752017-11-08 11:45:14 -08002287 $(HOST_OUT_EXECUTABLES)/checkvintf \
Ying Wangc45a47b2015-04-08 12:24:37 -07002288 $(HOST_OUT_EXECUTABLES)/mkbootfs \
2289 $(HOST_OUT_EXECUTABLES)/mkbootimg \
2290 $(HOST_OUT_EXECUTABLES)/fs_config \
2291 $(HOST_OUT_EXECUTABLES)/zipalign \
2292 $(HOST_OUT_EXECUTABLES)/bsdiff \
2293 $(HOST_OUT_EXECUTABLES)/imgdiff \
2294 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
2295 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
2296 $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
Tao Baoe8ef8f702017-05-17 11:41:50 -07002297 $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar \
Tao Baobcc31092017-01-06 14:24:18 -08002298 $(HOST_OUT_EXECUTABLES)/mke2fs \
2299 $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh \
2300 $(HOST_OUT_EXECUTABLES)/e2fsdroid \
Tao Baocffaf732016-04-14 12:11:36 -07002301 $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \
2302 $(HOST_OUT_EXECUTABLES)/mksquashfs \
2303 $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \
2304 $(HOST_OUT_EXECUTABLES)/make_f2fs \
Jaegeuk Kim2ea1eba2017-11-28 19:21:28 -08002305 $(HOST_OUT_EXECUTABLES)/sload_f2fs \
Ying Wangc45a47b2015-04-08 12:24:37 -07002306 $(HOST_OUT_EXECUTABLES)/simg2img \
2307 $(HOST_OUT_EXECUTABLES)/e2fsck \
2308 $(HOST_OUT_EXECUTABLES)/build_verity_tree \
Baligh Uddinc8bef142017-12-18 10:40:57 -08002309 $(HOST_OUT_EXECUTABLES)/generate_verity_key \
Ying Wangc45a47b2015-04-08 12:24:37 -07002310 $(HOST_OUT_EXECUTABLES)/verity_signer \
Tao Bao7f02f342016-11-18 17:04:24 -08002311 $(HOST_OUT_EXECUTABLES)/verity_verifier \
Ying Wangc45a47b2015-04-08 12:24:37 -07002312 $(HOST_OUT_EXECUTABLES)/append2simg \
Mohamad Ayyash353265b2015-06-24 15:42:19 -07002313 $(HOST_OUT_EXECUTABLES)/img2simg \
Sami Tolvanenf99b5312015-05-20 07:30:57 +01002314 $(HOST_OUT_EXECUTABLES)/boot_signer \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002315 $(HOST_OUT_EXECUTABLES)/fec \
Tao Bao6d8a8cc2016-01-19 14:47:17 -08002316 $(HOST_OUT_EXECUTABLES)/brillo_update_payload \
2317 $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \
Tao Baof54216f2016-03-29 15:12:37 -07002318 $(HOST_OUT_EXECUTABLES)/delta_generator \
Tao Bao3cba3742017-05-16 16:27:25 -07002319 $(AVBTOOL) \
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002320 $(BLK_ALLOC_TO_BASE_FS) \
Alex Deymob10e07a2017-11-09 23:53:42 +01002321 $(BROTLI)
Tao Bao5e04c382017-02-22 16:38:19 -08002322
2323ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
2324OTATOOLS += \
Tao Bao69ad1502017-02-23 11:03:45 -08002325 $(FUTILITY) \
2326 $(VBOOT_SIGNER)
Tao Bao5e04c382017-02-22 16:38:19 -08002327endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08002328
Ying Wangc45a47b2015-04-08 12:24:37 -07002329# Shared libraries.
Ying Wang09c4b682015-08-11 11:24:19 -07002330OTATOOLS += \
Mark Salyzync506e742015-04-13 09:01:24 -07002331 $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
2332 $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \
2333 $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02002334 $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \
Baligh Uddinc8bef142017-12-18 10:40:57 -08002335 $(HOST_LIBRARY_PATH)/libcrypto_utils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02002336 $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08002337 $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \
2338 $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \
2339 $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \
2340 $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \
Baligh Uddinb24470e2017-01-30 12:41:31 -08002341 $(HOST_LIBRARY_PATH)/libext2_misc$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08002342 $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \
2343 $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \
Alex Klyubin9667b182015-12-10 13:38:50 -08002344 $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002345 $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \
2346 $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \
2347 $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002348 $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \
2349 $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \
Dan Willemsen8c2b6bb2016-07-22 23:16:30 +00002350 $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \
Tao Baofdd26932016-02-11 09:50:41 -08002351 $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08002352 $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \
Johan Redestig8f800df2016-03-24 13:57:03 +01002353 $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \
Tao Bao138986b2017-01-26 08:16:57 -08002354 $(HOST_LIBRARY_PATH)/libsparse-host$(HOST_SHLIB_SUFFIX) \
Vikram Dattu8be44672016-12-16 16:33:03 +01002355 $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) \
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002356 $(HOST_LIBRARY_PATH)/libpcre2$(HOST_SHLIB_SUFFIX) \
2357 $(HOST_LIBRARY_PATH)/libbrotli$(HOST_SHLIB_SUFFIX)
2358
The Android Open Source Project88b60792009-03-03 19:28:42 -08002359
Ying Wang06898662010-06-17 17:52:18 -07002360.PHONY: otatools
2361otatools: $(OTATOOLS)
2362
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002363BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
Ying Wang62925a92015-04-08 16:37:34 -07002364$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002365
Tao Baoe8ef8f702017-05-17 11:41:50 -07002366OTATOOLS_DEPS := \
2367 system/extras/verity/build_verity_metadata.py \
2368 system/extras/ext4_utils/mke2fs.conf \
Tao Bao3cba3742017-05-16 16:27:25 -07002369 external/avb/test/data/testkey_rsa4096.pem \
Tao Bao14a32172018-02-10 03:04:12 +00002370 $(shell find system/update_engine/scripts -name \*.pyc -prune -o -type f -print | sort) \
2371 $(shell find build/target/product/security -type f -name \*.x509.pem -o -name \*.pk8 -o \
2372 -name verity_key | sort) \
2373 $(shell find device $(wildcard vendor) -type f -name \*.pk8 -o -name verifiedboot\* -o \
2374 -name \*.x509.pem -o -name oem\*.prop | sort)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002375
2376OTATOOLS_RELEASETOOLS := \
Tao Bao14a32172018-02-10 03:04:12 +00002377 $(shell find build/make/tools/releasetools -name \*.pyc -prune -o -type f | sort)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002378
2379ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
2380OTATOOLS_DEPS += \
Tao Bao14a32172018-02-10 03:04:12 +00002381 $(shell find external/vboot_reference/tests/devkeys -type f | sort)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002382endif
2383
2384$(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) $(OTATOOLS_DEPS) $(OTATOOLS_RELEASETOOLS) | $(ACP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002385 @echo "Package OTA tools: $@"
2386 $(hide) rm -rf $@ $(zip_root)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002387 $(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools
Ying Wangc45a47b2015-04-08 12:24:37 -07002388 $(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
Colin Crossfdea8932017-12-06 14:38:40 -08002389 $(hide) $(ACP) -r -d -p build/make/tools/releasetools/* $(zip_root)/releasetools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002390 $(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
Dan Willemsen48a621c2015-10-29 16:33:05 -07002391 $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *)
Tao Baoe8ef8f702017-05-17 11:41:50 -07002392 $(hide) echo $(OTATOOLS_DEPS) | xargs zip -qryX $(abspath $@)>/dev/null || true
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002393
2394.PHONY: otatools-package
2395otatools-package: $(BUILT_OTATOOLS_PACKAGE)
2396
Ying Wangbd2d0242015-09-22 11:17:52 -07002397endif # build_ota_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002398
The Android Open Source Project88b60792009-03-03 19:28:42 -08002399# -----------------------------------------------------------------
2400# A zip of the directories that map to the target filesystem.
2401# This zip can be used to create an OTA package or filesystem image
2402# as a post-build step.
2403#
2404name := $(TARGET_PRODUCT)
2405ifeq ($(TARGET_BUILD_TYPE),debug)
2406 name := $(name)_debug
2407endif
2408name := $(name)-target_files-$(FILE_NAME_TAG)
2409
2410intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
2411BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
2412$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
2413$(BUILT_TARGET_FILES_PACKAGE): \
2414 zip_root := $(intermediates)/$(name)
2415
2416# $(1): Directory to copy
2417# $(2): Location to copy it to
2418# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
2419define package_files-copy-root
2420 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
2421 mkdir -p $(2) && \
2422 $(ACP) -rd $(strip $(1))/* $(2); \
2423 fi
2424endef
2425
Tao Baoa04fca32015-11-30 12:22:24 -08002426built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07002427
2428# We can't build static executables when SANITIZE_TARGET=address
Ivan Krasin74b32b82015-09-18 11:54:43 -07002429ifeq ($(strip $(SANITIZE_TARGET)),)
Ying Wange6e544e2015-06-22 18:35:35 -07002430built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07002431 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
2432endif
2433
The Android Open Source Project88b60792009-03-03 19:28:42 -08002434$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
2435
Doug Zongkerb1134dd2009-06-17 17:09:40 -07002436$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08002437$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07002438
Doug Zongkerc18736b2009-09-30 09:20:32 -07002439ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
2440# default to common dir for device vendor
Dan Willemsen653bea92017-03-21 15:47:37 -07002441tool_extensions := $(TARGET_DEVICE_DIR)/../common
Doug Zongkerc18736b2009-09-30 09:20:32 -07002442else
Dan Willemsen653bea92017-03-21 15:47:37 -07002443tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
Doug Zongkerc18736b2009-09-30 09:20:32 -07002444endif
Dan Willemsen653bea92017-03-21 15:47:37 -07002445tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
2446$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSIONS := $(tool_extensions)
2447$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07002448
Sen Jiang4438fd92016-03-07 16:51:01 -08002449ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08002450updater_dep := system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08002451else
Steve Fung48e49f52015-10-01 23:53:31 -07002452# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002453updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07002454endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002455$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07002456
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002457# If we are using recovery as boot, output recovery files to BOOT/.
2458ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2459$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
2460else
2461$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
2462endif
2463
Dan Willemsen653bea92017-03-21 15:47:37 -07002464ifeq ($(AB_OTA_UPDATER),true)
2465 ifdef BRILLO_VENDOR_PARTITIONS
2466 $(BUILT_TARGET_FILES_PACKAGE): $(foreach p,$(BRILLO_VENDOR_PARTITIONS),\
2467 $(call word-colon,1,$(p))/$(call word-colon,2,$(p)))
2468 endif
2469 ifdef OSRELEASED_DIRECTORY
2470 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
2471 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
2472 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
2473 endif
2474endif
2475
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002476# Run fs_config while creating the target files package
2477# $1: root directory
2478# $2: add prefix
2479define fs_config
2480(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)
2481endef
2482
The Android Open Source Project88b60792009-03-03 19:28:42 -08002483# Depending on the various images guarantees that the underlying
2484# directories are up-to-date.
2485$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002486 $(INSTALLED_BOOTIMAGE_TARGET) \
2487 $(INSTALLED_RADIOIMAGE_TARGET) \
2488 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002489 $(FULL_SYSTEMIMAGE_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002490 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002491 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07002492 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002493 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Bowgo Tsai6a749792017-09-01 22:55:44 +08002494 $(INSTALLED_VBMETAIMAGE_TARGET) \
Yueyao Zhu211c9012017-04-27 00:34:50 -07002495 $(INSTALLED_DTBOIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002496 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002497 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Dan Willemsen653bea92017-03-21 15:47:37 -07002498 $(INSTALLED_KERNEL_TARGET) \
2499 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2500 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
2501 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002502 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07002503 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002504 $(APKCERTS_FILE) \
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002505 $(SOONG_ZIP) \
Doug Zongker283e2a12010-03-15 17:52:32 -07002506 $(HOST_OUT_EXECUTABLES)/fs_config \
Dan Willemsend79a08f2017-03-23 22:09:06 -07002507 $(HOST_OUT_EXECUTABLES)/imgdiff \
2508 $(HOST_OUT_EXECUTABLES)/bsdiff \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002509 $(BUILD_IMAGE_SRCS) \
Steven Moreland915f3512018-01-25 10:44:47 -08002510 $(BUILT_VENDOR_MANIFEST) \
2511 $(BUILT_VENDOR_MATRIX) \
Ying Wang5d887702015-11-04 10:06:25 -08002512 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002513 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07002514 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002515 $(call create-system-product-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002516 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002517 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002518ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002519 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002520 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002521 $(hide) $(call package_files-copy-root, \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002522 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002523ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002524 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08002525endif
2526ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002527 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08002528endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002529ifdef INTERNAL_KERNEL_CMDLINE
2530 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08002531endif
Doug Zongker38a649f2009-06-17 09:07:09 -07002532ifdef BOARD_KERNEL_BASE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002533 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07002534endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002535ifdef BOARD_KERNEL_PAGESIZE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002536 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07002537endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002538endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08002539 @# Components of the boot image
2540 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07002541ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
2542 $(hide) mkdir -p $(zip_root)/ROOT
2543 $(hide) $(call package_files-copy-root, \
2544 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
2545else
The Android Open Source Project88b60792009-03-03 19:28:42 -08002546 $(hide) $(call package_files-copy-root, \
2547 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07002548endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002549 @# If we are using recovery as boot, this is already done when processing recovery.
2550ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002551ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002552 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08002553endif
2554ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002555 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08002556endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002557ifdef INTERNAL_KERNEL_CMDLINE
2558 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08002559endif
Doug Zongker38a649f2009-06-17 09:07:09 -07002560ifdef BOARD_KERNEL_BASE
2561 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
2562endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002563ifdef BOARD_KERNEL_PAGESIZE
2564 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
2565endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002566endif # BOARD_USES_RECOVERY_AS_BOOT
Doug Zongkere01100c2009-06-19 17:12:18 -07002567 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
2568 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07002569 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002570 @# Contents of the system image
2571 $(hide) $(call package_files-copy-root, \
2572 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
2573 @# Contents of the data image
2574 $(hide) $(call package_files-copy-root, \
2575 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07002576ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2577 @# Contents of the vendor image
2578 $(hide) $(call package_files-copy-root, \
2579 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
2580endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002581ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2582 @# Contents of the product image
2583 $(hide) $(call package_files-copy-root, \
2584 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
2585endif
Alex Light4e358ab2016-06-16 14:47:10 -07002586ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
2587 @# Contents of the system_other image
2588 $(hide) $(call package_files-copy-root, \
2589 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
2590endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002591 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07002592 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07002593 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07002594ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08002595ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07002596 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07002597 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07002598endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08002599endif
Doug Zongker8678df42009-06-15 14:30:14 -07002600 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08002601 @# build them.
2602 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07002603 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
2604ifneq ($(tool_extension),)
2605 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
2606endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07002607 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07002608 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Doug Zongker37974732010-09-16 17:44:38 -07002609 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08002610 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002611ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07002612 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002613endif
2614ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08002615 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002616endif
Tao Baodb45efa2015-10-27 19:25:18 -07002617ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
2618 $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
2619endif
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002620ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08002621 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002622endif
JP Abgrall6ea5bd62014-10-22 20:01:22 -07002623ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
2624 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
2625 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
2626else
2627 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
2628endif
Dan Willemsen653bea92017-03-21 15:47:37 -07002629 $(hide) echo "tool_extensions=$(PRIVATE_TOOL_EXTENSIONS)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07002630 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07002631ifdef PRODUCT_EXTRA_RECOVERY_KEYS
2632 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08002633endif
Jianxun Zhang09849492013-04-17 15:19:19 -07002634 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Sami Tolvanen3303d902016-03-15 16:49:30 +00002635 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08002636 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Tao Bao8fad03e2017-03-01 14:36:26 -08002637 $(hide) echo "blockimgdiff_versions=3,4" >> $(zip_root)/META/misc_info.txt
Ying Wange24e17a2014-10-07 18:42:11 -07002638ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
Jeff Sharkey26e1a282014-03-21 16:20:05 -07002639 # OTA scripts are only interested in fingerprint related properties
Ying Wange24e17a2014-10-07 18:42:11 -07002640 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
Vineeta Srivastava27262112014-09-18 14:34:00 -07002641endif
Tao Baof54216f2016-03-29 15:12:37 -07002642ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07002643 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07002644 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH))
2645endif
2646ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07002647 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07002648 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH))
2649endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002650ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH),)
2651 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH) \
2652 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH))
2653endif
Ivan Krasin74b32b82015-09-18 11:54:43 -07002654ifneq ($(strip $(SANITIZE_TARGET)),)
Ying Wang2a048392015-06-25 13:56:53 -07002655 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
2656 $(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt
2657endif
Tao Bao8beab692015-07-22 12:33:18 -07002658ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
2659 $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
2660endif
David Zeuthen0eb10972016-09-28 17:55:27 -04002661ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002662 $(hide) echo "avb_enable=true" >> $(zip_root)/META/misc_info.txt
2663 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2664 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2665 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
2666 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2667ifdef BOARD_AVB_BOOT_KEY_PATH
2668 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2669 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2670 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
2671endif # BOARD_AVB_BOOT_KEY_PATH
David Zeuthen8fecb282017-12-01 16:24:01 -05002672 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2673ifdef BOARD_AVB_RECOVERY_KEY_PATH
2674 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2675 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2676 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
2677endif # BOARD_AVB_RECOVERY_KEY_PATH
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002678endif # BOARD_AVB_ENABLE
David Zeuthen25328622016-04-08 15:08:03 -04002679ifdef BOARD_BPT_INPUT_FILES
2680 $(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt
2681 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $(zip_root)/META/misc_info.txt
2682 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $(zip_root)/META/misc_info.txt
2683endif
2684ifdef BOARD_BPT_DISK_SIZE
2685 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $(zip_root)/META/misc_info.txt
2686endif
Ying Wangbd93d422011-10-28 17:02:30 -07002687 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Tao Baocbc6dc22015-08-18 18:03:56 -07002688ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Per Astrandcab66992015-03-25 14:06:30 +01002689 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08002690 build/make/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07002691endif
Alex Deymo70067ac2015-09-29 19:05:37 -07002692ifeq ($(AB_OTA_UPDATER),true)
2693 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07002694 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07002695 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07002696 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
2697 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08002698 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
2699 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
2700 done
Steve Fung4044b382015-11-05 02:04:04 -08002701 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
2702 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002703 $(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt
Wei Wang2e735ca2016-05-10 22:48:13 -07002704ifdef BRILLO_VENDOR_PARTITIONS
2705 $(hide) mkdir -p $(zip_root)/VENDOR_IMAGES
2706 $(hide) for f in $(BRILLO_VENDOR_PARTITIONS); do \
2707 pair1="$$(echo $$f | awk -F':' '{print $$1}')"; \
2708 pair2="$$(echo $$f | awk -F':' '{print $$2}')"; \
2709 src=$${pair1}/$${pair2}; \
2710 dest=$(zip_root)/VENDOR_IMAGES/$${pair2}; \
2711 mkdir -p $$(dirname "$${dest}"); \
Dan Willemsen653bea92017-03-21 15:47:37 -07002712 cp $${src} $${dest}; \
Wei Wang2e735ca2016-05-10 22:48:13 -07002713 done;
2714endif
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07002715ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07002716 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
2717 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
2718 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07002719endif
Alex Deymo70067ac2015-09-29 19:05:37 -07002720endif
Steve Fungdfbab492015-09-24 18:12:33 -07002721ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07002722 @# If breakpad symbols have been generated, add them to the zip.
Steve Fungdfbab492015-09-24 18:12:33 -07002723 $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
2724endif
Bowgo Tsai6a749792017-09-01 22:55:44 +08002725# BOARD_BUILD_DISABLED_VBMETAIMAGE is used to build a special vbmeta.img
2726# that disables AVB verification. The content is fixed and we can just copy
2727# it to $(zip_root)/IMAGES without passing some info into misc_info.txt for
2728# regeneration.
2729ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE))
2730 $(hide) mkdir -p $(zip_root)/IMAGES
2731 $(hide) cp $(INSTALLED_VBMETAIMAGE_TARGET) $(zip_root)/IMAGES/
2732endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002733ifdef BOARD_PREBUILT_VENDORIMAGE
2734 $(hide) mkdir -p $(zip_root)/IMAGES
2735 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
2736endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002737ifdef BOARD_PREBUILT_PRODUCTIMAGE
2738 $(hide) mkdir -p $(zip_root)/IMAGES
2739 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
2740endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07002741ifdef BOARD_PREBUILT_BOOTIMAGE
2742 $(hide) mkdir -p $(zip_root)/IMAGES
2743 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
2744endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07002745ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07002746 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
2747 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
2748 $(hide) echo "has_dtbo=true" >> $(zip_root)/META/misc_info.txt
2749ifeq ($(BOARD_AVB_ENABLE),true)
2750 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002751 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2752ifdef BOARD_AVB_DTBO_KEY_PATH
2753 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2754 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2755 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" \
Tao Baoc633ed02017-05-30 21:46:33 -07002756 >> $(zip_root)/META/misc_info.txt
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002757endif # BOARD_AVB_DTBO_KEY_PATH
2758endif # BOARD_AVB_ENABLE
2759endif # BOARD_PREBUILT_DTBOIMAGE
Tao Bao95a95c32017-06-16 15:30:23 -07002760 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
2761 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
2762 @# INSTALLED_RADIOIMAGE_TARGET.
2763 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
2764 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002765 @# Run fs_config on all the system, vendor, boot ramdisk,
2766 @# and recovery ramdisk files in the zip, and save the output
2767 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
2768ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2769 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
2770endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002771ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
2772 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
2773endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002774ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
2775 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
2776endif
2777 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
2778ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
2779 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
2780endif
2781ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
2782 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
2783endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002784 @# Metadata for compatibility verification.
Yifan Hongaa212212017-04-14 00:00:46 -07002785 $(hide) cp $(BUILT_SYSTEM_MANIFEST) $(zip_root)/META/system_manifest.xml
Yifan Hong35b34ef2017-05-15 18:00:37 -07002786 $(hide) cp $(BUILT_SYSTEM_COMPATIBILITY_MATRIX) $(zip_root)/META/system_matrix.xml
Yifan Hongaa212212017-04-14 00:00:46 -07002787ifdef BUILT_VENDOR_MANIFEST
2788 $(hide) cp $(BUILT_VENDOR_MANIFEST) $(zip_root)/META/vendor_manifest.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002789endif
Yifan Hongaa212212017-04-14 00:00:46 -07002790ifdef BUILT_VENDOR_MATRIX
2791 $(hide) cp $(BUILT_VENDOR_MATRIX) $(zip_root)/META/vendor_matrix.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002792endif
2793
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002794 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08002795 build/make/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root)
Alex Deymo92cfd6f2016-01-26 18:47:44 -08002796 @# Zip everything up, preserving symlinks and placing META/ files first to
2797 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002798 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07002799 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002800 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07002801
Ying Wanga0febe52013-03-20 11:02:05 -07002802.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08002803target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
2804
Ying Wang4709d7c2014-04-14 17:25:43 -07002805ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
2806$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
2807endif
Doug Zongker367910f2009-06-15 18:56:51 -07002808
Dan Albert4d323332016-10-14 13:23:06 -07002809# -----------------------------------------------------------------
2810# NDK Sysroot Package
2811NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
2812$(NDK_SYSROOT_TARGET): ndk
2813 @echo Package NDK sysroot...
2814 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
2815
2816$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
2817
Ying Wang09c4b682015-08-11 11:24:19 -07002818ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07002819# -----------------------------------------------------------------
2820# OTA update package
2821
Doug Zongker8678df42009-06-15 14:30:14 -07002822name := $(TARGET_PRODUCT)
2823ifeq ($(TARGET_BUILD_TYPE),debug)
2824 name := $(name)_debug
2825endif
2826name := $(name)-ota-$(FILE_NAME_TAG)
2827
2828INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2829
2830$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
2831
Tao Baoe53c6e72017-04-19 15:54:22 -07002832ifeq ($(AB_OTA_UPDATER),true)
2833$(INTERNAL_OTA_PACKAGE_TARGET): $(BRILLO_UPDATE_PAYLOAD)
Tianjie Xub0a29ad2017-07-06 15:13:59 -07002834else
Alex Deymob10e07a2017-11-09 23:53:42 +01002835$(INTERNAL_OTA_PACKAGE_TARGET): $(BROTLI)
Tao Baoe53c6e72017-04-19 15:54:22 -07002836endif
2837
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002838$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
Colin Crossfdea8932017-12-06 14:38:40 -08002839 build/make/tools/releasetools/ota_from_target_files
Doug Zongker8678df42009-06-15 14:30:14 -07002840 @echo "Package OTA: $@"
Ying Wang9d252e12015-02-09 17:20:06 -08002841 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Colin Crossfdea8932017-12-06 14:38:40 -08002842 build/make/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08002843 --block \
Dan Willemsencea5cd22017-03-21 14:44:27 -07002844 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
Doug Zongker602a84e2009-06-18 08:35:12 -07002845 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05002846 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07002847 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05002848 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07002849
2850.PHONY: otapackage
2851otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
2852
Ying Wang09c4b682015-08-11 11:24:19 -07002853endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07002854
Ying Wang09a00a62010-10-20 14:01:09 -07002855# -----------------------------------------------------------------
2856# The update package
2857
2858name := $(TARGET_PRODUCT)
2859ifeq ($(TARGET_BUILD_TYPE),debug)
2860 name := $(name)_debug
2861endif
2862name := $(name)-img-$(FILE_NAME_TAG)
2863
2864INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2865
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002866$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(ZIP2ZIP)
Ying Wang09a00a62010-10-20 14:01:09 -07002867 @echo "Package: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002868 $(hide) $(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
2869 OTA/android-info.txt:android-info.txt "IMAGES/*.img:."
Ying Wang09a00a62010-10-20 14:01:09 -07002870
2871.PHONY: updatepackage
2872updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
2873
The Android Open Source Project88b60792009-03-03 19:28:42 -08002874# -----------------------------------------------------------------
2875# A zip of the symbols directory. Keep the full paths to make it
2876# more obvious where these files came from.
2877#
2878name := $(TARGET_PRODUCT)
2879ifeq ($(TARGET_BUILD_TYPE),debug)
2880 name := $(name)_debug
2881endif
2882name := $(name)-symbols-$(FILE_NAME_TAG)
2883
2884SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07002885# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Ying Wangda3b9722014-10-24 11:36:59 -07002886ifndef TARGET_BUILD_APPS
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002887$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) \
2888 $(INSTALLED_BOOTIMAGE_TARGET) \
2889 $(INSTALLED_USERDATAIMAGE_TARGET) \
2890 $(INSTALLED_VENDORIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002891 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002892 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07002893endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002894$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
2895$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002896 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002897 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
2898 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
2899 $(hide) find $(TARGET_OUT_UNSTRIPPED) | sort >$(PRIVATE_LIST_FILE)
Dan Willemsen6cf21a72017-01-30 20:42:28 -08002900 $(hide) $(SOONG_ZIP) -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07002901# -----------------------------------------------------------------
2902# A zip of the coverage directory.
2903#
2904name := $(TARGET_PRODUCT)
2905ifeq ($(TARGET_BUILD_TYPE),debug)
2906name := $(name)_debug
2907endif
2908name := $(name)-coverage-$(FILE_NAME_TAG)
2909COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
2910ifndef TARGET_BUILD_APPS
2911$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE) \
2912 $(INSTALLED_BOOTIMAGE_TARGET) \
2913 $(INSTALLED_USERDATAIMAGE_TARGET) \
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002914 $(INSTALLED_VENDORIMAGE_TARGET) \
2915 $(INSTALLED_PRODUCTIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07002916endif
2917$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
2918$(COVERAGE_ZIP): $(SOONG_ZIP)
2919 @echo "Package coverage: $@"
2920 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
2921 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
2922 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
2923 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002924
2925# -----------------------------------------------------------------
2926# A zip of the Android Apps. Not keeping full path so that we don't
2927# include product names when distributing
2928#
2929name := $(TARGET_PRODUCT)
2930ifeq ($(TARGET_BUILD_TYPE),debug)
2931 name := $(name)_debug
2932endif
2933name := $(name)-apps-$(FILE_NAME_TAG)
2934
2935APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Ying Wang5d887702015-11-04 10:06:25 -08002936$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002937 @echo "Package apps: $@"
2938 $(hide) rm -rf $@
2939 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07002940 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
2941 if [ -z "$$apps_to_zip" ]; then \
2942 echo "No apps to zip up. Generating empty apps archive." ; \
2943 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
2944 else \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002945 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07002946 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07002947
Ying Wangbc415dd2012-08-15 12:22:44 -07002948ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07002949#------------------------------------------------------------------
2950# An archive of classes for use in generating code-coverage reports
2951# These are the uninstrumented versions of any classes that were
2952# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07002953# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07002954
Colin Crossa6bc3a82017-09-27 14:28:41 -07002955JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07002956$(JACOCO_REPORT_CLASSES_ALL) :
2957 @echo "Collecting uninstrumented classes"
2958 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" | \
2959 zip -@ -0 -q -X $@
2960# Meaning of these options:
2961# -@ scan stdin for file paths to add to the zip
2962# -0 don't do any compression
2963# -q supress most output
2964# -X skip storing extended file attributes
2965
Ying Wangbc415dd2012-08-15 12:22:44 -07002966endif # EMMA_INSTRUMENT=true
2967
Jeff Gastonaaae43c2017-04-11 16:36:46 -07002968
Ying Wangae9115a2013-08-22 20:52:47 -07002969#------------------------------------------------------------------
2970# A zip of Proguard obfuscation dictionary files.
2971# Only for apps_only build.
2972#
2973ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07002974PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07002975# the dependency will be set up later in build/make/core/main.mk.
Ying Wangae9115a2013-08-22 20:52:47 -07002976$(PROGUARD_DICT_ZIP) :
2977 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossa6bc3a82017-09-27 14:28:41 -07002978 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
Ying Wangae9115a2013-08-22 20:52:47 -07002979 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08002980 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002981 zip -qX $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07002982 else \
Ying Wangdcd90832015-02-26 09:36:27 -08002983 touch $(dir $@)/zipdummy; \
2984 (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \
2985 zip -qd $@ zipdummy; \
2986 rm $(dir $@)/zipdummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07002987 fi
2988
2989endif # TARGET_BUILD_APPS
2990
The Android Open Source Project88b60792009-03-03 19:28:42 -08002991# -----------------------------------------------------------------
2992# dalvik something
2993.PHONY: dalvikfiles
2994dalvikfiles: $(INTERNAL_DALVIK_MODULES)
2995
Bo Huf0d50bb2017-08-01 19:02:09 +00002996ifeq ($(BUILD_QEMU_IMAGES),true)
2997INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
2998MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
2999SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
3000$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_SYSTEMIMAGE) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3001 @echo Create system-qemu.img
3002 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/system.img)
3003
3004systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
3005droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
3006ifeq ($(BOARD_USES_VENDORIMAGE),true)
3007INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
3008$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3009 @echo Create vendor-qemu.img
3010 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/vendor.img)
3011
3012vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
3013droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
3014endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003015ifeq ($(BOARD_USES_PRODUCTIMAGE),true)
3016INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
3017$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
3018 @echo Create product-qemu.img
3019 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) ${PRODUCT_OUT}/product.img)
3020
3021productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
3022droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
3023endif
Bo Huf0d50bb2017-08-01 19:02:09 +00003024endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003025# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003026# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07003027ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003028INTERNAL_EMULATOR_PACKAGE_FILES += \
3029 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08003030 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003031 $(INSTALLED_RAMDISK_TARGET) \
3032 $(INSTALLED_SYSTEMIMAGE) \
3033 $(INSTALLED_USERDATAIMAGE_TARGET)
3034
3035name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
3036
3037INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
3038
Ying Wang5d887702015-11-04 10:06:25 -08003039$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003040 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07003041 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003042
Ying Wang7d8c5352012-07-26 10:15:21 -07003043endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08003044# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08003045# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08003046# The pdk package (Platform Development Kit)
3047
Keun young Park7fc7aad2012-02-27 15:49:23 -08003048#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
3049# include development/pdk/Pdk.mk
3050#endif
3051
The Android Open Source Project88b60792009-03-03 19:28:42 -08003052
3053# -----------------------------------------------------------------
3054# The SDK
3055
The Android Open Source Project88b60792009-03-03 19:28:42 -08003056# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07003057sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003058
3059# Build a name that looks like:
3060#
3061# linux-x86 --> android-sdk_12345_linux-x86
3062# darwin-x86 --> android-sdk_12345_mac-x86
3063# windows-x86 --> android-sdk_12345_windows
3064#
3065sdk_name := android-sdk_$(FILE_NAME_TAG)
3066ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07003067 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08003068else
Joe Onorato03fbe402009-04-13 08:31:16 -07003069 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003070endif
3071ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07003072 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003073endif
Joe Onorato03fbe402009-04-13 08:31:16 -07003074sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003075
3076sdk_dep_file := $(sdk_dir)/sdk_deps.mk
3077
3078ATREE_FILES :=
3079-include $(sdk_dep_file)
3080
3081# if we don't have a real list, then use "everything"
3082ifeq ($(strip $(ATREE_FILES)),)
3083ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003084 $(ALL_DEFAULT_INSTALLED_MODULES) \
3085 $(INSTALLED_RAMDISK_TARGET) \
3086 $(ALL_DOCS) \
3087 $(ALL_SDK_FILES)
3088endif
3089
3090atree_dir := development/build
3091
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01003092
The Android Open Source Project88b60792009-03-03 19:28:42 -08003093sdk_atree_files := \
3094 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07003095 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08003096
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02003097# development/build/sdk-android-<abi>.atree is used to differentiate
3098# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
3099# files like the kernel image. We use TARGET_CPU_ABI because we don't
3100# have a better way to distinguish between CPU models.
3101ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
3102 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
3103endif
3104
Griff Hazen433febb2014-02-28 08:45:59 -08003105ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
3106sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
3107else
3108sdk_atree_files += $(atree_dir)/sdk.atree
3109endif
3110
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003111include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07003112
The Android Open Source Project88b60792009-03-03 19:28:42 -08003113deps := \
3114 $(target_notice_file_txt) \
3115 $(tools_notice_file_txt) \
3116 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07003117 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07003118 $(COVERAGE_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07003119 $(INSTALLED_SYSTEMIMAGE) \
Bo Huf0d50bb2017-08-01 19:02:09 +00003120 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu18d18682017-08-14 14:52:20 -07003121 $(INSTALLED_QEMU_VENDORIMAGE) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07003122 $(INSTALLED_USERDATAIMAGE_TARGET) \
3123 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003124 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07003125 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003126 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08003127 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003128 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07003129 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003130 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003131
3132INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
3133$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
3134$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
3135$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
3136$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
3137
3138# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
3139#
3140#SDK_GNU_ERROR := true
3141
Ying Wang5d887702015-11-04 10:06:25 -08003142$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003143 @echo "Package SDK: $@"
3144 $(hide) rm -rf $(PRIVATE_DIR) $@
3145 $(hide) for f in $(target_gnu_MODULES); do \
3146 if [ -f $$f ]; then \
3147 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
3148 including GNU target $$f >&2; \
3149 FAIL=$(SDK_GNU_ERROR); \
3150 fi; \
3151 done; \
3152 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07003153 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08003154 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07003155 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003156 $(HOST_OUT_EXECUTABLES)/atree \
3157 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
3158 -m $(PRIVATE_DEP_FILE) \
3159 -I . \
3160 -I $(PRODUCT_OUT) \
3161 -I $(HOST_OUT) \
3162 -I $(TARGET_COMMON_OUT_ROOT) \
3163 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08003164 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08003165 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08003166 -v "TARGET_ARCH=$(TARGET_ARCH)" \
3167 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02003168 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07003169 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003170 -o $(PRIVATE_DIR) && \
3171 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07003172 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07003173 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003174 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08003175 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003176 chmod -R ug+rwX $(PRIVATE_DIR) && \
Dan Willemsen48a621c2015-10-29 16:33:05 -07003177 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003178 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
3179
Raphael3d224a02010-04-16 17:50:09 -07003180
3181# Is a Windows SDK requested? If so, we need some definitions from here
3182# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08003183MAIN_SDK_NAME := $(sdk_name)
3184MAIN_SDK_DIR := $(sdk_dir)
3185MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08003186ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07003187include $(TOPDIR)development/build/tools/windows_sdk.mk
3188endif
3189
The Android Open Source Project88b60792009-03-03 19:28:42 -08003190# -----------------------------------------------------------------
3191# Findbugs
3192INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
3193INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
3194$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
3195 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09003196 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08003197 > $@
3198$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
3199 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09003200 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07003201 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08003202
3203# -----------------------------------------------------------------
3204# Findbugs
3205
3206# -----------------------------------------------------------------
3207# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07003208ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003209include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01003210-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07003211-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07003212-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07003213# Also the project-specific tasks
3214-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
3215-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07003216-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07003217# Also add test specifc tasks
3218include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07003219include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07003220endif
Raphaelc4d47312011-02-15 16:09:36 -08003221
Ying Wang67132ba2015-10-28 16:42:39 -07003222include $(BUILD_SYSTEM)/product-graph.mk
3223
Raphaelc4d47312011-02-15 16:09:36 -08003224# -----------------------------------------------------------------
3225# Create SDK repository packages. Must be done after tasks/* since
3226# we need the addon rules defined.
3227ifneq ($(sdk_repo_goal),)
3228include $(TOPDIR)development/build/tools/sdk_repo.mk
3229endif