1 # Put some miscellaneous rules here 2 3 # HACK: clear LOCAL_PATH from including last build target before calling 4 # intermedites-dir-for 5 LOCAL_PATH := $(BUILD_SYSTEM) 6 7 # Pick a reasonable string to use to identify files. 8 ifneq "" "$(filter eng.%,$(BUILD_NUMBER))" 9 # 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) 12 else 13 FILE_NAME_TAG := $(BUILD_NUMBER) 14 endif 15 16 # ----------------------------------------------------------------- 17 # Define rules to copy PRODUCT_COPY_FILES defined by the product. 18 # PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>]. 19 # <dest file> is relative to $(PRODUCT_OUT), so it should look like, 20 # e.g., "system/etc/file.xml". 21 # The filter part means "only eval the copy-one-file rule if this 22 # src:dest pair is the first one to match the same dest" 23 #$(1): the src:dest pair 24 define check-product-copy-files 25 $(if $(filter %.apk, $(call word-colon, 2, $(1))),$(error \ 26 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)) 27 endef 28 # filter out the duplicate <source file>:<dest file> pairs. 29 unique_product_copy_files_pairs := 30 $(foreach cf,$(PRODUCT_COPY_FILES), \ 31 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\ 32 $(eval unique_product_copy_files_pairs += $(cf)))) 33 unique_product_copy_files_destinations := 34 $(foreach cf,$(unique_product_copy_files_pairs), \ 35 $(eval _src := $(call word-colon,1,$(cf))) \ 36 $(eval _dest := $(call word-colon,2,$(cf))) \ 37 $(call check-product-copy-files,$(cf)) \ 38 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \ 39 $(info PRODUCT_COPY_FILES $(cf) ignored.), \ 40 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \ 41 $(if $(filter %.xml,$(_dest)),\ 42 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\ 43 $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \ 44 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \ 45 $(eval unique_product_copy_files_destinations += $(_dest)))) 46 unique_product_copy_files_pairs := 47 unique_product_copy_files_destinations := 48 49 # ----------------------------------------------------------------- 50 # 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)))) 61 all_copied_headers: $(ALL_COPIED_HEADERS) 62 63 # ----------------------------------------------------------------- 64 # docs/index.html 65 ifeq (,$(TARGET_BUILD_APPS)) 66 gen := $(OUT_DOCS)/index.html 67 ALL_DOCS += $(gen) 68 $(gen): frameworks/base/docs/docs-redirect-index.html 69 @mkdir -p $(dir $@) 70 @cp -f $< $@ 71 endif 72 73 # ----------------------------------------------------------------- 74 # default.prop 75 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop 76 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET) 77 ADDITIONAL_DEFAULT_PROPERTIES := \ 78 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) 79 ADDITIONAL_DEFAULT_PROPERTIES += \ 80 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)) 81 ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \ 82 $(ADDITIONAL_DEFAULT_PROPERTIES),=) 83 84 intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop 85 86 $(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop) 87 @echo Target buildinfo: $@ 88 @mkdir -p $(dir $@) 89 $(hide) echo "#" > $@; \ 90 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \ 91 echo "#" >> $@; 92 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \ 93 echo "$(line)" >> $@;) 94 $(hide) echo "#" >> $@; \ 95 echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \ 96 echo "#" >> $@; 97 $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@ 98 $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@ 99 $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@ 100 $(hide) build/tools/post_process_props.py $@ 101 102 # ----------------------------------------------------------------- 103 # build.prop 104 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop 105 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) 106 ADDITIONAL_BUILD_PROPERTIES := \ 107 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES)) 108 ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \ 109 $(ADDITIONAL_BUILD_PROPERTIES),=) 110 111 # A list of arbitrary tags describing the build configuration. 112 # Force ":=" so we can use += 113 BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) 114 ifeq ($(TARGET_BUILD_TYPE),debug) 115 BUILD_VERSION_TAGS += debug 116 endif 117 # The "test-keys" tag marks builds signed with the old test keys, 118 # which are available in the SDK. "dev-keys" marks builds signed with 119 # non-default dev keys (usually private keys from a vendor directory). 120 # Both of these tags will be removed and replaced with "release-keys" 121 # when the target-files is signed in a post-build step. 122 ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey) 123 BUILD_KEYS := test-keys 124 else 125 BUILD_KEYS := dev-keys 126 endif 127 BUILD_VERSION_TAGS += $(BUILD_KEYS) 128 BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) 129 130 # A human-readable string that descibes this build in detail. 131 build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS) 132 $(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc) 133 134 # The string used to uniquely identify the combined build and product; used by the OTA server. 135 ifeq (,$(strip $(BUILD_FINGERPRINT))) 136 ifneq ($(filter eng.%,$(BUILD_NUMBER)),) 137 # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed 138 # the Android system property length limit (PROPERTY_VALUE_MAX=92). 139 BF_BUILD_NUMBER := $(shell echo $${USER:0:6})$(shell $(DATE) +%m%d%H%M) 140 else 141 BF_BUILD_NUMBER := $(BUILD_NUMBER) 142 endif 143 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 144 endif 145 ifneq ($(words $(BUILD_FINGERPRINT)),1) 146 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 147 endif 148 149 $(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) > $(PRODUCT_OUT)/build_fingerprint.txt) 150 BUILD_FINGERPRINT_FROM_FILE := $$(cat $(PRODUCT_OUT)/build_fingerprint.txt) 151 152 # The string used to uniquely identify the system build; used by the OTA server. 153 # This purposefully excludes any product-specific variables. 154 ifeq (,$(strip $(BUILD_THUMBPRINT))) 155 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 156 endif 157 ifneq ($(words $(BUILD_THUMBPRINT)),1) 158 $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)") 159 endif 160 161 KNOWN_OEM_THUMBPRINT_PROPERTIES := \ 162 ro.product.brand \ 163 ro.product.name \ 164 ro.product.device 165 OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\ 166 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES)) 167 168 # Display parameters shown under Settings -> About Phone 169 ifeq ($(TARGET_BUILD_VARIANT),user) 170 # User builds should show: 171 # release build number or branch.buld_number non-release builds 172 173 # Dev. branches should have DISPLAY_BUILD_NUMBER set 174 ifeq "true" "$(DISPLAY_BUILD_NUMBER)" 175 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS) 176 else 177 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS) 178 endif 179 else 180 # Non-user builds should show detailed build information 181 BUILD_DISPLAY_ID := $(build_desc) 182 endif 183 184 # Accepts a whitespace separated list of product locales such as 185 # (en_US en_AU en_GB...) and returns the first locale in the list with 186 # underscores replaced with hyphens. In the example above, this will 187 # return "en-US". 188 define get-default-product-locale 189 $(strip $(subst _,-, $(firstword $(1)))) 190 endef 191 192 BUILDINFO_SH := build/tools/buildinfo.sh 193 194 # TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test harness to distinguish builds. 195 TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) 196 ifdef SANITIZE_TARGET 197 TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan 198 endif 199 200 ifdef TARGET_SYSTEM_PROP 201 system_prop_file := $(TARGET_SYSTEM_PROP) 202 else 203 system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop) 204 endif 205 $(intermediate_system_build_prop): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET) 206 @echo Target buildinfo: $@ 207 @mkdir -p $(dir $@) 208 $(hide) echo > $@ 209 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),) 210 $(hide) echo "#" >> $@; \ 211 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \ 212 echo "#" >> $@; 213 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \ 214 echo "import /oem/oem.prop $(prop)" >> $@;) 215 endif 216 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ 217 TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \ 218 TARGET_DEVICE="$(TARGET_DEVICE)" \ 219 PRODUCT_NAME="$(TARGET_PRODUCT)" \ 220 PRODUCT_BRAND="$(PRODUCT_BRAND)" \ 221 PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \ 222 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \ 223 PRODUCT_MODEL="$(PRODUCT_MODEL)" \ 224 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \ 225 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \ 226 BUILD_ID="$(BUILD_ID)" \ 227 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ 228 DATE="$(DATE_FROM_FILE)" \ 229 BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \ 230 BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \ 231 AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \ 232 PLATFORM_VERSION="$(PLATFORM_VERSION)" \ 233 PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \ 234 PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \ 235 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \ 236 PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \ 237 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \ 238 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \ 239 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \ 240 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \ 241 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \ 242 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \ 243 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \ 244 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \ 245 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \ 246 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \ 247 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \ 248 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \ 249 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \ 250 bash $(BUILDINFO_SH) >> $@ 251 $(hide) $(foreach file,$(system_prop_file), \ 252 if [ -f "$(file)" ]; then \ 253 echo "#" >> $@; \ 254 echo Target buildinfo from: "$(file)"; \ 255 echo "# from $(file)" >> $@; \ 256 echo "#" >> $@; \ 257 cat $(file) >> $@; \ 258 fi;) 259 $(if $(ADDITIONAL_BUILD_PROPERTIES), \ 260 $(hide) echo >> $@; \ 261 echo "#" >> $@; \ 262 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ 263 echo "#" >> $@; ) 264 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ 265 echo "$(line)" >> $@;) 266 $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@ 267 $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST) 268 269 build_desc := 270 271 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 272 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 273 else 274 INSTALLED_RECOVERYIMAGE_TARGET := 275 endif 276 277 $(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) $(INSTALLED_RECOVERYIMAGE_TARGET) 278 @echo "Target build info: $@" 279 $(hide) cat $(intermediate_system_build_prop) > $@ 280 ifdef INSTALLED_RECOVERYIMAGE_TARGET 281 $(hide) echo ro.expect.recovery_id=`cat $(RECOVERYIMAGE_ID_FILE)` >> $@ 282 endif 283 284 # ----------------------------------------------------------------- 285 # vendor build.prop 286 # 287 # For verifying that the vendor build is what we thing it is 288 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 289 INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop 290 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET) 291 $(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 292 @echo Target vendor buildinfo: $@ 293 @mkdir -p $(dir $@) 294 $(hide) echo > $@ 295 $(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@ 296 $(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@ 297 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@ 298 endif 299 300 # ---------------------------------------------------------------- 301 302 # ----------------------------------------------------------------- 303 # sdk-build.prop 304 # 305 # There are certain things in build.prop that we don't want to 306 # ship with the sdk; remove them. 307 308 # This must be a list of entire property keys followed by 309 # "=" characters, without any internal spaces. 310 sdk_build_prop_remove := \ 311 ro.build.user= \ 312 ro.build.host= \ 313 ro.product.brand= \ 314 ro.product.manufacturer= \ 315 ro.product.device= 316 # TODO: Remove this soon-to-be obsolete property 317 sdk_build_prop_remove += ro.build.product= 318 INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop 319 $(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 320 @echo SDK buildinfo: $@ 321 @mkdir -p $(dir $@) 322 $(hide) grep -v "$(subst $(space),\|,$(strip \ 323 $(sdk_build_prop_remove)))" $< > $@.tmp 324 $(hide) for x in $(sdk_build_prop_remove); do \ 325 echo "$$x"generic >> $@.tmp; done 326 $(hide) mv $@.tmp $@ 327 328 # ----------------------------------------------------------------- 329 # package stats 330 PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt 331 PACKAGES_TO_STAT := \ 332 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \ 333 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES)))) 334 $(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT) 335 @echo Package stats: $@ 336 @mkdir -p $(dir $@) 337 $(hide) rm -f $@ 338 ifeq ($(PACKAGES_TO_STAT),) 339 # Create empty package stats file if target builds no jar(s) or apk(s). 340 $(hide) touch $@ 341 else 342 $(hide) build/tools/dump-package-stats $^ > $@ 343 endif 344 345 .PHONY: package-stats 346 package-stats: $(PACKAGE_STATS_FILE) 347 348 # ----------------------------------------------------------------- 349 # Cert-to-package mapping. Used by the post-build signing tools. 350 # Use a macro to add newline to each echo command 351 define _apkcerts_echo_with_newline 352 $(hide) echo $(1) 353 354 endef 355 356 name := $(TARGET_PRODUCT) 357 ifeq ($(TARGET_BUILD_TYPE),debug) 358 name := $(name)_debug 359 endif 360 name := $(name)-apkcerts-$(FILE_NAME_TAG) 361 intermediates := \ 362 $(call intermediates-dir-for,PACKAGING,apkcerts) 363 APKCERTS_FILE := $(intermediates)/$(name).txt 364 # We don't need to really build all the modules. 365 # TODO: rebuild APKCERTS_FILE if any app change its cert. 366 $(APKCERTS_FILE): 367 @echo APK certs list: $@ 368 @mkdir -p $(dir $@) 369 @rm -f $@ 370 $(foreach p,$(PACKAGES),\ 371 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\ 372 $(call _apkcerts_echo_with_newline,\ 373 'name="$(p).apk" certificate="EXTERNAL" \ 374 private_key=""' >> $@),\ 375 $(call _apkcerts_echo_with_newline,\ 376 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ 377 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@))) 378 # In case value of PACKAGES is empty. 379 $(hide) touch $@ 380 381 .PHONY: apkcerts-list 382 apkcerts-list: $(APKCERTS_FILE) 383 384 ifneq (,$(TARGET_BUILD_APPS)) 385 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt) 386 endif 387 388 # ----------------------------------------------------------------- 389 390 # The dev key is used to sign this package, and as the key required 391 # for future OTA packages installed by this system. Actual product 392 # deliverables will be re-signed by hand. We expect this file to 393 # exist with the suffixes ".x509.pem" and ".pk8". 394 DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) 395 396 397 # Rules that need to be present for the all targets, even 398 # if they don't do anything. 399 .PHONY: systemimage 400 systemimage: 401 402 # ----------------------------------------------------------------- 403 404 .PHONY: event-log-tags 405 406 # Produce an event logs tag file for everything we know about, in order 407 # to properly allocate numbers. Then produce a file that's filtered 408 # for what's going to be installed. 409 410 all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt 411 412 event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags 413 414 # Include tags from all packages that we know about 415 all_event_log_tags_src := \ 416 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS))) 417 418 # PDK builds will already have a full list of tags that needs to get merged 419 # in with the ones from source 420 pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES))) 421 422 $(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) 423 $(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) 424 $(hide) mkdir -p $(dir $@) 425 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES) 426 427 # Include tags from all packages included in this product, plus all 428 # tags that are part of the system (ie, not in a vendor/ or device/ 429 # directory). 430 event_log_tags_src := \ 431 $(sort $(foreach m,\ 432 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \ 433 $(call module-names-for-tag-list,user), \ 434 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \ 435 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src))) 436 437 $(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file) 438 $(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file) 439 $(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) 440 $(hide) mkdir -p $(dir $@) 441 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES) 442 443 event-log-tags: $(event_log_tags_file) 444 445 ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file) 446 447 448 # ################################################################# 449 # Targets for boot/OS images 450 # ################################################################# 451 ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true) 452 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader 453 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true) 454 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader 455 else 456 INSTALLED_2NDBOOTLOADER_TARGET := 457 endif 458 else 459 INSTALLED_BOOTLOADER_MODULE := 460 INSTALLED_2NDBOOTLOADER_TARGET := 461 endif # TARGET_NO_BOOTLOADER 462 ifneq ($(strip $(TARGET_NO_KERNEL)),true) 463 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel 464 else 465 INSTALLED_KERNEL_TARGET := 466 endif 467 468 # ----------------------------------------------------------------- 469 # the ramdisk 470 INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ 471 $(ALL_PREBUILT) \ 472 $(ALL_GENERATED_SOURCES) \ 473 $(ALL_DEFAULT_INSTALLED_MODULES)) 474 475 BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img 476 477 # We just build this directly to the install location. 478 INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET) 479 $(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP) 480 $(call pretty,"Target ram disk: $@") 481 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@ 482 483 .PHONY: ramdisk-nodeps 484 ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP) 485 @echo "make $@: ignoring dependencies" 486 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET) 487 488 ifneq ($(strip $(TARGET_NO_KERNEL)),true) 489 490 # ----------------------------------------------------------------- 491 # the boot image, which is a collection of other images. 492 INTERNAL_BOOTIMAGE_ARGS := \ 493 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 494 --kernel $(INSTALLED_KERNEL_TARGET) 495 496 ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) 497 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET) 498 endif 499 500 INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) 501 502 BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE)) 503 ifdef BOARD_KERNEL_BASE 504 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 505 endif 506 507 BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE)) 508 ifdef BOARD_KERNEL_PAGESIZE 509 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE) 510 endif 511 512 ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true) 513 ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) 514 VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \ 515 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'` 516 endif 517 endif 518 519 BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID)) 520 ifdef BOARD_KERNEL_CMDLINE 521 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 522 endif 523 524 INTERNAL_MKBOOTIMG_VERSION_ARGS := \ 525 --os_version $(PLATFORM_VERSION) \ 526 --os_patch_level $(PLATFORM_SECURITY_PATCH) 527 528 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 529 530 # BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true. 531 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) 532 ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) 533 $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.) 534 endif 535 endif 536 537 # We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true. 538 ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true) 539 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 540 $(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore) 541 else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # TARGET_BOOTIMAGE_USE_EXT2 != true 542 543 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER) 544 $(call pretty,"Target boot image: $@") 545 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ 546 $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@ 547 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 548 549 .PHONY: bootimage-nodeps 550 bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER) 551 @echo "make $@: ignoring dependencies" 552 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) 553 $(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) 554 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 555 556 else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true 557 558 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) 559 $(call pretty,"Target boot image: $@") 560 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned 561 $(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 $@ 562 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 563 564 .PHONY: bootimage-nodeps 565 bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) 566 @echo "make $@: ignoring dependencies" 567 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned 568 $(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) 569 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 570 571 else # PRODUCT_SUPPORTS_VBOOT != true 572 573 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) 574 $(call pretty,"Target boot image: $@") 575 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ 576 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 577 578 .PHONY: bootimage-nodeps 579 bootimage-nodeps: $(MKBOOTIMG) 580 @echo "make $@: ignoring dependencies" 581 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) 582 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 583 584 endif # TARGET_BOOTIMAGE_USE_EXT2 585 endif # BOARD_USES_RECOVERY_AS_BOOT 586 587 else # TARGET_NO_KERNEL 588 # HACK: The top-level targets depend on the bootimage. Not all targets 589 # can produce a bootimage, though, and emulator targets need the ramdisk 590 # instead. Fake it out by calling the ramdisk the bootimage. 591 # TODO: make the emulator use bootimages, and make mkbootimg accept 592 # kernel-less inputs. 593 INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 594 endif 595 596 # ----------------------------------------------------------------- 597 # NOTICE files 598 # 599 # We are required to publish the licenses for all code under BSD, GPL and 600 # Apache licenses (and possibly other more exotic ones as well). We err on the 601 # side of caution, so the licenses for other third-party code are included here 602 # too. 603 # 604 # This needs to be before the systemimage rules, because it adds to 605 # ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files 606 # go into the systemimage. 607 608 .PHONY: notice_files 609 610 # Create the rule to combine the files into text and html forms 611 # $(1) - Plain text output file 612 # $(2) - HTML output file 613 # $(3) - File title 614 # $(4) - Directory to use. Notice files are all $(4)/src. Other 615 # directories in there will be used for scratch 616 # $(5) - Dependencies for the output files 617 # 618 # The algorithm here is that we go collect a hash for each of the notice 619 # files and write the names of the files that match that hash. Then 620 # to generate the real files, we go print out all of the files and their 621 # hashes. 622 # 623 # These rules are fairly complex, so they depend on this makefile so if 624 # it changes, they'll run again. 625 # 626 # TODO: We could clean this up so that we just record the locations of the 627 # original notice files instead of making rules to copy them somwehere. 628 # Then we could traverse that without quite as much bash drama. 629 define combine-notice-files 630 $(1) $(2): PRIVATE_MESSAGE := $(3) 631 $(1) $(2): PRIVATE_DIR := $(4) 632 $(1) : $(2) 633 $(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py 634 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src 635 notice_files: $(1) $(2) 636 endef 637 638 # TODO These intermediate NOTICE.txt/NOTICE.html files should go into 639 # TARGET_OUT_NOTICE_FILES now that the notice files are gathered from 640 # the src subdirectory. 641 642 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 643 target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 644 target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 645 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 646 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 647 648 ifndef TARGET_BUILD_APPS 649 kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 650 pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES)) 651 652 $(eval $(call combine-notice-files, \ 653 $(target_notice_file_txt), \ 654 $(target_notice_file_html), \ 655 "Notices for files contained in the filesystem images in this directory:", \ 656 $(TARGET_OUT_NOTICE_FILES), \ 657 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files))) 658 659 $(eval $(call combine-notice-files, \ 660 $(tools_notice_file_txt), \ 661 $(tools_notice_file_html), \ 662 "Notices for files contained in the tools directory:", \ 663 $(HOST_OUT_NOTICE_FILES), \ 664 $(ALL_DEFAULT_INSTALLED_MODULES))) 665 666 # Install the html file at /system/etc/NOTICE.html.gz. 667 # This is not ideal, but this is very late in the game, after a lot of 668 # the module processing has already been done -- in fact, we used the 669 # fact that all that has been done to get the list of modules that we 670 # need notice files for. 671 $(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP) 672 $(hide) $(MINIGZIP) -9 < $< > $@ 673 installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz 674 $(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP) 675 $(copy-file-to-target) 676 677 # if we've been run my mm, mmm, etc, don't reinstall this every time 678 ifeq ($(ONE_SHOT_MAKEFILE),) 679 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 680 endif 681 endif # TARGET_BUILD_APPS 682 683 # The kernel isn't really a module, so to get its module file in there, we 684 # make the target NOTICE files depend on this particular file too, which will 685 # then be in the right directory for the find in combine-notice-files to work. 686 $(kernel_notice_file): \ 687 $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \ 688 | $(ACP) 689 @echo Copying: $@ 690 $(hide) mkdir -p $(dir $@) 691 $(hide) $(ACP) $< $@ 692 693 694 # ----------------------------------------------------------------- 695 # Build a keystore with the authorized keys in it, used to verify the 696 # authenticity of downloaded OTA packages. 697 # 698 # This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come 699 # before the rules that use that variable to build the image. 700 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 701 $(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 702 $(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME) 703 $(hide) rm -f $@ 704 $(hide) mkdir -p $(dir $@) 705 $(hide) zip -qjX $@ $< 706 $(remove-timestamps-from-package) 707 708 # Carry the public key for update_engine if it's a non-Brillo target that 709 # uses the AB updater. We use the same key as otacerts but in RSA public key 710 # format. 711 ifeq ($(AB_OTA_UPDATER),true) 712 ifeq ($(BRILLO),) 713 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem 714 $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) 715 $(hide) rm -f $@ 716 $(hide) mkdir -p $(dir $@) 717 $(hide) openssl x509 -pubkey -noout -in $< > $@ 718 719 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem 720 $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem: $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem 721 $(hide) cp -f $< $@ 722 endif 723 endif 724 725 .PHONY: otacerts 726 otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip 727 728 729 # ################################################################# 730 # Targets for user images 731 # ################################################################# 732 733 INTERNAL_USERIMAGES_EXT_VARIANT := 734 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 735 INTERNAL_USERIMAGES_USE_EXT := true 736 INTERNAL_USERIMAGES_EXT_VARIANT := ext2 737 else 738 ifeq ($(TARGET_USERIMAGES_USE_EXT3),true) 739 INTERNAL_USERIMAGES_USE_EXT := true 740 INTERNAL_USERIMAGES_EXT_VARIANT := ext3 741 else 742 ifeq ($(TARGET_USERIMAGES_USE_EXT4),true) 743 INTERNAL_USERIMAGES_USE_EXT := true 744 INTERNAL_USERIMAGES_EXT_VARIANT := ext4 745 endif 746 endif 747 endif 748 749 # These options tell the recovery updater/installer how to mount the partitions writebale. 750 # <fstype>=<fstype_opts>[|<fstype_opts>]... 751 # fstype_opts := <opt>[,<opt>]... 752 # opt := <name>[=<value>] 753 # The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10 754 DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc 755 756 ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)) 757 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s 758 endif 759 760 ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true) 761 INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG) 762 INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK) 763 ifeq ($(TARGET_USERIMAGES_USE_F2FS),true) 764 INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS) 765 endif 766 endif 767 768 ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)) 769 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s 770 endif 771 ifneq ($(filter $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),) 772 INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG) 773 endif 774 775 INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS))) 776 777 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) 778 INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER) 779 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC)) 780 INTERNAL_USERIMAGES_DEPS += $(FEC) 781 endif 782 endif 783 784 SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts.bin 785 INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC) 786 787 INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS) 788 789 # $(1): the path of the output dictionary file 790 # $(2): additional "key=value" pairs to append to the dictionary file. 791 define generate-userimage-prop-dictionary 792 $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1)) 793 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1)) 794 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 795 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1)) 796 $(if $(BOARD_HAS_EXT4_RESERVED_BLOCKS),$(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(1)) 797 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1)) 798 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1)) 799 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1)) 800 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1)) 801 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1)) 802 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 803 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1)) 804 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 805 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1)) 806 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 807 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1)) 808 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1)) 809 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1)) 810 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1)) 811 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1)) 812 $(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1)) 813 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1)) 814 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1)) 815 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1)) 816 $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1)) 817 $(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1)) 818 $(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1) 819 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1)) 820 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1)) 821 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1)) 822 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1)) 823 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1)) 824 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1)) 825 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1)) 826 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1)) 827 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY)" >> $(1)) 828 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1)) 829 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(FUTILITY)" >> $(1)) 830 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1)) 831 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\ 832 $(hide) echo "recovery_as_boot=true" >> $(1)) 833 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\ 834 $(hide) echo "system_root_image=true" >> $(1);\ 835 echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1)) 836 $(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);)) 837 endef 838 839 # ----------------------------------------------------------------- 840 # Recovery image 841 842 # Recovery image exists if we are building recovery, or building recovery as boot. 843 ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))) 844 845 INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \ 846 $(ALL_DEFAULT_INSTALLED_MODULES)) 847 848 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 849 recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery 850 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 851 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 852 recovery_build_prop := $(intermediate_system_build_prop) 853 recovery_resources_common := $(call include-path-for, recovery)/res 854 855 # Set recovery_density to the density bucket of the device. 856 recovery_density := unknown 857 ifneq (,$(PRODUCT_AAPT_PREF_CONFIG)) 858 # If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value. 859 recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG)) 860 else 861 # Otherwise, use the default medium density. 862 recovery_densities := mdpi 863 endif 864 865 ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density))) 866 recovery_resources_common := $(recovery_resources_common)-$(recovery_density) 867 else 868 recovery_resources_common := $(recovery_resources_common)-xhdpi 869 endif 870 871 # Select the 18x32 font on high-density devices (xhdpi and up); and 872 # the 12x22 font on other devices. Note that the font selected here 873 # can be overridden for a particular device by putting a font.png in 874 # its private recovery resources. 875 876 ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density))) 877 recovery_font := $(call include-path-for, recovery)/fonts/18x32.png 878 else 879 recovery_font := $(call include-path-for, recovery)/fonts/12x22.png 880 endif 881 882 ifndef TARGET_PRIVATE_RES_DIRS 883 TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res) 884 endif 885 recovery_resource_deps := $(shell find $(recovery_resources_common) \ 886 $(TARGET_PRIVATE_RES_DIRS) -type f) 887 ifdef TARGET_RECOVERY_FSTAB 888 recovery_fstab := $(TARGET_RECOVERY_FSTAB) 889 else 890 recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab)) 891 endif 892 ifdef TARGET_RECOVERY_WIPE 893 recovery_wipe := $(TARGET_RECOVERY_WIPE) 894 else 895 recovery_wipe := 896 endif 897 898 # Prior to A/B update, we used to have: 899 # boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img. 900 # recovery-resource.dat is needed only if we carry a patch of the boot and 901 # recovery images and invoke install-recovery.sh on the first boot post an 902 # OTA update. 903 # 904 # We no longer need that if one of the following conditions holds: 905 # a) We carry a full copy of the recovery image 906 # (BOARD_USES_FULL_RECOVERY_IMAGE = true); 907 # b) We build a single image that contains boot and recovery both 908 # (BOARD_USES_RECOVERY_AS_BOOT = true). 909 910 ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT))) 911 # Named '.dat' so we don't attempt to use imgdiff for patching it. 912 RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat 913 else 914 RECOVERY_RESOURCE_ZIP := 915 endif 916 917 ifeq ($(TARGET_PRIVATE_RES_DIRS),) 918 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) 919 endif 920 921 ifeq ($(recovery_fstab),) 922 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE)) 923 endif 924 925 INTERNAL_RECOVERYIMAGE_ARGS := \ 926 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 927 --kernel $(recovery_kernel) \ 928 --ramdisk $(recovery_ramdisk) 929 930 # Assumes this has already been stripped 931 ifdef BOARD_KERNEL_CMDLINE 932 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 933 endif 934 ifdef BOARD_KERNEL_BASE 935 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 936 endif 937 BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE)) 938 ifdef BOARD_KERNEL_PAGESIZE 939 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE) 940 endif 941 942 # Keys authorized to sign OTA packages this build will accept. The 943 # build always uses dev-keys for this; release packaging tools will 944 # substitute other keys for this one. 945 OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem 946 947 # Generate a file containing the keys that will be read by the 948 # recovery binary. 949 RECOVERY_INSTALL_OTA_KEYS := \ 950 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys 951 DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar 952 $(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS) 953 $(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS)) 954 $(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys) 955 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)" 956 @rm -rf $@ 957 @mkdir -p $(dir $@) 958 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@ 959 960 RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id 961 # $(1): output file 962 define build-recoveryimage-target 963 @echo ----- Making recovery image ------ 964 $(hide) mkdir -p $(TARGET_RECOVERY_OUT) 965 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp 966 @echo Copying baseline ramdisk... 967 $(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac. 968 @echo Modifying ramdisk contents... 969 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc 970 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ 971 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy 972 $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy 973 $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist. 974 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res 975 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/* 976 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res 977 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png 978 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \ 979 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline)) 980 $(hide) $(foreach item,$(recovery_fstab), \ 981 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab) 982 $(if $(strip $(recovery_wipe)), \ 983 $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe) 984 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys 985 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \ 986 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop 987 $(BOARD_RECOVERY_IMAGE_PREPARE) 988 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \ 989 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \ 990 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/system; \ 991 ln -sf /system_root/system $(TARGET_RECOVERY_ROOT_OUT)/system) # Mount the system_root_image to /system_root and symlink /system. 992 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk) 993 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \ 994 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \ 995 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1) --id > $(RECOVERYIMAGE_ID_FILE)) 996 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\ 997 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\ 998 $(BOOT_SIGNER) /boot $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\ 999 $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\ 1000 )\ 1001 ) 1002 $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \ 1003 $(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)) 1004 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \ 1005 $(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \ 1006 $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))) 1007 @echo ----- Made recovery image: $(1) -------- 1008 endef 1009 1010 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) 1011 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) 1012 $(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER) 1013 endif 1014 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) 1015 $(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER) 1016 endif 1017 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \ 1018 $(INSTALLED_RAMDISK_TARGET) \ 1019 $(INTERNAL_RECOVERYIMAGE_FILES) \ 1020 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \ 1021 $(INSTALLED_2NDBOOTLOADER_TARGET) \ 1022 $(recovery_build_prop) $(recovery_resource_deps) \ 1023 $(recovery_fstab) \ 1024 $(RECOVERY_INSTALL_OTA_KEYS) 1025 $(call pretty,"Target boot image from recovery: $@") 1026 $(call build-recoveryimage-target, $@) 1027 endif 1028 1029 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \ 1030 $(INSTALLED_RAMDISK_TARGET) \ 1031 $(INSTALLED_BOOTIMAGE_TARGET) \ 1032 $(INTERNAL_RECOVERYIMAGE_FILES) \ 1033 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \ 1034 $(INSTALLED_2NDBOOTLOADER_TARGET) \ 1035 $(recovery_build_prop) $(recovery_resource_deps) \ 1036 $(recovery_fstab) \ 1037 $(RECOVERY_INSTALL_OTA_KEYS) 1038 $(call build-recoveryimage-target, $@) 1039 1040 ifdef RECOVERY_RESOURCE_ZIP 1041 $(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME) 1042 $(hide) mkdir -p $(dir $@) 1043 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@ 1044 $(remove-timestamps-from-package) 1045 endif 1046 1047 .PHONY: recoveryimage-nodeps 1048 recoveryimage-nodeps: 1049 @echo "make $@: ignoring dependencies" 1050 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET)) 1051 1052 else # INSTALLED_RECOVERYIMAGE_TARGET not defined 1053 RECOVERY_RESOURCE_ZIP := 1054 endif 1055 1056 .PHONY: recoveryimage 1057 recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP) 1058 1059 ifeq ($(BOARD_NAND_PAGE_SIZE),) 1060 BOARD_NAND_PAGE_SIZE := 2048 1061 endif 1062 1063 ifeq ($(BOARD_NAND_SPARE_SIZE),) 1064 BOARD_NAND_SPARE_SIZE := 64 1065 endif 1066 1067 # ----------------------------------------------------------------- 1068 # system image 1069 # 1070 # Remove overridden packages from $(ALL_PDK_FUSION_FILES) 1071 PDK_FUSION_SYSIMG_FILES := \ 1072 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \ 1073 $(ALL_PDK_FUSION_FILES)) 1074 1075 INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 1076 $(ALL_PREBUILT) \ 1077 $(ALL_GENERATED_SOURCES) \ 1078 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1079 $(PDK_FUSION_SYSIMG_FILES) \ 1080 $(RECOVERY_RESOURCE_ZIP)) 1081 1082 1083 FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS) 1084 # ----------------------------------------------------------------- 1085 # installed file list 1086 # Depending on anything that $(BUILT_SYSTEMIMAGE) depends on. 1087 # We put installed-files.txt ahead of image itself in the dependency graph 1088 # so that we can get the size stat even if the build fails due to too large 1089 # system image. 1090 INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 1091 $(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) 1092 @echo Installed file list: $@ 1093 @mkdir -p $(dir $@) 1094 @rm -f $@ 1095 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@ 1096 1097 .PHONY: installed-file-list 1098 installed-file-list: $(INSTALLED_FILES_FILE) 1099 1100 $(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE)) 1101 1102 systemimage_intermediates := \ 1103 $(call intermediates-dir-for,PACKAGING,systemimage) 1104 BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img 1105 1106 # Create symlink /system/vendor to /vendor if necessary. 1107 ifdef BOARD_USES_VENDORIMAGE 1108 define create-system-vendor-symlink 1109 $(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \ 1110 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \ 1111 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \ 1112 exit 1; \ 1113 fi 1114 $(hide) ln -sf /vendor $(TARGET_OUT)/vendor 1115 endef 1116 else 1117 define create-system-vendor-symlink 1118 endef 1119 endif 1120 1121 # $(1): output file 1122 define build-systemimage-target 1123 @echo "Target system fs image: $(1)" 1124 $(call create-system-vendor-symlink) 1125 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt 1126 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \ 1127 skip_fsck=true) 1128 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1129 ./build/tools/releasetools/build_image.py \ 1130 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \ 1131 || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\ 1132 du -sm $(TARGET_OUT) 1>&2;\ 1133 if [ "$(INTERNAL_USERIMAGES_EXT_VARIANT)" == "ext4" ]; then \ 1134 maxsize=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE); \ 1135 if [ "$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" == "true" ]; then \ 1136 maxsize=$$((maxsize - 4096 * 4096)); \ 1137 fi; \ 1138 echo "The max is $$(( maxsize / 1048576 )) MB." 1>&2 ;\ 1139 else \ 1140 echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\ 1141 fi; \ 1142 mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \ 1143 exit 1 ) 1144 endef 1145 1146 $(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) 1147 $(call build-systemimage-target,$@) 1148 1149 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 1150 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 1151 1152 # The system partition needs room for the recovery image as well. We 1153 # now store the recovery image as a binary patch using the boot image 1154 # as the source (since they are very similar). Generate the patch so 1155 # we can see how big it's going to be, and include that in the system 1156 # image size check calculation. 1157 ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) 1158 ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true) 1159 intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch) 1160 RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p 1161 $(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \ 1162 $(INSTALLED_BOOTIMAGE_TARGET) \ 1163 $(HOST_OUT_EXECUTABLES)/imgdiff \ 1164 $(HOST_OUT_EXECUTABLES)/bsdiff 1165 @echo "Construct recovery from boot" 1166 mkdir -p $(dir $@) 1167 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@ 1168 else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true 1169 RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET) 1170 endif 1171 endif 1172 1173 1174 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP) 1175 @echo "Install system fs image: $@" 1176 $(copy-file-to-target) 1177 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) 1178 1179 systemimage: $(INSTALLED_SYSTEMIMAGE) 1180 1181 .PHONY: systemimage-nodeps snod 1182 systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \ 1183 | $(INTERNAL_USERIMAGES_DEPS) 1184 @echo "make $@: ignoring dependencies" 1185 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE)) 1186 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) 1187 1188 ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS))) 1189 ifeq (true,$(WITH_DEXPREOPT)) 1190 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.) 1191 endif 1192 endif 1193 1194 ####### 1195 ## system tarball 1196 define build-systemtarball-target 1197 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)") 1198 $(call create-system-vendor-symlink) 1199 $(MKTARBALL) $(FS_GET_STATS) \ 1200 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \ 1201 $(INSTALLED_SYSTEMTARBALL_TARGET) $(TARGET_OUT) 1202 endef 1203 1204 ifndef SYSTEM_TARBALL_FORMAT 1205 SYSTEM_TARBALL_FORMAT := bz2 1206 endif 1207 1208 system_tar := $(PRODUCT_OUT)/system.tar 1209 INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT) 1210 $(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar) 1211 $(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES) 1212 $(build-systemtarball-target) 1213 1214 .PHONY: systemtarball-nodeps 1215 systemtarball-nodeps: $(FS_GET_STATS) \ 1216 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 1217 $(build-systemtarball-target) 1218 1219 .PHONY: stnod 1220 stnod: systemtarball-nodeps 1221 1222 # ----------------------------------------------------------------- 1223 ## platform.zip: system, plus other files to be used in PDK fusion build, 1224 ## in a zip file 1225 ## 1226 ## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip. 1227 ## The variable will be typically set from BoardConfig.mk. 1228 ## Files under out dir will be rejected to prevent possible conflicts with other rules. 1229 pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\ 1230 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m)))) 1231 pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\ 1232 $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m)))) 1233 pdk_classes_dex := $(strip \ 1234 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \ 1235 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)) 1236 1237 pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk 1238 $(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs) 1239 $(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps) 1240 $(pdk_odex_config_mk) : 1241 @echo "PDK odex config makefile: $@" 1242 $(hide) mkdir -p $(dir $@) 1243 $(hide) echo "# Auto-generated. Do not modify." > $@ 1244 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@ 1245 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@ 1246 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\ 1247 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\ 1248 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\ 1249 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\ 1250 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\ 1251 ) 1252 $(foreach m,$(PRIVATE_APPS),\ 1253 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\ 1254 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\ 1255 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\ 1256 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\ 1257 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\ 1258 $(hide) echo "PDK.DEXPREOPT.$(m).PROPRIETARY_MODULE:=$(DEXPREOPT.$(m).PROPRIETARY_MODULE)" >> $@$(newline)\ 1259 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\ 1260 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\ 1261 ) 1262 1263 PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)) 1264 INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip 1265 1266 $(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex) 1267 $(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk) 1268 $(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk) 1269 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)") 1270 $(hide) rm -f $@ 1271 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \ 1272 $(TARGET_COPY_OUT_SYSTEM) \ 1273 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \ 1274 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST)) 1275 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1276 $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \ 1277 $(TARGET_COPY_OUT_VENDOR) 1278 endif 1279 ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),) 1280 $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS) 1281 endif 1282 ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),) 1283 $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES) 1284 endif 1285 @# Add dex-preopt files and config. 1286 $(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES))) 1287 $(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG) 1288 1289 .PHONY: platform 1290 platform: $(INSTALLED_PLATFORM_ZIP) 1291 1292 .PHONY: platform-java 1293 platform-java: platform 1294 1295 # Dist the platform.zip 1296 ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))) 1297 $(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP)) 1298 endif 1299 1300 # ----------------------------------------------------------------- 1301 ## boot tarball 1302 define build-boottarball-target 1303 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)" 1304 $(hide) mkdir -p $(PRODUCT_OUT)/boot 1305 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/. 1306 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline 1307 $(hide) $(MKTARBALL) $(FS_GET_STATS) \ 1308 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \ 1309 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT) 1310 endef 1311 1312 ifndef BOOT_TARBALL_FORMAT 1313 BOOT_TARBALL_FORMAT := bz2 1314 endif 1315 1316 boot_tar := $(PRODUCT_OUT)/boot.tar 1317 INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT) 1318 $(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar) 1319 $(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES) 1320 $(build-boottarball-target) 1321 1322 .PHONY: boottarball-nodeps btnod 1323 boottarball-nodeps btnod: $(FS_GET_STATS) \ 1324 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS)) 1325 $(build-boottarball-target) 1326 1327 1328 # ----------------------------------------------------------------- 1329 # data partition image 1330 INTERNAL_USERDATAIMAGE_FILES := \ 1331 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 1332 1333 # Don't build userdata.img if it's extfs but no partition size 1334 skip_userdata.img := 1335 ifdef INTERNAL_USERIMAGES_EXT_VARIANT 1336 ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE 1337 skip_userdata.img := true 1338 endif 1339 endif 1340 1341 ifneq ($(skip_userdata.img),true) 1342 userdataimage_intermediates := \ 1343 $(call intermediates-dir-for,PACKAGING,userdata) 1344 BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 1345 1346 define build-userdataimage-target 1347 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 1348 @mkdir -p $(TARGET_OUT_DATA) 1349 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt 1350 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true) 1351 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1352 ./build/tools/releasetools/build_image.py \ 1353 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT) 1354 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE)) 1355 endef 1356 1357 # We just build this directly to the install location. 1358 INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) 1359 $(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \ 1360 $(INTERNAL_USERDATAIMAGE_FILES) 1361 $(build-userdataimage-target) 1362 1363 .PHONY: userdataimage-nodeps 1364 userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1365 $(build-userdataimage-target) 1366 1367 endif # not skip_userdata.img 1368 skip_userdata.img := 1369 1370 ####### 1371 ## data partition tarball 1372 define build-userdatatarball-target 1373 $(call pretty,"Target userdata fs tarball: " \ 1374 "$(INSTALLED_USERDATATARBALL_TARGET)") 1375 $(MKTARBALL) $(FS_GET_STATS) \ 1376 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \ 1377 $(INSTALLED_USERDATATARBALL_TARGET) $(TARGET_OUT) 1378 endef 1379 1380 userdata_tar := $(PRODUCT_OUT)/userdata.tar 1381 INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2 1382 $(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar) 1383 $(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES) 1384 $(build-userdatatarball-target) 1385 1386 $(call dist-for-goals,userdatatarball,$(INSTALLED_USERDATATARBALL_TARGET)) 1387 1388 .PHONY: userdatatarball-nodeps 1389 userdatatarball-nodeps: $(FS_GET_STATS) 1390 $(build-userdatatarball-target) 1391 1392 1393 # ----------------------------------------------------------------- 1394 # cache partition image 1395 ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE 1396 INTERNAL_CACHEIMAGE_FILES := \ 1397 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 1398 1399 cacheimage_intermediates := \ 1400 $(call intermediates-dir-for,PACKAGING,cache) 1401 BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img 1402 1403 define build-cacheimage-target 1404 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)") 1405 @mkdir -p $(TARGET_OUT_CACHE) 1406 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt 1407 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true) 1408 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1409 ./build/tools/releasetools/build_image.py \ 1410 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT) 1411 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE)) 1412 endef 1413 1414 # We just build this directly to the install location. 1415 INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET) 1416 $(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) 1417 $(build-cacheimage-target) 1418 1419 .PHONY: cacheimage-nodeps 1420 cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1421 $(build-cacheimage-target) 1422 1423 else # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE 1424 # we need to ignore the broken cache link when doing the rsync 1425 IGNORE_CACHE_LINK := --exclude=cache 1426 endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE 1427 1428 1429 # ----------------------------------------------------------------- 1430 # system_other partition image 1431 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) 1432 BOARD_USES_SYSTEM_OTHER := true 1433 1434 # Marker file to identify that odex files are installed 1435 INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker 1436 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER) 1437 $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER): 1438 $(hide) touch $@ 1439 endif 1440 1441 ifdef BOARD_USES_SYSTEM_OTHER 1442 INTERNAL_SYSTEMOTHERIMAGE_FILES := \ 1443 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\ 1444 $(ALL_DEFAULT_INSTALLED_MODULES)\ 1445 $(ALL_PDK_FUSION_FILES)) 1446 1447 INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt 1448 $(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) 1449 @echo Installed file list: $@ 1450 @mkdir -p $(dir $@) 1451 @rm -f $@ 1452 $(hide) build/tools/fileslist.py $(TARGET_OUT_SYSTEM_OTHER) > $@ 1453 1454 systemotherimage_intermediates := \ 1455 $(call intermediates-dir-for,PACKAGING,system_other) 1456 BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img 1457 1458 # Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image. 1459 define build-systemotherimage-target 1460 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)") 1461 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER) 1462 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt 1463 $(call generate-userimage-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt, skip_fsck=true) 1464 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1465 ./build/tools/releasetools/build_image.py \ 1466 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT) 1467 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) 1468 endef 1469 1470 # We just build this directly to the install location. 1471 INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET) 1472 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER) 1473 $(build-systemotherimage-target) 1474 1475 .PHONY: systemotherimage-nodeps 1476 systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1477 $(build-systemotherimage-target) 1478 1479 endif # BOARD_USES_SYSTEM_OTHER 1480 1481 1482 # ----------------------------------------------------------------- 1483 # vendor partition image 1484 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1485 INTERNAL_VENDORIMAGE_FILES := \ 1486 $(filter $(TARGET_OUT_VENDOR)/%,\ 1487 $(ALL_DEFAULT_INSTALLED_MODULES)\ 1488 $(ALL_PDK_FUSION_FILES)) 1489 1490 # platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES). 1491 $(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES) 1492 1493 INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt 1494 $(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) 1495 @echo Installed file list: $@ 1496 @mkdir -p $(dir $@) 1497 @rm -f $@ 1498 $(hide) build/tools/fileslist.py $(TARGET_OUT_VENDOR) > $@ 1499 1500 vendorimage_intermediates := \ 1501 $(call intermediates-dir-for,PACKAGING,vendor) 1502 BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img 1503 1504 define build-vendorimage-target 1505 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)") 1506 @mkdir -p $(TARGET_OUT_VENDOR) 1507 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt 1508 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true) 1509 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1510 ./build/tools/releasetools/build_image.py \ 1511 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT) 1512 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE)) 1513 endef 1514 1515 # We just build this directly to the install location. 1516 INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET) 1517 $(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR) 1518 $(build-vendorimage-target) 1519 1520 .PHONY: vendorimage-nodeps 1521 vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1522 $(build-vendorimage-target) 1523 1524 else ifdef BOARD_PREBUILT_VENDORIMAGE 1525 INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img 1526 $(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET))) 1527 endif 1528 1529 # ----------------------------------------------------------------- 1530 # bring in the installer image generation defines if necessary 1531 ifeq ($(TARGET_USE_DISKINSTALLER),true) 1532 include bootable/diskinstaller/config.mk 1533 endif 1534 1535 # ----------------------------------------------------------------- 1536 # host tools needed to build dist and OTA packages 1537 1538 build_ota_package := true 1539 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true) 1540 build_ota_package := false 1541 endif 1542 ifeq ($(BUILD_OS),darwin) 1543 build_ota_package := false 1544 endif 1545 ifneq ($(strip $(SANITIZE_TARGET)),) 1546 build_ota_package := false 1547 endif 1548 ifeq ($(TARGET_PRODUCT),sdk) 1549 build_ota_package := false 1550 endif 1551 ifneq ($(filter generic%,$(TARGET_DEVICE)),) 1552 build_ota_package := false 1553 endif 1554 ifeq ($(TARGET_NO_KERNEL),true) 1555 build_ota_package := false 1556 endif 1557 ifeq ($(recovery_fstab),) 1558 build_ota_package := false 1559 endif 1560 ifeq ($(TARGET_BUILD_PDK),true) 1561 build_ota_package := false 1562 endif 1563 1564 ifeq ($(build_ota_package),true) 1565 OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ 1566 $(HOST_OUT_EXECUTABLES)/aapt \ 1567 $(HOST_OUT_EXECUTABLES)/mkbootfs \ 1568 $(HOST_OUT_EXECUTABLES)/mkbootimg \ 1569 $(HOST_OUT_EXECUTABLES)/fs_config \ 1570 $(HOST_OUT_EXECUTABLES)/zipalign \ 1571 $(HOST_OUT_EXECUTABLES)/bsdiff \ 1572 $(HOST_OUT_EXECUTABLES)/imgdiff \ 1573 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \ 1574 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \ 1575 $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \ 1576 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \ 1577 $(HOST_OUT_EXECUTABLES)/make_ext4fs \ 1578 $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \ 1579 $(HOST_OUT_EXECUTABLES)/mksquashfs \ 1580 $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \ 1581 $(HOST_OUT_EXECUTABLES)/make_f2fs \ 1582 $(HOST_OUT_EXECUTABLES)/simg2img \ 1583 $(HOST_OUT_EXECUTABLES)/e2fsck \ 1584 $(HOST_OUT_EXECUTABLES)/build_verity_tree \ 1585 $(HOST_OUT_EXECUTABLES)/verity_signer \ 1586 $(HOST_OUT_EXECUTABLES)/append2simg \ 1587 $(HOST_OUT_EXECUTABLES)/img2simg \ 1588 $(HOST_OUT_EXECUTABLES)/boot_signer \ 1589 $(HOST_OUT_EXECUTABLES)/fec \ 1590 $(HOST_OUT_EXECUTABLES)/brillo_update_payload \ 1591 $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \ 1592 $(HOST_OUT_EXECUTABLES)/delta_generator \ 1593 $(BLK_ALLOC_TO_BASE_FS) 1594 1595 # Shared libraries. 1596 OTATOOLS += \ 1597 $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \ 1598 $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \ 1599 $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \ 1600 $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \ 1601 $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \ 1602 $(HOST_LIBRARY_PATH)/libdivsufsort$(HOST_SHLIB_SUFFIX) \ 1603 $(HOST_LIBRARY_PATH)/libdivsufsort64$(HOST_SHLIB_SUFFIX) \ 1604 $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \ 1605 $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \ 1606 $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \ 1607 $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \ 1608 $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \ 1609 $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \ 1610 $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \ 1611 $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \ 1612 $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \ 1613 $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \ 1614 $(HOST_LIBRARY_PATH)/libbrillo-http$(HOST_SHLIB_SUFFIX) \ 1615 $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \ 1616 $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \ 1617 $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \ 1618 $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \ 1619 $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \ 1620 $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \ 1621 $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) 1622 1623 .PHONY: otatools 1624 otatools: $(OTATOOLS) 1625 1626 BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip 1627 $(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools 1628 1629 $(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) | $(ACP) 1630 @echo "Package OTA tools: $@" 1631 $(hide) rm -rf $@ $(zip_root) 1632 $(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity 1633 $(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root)) 1634 $(hide) $(ACP) $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar $(zip_root)/framework/ 1635 $(hide) $(ACP) -p system/extras/verity/build_verity_metadata.py $(zip_root)/system/extras/verity/ 1636 $(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools 1637 $(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc 1638 $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *) 1639 $(hide) zip -qryX $(abspath $@) build/target/product/security/ 1640 $(hide) find device vendor -name \*.pk8 -o -name verifiedboot\* -o -name \*.x509.pem -o -name oem\*.prop | xargs zip -qryX $(abspath $@)>/dev/null || true 1641 1642 .PHONY: otatools-package 1643 otatools-package: $(BUILT_OTATOOLS_PACKAGE) 1644 1645 endif # build_ota_package 1646 1647 # ----------------------------------------------------------------- 1648 # A zip of the directories that map to the target filesystem. 1649 # This zip can be used to create an OTA package or filesystem image 1650 # as a post-build step. 1651 # 1652 name := $(TARGET_PRODUCT) 1653 ifeq ($(TARGET_BUILD_TYPE),debug) 1654 name := $(name)_debug 1655 endif 1656 name := $(name)-target_files-$(FILE_NAME_TAG) 1657 1658 intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 1659 BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 1660 $(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 1661 $(BUILT_TARGET_FILES_PACKAGE): \ 1662 zip_root := $(intermediates)/$(name) 1663 1664 # $(1): Directory to copy 1665 # $(2): Location to copy it to 1666 # The "ls -A" is to prevent "acp s/* d" from failing if s is empty. 1667 define package_files-copy-root 1668 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 1669 mkdir -p $(2) && \ 1670 $(ACP) -rd $(strip $(1))/* $(2); \ 1671 fi 1672 endef 1673 1674 built_ota_tools := 1675 1676 # We can't build static executables when SANITIZE_TARGET=address 1677 ifeq ($(strip $(SANITIZE_TARGET)),) 1678 built_ota_tools += \ 1679 $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater 1680 endif 1681 1682 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools) 1683 1684 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION) 1685 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION) 1686 1687 ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),) 1688 # default to common dir for device vendor 1689 $(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common 1690 else 1691 $(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS) 1692 endif 1693 1694 # Build OTA tools if not using the AB Updater. 1695 ifneq ($(AB_OTA_UPDATER),true) 1696 $(BUILT_TARGET_FILES_PACKAGE): $(built_ota_tools) 1697 endif 1698 1699 # If we are using recovery as boot, output recovery files to BOOT/. 1700 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) 1701 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT 1702 else 1703 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY 1704 endif 1705 1706 # Depending on the various images guarantees that the underlying 1707 # directories are up-to-date. 1708 $(BUILT_TARGET_FILES_PACKAGE): \ 1709 $(INSTALLED_BOOTIMAGE_TARGET) \ 1710 $(INSTALLED_RADIOIMAGE_TARGET) \ 1711 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 1712 $(INSTALLED_SYSTEMIMAGE) \ 1713 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1714 $(INSTALLED_CACHEIMAGE_TARGET) \ 1715 $(INSTALLED_VENDORIMAGE_TARGET) \ 1716 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \ 1717 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 1718 $(SELINUX_FC) \ 1719 $(APKCERTS_FILE) \ 1720 $(HOST_OUT_EXECUTABLES)/fs_config \ 1721 | $(ACP) 1722 @echo "Package target files: $@" 1723 $(hide) rm -rf $@ $(zip_root) 1724 $(hide) mkdir -p $(dir $@) $(zip_root) 1725 ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))) 1726 @# Components of the recovery image 1727 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT) 1728 $(hide) $(call package_files-copy-root, \ 1729 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK) 1730 ifdef INSTALLED_KERNEL_TARGET 1731 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel 1732 endif 1733 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1734 $(hide) $(ACP) \ 1735 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second 1736 endif 1737 ifdef BOARD_KERNEL_CMDLINE 1738 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline 1739 endif 1740 ifdef BOARD_KERNEL_BASE 1741 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base 1742 endif 1743 ifdef BOARD_KERNEL_PAGESIZE 1744 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize 1745 endif 1746 endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true 1747 @# Components of the boot image 1748 $(hide) mkdir -p $(zip_root)/BOOT 1749 ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) 1750 $(hide) mkdir -p $(zip_root)/ROOT 1751 $(hide) $(call package_files-copy-root, \ 1752 $(TARGET_ROOT_OUT),$(zip_root)/ROOT) 1753 else 1754 $(hide) $(call package_files-copy-root, \ 1755 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) 1756 endif 1757 @# If we are using recovery as boot, this is already done when processing recovery. 1758 ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true) 1759 ifdef INSTALLED_KERNEL_TARGET 1760 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 1761 endif 1762 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1763 $(hide) $(ACP) \ 1764 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 1765 endif 1766 ifdef BOARD_KERNEL_CMDLINE 1767 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 1768 endif 1769 ifdef BOARD_KERNEL_BASE 1770 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base 1771 endif 1772 ifdef BOARD_KERNEL_PAGESIZE 1773 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize 1774 endif 1775 endif # BOARD_USES_RECOVERY_AS_BOOT 1776 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\ 1777 mkdir -p $(zip_root)/RADIO; \ 1778 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));) 1779 @# Contents of the system image 1780 $(hide) $(call package_files-copy-root, \ 1781 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) 1782 @# Contents of the data image 1783 $(hide) $(call package_files-copy-root, \ 1784 $(TARGET_OUT_DATA),$(zip_root)/DATA) 1785 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1786 @# Contents of the vendor image 1787 $(hide) $(call package_files-copy-root, \ 1788 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR) 1789 endif 1790 ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET 1791 @# Contents of the system_other image 1792 $(hide) $(call package_files-copy-root, \ 1793 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER) 1794 endif 1795 @# Extra contents of the OTA package 1796 $(hide) mkdir -p $(zip_root)/OTA 1797 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/ 1798 ifneq ($(AB_OTA_UPDATER),true) 1799 ifneq ($(built_ota_tools),) 1800 $(hide) mkdir -p $(zip_root)/OTA/bin 1801 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ 1802 endif 1803 endif 1804 @# Files that do not end up in any images, but are necessary to 1805 @# build them. 1806 $(hide) mkdir -p $(zip_root)/META 1807 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt 1808 $(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi 1809 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt 1810 $(hide) $(ACP) $(SELINUX_FC) $(zip_root)/META/file_contexts.bin 1811 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt 1812 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt 1813 ifdef BOARD_FLASH_BLOCK_SIZE 1814 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt 1815 endif 1816 ifdef BOARD_BOOTIMAGE_PARTITION_SIZE 1817 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt 1818 endif 1819 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),) 1820 $(hide) echo "recovery_as_boot=$(BOARD_USES_RECOVERY_AS_BOOT)" >> $(zip_root)/META/misc_info.txt 1821 endif 1822 ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),) 1823 $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt 1824 endif 1825 ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE 1826 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt 1827 endif 1828 ifdef BOARD_HAS_EXT4_RESERVED_BLOCKS 1829 $(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(zip_root)/META/misc_info.txt 1830 endif 1831 ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS 1832 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used. 1833 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt 1834 else 1835 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt 1836 endif 1837 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt 1838 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt 1839 ifdef PRODUCT_EXTRA_RECOVERY_KEYS 1840 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt 1841 endif 1842 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt 1843 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt 1844 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt 1845 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt 1846 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt 1847 $(hide) echo "blockimgdiff_versions=1,2,3,4" >> $(zip_root)/META/misc_info.txt 1848 ifneq ($(OEM_THUMBPRINT_PROPERTIES),) 1849 # OTA scripts are only interested in fingerprint related properties 1850 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt 1851 endif 1852 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),) 1853 $(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \ 1854 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)) 1855 endif 1856 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),) 1857 $(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \ 1858 $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)) 1859 endif 1860 ifneq ($(strip $(SANITIZE_TARGET)),) 1861 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img. 1862 $(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt 1863 endif 1864 ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true) 1865 $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt 1866 endif 1867 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt) 1868 ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) 1869 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ 1870 ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root) 1871 endif 1872 ifeq ($(AB_OTA_UPDATER),true) 1873 @# When using the A/B updater, include the updater config files in the zip. 1874 $(hide) $(ACP) $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt 1875 $(hide) for part in $(AB_OTA_PARTITIONS); do \ 1876 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \ 1877 done 1878 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \ 1879 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \ 1880 done 1881 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds. 1882 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt 1883 $(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt 1884 ifdef OSRELEASED_DIRECTORY 1885 $(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt 1886 $(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt 1887 endif 1888 endif 1889 ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true) 1890 @# If breakpad symbols have been generated, add them to the zip. 1891 $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD 1892 endif 1893 ifdef BOARD_PREBUILT_VENDORIMAGE 1894 $(hide) mkdir -p $(zip_root)/IMAGES 1895 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/ 1896 endif 1897 @# Zip everything up, preserving symlinks and placing META/ files first to 1898 @# help early validation of the .zip file while uploading it. 1899 $(hide) (cd $(zip_root) && \ 1900 zip -qryX ../$(notdir $@) ./META && \ 1901 zip -qryXu ../$(notdir $@) .) 1902 @# Run fs_config on all the system, vendor, boot ramdisk, 1903 @# and recovery ramdisk files in the zip, and save the output 1904 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt 1905 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt 1906 ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) 1907 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="ROOT/" } /^ROOT\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/root_filesystem_config.txt 1908 endif 1909 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt 1910 ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) 1911 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt 1912 endif 1913 ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET 1914 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM_OTHER/" } /^SYSTEM_OTHER\// { print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/system_other_filesystem_config.txt 1915 endif 1916 $(hide) (cd $(zip_root) && zip -qX ../$(notdir $@) META/*filesystem_config.txt) 1917 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ 1918 ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $@ 1919 1920 .PHONY: target-files-package 1921 target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 1922 1923 ifneq ($(filter $(MAKECMDGOALS),target-files-package),) 1924 $(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE)) 1925 endif 1926 1927 ifeq ($(build_ota_package),true) 1928 # ----------------------------------------------------------------- 1929 # OTA update package 1930 1931 name := $(TARGET_PRODUCT) 1932 ifeq ($(TARGET_BUILD_TYPE),debug) 1933 name := $(name)_debug 1934 endif 1935 name := $(name)-ota-$(FILE_NAME_TAG) 1936 1937 INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1938 1939 $(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 1940 1941 $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) 1942 @echo "Package OTA: $@" 1943 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ 1944 ./build/tools/releasetools/ota_from_target_files -v \ 1945 --block \ 1946 -p $(HOST_OUT) \ 1947 -k $(KEY_CERT_PAIR) \ 1948 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \ 1949 $(BUILT_TARGET_FILES_PACKAGE) $@ 1950 1951 .PHONY: otapackage 1952 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 1953 1954 endif # build_ota_package 1955 1956 # ----------------------------------------------------------------- 1957 # The update package 1958 1959 name := $(TARGET_PRODUCT) 1960 ifeq ($(TARGET_BUILD_TYPE),debug) 1961 name := $(name)_debug 1962 endif 1963 name := $(name)-img-$(FILE_NAME_TAG) 1964 1965 INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1966 1967 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) 1968 @echo "Package: $@" 1969 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ 1970 ./build/tools/releasetools/img_from_target_files -v \ 1971 -p $(HOST_OUT) \ 1972 $(BUILT_TARGET_FILES_PACKAGE) $@ 1973 1974 .PHONY: updatepackage 1975 updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET) 1976 1977 # ----------------------------------------------------------------- 1978 # A zip of the symbols directory. Keep the full paths to make it 1979 # more obvious where these files came from. 1980 # 1981 name := $(TARGET_PRODUCT) 1982 ifeq ($(TARGET_BUILD_TYPE),debug) 1983 name := $(name)_debug 1984 endif 1985 name := $(name)-symbols-$(FILE_NAME_TAG) 1986 1987 SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 1988 # For apps_only build we'll establish the dependency later in build/core/main.mk. 1989 ifndef TARGET_BUILD_APPS 1990 $(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 1991 endif 1992 $(SYMBOLS_ZIP): 1993 @echo "Package symbols: $@" 1994 $(hide) rm -rf $@ 1995 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) 1996 $(hide) zip -qrX $@ $(TARGET_OUT_UNSTRIPPED) 1997 1998 # ----------------------------------------------------------------- 1999 # A zip of the Android Apps. Not keeping full path so that we don't 2000 # include product names when distributing 2001 # 2002 name := $(TARGET_PRODUCT) 2003 ifeq ($(TARGET_BUILD_TYPE),debug) 2004 name := $(name)_debug 2005 endif 2006 name := $(name)-apps-$(FILE_NAME_TAG) 2007 2008 APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 2009 $(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 2010 @echo "Package apps: $@" 2011 $(hide) rm -rf $@ 2012 $(hide) mkdir -p $(dir $@) 2013 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \ 2014 if [ -z "$$apps_to_zip" ]; then \ 2015 echo "No apps to zip up. Generating empty apps archive." ; \ 2016 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \ 2017 else \ 2018 zip -qjX $@ $$apps_to_zip; \ 2019 fi 2020 2021 #------------------------------------------------------------------ 2022 # A zip of emma code coverage meta files. Generated for fully emma 2023 # instrumented build. 2024 # 2025 ifeq (true,$(EMMA_INSTRUMENT)) 2026 EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip 2027 # the dependency will be set up later in build/core/main.mk. 2028 $(EMMA_META_ZIP) : 2029 @echo "Collecting Emma coverage meta files." 2030 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \ 2031 zip -@ -qX $@ 2032 2033 endif # EMMA_INSTRUMENT=true 2034 2035 #------------------------------------------------------------------ 2036 # A zip of Proguard obfuscation dictionary files. 2037 # Only for apps_only build. 2038 # 2039 ifdef TARGET_BUILD_APPS 2040 PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip 2041 # the dependency will be set up later in build/core/main.mk. 2042 $(PROGUARD_DICT_ZIP) : 2043 @echo "Packaging Proguard obfuscation dictionary files." 2044 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary -o -name jack_dictionary`; \ 2045 if [ -n "$$dict_files" ]; then \ 2046 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \ 2047 zip -qX $@ $$dict_files $$unobfuscated_jars; \ 2048 else \ 2049 touch $(dir $@)/zipdummy; \ 2050 (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \ 2051 zip -qd $@ zipdummy; \ 2052 rm $(dir $@)/zipdummy; \ 2053 fi 2054 2055 endif # TARGET_BUILD_APPS 2056 2057 # ----------------------------------------------------------------- 2058 # dalvik something 2059 .PHONY: dalvikfiles 2060 dalvikfiles: $(INTERNAL_DALVIK_MODULES) 2061 2062 # ----------------------------------------------------------------- 2063 # The emulator package 2064 ifeq ($(BUILD_EMULATOR),true) 2065 INTERNAL_EMULATOR_PACKAGE_FILES += \ 2066 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \ 2067 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \ 2068 $(INSTALLED_RAMDISK_TARGET) \ 2069 $(INSTALLED_SYSTEMIMAGE) \ 2070 $(INSTALLED_USERDATAIMAGE_TARGET) 2071 2072 name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 2073 2074 INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 2075 2076 $(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 2077 @echo "Package: $@" 2078 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 2079 2080 endif 2081 # ----------------------------------------------------------------- 2082 # Old PDK stuffs, retired 2083 # The pdk package (Platform Development Kit) 2084 2085 #ifneq (,$(filter pdk,$(MAKECMDGOALS))) 2086 # include development/pdk/Pdk.mk 2087 #endif 2088 2089 2090 # ----------------------------------------------------------------- 2091 # The SDK 2092 2093 # The SDK includes host-specific components, so it belongs under HOST_OUT. 2094 sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT) 2095 2096 # Build a name that looks like: 2097 # 2098 # linux-x86 --> android-sdk_12345_linux-x86 2099 # darwin-x86 --> android-sdk_12345_mac-x86 2100 # windows-x86 --> android-sdk_12345_windows 2101 # 2102 sdk_name := android-sdk_$(FILE_NAME_TAG) 2103 ifeq ($(HOST_OS),darwin) 2104 INTERNAL_SDK_HOST_OS_NAME := mac 2105 else 2106 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) 2107 endif 2108 ifneq ($(HOST_OS),windows) 2109 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH) 2110 endif 2111 sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) 2112 2113 sdk_dep_file := $(sdk_dir)/sdk_deps.mk 2114 2115 ATREE_FILES := 2116 -include $(sdk_dep_file) 2117 2118 # if we don't have a real list, then use "everything" 2119 ifeq ($(strip $(ATREE_FILES)),) 2120 ATREE_FILES := \ 2121 $(ALL_PREBUILT) \ 2122 $(ALL_DEFAULT_INSTALLED_MODULES) \ 2123 $(INSTALLED_RAMDISK_TARGET) \ 2124 $(ALL_DOCS) \ 2125 $(ALL_SDK_FILES) 2126 endif 2127 2128 atree_dir := development/build 2129 2130 2131 sdk_atree_files := \ 2132 $(atree_dir)/sdk.exclude.atree \ 2133 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree 2134 2135 # development/build/sdk-android-<abi>.atree is used to differentiate 2136 # between architecture models (e.g. ARMv5TE versus ARMv7) when copying 2137 # files like the kernel image. We use TARGET_CPU_ABI because we don't 2138 # have a better way to distinguish between CPU models. 2139 ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree))) 2140 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree 2141 endif 2142 2143 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),) 2144 sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES) 2145 else 2146 sdk_atree_files += $(atree_dir)/sdk.atree 2147 endif 2148 2149 include $(BUILD_SYSTEM)/sdk_font.mk 2150 2151 deps := \ 2152 $(target_notice_file_txt) \ 2153 $(tools_notice_file_txt) \ 2154 $(OUT_DOCS)/offline-sdk-timestamp \ 2155 $(SYMBOLS_ZIP) \ 2156 $(INSTALLED_SYSTEMIMAGE) \ 2157 $(INSTALLED_USERDATAIMAGE_TARGET) \ 2158 $(INSTALLED_RAMDISK_TARGET) \ 2159 $(INSTALLED_SDK_BUILD_PROP_TARGET) \ 2160 $(INSTALLED_BUILD_PROP_TARGET) \ 2161 $(ATREE_FILES) \ 2162 $(sdk_atree_files) \ 2163 $(HOST_OUT_EXECUTABLES)/atree \ 2164 $(HOST_OUT_EXECUTABLES)/line_endings \ 2165 $(SDK_FONT_DEPS) 2166 2167 INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip 2168 $(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name) 2169 $(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name) 2170 $(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file) 2171 $(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files) 2172 2173 # Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 2174 # 2175 #SDK_GNU_ERROR := true 2176 2177 $(INTERNAL_SDK_TARGET): $(deps) 2178 @echo "Package SDK: $@" 2179 $(hide) rm -rf $(PRIVATE_DIR) $@ 2180 $(hide) for f in $(target_gnu_MODULES); do \ 2181 if [ -f $$f ]; then \ 2182 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \ 2183 including GNU target $$f >&2; \ 2184 FAIL=$(SDK_GNU_ERROR); \ 2185 fi; \ 2186 done; \ 2187 if [ $$FAIL ]; then exit 1; fi 2188 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt 2189 $(hide) ( \ 2190 ATREE_STRIP="strip -x" \ 2191 $(HOST_OUT_EXECUTABLES)/atree \ 2192 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 2193 -m $(PRIVATE_DEP_FILE) \ 2194 -I . \ 2195 -I $(PRODUCT_OUT) \ 2196 -I $(HOST_OUT) \ 2197 -I $(TARGET_COMMON_OUT_ROOT) \ 2198 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \ 2199 -v "OUT_DIR=$(OUT_DIR)" \ 2200 -v "HOST_OUT=$(HOST_OUT)" \ 2201 -v "TARGET_ARCH=$(TARGET_ARCH)" \ 2202 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \ 2203 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \ 2204 -v "FONT_OUT=$(SDK_FONT_TEMP)" \ 2205 -v "JACK_SDKTOOL_VERSION=$(JACK_SDKTOOL_VERSION)" \ 2206 -o $(PRIVATE_DIR) && \ 2207 cp -f $(target_notice_file_txt) \ 2208 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \ 2209 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \ 2210 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ 2211 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \ 2212 chmod -R ug+rwX $(PRIVATE_DIR) && \ 2213 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \ 2214 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) 2215 2216 2217 # Is a Windows SDK requested? If so, we need some definitions from here 2218 # in order to find the Linux SDK used to create the Windows one. 2219 MAIN_SDK_NAME := $(sdk_name) 2220 MAIN_SDK_DIR := $(sdk_dir) 2221 MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET) 2222 ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),) 2223 include $(TOPDIR)development/build/tools/windows_sdk.mk 2224 endif 2225 2226 # ----------------------------------------------------------------- 2227 # Findbugs 2228 INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 2229 INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 2230 $(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 2231 @echo UnionBugs: $@ 2232 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \ 2233 > $@ 2234 $(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET) 2235 @echo ConvertXmlToText: $@ 2236 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \ 2237 $(INTERNAL_FINDBUGS_XML_TARGET) > $@ 2238 2239 # ----------------------------------------------------------------- 2240 # Findbugs 2241 2242 # ----------------------------------------------------------------- 2243 # These are some additional build tasks that need to be run. 2244 ifneq ($(dont_bother),true) 2245 include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 2246 -include $(sort $(wildcard vendor/*/build/tasks/*.mk)) 2247 -include $(sort $(wildcard device/*/build/tasks/*.mk)) 2248 -include $(sort $(wildcard product/*/build/tasks/*.mk)) 2249 # Also the project-specific tasks 2250 -include $(sort $(wildcard vendor/*/*/build/tasks/*.mk)) 2251 -include $(sort $(wildcard device/*/*/build/tasks/*.mk)) 2252 -include $(sort $(wildcard product/*/*/build/tasks/*.mk)) 2253 endif 2254 2255 include $(BUILD_SYSTEM)/product-graph.mk 2256 2257 # ----------------------------------------------------------------- 2258 # Create SDK repository packages. Must be done after tasks/* since 2259 # we need the addon rules defined. 2260 ifneq ($(sdk_repo_goal),) 2261 include $(TOPDIR)development/build/tools/sdk_repo.mk 2262 endif 2263