blob: d5f83736a51f8a1da7e226c2f1c30f9d11d2c242 [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 :=
34$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070035 $(eval _src := $(call word-colon,1,$(cf))) \
36 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang68864102011-09-29 13:23:25 -070037 $(call check-product-copy-files,$(cf)) \
Ying Wang193010c2011-12-16 11:54:25 -080038 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
39 $(info PRODUCT_COPY_FILES $(cf) ignored.), \
Ying Wang462d26b2010-11-02 21:31:47 -070040 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070041 $(if $(filter %.xml,$(_dest)),\
42 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
43 $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \
Ying Wang462d26b2010-11-02 21:31:47 -070044 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070045 $(eval unique_product_copy_files_destinations += $(_dest))))
Ying Wang619fccf2012-09-05 18:08:29 -070046unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070047unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080048
49# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -080050# Define rules to copy headers defined in copy_headers.mk
51# If more than one makefile declared a header, print a warning,
52# then copy the last one defined. This matches the previous make
53# behavior.
54$(foreach dest,$(ALL_COPIED_HEADERS), \
55 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
56 $(eval _src := $(word $(words $(_srcs)),$(_srcs))) \
57 $(if $(call streq,$(_src),$(_srcs)),, \
58 $(warning Duplicate header copy: $(dest)) \
59 $(warning Defined in: $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
60 $(eval $(call copy-one-header,$(_src),$(dest))))
61all_copied_headers: $(ALL_COPIED_HEADERS)
62
63# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -080064# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070065ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080066gen := $(OUT_DOCS)/index.html
67ALL_DOCS += $(gen)
68$(gen): frameworks/base/docs/docs-redirect-index.html
69 @mkdir -p $(dir $@)
70 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070071endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080072
73# -----------------------------------------------------------------
Jaekyun Seokfbc07f92017-03-03 12:40:21 +090074# property_overrides_split_enabled
75property_overrides_split_enabled :=
76ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
77 property_overrides_split_enabled := true
Jaekyun Seok8bee1202017-01-31 20:07:02 +090078endif
79
80# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -080081# default.prop
82INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
83ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +090084FINAL_DEFAULT_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070085 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
Jaekyun Seokfbc07f92017-03-03 12:40:21 +090086ifndef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +090087 FINAL_DEFAULT_PROPERTIES += \
88 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
89endif
Jaekyun Seok294286d2017-01-20 13:17:12 +090090FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
91 $(FINAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080092
Andres Moralesb8876e12015-05-06 20:44:22 -070093intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
94
95$(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -080096 @echo Target buildinfo: $@
97 @mkdir -p $(dir $@)
98 $(hide) echo "#" > $@; \
99 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
100 echo "#" >> $@;
Jaekyun Seok294286d2017-01-20 13:17:12 +0900101 $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700102 echo "$(line)" >> $@;)
Andres Moralesb8876e12015-05-06 20:44:22 -0700103 $(hide) echo "#" >> $@; \
104 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
105 echo "#" >> $@;
Dan Willemsen014719f2015-08-17 20:44:29 -0700106 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
107 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Cross73021682015-07-21 12:54:17 -0700108 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Andres Moralesb8876e12015-05-06 20:44:22 -0700109 $(hide) build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800110
111# -----------------------------------------------------------------
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900112# vendor default.prop
113INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900114ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900115INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
116ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
117
118FINAL_VENDOR_DEFAULT_PROPERTIES += \
119 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
120FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
121 $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
122
123$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
124 @echo Target buildinfo: $@
125 @mkdir -p $(dir $@)
126 $(hide) echo "#" > $@; \
127 echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
128 echo "#" >> $@;
129 $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
130 echo "$(line)" >> $@;)
131 $(hide) build/tools/post_process_props.py $@
132
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900133endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900134
135# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136# build.prop
137INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
138ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900139FINAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -0700140 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
Jaekyun Seok294286d2017-01-20 13:17:12 +0900141FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
142 $(FINAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800143
144# A list of arbitrary tags describing the build configuration.
145# Force ":=" so we can use +=
146BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
147ifeq ($(TARGET_BUILD_TYPE),debug)
148 BUILD_VERSION_TAGS += debug
149endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700150# The "test-keys" tag marks builds signed with the old test keys,
151# which are available in the SDK. "dev-keys" marks builds signed with
152# non-default dev keys (usually private keys from a vendor directory).
153# Both of these tags will be removed and replaced with "release-keys"
154# when the target-files is signed in a post-build step.
155ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700156BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700157else
Doug Zongkera8608a72013-07-23 11:51:04 -0700158BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700159endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700160BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800161BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
162
163# A human-readable string that descibes this build in detail.
Colin Crossf37b4552015-07-16 17:15:19 -0700164build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS)
Andres Moralesb8876e12015-05-06 20:44:22 -0700165$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800166
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700167# 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 -0800168ifeq (,$(strip $(BUILD_FINGERPRINT)))
Ying Wang50367cc2014-06-12 18:42:53 -0700169 ifneq ($(filter eng.%,$(BUILD_NUMBER)),)
170 # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed
171 # the Android system property length limit (PROPERTY_VALUE_MAX=92).
wei qiao6fa82b52015-12-01 14:20:55 +0800172 BF_BUILD_NUMBER := $(shell echo $${USER:0:6})$(shell $(DATE) +%m%d%H%M)
Ying Wang50367cc2014-06-12 18:42:53 -0700173 else
174 BF_BUILD_NUMBER := $(BUILD_NUMBER)
175 endif
176 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 -0800177endif
178ifneq ($(words $(BUILD_FINGERPRINT)),1)
179 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
180endif
181
Ying Wang06332732015-07-21 16:22:51 -0700182$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) > $(PRODUCT_OUT)/build_fingerprint.txt)
Colin Crossf37b4552015-07-16 17:15:19 -0700183BUILD_FINGERPRINT_FROM_FILE := $$(cat $(PRODUCT_OUT)/build_fingerprint.txt)
184
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700185# The string used to uniquely identify the system build; used by the OTA server.
186# This purposefully excludes any product-specific variables.
187ifeq (,$(strip $(BUILD_THUMBPRINT)))
188 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
189endif
190ifneq ($(words $(BUILD_THUMBPRINT)),1)
191 $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)")
192endif
193
Ying Wange24e17a2014-10-07 18:42:11 -0700194KNOWN_OEM_THUMBPRINT_PROPERTIES := \
195 ro.product.brand \
196 ro.product.name \
197 ro.product.device
198OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
199 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))
200
Sriram Raman7b641242009-03-24 22:40:59 -0700201# Display parameters shown under Settings -> About Phone
202ifeq ($(TARGET_BUILD_VARIANT),user)
203 # User builds should show:
204 # release build number or branch.buld_number non-release builds
205
206 # Dev. branches should have DISPLAY_BUILD_NUMBER set
Colin Cross63fe36a2017-02-21 17:23:02 -0800207 ifeq (true,$(DISPLAY_BUILD_NUMBER))
Colin Crossf37b4552015-07-16 17:15:19 -0700208 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700209 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700210 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700211 endif
212else
213 # Non-user builds should show detailed build information
214 BUILD_DISPLAY_ID := $(build_desc)
215endif
216
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000217# Accepts a whitespace separated list of product locales such as
218# (en_US en_AU en_GB...) and returns the first locale in the list with
219# underscores replaced with hyphens. In the example above, this will
220# return "en-US".
221define get-default-product-locale
222$(strip $(subst _,-, $(firstword $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800223endef
224
225BUILDINFO_SH := build/tools/buildinfo.sh
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900226VENDOR_BUILDINFO_SH := build/tools/vendor_buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700227
Ying Wang21ec03d2015-10-28 18:45:03 -0700228# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test harness to distinguish builds.
229TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
230ifdef SANITIZE_TARGET
231TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan
232endif
233
Andrew Boiefa61ff02012-09-28 09:33:45 -0700234ifdef TARGET_SYSTEM_PROP
235system_prop_file := $(TARGET_SYSTEM_PROP)
236else
237system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
238endif
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900239$(intermediate_system_build_prop): $(VENDOR_BUILDINFO_SH) $(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 -0800240 @echo Target buildinfo: $@
241 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700242 $(hide) echo > $@
243ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
244 $(hide) echo "#" >> $@; \
245 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700246 echo "#" >> $@;
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700247 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
248 echo "import /oem/oem.prop $(prop)" >> $@;)
249endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800250 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
Ying Wang21ec03d2015-10-28 18:45:03 -0700251 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800252 TARGET_DEVICE="$(TARGET_DEVICE)" \
253 PRODUCT_NAME="$(TARGET_PRODUCT)" \
254 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
Narayan Kamathbaf3eb92015-01-15 18:16:24 +0000255 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700256 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800257 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
258 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
259 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
260 BUILD_ID="$(BUILD_ID)" \
261 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
Dan Willemsenccc933e2015-08-11 15:25:12 -0700262 DATE="$(DATE_FROM_FILE)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700263 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
Daniel Rosenberg59156a62015-06-29 17:20:43 -0700264 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
Tao Bao532fdf42015-11-11 10:22:48 -0800265 AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800266 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
Dianne Hackborne593e5c2015-08-12 16:11:20 -0700267 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
268 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800269 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Adam Powellbdd5e8e2015-05-21 13:49:05 -0700270 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700271 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
Dianne Hackborn6ee3c432014-04-24 16:19:14 -0700272 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800273 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
Colin Crossf37b4552015-07-16 17:15:19 -0700274 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
Ying Wange24e17a2014-10-07 18:42:11 -0700275 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000276 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100277 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
278 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700279 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800280 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800281 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700282 bash $(BUILDINFO_SH) >> $@
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900283ifndef property_overrides_split_enabled
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900284 $(hide) TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
285 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
286 bash $(VENDOR_BUILDINFO_SH) >> $@
287endif
Johan Redestig674a27d2012-04-12 17:00:58 +0200288 $(hide) $(foreach file,$(system_prop_file), \
289 if [ -f "$(file)" ]; then \
290 echo "#" >> $@; \
291 echo Target buildinfo from: "$(file)"; \
292 echo "# from $(file)" >> $@; \
293 echo "#" >> $@; \
294 cat $(file) >> $@; \
295 fi;)
Jaekyun Seok294286d2017-01-20 13:17:12 +0900296 $(if $(FINAL_BUILD_PROPERTIES), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800297 $(hide) echo >> $@; \
298 echo "#" >> $@; \
299 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
300 echo "#" >> $@; )
Jaekyun Seok294286d2017-01-20 13:17:12 +0900301 $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700302 echo "$(line)" >> $@;)
Andres Morales085a0ce2015-02-06 10:12:55 -0800303 $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700304 $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800305
306build_desc :=
307
Andres Moralesb8876e12015-05-06 20:44:22 -0700308ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
309INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
310else
311INSTALLED_RECOVERYIMAGE_TARGET :=
312endif
313
314$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) $(INSTALLED_RECOVERYIMAGE_TARGET)
315 @echo "Target build info: $@"
316 $(hide) cat $(intermediate_system_build_prop) > $@
317ifdef INSTALLED_RECOVERYIMAGE_TARGET
318 $(hide) echo ro.expect.recovery_id=`cat $(RECOVERYIMAGE_ID_FILE)` >> $@
319endif
320
The Android Open Source Project88b60792009-03-03 19:28:42 -0800321# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700322# vendor build.prop
323#
Alex Naidis47e24e92016-01-10 14:18:54 +0000324# For verifying that the vendor build is what we think it is
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700325ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
326INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
327ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900328
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900329ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900330FINAL_VENDOR_BUILD_PROPERTIES += \
331 $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
332FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
333 $(FINAL_VENDOR_BUILD_PROPERTIES),=)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900334endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900335
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900336$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(VENDOR_BUILDINFO_SH)
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700337 @echo Target vendor buildinfo: $@
338 @mkdir -p $(dir $@)
339 $(hide) echo > $@
Dan Willemsenccc933e2015-08-11 15:25:12 -0700340 $(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
341 $(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
Colin Crossf37b4552015-07-16 17:15:19 -0700342 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900343ifdef property_overrides_split_enabled
Jaekyun Seok4e3fcca2017-02-27 13:12:07 +0900344 $(hide) TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
345 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
346 bash $(VENDOR_BUILDINFO_SH) >> $@
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900347 $(hide) echo "#" >> $@; \
348 echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
349 echo "#" >> $@;
350 $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
351 echo "$(line)" >> $@;)
352 $(hide) build/tools/post_process_props.py $@
Jaekyun Seokfbc07f92017-03-03 12:40:21 +0900353endif # property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +0900354endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700355
Andres Morales9c820f82015-01-13 15:30:34 -0800356# ----------------------------------------------------------------
Andres Morales9c820f82015-01-13 15:30:34 -0800357
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700358# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800359# sdk-build.prop
360#
361# There are certain things in build.prop that we don't want to
362# ship with the sdk; remove them.
363
364# This must be a list of entire property keys followed by
365# "=" characters, without any internal spaces.
366sdk_build_prop_remove := \
367 ro.build.user= \
368 ro.build.host= \
369 ro.product.brand= \
370 ro.product.manufacturer= \
371 ro.product.device=
372# TODO: Remove this soon-to-be obsolete property
373sdk_build_prop_remove += ro.build.product=
374INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
375$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
376 @echo SDK buildinfo: $@
377 @mkdir -p $(dir $@)
378 $(hide) grep -v "$(subst $(space),\|,$(strip \
379 $(sdk_build_prop_remove)))" $< > $@.tmp
380 $(hide) for x in $(sdk_build_prop_remove); do \
381 echo "$$x"generic >> $@.tmp; done
382 $(hide) mv $@.tmp $@
383
384# -----------------------------------------------------------------
385# package stats
386PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
387PACKAGES_TO_STAT := \
388 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
389 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
390$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
391 @echo Package stats: $@
392 @mkdir -p $(dir $@)
393 $(hide) rm -f $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700394ifeq ($(PACKAGES_TO_STAT),)
395# Create empty package stats file if target builds no jar(s) or apk(s).
396 $(hide) touch $@
397else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800398 $(hide) build/tools/dump-package-stats $^ > $@
Gaurav Shah67c2ed32015-08-23 09:40:05 -0700399endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800400
401.PHONY: package-stats
402package-stats: $(PACKAGE_STATS_FILE)
403
404# -----------------------------------------------------------------
405# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700406# Use a macro to add newline to each echo command
407define _apkcerts_echo_with_newline
408$(hide) echo $(1)
409
410endef
411
The Android Open Source Project88b60792009-03-03 19:28:42 -0800412name := $(TARGET_PRODUCT)
413ifeq ($(TARGET_BUILD_TYPE),debug)
414 name := $(name)_debug
415endif
416name := $(name)-apkcerts-$(FILE_NAME_TAG)
417intermediates := \
418 $(call intermediates-dir-for,PACKAGING,apkcerts)
419APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800420# We don't need to really build all the modules.
421# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700422$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800423 @echo APK certs list: $@
424 @mkdir -p $(dir $@)
425 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700426 $(foreach p,$(PACKAGES),\
427 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
428 $(call _apkcerts_echo_with_newline,\
429 'name="$(p).apk" certificate="EXTERNAL" \
430 private_key=""' >> $@),\
431 $(call _apkcerts_echo_with_newline,\
432 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
433 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
434 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700435 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800436
437.PHONY: apkcerts-list
438apkcerts-list: $(APKCERTS_FILE)
439
Ying Wang15e487a2011-02-15 10:56:18 -0800440ifneq (,$(TARGET_BUILD_APPS))
441 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
442endif
Ying Wangefb21682010-07-23 16:42:13 -0700443
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700445# build system stats
446BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
447$(BUILD_SYSTEM_STATS):
448 @rm -f $@
449 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
450 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
451$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700452
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700453# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700454# Modules ready to be converted to Soong, ordered by how many
455# modules depend on them.
456SOONG_CONV := $(sort $(SOONG_CONV))
457SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
458$(SOONG_CONV_DATA):
459 @rm -f $@
460 @$(foreach s,$(SOONG_CONV),echo "$(s),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS)))" >>$@;)
461
462SOONG_TO_CONVERT_SCRIPT := build/tools/soong_to_convert.py
463SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
464$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
465 @rm -f $@
466 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
467$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
468
469# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700470# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700471# for future OTA packages installed by this system. Actual product
472# deliverables will be re-signed by hand. We expect this file to
473# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700474DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700475
476
Jeff Browne33ba4c2011-07-11 22:11:46 -0700477# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800478# if they don't do anything.
479.PHONY: systemimage
480systemimage:
481
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800482# -----------------------------------------------------------------
483
484.PHONY: event-log-tags
485
Joe Onoratob7510532010-07-14 10:22:54 -0700486# Produce an event logs tag file for everything we know about, in order
487# to properly allocate numbers. Then produce a file that's filtered
488# for what's going to be installed.
489
490all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
491
Colin Crossdc8f8e42012-04-12 13:25:54 -0700492event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
493
Joe Onoratob7510532010-07-14 10:22:54 -0700494# Include tags from all packages that we know about
495all_event_log_tags_src := \
496 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
497
Colin Crossdc8f8e42012-04-12 13:25:54 -0700498# PDK builds will already have a full list of tags that needs to get merged
499# in with the ones from source
500pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
501
502$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900503$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700504 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900505 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700506
Doug Zongkera34fa952011-02-23 12:17:29 -0800507# Include tags from all packages included in this product, plus all
508# tags that are part of the system (ie, not in a vendor/ or device/
509# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800510event_log_tags_src := \
511 $(sort $(foreach m,\
512 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
513 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800514 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
515 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800516
Colin Crossdc8f8e42012-04-12 13:25:54 -0700517$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700518$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900519$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800520 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900521 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800522
523event-log-tags: $(event_log_tags_file)
524
525ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
526
Joe Onoratob7510532010-07-14 10:22:54 -0700527
The Android Open Source Project88b60792009-03-03 19:28:42 -0800528# #################################################################
529# Targets for boot/OS images
530# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800531ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
532 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
533 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
534 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
535 else
536 INSTALLED_2NDBOOTLOADER_TARGET :=
537 endif
538else
539 INSTALLED_BOOTLOADER_MODULE :=
540 INSTALLED_2NDBOOTLOADER_TARGET :=
541endif # TARGET_NO_BOOTLOADER
542ifneq ($(strip $(TARGET_NO_KERNEL)),true)
543 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
544else
545 INSTALLED_KERNEL_TARGET :=
546endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547
548# -----------------------------------------------------------------
549# the ramdisk
550INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800551 $(ALL_GENERATED_SOURCES) \
552 $(ALL_DEFAULT_INSTALLED_MODULES))
553
Joe Onorato64d85d02009-04-09 19:31:12 -0700554BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
555
556# We just build this directly to the install location.
557INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700558$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800559 $(call pretty,"Target ram disk: $@")
Thierry Strudel74a81e62015-07-09 09:54:55 -0700560 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800561
Ying Wangad7fd292013-08-08 16:34:29 -0700562.PHONY: ramdisk-nodeps
563ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
564 @echo "make $@: ignoring dependencies"
Thierry Strudel74a81e62015-07-09 09:54:55 -0700565 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800566
567ifneq ($(strip $(TARGET_NO_KERNEL)),true)
568
569# -----------------------------------------------------------------
570# the boot image, which is a collection of other images.
571INTERNAL_BOOTIMAGE_ARGS := \
572 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700573 --kernel $(INSTALLED_KERNEL_TARGET)
574
575ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
576INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
577endif
578
The Android Open Source Project88b60792009-03-03 19:28:42 -0800579INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
580
Dima Zavin1e0847c2009-05-07 19:43:08 -0700581ifdef BOARD_KERNEL_BASE
582 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
583endif
584
Ying Wangffff0022010-08-23 12:56:25 -0700585ifdef BOARD_KERNEL_PAGESIZE
586 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
587endif
588
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700589ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
590ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
591VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
592 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
593endif
594endif
595
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700596INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
597ifdef INTERNAL_KERNEL_CMDLINE
598INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700599endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700600
Sami Tolvanen3303d902016-03-15 16:49:30 +0000601INTERNAL_MKBOOTIMG_VERSION_ARGS := \
602 --os_version $(PLATFORM_VERSION) \
603 --os_patch_level $(PLATFORM_SECURITY_PATCH)
604
The Android Open Source Project88b60792009-03-03 19:28:42 -0800605INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
606
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800607# BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true.
608ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
609ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
610 $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.)
611endif
612endif
613
614# We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true.
615ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800616ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800617$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400618
619else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
620
621$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES)
622 $(call pretty,"Target boot image: $@")
623 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
624 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
625 $(hide) $(AVBTOOL) add_hash_footer \
626 --image $@ \
627 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
628 --partition_name boot $(INTERNAL_AVB_SIGNING_ARGS) \
629 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
630
631.PHONY: bootimage-nodeps
632bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL)
633 @echo "make $@: ignoring dependencies"
634 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
635 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
636 $(hide) $(AVBTOOL) add_hash_footer \
637 --image $@ \
638 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
639 --partition_name boot $(INTERNAL_AVB_SIGNING_ARGS) \
640 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
641
642else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700643
644$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
645 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000646 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800647 $(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 -0700648 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
649
650.PHONY: bootimage-nodeps
651bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
652 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000653 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Sami Tolvanen72d90eb2014-11-06 20:38:00 -0800654 $(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 -0700655 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
656
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100657else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800658
Tao Bao4b577412017-02-22 22:54:39 -0800659$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800660 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000661 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700662 $(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 -0800663 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
664
665.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800666bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800667 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000668 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700669 $(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 -0800670 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
671
672else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800673
674$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
675 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000676 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700677 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700678
679.PHONY: bootimage-nodeps
680bootimage-nodeps: $(MKBOOTIMG)
681 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000682 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700683 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700684
The Android Open Source Project88b60792009-03-03 19:28:42 -0800685endif # TARGET_BOOTIMAGE_USE_EXT2
Daniel Rosenbergd80bef22015-11-10 19:21:34 -0800686endif # BOARD_USES_RECOVERY_AS_BOOT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800687
688else # TARGET_NO_KERNEL
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700689INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800690# HACK: The top-level targets depend on the bootimage. Not all targets
691# can produce a bootimage, though, and emulator targets need the ramdisk
692# instead. Fake it out by calling the ramdisk the bootimage.
693# TODO: make the emulator use bootimages, and make mkbootimg accept
694# kernel-less inputs.
695INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
696endif
697
698# -----------------------------------------------------------------
699# NOTICE files
700#
Steve Blockd14d3b42012-03-01 11:34:41 +0000701# We are required to publish the licenses for all code under BSD, GPL and
702# Apache licenses (and possibly other more exotic ones as well). We err on the
703# side of caution, so the licenses for other third-party code are included here
704# too.
705#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800706# This needs to be before the systemimage rules, because it adds to
707# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
708# go into the systemimage.
709
Steve Block495e5852012-02-29 19:18:08 +0000710.PHONY: notice_files
711
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900712# Create the rule to combine the files into text and html/xml forms
713# $(1) - xml_excluded_vendor|xml_vendor|html
714# $(2) - Plain text output file
715# $(3) - HTML/XML output file
716# $(4) - File title
717# $(5) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800718# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900719# $(6) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800720#
721# The algorithm here is that we go collect a hash for each of the notice
722# files and write the names of the files that match that hash. Then
723# to generate the real files, we go print out all of the files and their
724# hashes.
725#
726# These rules are fairly complex, so they depend on this makefile so if
727# it changes, they'll run again.
728#
729# TODO: We could clean this up so that we just record the locations of the
730# original notice files instead of making rules to copy them somwehere.
731# Then we could traverse that without quite as much bash drama.
732define combine-notice-files
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900733$(2) $(3): PRIVATE_MESSAGE := $(4)
734$(2) $(3): PRIVATE_DIR := $(5)
735$(2) : $(3)
736$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
737 build/tools/generate-notice-files.py --text-output $(2) \
738 $(if $(filter $(1),xml_excluded_vendor),-e vendor --xml-output, \
739 $(if $(filter $(1),xml_vendor),-i vendor --xml-output, \
740 --html-output)) $(3) \
741 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
742notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800743endef
744
745# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
746# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
747# the src subdirectory.
748
Steve Block495e5852012-02-29 19:18:08 +0000749target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900750target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
751target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
752installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000753tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800754tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
755
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900756ifeq ($(PRODUCT_FULL_TREBLE),true)
757target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
758target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
759installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
760
761target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
762target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
763target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
764installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
765endif
766
Ying Wang62c81f82013-08-22 20:02:03 -0700767ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800768kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Josh Gao4d9268e2017-02-23 13:17:46 -0800769winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
Ying Wang4534d812012-04-09 17:04:12 -0700770pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800771
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900772ifdef target_vendor_notice_file_xml_gz
773$(eval $(call combine-notice-files, xml_excluded_vendor, \
Steve Block495e5852012-02-29 19:18:08 +0000774 $(target_notice_file_txt), \
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900775 $(target_notice_file_html_or_xml), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776 "Notices for files contained in the filesystem images in this directory:", \
777 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700778 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900779$(eval $(call combine-notice-files, xml_vendor, \
780 $(target_vendor_notice_file_txt), \
781 $(target_vendor_notice_file_xml), \
782 "Notices for files contained in the vendor filesystem image in this directory:", \
783 $(TARGET_OUT_NOTICE_FILES), \
784 $(target_notice_file_html_or_xml)))
785else
786$(eval $(call combine-notice-files, html, \
787 $(target_notice_file_txt), \
788 $(target_notice_file_html_or_xml), \
789 "Notices for files contained in the filesystem images in this directory:", \
790 $(TARGET_OUT_NOTICE_FILES), \
791 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
792endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800793
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900794$(eval $(call combine-notice-files, html, \
Steve Block495e5852012-02-29 19:18:08 +0000795 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800796 $(tools_notice_file_html), \
797 "Notices for files contained in the tools directory:", \
798 $(HOST_OUT_NOTICE_FILES), \
Josh Gao4d9268e2017-02-23 13:17:46 -0800799 $(ALL_DEFAULT_INSTALLED_MODULES) \
800 $(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800801
802# Install the html file at /system/etc/NOTICE.html.gz.
803# This is not ideal, but this is very late in the game, after a lot of
804# the module processing has already been done -- in fact, we used the
805# fact that all that has been done to get the list of modules that we
806# need notice files for.
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900807$(target_notice_file_html_or_xml_gz): $(target_notice_file_html_or_xml) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700808 $(hide) $(MINIGZIP) -9 < $< > $@
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900809$(installed_notice_html_or_xml_gz): $(target_notice_file_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800810 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700811
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900812ifdef target_vendor_notice_file_xml_gz
813# Install the vendor html file at /vendor/etc/NOTICE.xml.gz.
814$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
815 $(hide) $(MINIGZIP) -9 < $< > $@
816$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
817 $(copy-file-to-target)
818endif
819
Joe Onorato7b2845a2009-04-30 13:52:50 -0700820# if we've been run my mm, mmm, etc, don't reinstall this every time
821ifeq ($(ONE_SHOT_MAKEFILE),)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900822 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
823 ifdef target_vendor_notice_file_xml_gz
824 ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
825 endif
Joe Onorato7b2845a2009-04-30 13:52:50 -0700826endif
Ying Wang62c81f82013-08-22 20:02:03 -0700827endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800828
829# The kernel isn't really a module, so to get its module file in there, we
830# make the target NOTICE files depend on this particular file too, which will
831# then be in the right directory for the find in combine-notice-files to work.
832$(kernel_notice_file): \
Lee Campbellb463fcd2015-11-08 16:28:15 -0800833 $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800834 | $(ACP)
835 @echo Copying: $@
836 $(hide) mkdir -p $(dir $@)
837 $(hide) $(ACP) $< $@
838
Josh Gao4d9268e2017-02-23 13:17:46 -0800839$(winpthreads_notice_file): \
840 $(BUILD_SYSTEM)/WINPTHREADS_COPYING \
841 | $(ACP)
842 @echo Copying: $@
843 $(hide) mkdir -p $(dir $@)
844 $(hide) $(ACP) $< $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800845
Doug Zongker8678df42009-06-15 14:30:14 -0700846# -----------------------------------------------------------------
847# Build a keystore with the authorized keys in it, used to verify the
848# authenticity of downloaded OTA packages.
849#
850# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
851# before the rules that use that variable to build the image.
Dan Willemsenb589ae42015-10-29 21:26:18 +0000852ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
853$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Dan Willemsen48a621c2015-10-29 16:33:05 -0700854$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME)
Doug Zongker8678df42009-06-15 14:30:14 -0700855 $(hide) rm -f $@
856 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -0700857 $(hide) zip -qjX $@ $<
858 $(remove-timestamps-from-package)
Doug Zongker8678df42009-06-15 14:30:14 -0700859
Tao Bao38812d62016-01-20 20:58:20 -0800860# Carry the public key for update_engine if it's a non-Brillo target that
861# uses the AB updater. We use the same key as otacerts but in RSA public key
862# format.
863ifeq ($(AB_OTA_UPDATER),true)
864ifeq ($(BRILLO),)
Tao Bao23c3db92016-01-21 14:28:50 -0800865ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
866$(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Tao Bao38812d62016-01-20 20:58:20 -0800867 $(hide) rm -f $@
868 $(hide) mkdir -p $(dir $@)
869 $(hide) openssl x509 -pubkey -noout -in $< > $@
Alex Deymoc6ebe9f2016-08-03 20:52:54 -0700870
871ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem
872$(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem: $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem
873 $(hide) cp -f $< $@
Tao Bao38812d62016-01-20 20:58:20 -0800874endif
875endif
876
Doug Zongker8678df42009-06-15 14:30:14 -0700877.PHONY: otacerts
878otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
879
880
The Android Open Source Project88b60792009-03-03 19:28:42 -0800881# #################################################################
882# Targets for user images
883# #################################################################
884
Ying Wang933abf12010-06-16 14:31:34 -0700885INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800886ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700887INTERNAL_USERIMAGES_USE_EXT := true
888INTERNAL_USERIMAGES_EXT_VARIANT := ext2
889else
890ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
891INTERNAL_USERIMAGES_USE_EXT := true
892INTERNAL_USERIMAGES_EXT_VARIANT := ext3
893else
894ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
895INTERNAL_USERIMAGES_USE_EXT := true
896INTERNAL_USERIMAGES_EXT_VARIANT := ext4
897endif
898endif
899endif
900
JP Abgrall6ea5bd62014-10-22 20:01:22 -0700901# These options tell the recovery updater/installer how to mount the partitions writebale.
902# <fstype>=<fstype_opts>[|<fstype_opts>]...
903# fstype_opts := <opt>[,<opt>]...
904# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -0700905# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
906DEFAULT_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 -0700907
Ying Wang542903a2010-11-17 15:40:38 -0800908ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
909 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
910endif
911
Colin Cross0a7b2c52010-05-07 02:23:59 -0700912ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700913INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
914INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
915ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
916INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
917endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800918endif
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700919
Todd Poynorb2a555e2015-12-15 18:00:14 -0800920ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
921 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
922endif
Patrick Tjin426ec552016-02-09 14:12:47 -0800923ifneq ($(filter $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),)
Mohamad Ayyash353265b2015-06-24 15:42:19 -0700924INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -0800925endif
926
Ying Wang178ef922011-10-31 18:13:30 -0700927INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928
Colin Cross8a30f722014-04-28 16:27:32 -0700929ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
Colin Cross477cf2b2014-04-16 18:49:56 -0700930INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Sami Tolvanenf99b5312015-05-20 07:30:57 +0100931ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC))
932INTERNAL_USERIMAGES_DEPS += $(FEC)
933endif
Geremy Condrafd6f7512013-06-16 17:26:08 -0700934endif
935
Alex Klyubin092c9022017-03-13 13:28:34 -0700936SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800937INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
938
Mohamad Ayyashf8765552016-03-02 21:07:23 -0800939INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS)
940
Jiyong Park06241052017-03-10 21:29:47 +0900941INTERNAL_USERIMAGES_DEPS += \
942 $(ALL_MODULES.fs_config_dirs.INSTALLED) \
943 $(ALL_MODULES.fs_config_files.INSTALLED) \
944
Jin Qianabcec5e2017-03-10 16:53:45 -0800945ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
946INTERNAL_USERIMAGES_DEPS += $(MKE2FS_CONF)
947endif
948
Ying Wangbd93d422011-10-28 17:02:30 -0700949# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -0800950# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -0700951define generate-userimage-prop-dictionary
Vikram Dattu29e88b82016-12-16 09:45:19 +0100952$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Ying Wangbd93d422011-10-28 17:02:30 -0700953$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
954$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Mohamad Ayyash68946952015-03-03 12:30:37 -0800955$(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -0700956$(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 -0800957$(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
Tao Baoc7a6f1e2015-06-23 11:16:05 -0700958$(if $(BOARD_HAS_EXT4_RESERVED_BLOCKS),$(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(1))
Simon Wilsonf86e7ee2015-06-17 12:35:15 -0700959$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
960$(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 -0700961$(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 -0700962$(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 -0700963$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700964$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700965$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Connor O'Briene9ee68d2017-01-05 16:48:14 -0800966$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
967$(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 -0700968$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
969$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -0700970$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -0700971$(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 -0700972$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -0800973$(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
Patrick Tjine11aa502016-02-09 15:40:38 -0800974$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
975$(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 -0700976$(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 -0700977$(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 -0700978$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
Ying Wangb8888432014-03-11 17:13:27 -0700979$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangf3b86352014-11-18 18:03:13 -0800980$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
Patrick Tjinb59eca32016-10-20 10:58:12 -0700981$(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 -0700982$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -0800983$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800984$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100985$(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 -0700986$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
Paul Lawrencea37b2bb2014-11-13 17:54:30 -0800987$(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 +0200988$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
Sami Tolvanenf99b5312015-05-20 07:30:57 +0100989$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700990$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
991$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -0700992$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1))
993$(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 -0700994$(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 -0800995$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
Tao Baod95e9fd2015-03-29 23:07:41 -0700996$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
David Zeuthen52872ba2016-10-03 12:00:35 -0400997$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_signing_args=$(INTERNAL_AVB_SIGNING_ARGS)" >> $(1))
998$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(AVBTOOL)" >> $(1))
999$(if $(BOARD_AVB_ENABLE),$(hide) echo "system_avb_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1000$(if $(BOARD_AVB_ENABLE),$(hide) echo "system_avb_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
Bowgo Tsai3f0fd3d2017-03-31 15:21:26 +08001001$(if $(BOARD_AVB_ENABLE),$(hide) echo "vendor_avb_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1002$(if $(BOARD_AVB_ENABLE),$(hide) echo "vendor_avb_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001003$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1004 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001005$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
1006 $(hide) echo "system_root_image=true" >> $(1);\
1007 echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1))
Ying Wang6a42a252013-02-27 13:54:02 -08001008$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -07001009endef
1010
The Android Open Source Project88b60792009-03-03 19:28:42 -08001011# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001012# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001013
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001014# Recovery image exists if we are building recovery, or building recovery as boot.
1015ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Doug Zongker4647f122009-07-02 09:00:54 -07001016
Ying Wang37526142015-03-10 12:02:57 -07001017INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1018 $(ALL_DEFAULT_INSTALLED_MODULES))
1019
Doug Zongker4647f122009-07-02 09:00:54 -07001020recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001021recovery_sepolicy := \
1022 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
1023 $(TARGET_RECOVERY_ROOT_OUT)/file_contexts.bin \
1024 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
1025 $(TARGET_RECOVERY_ROOT_OUT)/nonplat_property_contexts
1026# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1027# SELinux files
1028IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1029
Doug Zongker4647f122009-07-02 09:00:54 -07001030recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1031recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001032recovery_build_props := $(intermediate_system_build_prop)
Jaekyun Seokfbc07f92017-03-03 12:40:21 +09001033ifdef property_overrides_split_enabled
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001034recovery_build_props += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
1035endif
Doug Zongker4647f122009-07-02 09:00:54 -07001036recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -08001037
Doug Zongker8eaeea92014-05-12 15:32:20 -07001038# Set recovery_density to the density bucket of the device.
1039recovery_density := unknown
1040ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
1041# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
1042recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
Doug Zongker25d55f82014-04-04 13:51:15 -07001043else
Adam Lesinski83ee6d72014-12-02 16:13:09 -08001044# Otherwise, use the default medium density.
1045recovery_densities := mdpi
Doug Zongker8eaeea92014-05-12 15:32:20 -07001046endif
1047
1048ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1049recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1050else
Doug Zongker25d55f82014-04-04 13:51:15 -07001051recovery_resources_common := $(recovery_resources_common)-xhdpi
1052endif
1053
Doug Zongker8eaeea92014-05-12 15:32:20 -07001054# Select the 18x32 font on high-density devices (xhdpi and up); and
1055# the 12x22 font on other devices. Note that the font selected here
1056# can be overridden for a particular device by putting a font.png in
1057# its private recovery resources.
1058
Tao Baoabbc9112015-04-08 14:14:43 -07001059ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -08001060recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
1061else
1062recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
1063endif
1064
Ying Wang9a175682015-08-06 11:47:47 -07001065ifndef TARGET_PRIVATE_RES_DIRS
1066TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1067endif
Doug Zongker4647f122009-07-02 09:00:54 -07001068recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001069 $(TARGET_PRIVATE_RES_DIRS) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -07001070ifdef TARGET_RECOVERY_FSTAB
1071recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1072else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001073recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001074endif
Tao Baoc3c17532016-06-10 10:11:54 -07001075ifdef TARGET_RECOVERY_WIPE
1076recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001077else
Tao Baoc3c17532016-06-10 10:11:54 -07001078recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001079endif
Tao Bao8beab692015-07-22 12:33:18 -07001080
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001081# Prior to A/B update, we used to have:
1082# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
1083# recovery-resource.dat is needed only if we carry a patch of the boot and
1084# recovery images and invoke install-recovery.sh on the first boot post an
1085# OTA update.
1086#
1087# We no longer need that if one of the following conditions holds:
1088# a) We carry a full copy of the recovery image
1089# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
1090# b) We build a single image that contains boot and recovery both
1091# (BOARD_USES_RECOVERY_AS_BOOT = true).
1092
1093ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07001094# Named '.dat' so we don't attempt to use imgdiff for patching it.
1095RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Tao Bao8beab692015-07-22 12:33:18 -07001096else
Tao Bao8beab692015-07-22 12:33:18 -07001097RECOVERY_RESOURCE_ZIP :=
1098endif
Doug Zongker4647f122009-07-02 09:00:54 -07001099
Ying Wang9a175682015-08-06 11:47:47 -07001100ifeq ($(TARGET_PRIVATE_RES_DIRS),)
Doug Zongker4647f122009-07-02 09:00:54 -07001101 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
1102endif
1103
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001104ifeq ($(recovery_fstab),)
1105 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
1106endif
1107
Doug Zongker4647f122009-07-02 09:00:54 -07001108INTERNAL_RECOVERYIMAGE_ARGS := \
1109 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
1110 --kernel $(recovery_kernel) \
1111 --ramdisk $(recovery_ramdisk)
1112
1113# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001114ifdef INTERNAL_KERNEL_CMDLINE
1115 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001116endif
1117ifdef BOARD_KERNEL_BASE
1118 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1119endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001120ifdef BOARD_KERNEL_PAGESIZE
1121 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1122endif
Doug Zongker4647f122009-07-02 09:00:54 -07001123
1124# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -07001125# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -07001126# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -07001127OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -07001128
1129# Generate a file containing the keys that will be read by the
1130# recovery binary.
1131RECOVERY_INSTALL_OTA_KEYS := \
1132 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
1133DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
1134$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -07001135$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -08001136$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
1137 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -07001138 @rm -rf $@
1139 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -08001140 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -07001141
Andres Moralesb8876e12015-05-06 20:44:22 -07001142RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id
Howard Chen1756f8d2017-02-22 17:27:10 +08001143
1144# $(1): modules list
1145# $(2): output dir
1146# $(3): mount point
1147# $(4): staging dir
1148# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
1149define build-image-kernel-modules
1150 $(hide) rm -rf $(2)/lib/modules
1151 $(hide) mkdir -p $(2)/lib/modules
1152 $(hide) cp $(1) $(2)/lib/modules/
1153 $(hide) rm -rf $(4)
1154 $(hide) mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules
1155 $(hide) cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules
1156 $(hide) $(DEPMOD) -b $(4) 0.0
Steve Muckleb74e0b92017-03-24 10:42:59 -07001157 $(hide) sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' -i $(4)/lib/modules/0.0/modules.dep
Howard Chen1756f8d2017-02-22 17:27:10 +08001158 $(hide) cp $(4)/lib/modules/0.0/modules.dep $(2)/lib/modules
1159endef
1160
Ying Wang747b9f12015-01-30 14:05:22 -08001161# $(1): output file
1162define build-recoveryimage-target
1163 @echo ----- Making recovery image ------
Ying Wang747b9f12015-01-30 14:05:22 -08001164 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
Tao Bao3f56a332016-01-12 11:34:58 -08001165 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
Ying Wang747b9f12015-01-30 14:05:22 -08001166 @echo Copying baseline ramdisk...
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001167 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1168 $(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Ying Wang747b9f12015-01-30 14:05:22 -08001169 @echo Modifying ramdisk contents...
Howard Chen1756f8d2017-02-22 17:27:10 +08001170 $(if $(BOARD_RECOVERY_KERNEL_MODULES), \
1171 $(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery)))
Ying Wang747b9f12015-01-30 14:05:22 -08001172 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
1173 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
Ying Wang36b039a2015-04-02 12:48:32 -07001174 $(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 -08001175 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1176 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1177 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1178 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Ying Wang9a175682015-08-06 11:47:47 -07001179 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1180 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
Ying Wang747b9f12015-01-30 14:05:22 -08001181 $(hide) $(foreach item,$(recovery_fstab), \
1182 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Tao Baoc3c17532016-06-10 10:11:54 -07001183 $(if $(strip $(recovery_wipe)), \
1184 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe)
Ying Wang747b9f12015-01-30 14:05:22 -08001185 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001186 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) \
Ying Wang747b9f12015-01-30 14:05:22 -08001187 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001188 $(if $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET), \
1189 $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1190 >> $(TARGET_RECOVERY_ROOT_OUT)/default.prop)
1191 $(hide) cat $(recovery_build_props) \
1192 >> $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Andriy Naborskyy53105572016-07-22 11:03:31 -07001193 $(BOARD_RECOVERY_IMAGE_PREPARE)
Tao Baobe46a542015-07-30 14:34:01 -07001194 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \
1195 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \
1196 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/system; \
1197 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 -07001198 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
Tao Baod95e9fd2015-03-29 23:07:41 -07001199 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001200 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
1201 $(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 +01001202 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001203 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1204 $(BOOT_SIGNER) /boot $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1205 $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
1206 )\
1207 )
Tao Baod95e9fd2015-03-29 23:07:41 -07001208 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
Furquan Shaikhe8c21222015-08-07 11:58:05 -07001209 $(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))
David Zeuthenb76f8a42016-10-06 15:02:48 -04001210 $(if $(and $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),$(filter true,$(BOARD_AVB_ENABLE))), \
1211 $(hide) $(AVBTOOL) add_hash_footer \
1212 --image $(1) \
1213 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
1214 --partition_name boot $(INTERNAL_AVB_SIGNING_ARGS) \
1215 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS))
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001216 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001217 $(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \
1218 $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
Ying Wang747b9f12015-01-30 14:05:22 -08001219 @echo ----- Made recovery image: $(1) --------
1220endef
1221
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001222ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Ying Wangbd07ad02016-03-10 12:57:33 -08001223ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER))
1224$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER)
1225endif
1226ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1227$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER)
1228endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001229$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
1230 $(INSTALLED_RAMDISK_TARGET) \
1231 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001232 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001233 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001234 $(recovery_build_props) $(recovery_resource_deps) \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001235 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001236 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001237 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1238 $(BOARD_RECOVERY_KERNEL_MODULES) \
1239 $(DEPMOD)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001240 $(call pretty,"Target boot image from recovery: $@")
1241 $(call build-recoveryimage-target, $@)
1242endif
1243
Doug Zongker4647f122009-07-02 09:00:54 -07001244$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
1245 $(INSTALLED_RAMDISK_TARGET) \
1246 $(INSTALLED_BOOTIMAGE_TARGET) \
Ying Wang37526142015-03-10 12:02:57 -07001247 $(INTERNAL_RECOVERYIMAGE_FILES) \
Daniel Cashmandf1e2102016-12-17 00:53:52 +00001248 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Doug Zongker4647f122009-07-02 09:00:54 -07001249 $(INSTALLED_2NDBOOTLOADER_TARGET) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001250 $(recovery_build_props) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001251 $(recovery_fstab) \
Jaekyun Seok8bee1202017-01-31 20:07:02 +09001252 $(RECOVERY_INSTALL_OTA_KEYS) \
Howard Chen1756f8d2017-02-22 17:27:10 +08001253 $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
1254 $(BOARD_RECOVERY_KERNEL_MODULES) \
1255 $(DEPMOD)
Ying Wang747b9f12015-01-30 14:05:22 -08001256 $(call build-recoveryimage-target, $@)
Doug Zongker4647f122009-07-02 09:00:54 -07001257
Tao Bao4594d0e2015-12-22 09:47:46 -08001258ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001259$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001260 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001261 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1262 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001263endif
Doug Zongker56588872012-08-20 15:38:58 -07001264
Ying Wang747b9f12015-01-30 14:05:22 -08001265.PHONY: recoveryimage-nodeps
1266recoveryimage-nodeps:
1267 @echo "make $@: ignoring dependencies"
1268 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1269
Tao Bao8beab692015-07-22 12:33:18 -07001270else # INSTALLED_RECOVERYIMAGE_TARGET not defined
Doug Zongker56588872012-08-20 15:38:58 -07001271RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -07001272endif
1273
1274.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001275recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001276
Elliott Hughes65d41862015-02-04 19:58:09 -08001277ifeq ($(BOARD_NAND_PAGE_SIZE),)
Lars Svensson9cb8c282010-12-06 15:24:58 +01001278BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -08001279endif
1280
Elliott Hughes65d41862015-02-04 19:58:09 -08001281ifeq ($(BOARD_NAND_SPARE_SIZE),)
Lars Svensson9cb8c282010-12-06 15:24:58 +01001282BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -07001283endif
1284
Doug Zongker4647f122009-07-02 09:00:54 -07001285# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07001286# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08001287#
Ying Wang9c649a72012-08-08 15:27:00 -07001288# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
1289PDK_FUSION_SYSIMG_FILES := \
1290 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
1291 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001292
1293INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07001294 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07001295 $(ALL_DEFAULT_INSTALLED_MODULES) \
1296 $(PDK_FUSION_SYSIMG_FILES) \
1297 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -07001298
Mohamad Ayyash68946952015-03-03 12:30:37 -08001299
Ying Wang82cceba2012-08-13 15:03:00 -07001300FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampea92434f2017-03-24 16:06:31 -07001301
1302# ASAN libraries in the system image - add dependency.
1303ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
1304ifneq (,$(SANITIZE_TARGET))
1305 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
1306 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
1307 endif
1308endif
1309
Ying Wange5e8c5f2011-09-09 16:35:53 -07001310# -----------------------------------------------------------------
1311# installed file list
1312# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
1313# We put installed-files.txt ahead of image itself in the dependency graph
1314# so that we can get the size stat even if the build fails due to too large
1315# system image.
1316INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Makoto Onuki517d32d2017-03-16 09:41:19 -07001317$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001318 @echo Installed file list: $@
1319 @mkdir -p $(dir $@)
1320 @rm -f $@
Makoto Onuki517d32d2017-03-16 09:41:19 -07001321 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Sasha Levitskiy83561d12016-10-10 22:48:10 -07001322 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07001323
1324.PHONY: installed-file-list
1325installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08001326
1327$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07001328
1329systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001330 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07001331BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
1332
Ying Wang23898df2014-06-18 20:26:24 -07001333# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07001334ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07001335define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07001336$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
1337 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
1338 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
1339 exit 1; \
1340fi
Ying Wang23898df2014-06-18 20:26:24 -07001341$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
1342endef
1343else
1344define create-system-vendor-symlink
1345endef
1346endif
1347
The Android Open Source Project88b60792009-03-03 19:28:42 -08001348# $(1): output file
1349define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07001350 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07001351 $(call create-system-vendor-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07001352 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -07001353 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07001354 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001355 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1356 ./build/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001357 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
Ying Wang45ff36e2014-08-13 12:36:05 -07001358 || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\
1359 du -sm $(TARGET_OUT) 1>&2;\
Tao Baoc7a6f1e2015-06-23 11:16:05 -07001360 if [ "$(INTERNAL_USERIMAGES_EXT_VARIANT)" == "ext4" ]; then \
1361 maxsize=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE); \
1362 if [ "$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" == "true" ]; then \
1363 maxsize=$$((maxsize - 4096 * 4096)); \
1364 fi; \
1365 echo "The max is $$(( maxsize / 1048576 )) MB." 1>&2 ;\
1366 else \
1367 echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\
1368 fi; \
Ying Wangebe63fb2014-08-19 12:21:35 -07001369 mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
Ying Wang45ff36e2014-08-13 12:36:05 -07001370 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08001371endef
1372
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001373$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001374 $(call build-systemimage-target,$@)
1375
The Android Open Source Project88b60792009-03-03 19:28:42 -08001376INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07001377SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001378
Doug Zongker73ef8252009-07-23 15:12:53 -07001379# The system partition needs room for the recovery image as well. We
1380# now store the recovery image as a binary patch using the boot image
1381# as the source (since they are very similar). Generate the patch so
1382# we can see how big it's going to be, and include that in the system
1383# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -07001384ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07001385ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Doug Zongker73ef8252009-07-23 15:12:53 -07001386intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
1387RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
1388$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
1389 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -07001390 $(HOST_OUT_EXECUTABLES)/imgdiff \
1391 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -07001392 @echo "Construct recovery from boot"
1393 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -07001394 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07001395else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
1396RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
1397endif
Sriram Raman1e96ac82009-07-24 13:52:32 -07001398endif
1399
Doug Zongker73ef8252009-07-23 15:12:53 -07001400
Dan Willemsen7f016152016-02-29 17:52:39 -08001401$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001402 @echo "Install system fs image: $@"
1403 $(copy-file-to-target)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001404 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001405
1406systemimage: $(INSTALLED_SYSTEMIMAGE)
1407
1408.PHONY: systemimage-nodeps snod
1409systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07001410 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001411 @echo "make $@: ignoring dependencies"
1412 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001413 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001414
Ying Wangacf01ec2012-02-24 11:05:48 -08001415ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
1416ifeq (true,$(WITH_DEXPREOPT))
1417$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
1418endif
1419endif
1420
The Android Open Source Project88b60792009-03-03 19:28:42 -08001421#######
1422## system tarball
1423define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -07001424 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
1425 $(call create-system-vendor-symlink)
1426 $(MKTARBALL) $(FS_GET_STATS) \
1427 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001428 $(INSTALLED_SYSTEMTARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001429endef
1430
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001431ifndef SYSTEM_TARBALL_FORMAT
1432 SYSTEM_TARBALL_FORMAT := bz2
1433endif
1434
The Android Open Source Project88b60792009-03-03 19:28:42 -08001435system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001436INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001437$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
1438$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
1439 $(build-systemtarball-target)
1440
1441.PHONY: systemtarball-nodeps
1442systemtarball-nodeps: $(FS_GET_STATS) \
1443 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
1444 $(build-systemtarball-target)
1445
1446.PHONY: stnod
1447stnod: systemtarball-nodeps
1448
Ying Wang3a61eeb2016-03-11 10:32:01 -08001449# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07001450## platform.zip: system, plus other files to be used in PDK fusion build,
1451## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07001452##
1453## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
1454## The variable will be typically set from BoardConfig.mk.
1455## Files under out dir will be rejected to prevent possible conflicts with other rules.
Ying Wang3a61eeb2016-03-11 10:32:01 -08001456pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
1457 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
1458pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
1459 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
1460pdk_classes_dex := $(strip \
1461 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
1462 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk))
1463
1464pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
1465$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
1466$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
1467$(pdk_odex_config_mk) :
1468 @echo "PDK odex config makefile: $@"
1469 $(hide) mkdir -p $(dir $@)
1470 $(hide) echo "# Auto-generated. Do not modify." > $@
1471 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
1472 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
1473 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
1474 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
1475 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
1476 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
1477 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
1478 )
1479 $(foreach m,$(PRIVATE_APPS),\
1480 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\
1481 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
1482 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
1483 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
1484 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07001485 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08001486 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
1487 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
1488 )
1489
keunyoungc0178062013-07-22 14:54:58 -07001490PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07001491INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08001492
1493$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
1494$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
1495$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk)
Keun young Park816b9fd2012-05-16 10:32:41 -07001496 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07001497 $(hide) rm -f $@
Dan Willemsen48a621c2015-10-29 16:33:05 -07001498 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wang4534d812012-04-09 17:04:12 -07001499 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07001500 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
1501 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Ying Wangcff38622014-07-16 17:46:35 -07001502ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
Dan Willemsen48a621c2015-10-29 16:33:05 -07001503 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
Ying Wangcff38622014-07-16 17:46:35 -07001504 $(TARGET_COPY_OUT_VENDOR)
1505endif
Colin Crossc451a372013-12-18 19:36:44 -08001506ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001507 $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07001508endif
keunyoungc0178062013-07-22 14:54:58 -07001509ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001510 $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
keunyoungc0178062013-07-22 14:54:58 -07001511endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08001512 @# Add dex-preopt files and config.
1513 $(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES)))
1514 $(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG)
Ying Wang4c289e52012-03-30 13:52:54 -07001515
1516.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07001517platform: $(INSTALLED_PLATFORM_ZIP)
1518
1519.PHONY: platform-java
1520platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07001521
1522# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07001523ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
1524$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07001525endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001526
Ying Wang3a61eeb2016-03-11 10:32:01 -08001527# -----------------------------------------------------------------
Bruce Beare52aac202010-06-04 15:24:49 -07001528## boot tarball
1529define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07001530 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07001531 $(hide) mkdir -p $(PRODUCT_OUT)/boot
1532 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001533 $(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
Bruce Beare52aac202010-06-04 15:24:49 -07001534 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
1535 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001536 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
Bruce Beare52aac202010-06-04 15:24:49 -07001537endef
1538
1539ifndef BOOT_TARBALL_FORMAT
1540 BOOT_TARBALL_FORMAT := bz2
1541endif
1542
1543boot_tar := $(PRODUCT_OUT)/boot.tar
1544INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
1545$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
1546$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
1547 $(build-boottarball-target)
1548
1549.PHONY: boottarball-nodeps btnod
1550boottarball-nodeps btnod: $(FS_GET_STATS) \
1551 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
1552 $(build-boottarball-target)
1553
1554
The Android Open Source Project88b60792009-03-03 19:28:42 -08001555# -----------------------------------------------------------------
1556# data partition image
1557INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001558 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001559
Ying Wangd7321d32013-03-15 10:32:29 -07001560# Don't build userdata.img if it's extfs but no partition size
1561skip_userdata.img :=
1562ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1563ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1564skip_userdata.img := true
1565endif
1566endif
1567
1568ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001569userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001570 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001571BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1572
Ying Wangbd93d422011-10-28 17:02:30 -07001573define build-userdataimage-target
1574 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1575 @mkdir -p $(TARGET_OUT_DATA)
1576 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001577 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001578 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1579 ./build/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001580 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001581 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07001582endef
1583
Joe Onorato64d85d02009-04-09 19:31:12 -07001584# We just build this directly to the install location.
1585INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampea92434f2017-03-24 16:06:31 -07001586INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
1587 $(INTERNAL_USERIMAGES_DEPS) \
1588 $(INTERNAL_USERDATAIMAGE_FILES) \
1589 $(BUILD_IMAGE_SRCS)
1590$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001591 $(build-userdataimage-target)
1592
1593.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001594userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001595 $(build-userdataimage-target)
1596
Ying Wangd7321d32013-03-15 10:32:29 -07001597endif # not skip_userdata.img
1598skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001599
Andreas Gampea92434f2017-03-24 16:06:31 -07001600# ASAN libraries in the system image - build rule.
1601ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
1602 $(TARGET_OUT_SHARED_LIBRARIES) \
1603 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
1604 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
1605 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampee5339ae2017-03-30 16:54:23 -07001606# Extra options: Enforce the system user for the files to avoid having to change ownership.
1607ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampea92434f2017-03-24 16:06:31 -07001608# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
1609# enough space.
1610$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampee5339ae2017-03-30 16:54:23 -07001611 tar cfj $(ASAN_IN_SYSTEM_INSTALLED) $(ASAN_SYSTEM_INSTALL_OPTIONS) -C $(TARGET_OUT_DATA)/.. $(ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL) >/dev/null
Andreas Gampea92434f2017-03-24 16:06:31 -07001612
The Android Open Source Project88b60792009-03-03 19:28:42 -08001613#######
1614## data partition tarball
1615define build-userdatatarball-target
1616 $(call pretty,"Target userdata fs tarball: " \
1617 "$(INSTALLED_USERDATATARBALL_TARGET)")
1618 $(MKTARBALL) $(FS_GET_STATS) \
1619 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001620 $(INSTALLED_USERDATATARBALL_TARGET) $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001621endef
1622
1623userdata_tar := $(PRODUCT_OUT)/userdata.tar
1624INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1625$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1626$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1627 $(build-userdatatarball-target)
1628
Dan Willemsen69af2e42016-08-16 16:36:05 -07001629$(call dist-for-goals,userdatatarball,$(INSTALLED_USERDATATARBALL_TARGET))
1630
The Android Open Source Project88b60792009-03-03 19:28:42 -08001631.PHONY: userdatatarball-nodeps
1632userdatatarball-nodeps: $(FS_GET_STATS)
1633 $(build-userdatatarball-target)
1634
1635
The Android Open Source Project88b60792009-03-03 19:28:42 -08001636# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04001637# partition table image
1638ifdef BOARD_BPT_INPUT_FILES
1639
1640BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001641BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04001642
1643INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
1644 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001645 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04001646 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
1647
1648ifdef BOARD_BPT_DISK_SIZE
1649INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
1650endif
1651
1652define build-bptimage-target
1653 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
1654 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
1655endef
1656
1657INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07001658$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
1659 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
1660
David Zeuthen25328622016-04-08 15:08:03 -04001661$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
1662 $(build-bptimage-target)
1663
1664.PHONY: bptimage-nodeps
1665bptimage-nodeps:
1666 $(build-bptimage-target)
1667
1668endif # BOARD_BPT_INPUT_FILES
1669
1670# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001671# cache partition image
1672ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1673INTERNAL_CACHEIMAGE_FILES := \
1674 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1675
1676cacheimage_intermediates := \
1677 $(call intermediates-dir-for,PACKAGING,cache)
1678BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1679
1680define build-cacheimage-target
1681 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1682 @mkdir -p $(TARGET_OUT_CACHE)
1683 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001684 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001685 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1686 ./build/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001687 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001688 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001689endef
1690
1691# We just build this directly to the install location.
1692INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Shinichiro Hamaji3deb87d2016-04-19 18:41:27 +09001693$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) $(BUILD_IMAGE_SRCS)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001694 $(build-cacheimage-target)
1695
1696.PHONY: cacheimage-nodeps
1697cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1698 $(build-cacheimage-target)
1699
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07001700else # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1701# we need to ignore the broken cache link when doing the rsync
1702IGNORE_CACHE_LINK := --exclude=cache
Ying Wang9f8e8db2011-11-04 11:37:01 -07001703endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1704
David Zeuthen0eb10972016-09-28 17:55:27 -04001705# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07001706# system_other partition image
1707ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
1708BOARD_USES_SYSTEM_OTHER := true
1709
1710# Marker file to identify that odex files are installed
1711INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
1712ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
1713$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
1714 $(hide) touch $@
1715endif
1716
1717ifdef BOARD_USES_SYSTEM_OTHER
1718INTERNAL_SYSTEMOTHERIMAGE_FILES := \
1719 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
1720 $(ALL_DEFAULT_INSTALLED_MODULES)\
1721 $(ALL_PDK_FUSION_FILES))
1722
1723INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Makoto Onuki517d32d2017-03-16 09:41:19 -07001724$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST)
Alex Light4e358ab2016-06-16 14:47:10 -07001725 @echo Installed file list: $@
1726 @mkdir -p $(dir $@)
1727 @rm -f $@
Makoto Onuki517d32d2017-03-16 09:41:19 -07001728 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Sasha Levitskiy83561d12016-10-10 22:48:10 -07001729 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07001730
1731systemotherimage_intermediates := \
1732 $(call intermediates-dir-for,PACKAGING,system_other)
1733BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
1734
1735# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
1736define build-systemotherimage-target
1737 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
1738 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
1739 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
1740 $(call generate-userimage-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt, skip_fsck=true)
1741 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1742 ./build/tools/releasetools/build_image.py \
1743 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
1744 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
1745endef
1746
1747# We just build this directly to the install location.
1748INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
1749$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
1750 $(build-systemotherimage-target)
1751
1752.PHONY: systemotherimage-nodeps
1753systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1754 $(build-systemotherimage-target)
1755
1756endif # BOARD_USES_SYSTEM_OTHER
1757
1758
1759# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07001760# vendor partition image
1761ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1762INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07001763 $(filter $(TARGET_OUT_VENDOR)/%,\
1764 $(ALL_DEFAULT_INSTALLED_MODULES)\
1765 $(ALL_PDK_FUSION_FILES))
1766
1767# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
1768$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07001769
Ying Wang8da19e32015-09-15 14:22:12 -07001770INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Makoto Onuki517d32d2017-03-16 09:41:19 -07001771$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST)
Ying Wang8da19e32015-09-15 14:22:12 -07001772 @echo Installed file list: $@
1773 @mkdir -p $(dir $@)
1774 @rm -f $@
Makoto Onuki517d32d2017-03-16 09:41:19 -07001775 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Sasha Levitskiy83561d12016-10-10 22:48:10 -07001776 $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07001777
Ying Wanga0febe52013-03-20 11:02:05 -07001778vendorimage_intermediates := \
1779 $(call intermediates-dir-for,PACKAGING,vendor)
1780BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07001781define build-vendorimage-target
1782 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1783 @mkdir -p $(TARGET_OUT_VENDOR)
1784 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1785 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
Howard Chen1756f8d2017-02-22 17:27:10 +08001786 $(if $(BOARD_VENDOR_KERNEL_MODULES), \
1787 $(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 -07001788 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1789 ./build/tools/releasetools/build_image.py \
Thierry Strudel74a81e62015-07-09 09:54:55 -07001790 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001791 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07001792endef
1793
1794# We just build this directly to the install location.
1795INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Howard Chen1756f8d2017-02-22 17:27:10 +08001796$(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 -07001797 $(build-vendorimage-target)
1798
Steven Morelanda2e734d2017-03-07 12:10:09 -08001799.PHONY: vendorimage-nodeps vnod
1800vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD)
Ying Wanga0febe52013-03-20 11:02:05 -07001801 $(build-vendorimage-target)
1802
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07001803else ifdef BOARD_PREBUILT_VENDORIMAGE
1804INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1805$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
1806endif
Ying Wanga0febe52013-03-20 11:02:05 -07001807
Ying Wang9f8e8db2011-11-04 11:37:01 -07001808# -----------------------------------------------------------------
Bowgo Tsai3f0fd3d2017-03-31 15:21:26 +08001809# vbmeta image
1810ifeq ($(BOARD_AVB_ENABLE),true)
1811
1812BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
1813
1814INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS := \
1815 --include_descriptors_from_image $(INSTALLED_BOOTIMAGE_TARGET) \
1816 --include_descriptors_from_image $(INSTALLED_SYSTEMIMAGE) \
Bowgo Tsai3f0fd3d2017-03-31 15:21:26 +08001817
1818ifdef INSTALLED_VENDORIMAGE_TARGET
1819INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
1820 --include_descriptors_from_image $(INSTALLED_VENDORIMAGE_TARGET)
1821endif
1822
Bowgo Tsai16ba5632017-04-14 18:50:11 +08001823ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1824INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += --setup_rootfs_from_kernel $(BUILT_SYSTEMIMAGE)
1825endif
1826
Bowgo Tsai3f0fd3d2017-03-31 15:21:26 +08001827ifdef BOARD_AVB_ROLLBACK_INDEX
1828INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
1829endif
1830
1831ifndef BOARD_AVB_KEY_PATH
1832# If key path isn't specified, use the 4096-bit test key.
1833INTERNAL_AVB_SIGNING_ARGS := \
1834 --algorithm SHA256_RSA4096 \
1835 --key external/avb/test/data/testkey_rsa4096.pem
1836else
1837INTERNAL_AVB_SIGNING_ARGS := \
1838 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
1839endif
1840
1841ifndef BOARD_BOOTIMAGE_PARTITION_SIZE
1842 $(error BOARD_BOOTIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
1843endif
1844
1845ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1846 $(error BOARD_SYSTEMIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
1847endif
1848
1849define build-vbmetaimage-target
1850 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
1851 $(hide) $(AVBTOOL) make_vbmeta_image \
1852 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
1853 $(INTERNAL_AVB_SIGNING_ARGS) \
1854 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
1855 --output $@
1856endef
1857
1858INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
1859$(INSTALLED_VBMETAIMAGE_TARGET): $(AVBTOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_VENDORIMAGE_TARGET)
1860 $(build-vbmetaimage-target)
1861
1862.PHONY: vbmetaimage-nodeps
1863vbmetaimage-nodeps:
1864 $(build-vbmetaimage-target)
1865
1866# We need $(AVBTOOL) for system.img generation.
1867FULL_SYSTEMIMAGE_DEPS += $(AVBTOOL)
1868
1869endif # BOARD_AVB_ENABLE
1870
1871# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08001872# bring in the installer image generation defines if necessary
1873ifeq ($(TARGET_USE_DISKINSTALLER),true)
1874include bootable/diskinstaller/config.mk
1875endif
1876
1877# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001878# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001879
Ying Wangbd2d0242015-09-22 11:17:52 -07001880build_ota_package := true
1881ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
1882build_ota_package := false
1883endif
1884ifeq ($(BUILD_OS),darwin)
1885build_ota_package := false
1886endif
1887ifneq ($(strip $(SANITIZE_TARGET)),)
1888build_ota_package := false
1889endif
1890ifeq ($(TARGET_PRODUCT),sdk)
1891build_ota_package := false
1892endif
1893ifneq ($(filter generic%,$(TARGET_DEVICE)),)
1894build_ota_package := false
1895endif
1896ifeq ($(TARGET_NO_KERNEL),true)
1897build_ota_package := false
1898endif
1899ifeq ($(recovery_fstab),)
1900build_ota_package := false
1901endif
Colin Cross481cc5a2016-02-04 15:09:23 -08001902ifeq ($(TARGET_BUILD_PDK),true)
1903build_ota_package := false
1904endif
Ying Wangbd2d0242015-09-22 11:17:52 -07001905
1906ifeq ($(build_ota_package),true)
Ying Wang09c4b682015-08-11 11:24:19 -07001907OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
1908 $(HOST_OUT_EXECUTABLES)/aapt \
Ying Wangc45a47b2015-04-08 12:24:37 -07001909 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1910 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1911 $(HOST_OUT_EXECUTABLES)/fs_config \
1912 $(HOST_OUT_EXECUTABLES)/zipalign \
1913 $(HOST_OUT_EXECUTABLES)/bsdiff \
1914 $(HOST_OUT_EXECUTABLES)/imgdiff \
1915 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
1916 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1917 $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
Tao Baobcc31092017-01-06 14:24:18 -08001918 $(HOST_OUT_EXECUTABLES)/make_ext4fs \
1919 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
1920 $(HOST_OUT_EXECUTABLES)/mke2fs \
1921 $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh \
1922 $(HOST_OUT_EXECUTABLES)/e2fsdroid \
Tao Baocffaf732016-04-14 12:11:36 -07001923 $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \
1924 $(HOST_OUT_EXECUTABLES)/mksquashfs \
1925 $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \
1926 $(HOST_OUT_EXECUTABLES)/make_f2fs \
Ying Wangc45a47b2015-04-08 12:24:37 -07001927 $(HOST_OUT_EXECUTABLES)/simg2img \
1928 $(HOST_OUT_EXECUTABLES)/e2fsck \
1929 $(HOST_OUT_EXECUTABLES)/build_verity_tree \
1930 $(HOST_OUT_EXECUTABLES)/verity_signer \
Tao Bao7f02f342016-11-18 17:04:24 -08001931 $(HOST_OUT_EXECUTABLES)/verity_verifier \
Ying Wangc45a47b2015-04-08 12:24:37 -07001932 $(HOST_OUT_EXECUTABLES)/append2simg \
Mohamad Ayyash353265b2015-06-24 15:42:19 -07001933 $(HOST_OUT_EXECUTABLES)/img2simg \
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001934 $(HOST_OUT_EXECUTABLES)/boot_signer \
Tao Baof8e6fbe2016-01-04 09:57:32 -08001935 $(HOST_OUT_EXECUTABLES)/fec \
Tao Bao6d8a8cc2016-01-19 14:47:17 -08001936 $(HOST_OUT_EXECUTABLES)/brillo_update_payload \
1937 $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \
Tao Baof54216f2016-03-29 15:12:37 -07001938 $(HOST_OUT_EXECUTABLES)/delta_generator \
Tao Bao5e04c382017-02-22 16:38:19 -08001939 $(BLK_ALLOC_TO_BASE_FS)
1940
1941ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1942OTATOOLS += \
Tao Bao69ad1502017-02-23 11:03:45 -08001943 $(FUTILITY) \
1944 $(VBOOT_SIGNER)
Tao Bao5e04c382017-02-22 16:38:19 -08001945endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08001946
Tao Baod2aed432017-02-22 16:38:19 -08001947ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1948OTATOOLS += \
Tao Baoe98fb7a2017-02-17 14:11:13 -08001949 $(FUTILITY) \
1950 $(VBOOT_SIGNER)
Tao Baod2aed432017-02-22 16:38:19 -08001951endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08001952
Ying Wangc45a47b2015-04-08 12:24:37 -07001953# Shared libraries.
Ying Wang09c4b682015-08-11 11:24:19 -07001954OTATOOLS += \
Mark Salyzync506e742015-04-13 09:01:24 -07001955 $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
1956 $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \
1957 $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
Claes Elgemarkd0ec6652015-06-03 08:35:52 +02001958 $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \
1959 $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08001960 $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \
1961 $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \
1962 $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \
1963 $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \
Baligh Uddinb24470e2017-01-30 12:41:31 -08001964 $(HOST_LIBRARY_PATH)/libext2_misc$(HOST_SHLIB_SUFFIX) \
Alex Deymo0d799562015-12-09 18:02:56 -08001965 $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \
1966 $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \
Alex Klyubin9667b182015-12-10 13:38:50 -08001967 $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08001968 $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \
1969 $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \
1970 $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08001971 $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \
1972 $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \
Dan Willemsen8c2b6bb2016-07-22 23:16:30 +00001973 $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \
Tao Baofdd26932016-02-11 09:50:41 -08001974 $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \
Tao Baof8e6fbe2016-01-04 09:57:32 -08001975 $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \
Johan Redestig8f800df2016-03-24 13:57:03 +01001976 $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \
Tao Bao138986b2017-01-26 08:16:57 -08001977 $(HOST_LIBRARY_PATH)/libsparse-host$(HOST_SHLIB_SUFFIX) \
Vikram Dattu8be44672016-12-16 16:33:03 +01001978 $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) \
1979 $(HOST_LIBRARY_PATH)/libpcre2$(HOST_SHLIB_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001980
Ying Wang06898662010-06-17 17:52:18 -07001981.PHONY: otatools
1982otatools: $(OTATOOLS)
1983
Doug Zongkerf22b0f42014-08-22 08:04:58 -07001984BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
Ying Wang62925a92015-04-08 16:37:34 -07001985$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
Doug Zongkerf22b0f42014-08-22 08:04:58 -07001986
Ying Wang5d887702015-11-04 10:06:25 -08001987$(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) | $(ACP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07001988 @echo "Package OTA tools: $@"
1989 $(hide) rm -rf $@ $(zip_root)
Jin Qianabcec5e2017-03-10 16:53:45 -08001990 $(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity $(zip_root)/system/extras/ext4_utils
Ying Wangc45a47b2015-04-08 12:24:37 -07001991 $(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
Claes Elgemarkd53cd9b2015-06-02 11:59:32 +02001992 $(hide) $(ACP) $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar $(zip_root)/framework/
Claes Elgemark82a19d32015-06-04 10:07:44 +02001993 $(hide) $(ACP) -p system/extras/verity/build_verity_metadata.py $(zip_root)/system/extras/verity/
Jin Qianabcec5e2017-03-10 16:53:45 -08001994 $(hide) $(ACP) -p system/extras/ext4_utils/mke2fs.conf $(zip_root)/system/extras/ext4_utils/
Doug Zongkerf22b0f42014-08-22 08:04:58 -07001995 $(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools
Tao Baod2aed432017-02-22 16:38:19 -08001996ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
1997 $(hide) mkdir -p $(zip_root)/external/vboot_reference/tests/devkeys
1998 $(hide) $(ACP) -r -d -p external/vboot_reference/tests/devkeys/* $(zip_root)/external/vboot_reference/tests/devkeys
1999endif
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002000 $(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
Dan Willemsen48a621c2015-10-29 16:33:05 -07002001 $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *)
2002 $(hide) zip -qryX $(abspath $@) build/target/product/security/
Baligh Uddin04184062016-05-20 17:27:18 -07002003 $(hide) find device vendor -name \*.pk8 -o -name verifiedboot\* -o -name \*.x509.pem -o -name oem\*.prop | xargs zip -qryX $(abspath $@)>/dev/null || true
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002004
2005.PHONY: otatools-package
2006otatools-package: $(BUILT_OTATOOLS_PACKAGE)
2007
Ying Wangbd2d0242015-09-22 11:17:52 -07002008endif # build_ota_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07002009
The Android Open Source Project88b60792009-03-03 19:28:42 -08002010# -----------------------------------------------------------------
2011# A zip of the directories that map to the target filesystem.
2012# This zip can be used to create an OTA package or filesystem image
2013# as a post-build step.
2014#
2015name := $(TARGET_PRODUCT)
2016ifeq ($(TARGET_BUILD_TYPE),debug)
2017 name := $(name)_debug
2018endif
2019name := $(name)-target_files-$(FILE_NAME_TAG)
2020
2021intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
2022BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
2023$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
2024$(BUILT_TARGET_FILES_PACKAGE): \
2025 zip_root := $(intermediates)/$(name)
2026
2027# $(1): Directory to copy
2028# $(2): Location to copy it to
2029# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
2030define package_files-copy-root
2031 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
2032 mkdir -p $(2) && \
2033 $(ACP) -rd $(strip $(1))/* $(2); \
2034 fi
2035endef
2036
Tao Baoa04fca32015-11-30 12:22:24 -08002037built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07002038
2039# We can't build static executables when SANITIZE_TARGET=address
Ivan Krasin74b32b82015-09-18 11:54:43 -07002040ifeq ($(strip $(SANITIZE_TARGET)),)
Ying Wange6e544e2015-06-22 18:35:35 -07002041built_ota_tools += \
Ying Wange6e544e2015-06-22 18:35:35 -07002042 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
2043endif
2044
The Android Open Source Project88b60792009-03-03 19:28:42 -08002045$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
2046
Doug Zongkerb1134dd2009-06-17 17:09:40 -07002047$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08002048$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07002049
Doug Zongkerc18736b2009-09-30 09:20:32 -07002050ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
2051# default to common dir for device vendor
Dan Willemsen653bea92017-03-21 15:47:37 -07002052tool_extensions := $(TARGET_DEVICE_DIR)/../common
Doug Zongkerc18736b2009-09-30 09:20:32 -07002053else
Dan Willemsen653bea92017-03-21 15:47:37 -07002054tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
Doug Zongkerc18736b2009-09-30 09:20:32 -07002055endif
Dan Willemsen653bea92017-03-21 15:47:37 -07002056tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
2057$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSIONS := $(tool_extensions)
2058$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07002059
Sen Jiang4438fd92016-03-07 16:51:01 -08002060ifeq ($(AB_OTA_UPDATER),true)
2061# Build zlib fingerprint if using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002062updater_dep := $(TARGET_OUT_COMMON_GEN)/zlib_fingerprint
Dan Willemsen653bea92017-03-21 15:47:37 -07002063updater_dep += system/update_engine/update_engine.conf
Sen Jiang4438fd92016-03-07 16:51:01 -08002064else
Steve Fung48e49f52015-10-01 23:53:31 -07002065# Build OTA tools if not using the AB Updater.
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002066updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07002067endif
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002068$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07002069
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002070# If we are using recovery as boot, output recovery files to BOOT/.
2071ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2072$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
2073else
2074$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
2075endif
2076
Dan Willemsen653bea92017-03-21 15:47:37 -07002077ifeq ($(AB_OTA_UPDATER),true)
2078 ifdef BRILLO_VENDOR_PARTITIONS
2079 $(BUILT_TARGET_FILES_PACKAGE): $(foreach p,$(BRILLO_VENDOR_PARTITIONS),\
2080 $(call word-colon,1,$(p))/$(call word-colon,2,$(p)))
2081 endif
2082 ifdef OSRELEASED_DIRECTORY
2083 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
2084 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
2085 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
2086 endif
2087endif
2088
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002089# Run fs_config while creating the target files package
2090# $1: root directory
2091# $2: add prefix
2092define fs_config
2093(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)
2094endef
2095
The Android Open Source Project88b60792009-03-03 19:28:42 -08002096# Depending on the various images guarantees that the underlying
2097# directories are up-to-date.
2098$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002099 $(INSTALLED_BOOTIMAGE_TARGET) \
2100 $(INSTALLED_RADIOIMAGE_TARGET) \
2101 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002102 $(FULL_SYSTEMIMAGE_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002103 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002104 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07002105 $(INSTALLED_VENDORIMAGE_TARGET) \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002106 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002107 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Dan Willemsen653bea92017-03-21 15:47:37 -07002108 $(INSTALLED_KERNEL_TARGET) \
2109 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2110 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
2111 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07002112 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002113 $(APKCERTS_FILE) \
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002114 $(SOONG_ZIP) \
Doug Zongker283e2a12010-03-15 17:52:32 -07002115 $(HOST_OUT_EXECUTABLES)/fs_config \
Dan Willemsend79a08f2017-03-23 22:09:06 -07002116 $(HOST_OUT_EXECUTABLES)/imgdiff \
2117 $(HOST_OUT_EXECUTABLES)/bsdiff \
Dan Willemsenaadd4992017-03-21 16:01:02 -07002118 $(BUILD_IMAGE_SRCS) \
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002119 $(INSTALLED_VENDOR_MANIFEST) \
2120 $(INSTALLED_VENDOR_MATRIX) \
Ying Wang5d887702015-11-04 10:06:25 -08002121 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002122 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07002123 $(call create-system-vendor-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002124 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002125 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002126ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002127 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002128 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002129 $(hide) $(call package_files-copy-root, \
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002130 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002131ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002132 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08002133endif
2134ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002135 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08002136endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002137ifdef INTERNAL_KERNEL_CMDLINE
2138 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08002139endif
Doug Zongker38a649f2009-06-17 09:07:09 -07002140ifdef BOARD_KERNEL_BASE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002141 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07002142endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002143ifdef BOARD_KERNEL_PAGESIZE
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002144 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07002145endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002146endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08002147 @# Components of the boot image
2148 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07002149ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
2150 $(hide) mkdir -p $(zip_root)/ROOT
2151 $(hide) $(call package_files-copy-root, \
2152 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
2153else
The Android Open Source Project88b60792009-03-03 19:28:42 -08002154 $(hide) $(call package_files-copy-root, \
2155 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07002156endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002157 @# If we are using recovery as boot, this is already done when processing recovery.
2158ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002159ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002160 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08002161endif
2162ifdef INSTALLED_2NDBOOTLOADER_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07002163 $(hide) cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08002164endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002165ifdef INTERNAL_KERNEL_CMDLINE
2166 $(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08002167endif
Doug Zongker38a649f2009-06-17 09:07:09 -07002168ifdef BOARD_KERNEL_BASE
2169 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
2170endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002171ifdef BOARD_KERNEL_PAGESIZE
2172 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
2173endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002174endif # BOARD_USES_RECOVERY_AS_BOOT
Doug Zongkere01100c2009-06-19 17:12:18 -07002175 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
2176 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07002177 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002178 @# Contents of the system image
2179 $(hide) $(call package_files-copy-root, \
2180 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
2181 @# Contents of the data image
2182 $(hide) $(call package_files-copy-root, \
2183 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07002184ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2185 @# Contents of the vendor image
2186 $(hide) $(call package_files-copy-root, \
2187 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
2188endif
Alex Light4e358ab2016-06-16 14:47:10 -07002189ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
2190 @# Contents of the system_other image
2191 $(hide) $(call package_files-copy-root, \
2192 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
2193endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002194 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07002195 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07002196 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Steve Fung48e49f52015-10-01 23:53:31 -07002197ifneq ($(AB_OTA_UPDATER),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08002198ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07002199 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07002200 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07002201endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08002202endif
Doug Zongker8678df42009-06-15 14:30:14 -07002203 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08002204 @# build them.
2205 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07002206 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
2207ifneq ($(tool_extension),)
2208 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
2209endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07002210 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07002211 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Doug Zongker37974732010-09-16 17:44:38 -07002212 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08002213 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002214ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07002215 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002216endif
2217ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08002218 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002219endif
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002220ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),)
2221 $(hide) echo "recovery_as_boot=$(BOARD_USES_RECOVERY_AS_BOOT)" >> $(zip_root)/META/misc_info.txt
2222endif
Tao Baodb45efa2015-10-27 19:25:18 -07002223ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
2224 $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
2225endif
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002226ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08002227 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07002228endif
Tao Baoc7a6f1e2015-06-23 11:16:05 -07002229ifdef BOARD_HAS_EXT4_RESERVED_BLOCKS
2230 $(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(zip_root)/META/misc_info.txt
2231endif
JP Abgrall6ea5bd62014-10-22 20:01:22 -07002232ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
2233 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
2234 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
2235else
2236 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
2237endif
Dan Willemsen653bea92017-03-21 15:47:37 -07002238 $(hide) echo "tool_extensions=$(PRIVATE_TOOL_EXTENSIONS)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07002239 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07002240ifdef PRODUCT_EXTRA_RECOVERY_KEYS
2241 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08002242endif
Jianxun Zhang09849492013-04-17 15:19:19 -07002243 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Sami Tolvanen3303d902016-03-15 16:49:30 +00002244 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08002245 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Tao Bao8fad03e2017-03-01 14:36:26 -08002246 $(hide) echo "blockimgdiff_versions=3,4" >> $(zip_root)/META/misc_info.txt
Ying Wange24e17a2014-10-07 18:42:11 -07002247ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
Jeff Sharkey26e1a282014-03-21 16:20:05 -07002248 # OTA scripts are only interested in fingerprint related properties
Ying Wange24e17a2014-10-07 18:42:11 -07002249 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
Vineeta Srivastava27262112014-09-18 14:34:00 -07002250endif
Tao Baof54216f2016-03-29 15:12:37 -07002251ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07002252 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07002253 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH))
2254endif
2255ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),)
Dan Willemsen653bea92017-03-21 15:47:37 -07002256 $(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
Tao Baof54216f2016-03-29 15:12:37 -07002257 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH))
2258endif
Ivan Krasin74b32b82015-09-18 11:54:43 -07002259ifneq ($(strip $(SANITIZE_TARGET)),)
Ying Wang2a048392015-06-25 13:56:53 -07002260 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
2261 $(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt
2262endif
Tao Bao8beab692015-07-22 12:33:18 -07002263ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
2264 $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
2265endif
David Zeuthen0eb10972016-09-28 17:55:27 -04002266ifeq ($(BOARD_AVB_ENABLE),true)
2267 $(hide) echo "board_avb_enable=true" >> $(zip_root)/META/misc_info.txt
2268 $(hide) echo "board_avb_rollback_index=$(BOARD_AVB_ROLLBACK_INDEX)" >> $(zip_root)/META/misc_info.txt
2269 $(hide) echo "board_avb_key_path=$(BOARD_AVB_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
2270 $(hide) echo "board_avb_algorithm=$(BOARD_AVB_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
2271 $(hide) echo "board_avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2272 $(hide) echo "board_avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
2273 $(hide) echo "board_avb_make_vbmeta_image_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
David Zeuthend995f4b2016-01-29 16:59:17 -05002274endif
David Zeuthen25328622016-04-08 15:08:03 -04002275ifdef BOARD_BPT_INPUT_FILES
2276 $(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt
2277 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $(zip_root)/META/misc_info.txt
2278 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $(zip_root)/META/misc_info.txt
2279endif
2280ifdef BOARD_BPT_DISK_SIZE
2281 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $(zip_root)/META/misc_info.txt
2282endif
Ying Wangbd93d422011-10-28 17:02:30 -07002283 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Tao Baocbc6dc22015-08-18 18:03:56 -07002284ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Per Astrandcab66992015-03-25 14:06:30 +01002285 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Ying Wang9d252e12015-02-09 17:20:06 -08002286 ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07002287endif
Alex Deymo70067ac2015-09-29 19:05:37 -07002288ifeq ($(AB_OTA_UPDATER),true)
2289 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07002290 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
2291 $(hide) cp $(TARGET_OUT_COMMON_GEN)/zlib_fingerprint $(zip_root)/META/zlib_fingerprint.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07002292 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07002293 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
2294 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08002295 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
2296 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
2297 done
Steve Fung4044b382015-11-05 02:04:04 -08002298 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
2299 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002300 $(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt
Wei Wang2e735ca2016-05-10 22:48:13 -07002301ifdef BRILLO_VENDOR_PARTITIONS
2302 $(hide) mkdir -p $(zip_root)/VENDOR_IMAGES
2303 $(hide) for f in $(BRILLO_VENDOR_PARTITIONS); do \
2304 pair1="$$(echo $$f | awk -F':' '{print $$1}')"; \
2305 pair2="$$(echo $$f | awk -F':' '{print $$2}')"; \
2306 src=$${pair1}/$${pair2}; \
2307 dest=$(zip_root)/VENDOR_IMAGES/$${pair2}; \
2308 mkdir -p $$(dirname "$${dest}"); \
Dan Willemsen653bea92017-03-21 15:47:37 -07002309 cp $${src} $${dest}; \
Wei Wang2e735ca2016-05-10 22:48:13 -07002310 done;
2311endif
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07002312ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07002313 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
2314 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
2315 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07002316endif
Alex Deymo70067ac2015-09-29 19:05:37 -07002317endif
Steve Fungdfbab492015-09-24 18:12:33 -07002318ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07002319 @# If breakpad symbols have been generated, add them to the zip.
Steve Fungdfbab492015-09-24 18:12:33 -07002320 $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
2321endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002322ifdef BOARD_PREBUILT_VENDORIMAGE
2323 $(hide) mkdir -p $(zip_root)/IMAGES
2324 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
2325endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002326 @# Run fs_config on all the system, vendor, boot ramdisk,
2327 @# and recovery ramdisk files in the zip, and save the output
2328 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
2329ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
2330 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
2331endif
2332ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
2333 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
2334endif
2335 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
2336ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
2337 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
2338endif
2339ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
2340 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
2341endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002342 @# Metadata for compatibility verification.
Yifan Hongaa212212017-04-14 00:00:46 -07002343 $(hide) cp $(BUILT_SYSTEM_MANIFEST) $(zip_root)/META/system_manifest.xml
Yifan Hongb5cbe222017-04-28 14:39:50 -07002344 $(hide) cp $(BUILT_SYSTEM_COMPATIBILITY_MATRIX) $(zip_root)/META/system_compatibility_matrix.xml
Yifan Hongaa212212017-04-14 00:00:46 -07002345ifdef BUILT_VENDOR_MANIFEST
2346 $(hide) cp $(BUILT_VENDOR_MANIFEST) $(zip_root)/META/vendor_manifest.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002347endif
Yifan Hongaa212212017-04-14 00:00:46 -07002348ifdef BUILT_VENDOR_MATRIX
2349 $(hide) cp $(BUILT_VENDOR_MATRIX) $(zip_root)/META/vendor_matrix.xml
Michael Schwartz4d9cb562017-04-04 13:01:18 -07002350endif
2351
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08002352 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
2353 ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root)
Alex Deymo92cfd6f2016-01-26 18:47:44 -08002354 @# Zip everything up, preserving symlinks and placing META/ files first to
2355 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002356 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07002357 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002358 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07002359
Ying Wanga0febe52013-03-20 11:02:05 -07002360.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08002361target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
2362
Ying Wang4709d7c2014-04-14 17:25:43 -07002363ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
2364$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
2365endif
Doug Zongker367910f2009-06-15 18:56:51 -07002366
Dan Albert4d323332016-10-14 13:23:06 -07002367# -----------------------------------------------------------------
2368# NDK Sysroot Package
2369NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
2370$(NDK_SYSROOT_TARGET): ndk
2371 @echo Package NDK sysroot...
2372 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
2373
2374$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
2375
Ying Wang09c4b682015-08-11 11:24:19 -07002376ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07002377# -----------------------------------------------------------------
2378# OTA update package
2379
Doug Zongker8678df42009-06-15 14:30:14 -07002380name := $(TARGET_PRODUCT)
2381ifeq ($(TARGET_BUILD_TYPE),debug)
2382 name := $(name)_debug
2383endif
2384name := $(name)-ota-$(FILE_NAME_TAG)
2385
2386INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2387
2388$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
2389
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002390$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
2391 build/tools/releasetools/ota_from_target_files
Doug Zongker8678df42009-06-15 14:30:14 -07002392 @echo "Package OTA: $@"
Ying Wang9d252e12015-02-09 17:20:06 -08002393 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08002394 ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08002395 --block \
Dan Willemsencea5cd22017-03-21 14:44:27 -07002396 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
Doug Zongker602a84e2009-06-18 08:35:12 -07002397 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05002398 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07002399 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05002400 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07002401
2402.PHONY: otapackage
2403otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
2404
Ying Wang09c4b682015-08-11 11:24:19 -07002405endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07002406
Ying Wang09a00a62010-10-20 14:01:09 -07002407# -----------------------------------------------------------------
2408# The update package
2409
2410name := $(TARGET_PRODUCT)
2411ifeq ($(TARGET_BUILD_TYPE),debug)
2412 name := $(name)_debug
2413endif
2414name := $(name)-img-$(FILE_NAME_TAG)
2415
2416INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2417
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002418$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(ZIP2ZIP)
Ying Wang09a00a62010-10-20 14:01:09 -07002419 @echo "Package: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002420 $(hide) $(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
2421 OTA/android-info.txt:android-info.txt "IMAGES/*.img:."
Ying Wang09a00a62010-10-20 14:01:09 -07002422
2423.PHONY: updatepackage
2424updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
2425
The Android Open Source Project88b60792009-03-03 19:28:42 -08002426# -----------------------------------------------------------------
2427# A zip of the symbols directory. Keep the full paths to make it
2428# more obvious where these files came from.
2429#
2430name := $(TARGET_PRODUCT)
2431ifeq ($(TARGET_BUILD_TYPE),debug)
2432 name := $(name)_debug
2433endif
2434name := $(name)-symbols-$(FILE_NAME_TAG)
2435
2436SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Ying Wangda3b9722014-10-24 11:36:59 -07002437# For apps_only build we'll establish the dependency later in build/core/main.mk.
2438ifndef TARGET_BUILD_APPS
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09002439$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) \
2440 $(INSTALLED_BOOTIMAGE_TARGET) \
2441 $(INSTALLED_USERDATAIMAGE_TARGET) \
2442 $(INSTALLED_VENDORIMAGE_TARGET) \
2443 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07002444endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002445$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
2446$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002447 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07002448 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
2449 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
2450 $(hide) find $(TARGET_OUT_UNSTRIPPED) | sort >$(PRIVATE_LIST_FILE)
Dan Willemsen6cf21a72017-01-30 20:42:28 -08002451 $(hide) $(SOONG_ZIP) -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07002452# -----------------------------------------------------------------
2453# A zip of the coverage directory.
2454#
2455name := $(TARGET_PRODUCT)
2456ifeq ($(TARGET_BUILD_TYPE),debug)
2457name := $(name)_debug
2458endif
2459name := $(name)-coverage-$(FILE_NAME_TAG)
2460COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
2461ifndef TARGET_BUILD_APPS
2462$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE) \
2463 $(INSTALLED_BOOTIMAGE_TARGET) \
2464 $(INSTALLED_USERDATAIMAGE_TARGET) \
2465 $(INSTALLED_VENDORIMAGE_TARGET)
2466endif
2467$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
2468$(COVERAGE_ZIP): $(SOONG_ZIP)
2469 @echo "Package coverage: $@"
2470 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
2471 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
2472 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
2473 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002474
2475# -----------------------------------------------------------------
2476# A zip of the Android Apps. Not keeping full path so that we don't
2477# include product names when distributing
2478#
2479name := $(TARGET_PRODUCT)
2480ifeq ($(TARGET_BUILD_TYPE),debug)
2481 name := $(name)_debug
2482endif
2483name := $(name)-apps-$(FILE_NAME_TAG)
2484
2485APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Ying Wang5d887702015-11-04 10:06:25 -08002486$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002487 @echo "Package apps: $@"
2488 $(hide) rm -rf $@
2489 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07002490 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
2491 if [ -z "$$apps_to_zip" ]; then \
2492 echo "No apps to zip up. Generating empty apps archive." ; \
2493 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
2494 else \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002495 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07002496 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07002497
2498#------------------------------------------------------------------
2499# A zip of emma code coverage meta files. Generated for fully emma
2500# instrumented build.
2501#
Ying Wangbc415dd2012-08-15 12:22:44 -07002502ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07002503EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07002504# the dependency will be set up later in build/core/main.mk.
2505$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07002506 @echo "Collecting Emma coverage meta files."
Ying Wang1ff08362013-12-27 15:55:08 -08002507 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002508 zip -@ -qX $@
Guang Zhu0198d6e2010-04-23 11:54:37 -07002509
Ying Wangbc415dd2012-08-15 12:22:44 -07002510endif # EMMA_INSTRUMENT=true
2511
Ying Wangae9115a2013-08-22 20:52:47 -07002512#------------------------------------------------------------------
2513# A zip of Proguard obfuscation dictionary files.
2514# Only for apps_only build.
2515#
2516ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07002517PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Ying Wangae9115a2013-08-22 20:52:47 -07002518# the dependency will be set up later in build/core/main.mk.
2519$(PROGUARD_DICT_ZIP) :
2520 @echo "Packaging Proguard obfuscation dictionary files."
Dan Willemsenb6c061e2016-09-01 11:02:43 -07002521 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary -o -name jack_dictionary`; \
Ying Wangae9115a2013-08-22 20:52:47 -07002522 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08002523 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002524 zip -qX $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07002525 else \
Ying Wangdcd90832015-02-26 09:36:27 -08002526 touch $(dir $@)/zipdummy; \
2527 (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \
2528 zip -qd $@ zipdummy; \
2529 rm $(dir $@)/zipdummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07002530 fi
2531
2532endif # TARGET_BUILD_APPS
2533
The Android Open Source Project88b60792009-03-03 19:28:42 -08002534# -----------------------------------------------------------------
2535# dalvik something
2536.PHONY: dalvikfiles
2537dalvikfiles: $(INTERNAL_DALVIK_MODULES)
2538
2539# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002540# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07002541ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002542INTERNAL_EMULATOR_PACKAGE_FILES += \
2543 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08002544 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002545 $(INSTALLED_RAMDISK_TARGET) \
2546 $(INSTALLED_SYSTEMIMAGE) \
2547 $(INSTALLED_USERDATAIMAGE_TARGET)
2548
2549name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
2550
2551INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
2552
Ying Wang5d887702015-11-04 10:06:25 -08002553$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002554 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07002555 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002556
Ying Wang7d8c5352012-07-26 10:15:21 -07002557endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002558# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08002559# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08002560# The pdk package (Platform Development Kit)
2561
Keun young Park7fc7aad2012-02-27 15:49:23 -08002562#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
2563# include development/pdk/Pdk.mk
2564#endif
2565
The Android Open Source Project88b60792009-03-03 19:28:42 -08002566
2567# -----------------------------------------------------------------
2568# The SDK
2569
The Android Open Source Project88b60792009-03-03 19:28:42 -08002570# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07002571sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002572
2573# Build a name that looks like:
2574#
2575# linux-x86 --> android-sdk_12345_linux-x86
2576# darwin-x86 --> android-sdk_12345_mac-x86
2577# windows-x86 --> android-sdk_12345_windows
2578#
2579sdk_name := android-sdk_$(FILE_NAME_TAG)
2580ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07002581 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08002582else
Joe Onorato03fbe402009-04-13 08:31:16 -07002583 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002584endif
2585ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07002586 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002587endif
Joe Onorato03fbe402009-04-13 08:31:16 -07002588sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002589
2590sdk_dep_file := $(sdk_dir)/sdk_deps.mk
2591
2592ATREE_FILES :=
2593-include $(sdk_dep_file)
2594
2595# if we don't have a real list, then use "everything"
2596ifeq ($(strip $(ATREE_FILES)),)
2597ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002598 $(ALL_DEFAULT_INSTALLED_MODULES) \
2599 $(INSTALLED_RAMDISK_TARGET) \
2600 $(ALL_DOCS) \
2601 $(ALL_SDK_FILES)
2602endif
2603
2604atree_dir := development/build
2605
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01002606
The Android Open Source Project88b60792009-03-03 19:28:42 -08002607sdk_atree_files := \
2608 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07002609 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08002610
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02002611# development/build/sdk-android-<abi>.atree is used to differentiate
2612# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
2613# files like the kernel image. We use TARGET_CPU_ABI because we don't
2614# have a better way to distinguish between CPU models.
2615ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
2616 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
2617endif
2618
Griff Hazen433febb2014-02-28 08:45:59 -08002619ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
2620sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
2621else
2622sdk_atree_files += $(atree_dir)/sdk.atree
2623endif
2624
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07002625include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07002626
The Android Open Source Project88b60792009-03-03 19:28:42 -08002627deps := \
2628 $(target_notice_file_txt) \
2629 $(tools_notice_file_txt) \
2630 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07002631 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07002632 $(COVERAGE_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07002633 $(INSTALLED_SYSTEMIMAGE) \
2634 $(INSTALLED_USERDATAIMAGE_TARGET) \
2635 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002636 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07002637 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002638 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08002639 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002640 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07002641 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07002642 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002643
2644INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
2645$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
2646$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
2647$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
2648$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
2649
2650# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
2651#
2652#SDK_GNU_ERROR := true
2653
Ying Wang5d887702015-11-04 10:06:25 -08002654$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002655 @echo "Package SDK: $@"
2656 $(hide) rm -rf $(PRIVATE_DIR) $@
2657 $(hide) for f in $(target_gnu_MODULES); do \
2658 if [ -f $$f ]; then \
2659 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
2660 including GNU target $$f >&2; \
2661 FAIL=$(SDK_GNU_ERROR); \
2662 fi; \
2663 done; \
2664 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07002665 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08002666 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07002667 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002668 $(HOST_OUT_EXECUTABLES)/atree \
2669 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
2670 -m $(PRIVATE_DEP_FILE) \
2671 -I . \
2672 -I $(PRODUCT_OUT) \
2673 -I $(HOST_OUT) \
2674 -I $(TARGET_COMMON_OUT_ROOT) \
2675 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08002676 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08002677 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08002678 -v "TARGET_ARCH=$(TARGET_ARCH)" \
2679 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02002680 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07002681 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
Yohann Roussel233584b2016-03-17 12:02:27 +01002682 -v "JACK_SDKTOOL_VERSION=$(JACK_SDKTOOL_VERSION)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002683 -o $(PRIVATE_DIR) && \
2684 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07002685 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07002686 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002687 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08002688 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002689 chmod -R ug+rwX $(PRIVATE_DIR) && \
Dan Willemsen48a621c2015-10-29 16:33:05 -07002690 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002691 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
2692
Raphael3d224a02010-04-16 17:50:09 -07002693
2694# Is a Windows SDK requested? If so, we need some definitions from here
2695# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08002696MAIN_SDK_NAME := $(sdk_name)
2697MAIN_SDK_DIR := $(sdk_dir)
2698MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08002699ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07002700include $(TOPDIR)development/build/tools/windows_sdk.mk
2701endif
2702
The Android Open Source Project88b60792009-03-03 19:28:42 -08002703# -----------------------------------------------------------------
2704# Findbugs
2705INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
2706INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
2707$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
2708 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09002709 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08002710 > $@
2711$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
2712 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09002713 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07002714 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08002715
2716# -----------------------------------------------------------------
2717# Findbugs
2718
2719# -----------------------------------------------------------------
2720# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07002721ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002722include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01002723-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07002724-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07002725-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07002726# Also the project-specific tasks
2727-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
2728-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07002729-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07002730# Also add test specifc tasks
2731include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07002732include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07002733endif
Raphaelc4d47312011-02-15 16:09:36 -08002734
Ying Wang67132ba2015-10-28 16:42:39 -07002735include $(BUILD_SYSTEM)/product-graph.mk
2736
Raphaelc4d47312011-02-15 16:09:36 -08002737# -----------------------------------------------------------------
2738# Create SDK repository packages. Must be done after tasks/* since
2739# we need the addon rules defined.
2740ifneq ($(sdk_repo_goal),)
2741include $(TOPDIR)development/build/tools/sdk_repo.mk
2742endif