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 # docs/index.html 51 ifeq (,$(TARGET_BUILD_APPS)) 52 gen := $(OUT_DOCS)/index.html 53 ALL_DOCS += $(gen) 54 $(gen): frameworks/base/docs/docs-redirect-index.html 55 @mkdir -p $(dir $@) 56 @cp -f $< $@ 57 endif 58 59 # ----------------------------------------------------------------- 60 # default.prop 61 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop 62 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET) 63 ADDITIONAL_DEFAULT_PROPERTIES := \ 64 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) 65 ADDITIONAL_DEFAULT_PROPERTIES += \ 66 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)) 67 ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \ 68 $(ADDITIONAL_DEFAULT_PROPERTIES),=) 69 70 $(INSTALLED_DEFAULT_PROP_TARGET): 71 @echo Target buildinfo: $@ 72 @mkdir -p $(dir $@) 73 $(hide) echo "#" > $@; \ 74 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \ 75 echo "#" >> $@; 76 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \ 77 echo "$(line)" >> $@;) 78 build/tools/post_process_props.py $@ 79 80 # ----------------------------------------------------------------- 81 # build.prop 82 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop 83 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) 84 ADDITIONAL_BUILD_PROPERTIES := \ 85 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES)) 86 ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \ 87 $(ADDITIONAL_BUILD_PROPERTIES),=) 88 89 # A list of arbitrary tags describing the build configuration. 90 # Force ":=" so we can use += 91 BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) 92 ifeq ($(TARGET_BUILD_TYPE),debug) 93 BUILD_VERSION_TAGS += debug 94 endif 95 # The "test-keys" tag marks builds signed with the old test keys, 96 # which are available in the SDK. "dev-keys" marks builds signed with 97 # non-default dev keys (usually private keys from a vendor directory). 98 # Both of these tags will be removed and replaced with "release-keys" 99 # when the target-files is signed in a post-build step. 100 ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey) 101 BUILD_KEYS := test-keys 102 else 103 BUILD_KEYS := dev-keys 104 endif 105 BUILD_VERSION_TAGS += $(BUILD_KEYS) 106 BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) 107 108 # A human-readable string that descibes this build in detail. 109 build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS) 110 $(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc) 111 112 # The string used to uniquely identify the combined build and product; used by the OTA server. 113 ifeq (,$(strip $(BUILD_FINGERPRINT))) 114 ifneq ($(filter eng.%,$(BUILD_NUMBER)),) 115 # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed 116 # the Android system property length limit (PROPERTY_VALUE_MAX=92). 117 BF_BUILD_NUMBER := $(USER)$(shell date +%m%d%H%M) 118 else 119 BF_BUILD_NUMBER := $(BUILD_NUMBER) 120 endif 121 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 122 endif 123 ifneq ($(words $(BUILD_FINGERPRINT)),1) 124 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 125 endif 126 127 # The string used to uniquely identify the system build; used by the OTA server. 128 # This purposefully excludes any product-specific variables. 129 ifeq (,$(strip $(BUILD_THUMBPRINT))) 130 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 131 endif 132 ifneq ($(words $(BUILD_THUMBPRINT)),1) 133 $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)") 134 endif 135 136 KNOWN_OEM_THUMBPRINT_PROPERTIES := \ 137 ro.product.brand \ 138 ro.product.name \ 139 ro.product.device 140 OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\ 141 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES)) 142 143 # Display parameters shown under Settings -> About Phone 144 ifeq ($(TARGET_BUILD_VARIANT),user) 145 # User builds should show: 146 # release build number or branch.buld_number non-release builds 147 148 # Dev. branches should have DISPLAY_BUILD_NUMBER set 149 ifeq "true" "$(DISPLAY_BUILD_NUMBER)" 150 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) $(BUILD_KEYS) 151 else 152 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS) 153 endif 154 else 155 # Non-user builds should show detailed build information 156 BUILD_DISPLAY_ID := $(build_desc) 157 endif 158 159 # Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES 160 product_property_override_locale_language := $(strip \ 161 $(patsubst ro.product.locale.language=%,%,\ 162 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES)))) 163 product_property_overrides_locale_region := $(strip \ 164 $(patsubst ro.product.locale.region=%,%,\ 165 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES)))) 166 167 # Selects the first locale in the list given as the argument, 168 # and splits it into language and region, which each may be 169 # empty. 170 define default-locale 171 $(subst _, , $(firstword $(1))) 172 endef 173 174 # Selects the first locale in the list given as the argument 175 # and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES; 176 # Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES. 177 define default-locale-language 178 $(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1)))) 179 endef 180 define default-locale-region 181 $(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1)))) 182 endef 183 184 BUILDINFO_SH := build/tools/buildinfo.sh 185 186 ifdef TARGET_SYSTEM_PROP 187 system_prop_file := $(TARGET_SYSTEM_PROP) 188 else 189 system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop) 190 endif 191 $(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) 192 @echo Target buildinfo: $@ 193 @mkdir -p $(dir $@) 194 $(hide) echo > $@ 195 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),) 196 $(hide) echo "#" >> $@; \ 197 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \ 198 echo "#" >> $@; 199 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \ 200 echo "import /oem/oem.prop $(prop)" >> $@;) 201 endif 202 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ 203 TARGET_DEVICE="$(TARGET_DEVICE)" \ 204 PRODUCT_NAME="$(TARGET_PRODUCT)" \ 205 PRODUCT_BRAND="$(PRODUCT_BRAND)" \ 206 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \ 207 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \ 208 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \ 209 PRODUCT_MODEL="$(PRODUCT_MODEL)" \ 210 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \ 211 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \ 212 BUILD_ID="$(BUILD_ID)" \ 213 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ 214 BUILD_NUMBER="$(BUILD_NUMBER)" \ 215 PLATFORM_VERSION="$(PLATFORM_VERSION)" \ 216 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \ 217 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \ 218 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \ 219 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \ 220 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \ 221 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \ 222 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \ 223 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \ 224 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \ 225 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \ 226 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \ 227 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \ 228 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \ 229 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \ 230 bash $(BUILDINFO_SH) >> $@ 231 $(hide) $(foreach file,$(system_prop_file), \ 232 if [ -f "$(file)" ]; then \ 233 echo "#" >> $@; \ 234 echo Target buildinfo from: "$(file)"; \ 235 echo "# from $(file)" >> $@; \ 236 echo "#" >> $@; \ 237 cat $(file) >> $@; \ 238 fi;) 239 $(if $(ADDITIONAL_BUILD_PROPERTIES), \ 240 $(hide) echo >> $@; \ 241 echo "#" >> $@; \ 242 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ 243 echo "#" >> $@; ) 244 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ 245 echo "$(line)" >> $@;) 246 $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST) 247 248 build_desc := 249 250 # ----------------------------------------------------------------- 251 # vendor build.prop 252 # 253 # For verifying that the vendor build is what we thing it is 254 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 255 INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop 256 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET) 257 $(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 258 @echo Target vendor buildinfo: $@ 259 @mkdir -p $(dir $@) 260 $(hide) echo > $@ 261 $(hide) echo ro.vendor.build.date=`date`>>$@ 262 $(hide) echo ro.vendor.build.date.utc=`date +%s`>>$@ 263 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT)">>$@ 264 endif 265 266 # ----------------------------------------------------------------- 267 # sdk-build.prop 268 # 269 # There are certain things in build.prop that we don't want to 270 # ship with the sdk; remove them. 271 272 # This must be a list of entire property keys followed by 273 # "=" characters, without any internal spaces. 274 sdk_build_prop_remove := \ 275 ro.build.user= \ 276 ro.build.host= \ 277 ro.product.brand= \ 278 ro.product.manufacturer= \ 279 ro.product.device= 280 # TODO: Remove this soon-to-be obsolete property 281 sdk_build_prop_remove += ro.build.product= 282 INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop 283 $(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 284 @echo SDK buildinfo: $@ 285 @mkdir -p $(dir $@) 286 $(hide) grep -v "$(subst $(space),\|,$(strip \ 287 $(sdk_build_prop_remove)))" $< > $@.tmp 288 $(hide) for x in $(sdk_build_prop_remove); do \ 289 echo "$$x"generic >> $@.tmp; done 290 $(hide) mv $@.tmp $@ 291 292 # ----------------------------------------------------------------- 293 # package stats 294 PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt 295 PACKAGES_TO_STAT := \ 296 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \ 297 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES)))) 298 $(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT) 299 @echo Package stats: $@ 300 @mkdir -p $(dir $@) 301 $(hide) rm -f $@ 302 $(hide) build/tools/dump-package-stats $^ > $@ 303 304 .PHONY: package-stats 305 package-stats: $(PACKAGE_STATS_FILE) 306 307 # ----------------------------------------------------------------- 308 # Cert-to-package mapping. Used by the post-build signing tools. 309 # Use a macro to add newline to each echo command 310 define _apkcerts_echo_with_newline 311 $(hide) echo $(1) 312 313 endef 314 315 name := $(TARGET_PRODUCT) 316 ifeq ($(TARGET_BUILD_TYPE),debug) 317 name := $(name)_debug 318 endif 319 name := $(name)-apkcerts-$(FILE_NAME_TAG) 320 intermediates := \ 321 $(call intermediates-dir-for,PACKAGING,apkcerts) 322 APKCERTS_FILE := $(intermediates)/$(name).txt 323 # We don't need to really build all the modules. 324 # TODO: rebuild APKCERTS_FILE if any app change its cert. 325 $(APKCERTS_FILE): 326 @echo APK certs list: $@ 327 @mkdir -p $(dir $@) 328 @rm -f $@ 329 $(foreach p,$(PACKAGES),\ 330 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\ 331 $(call _apkcerts_echo_with_newline,\ 332 'name="$(p).apk" certificate="EXTERNAL" \ 333 private_key=""' >> $@),\ 334 $(call _apkcerts_echo_with_newline,\ 335 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ 336 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@))) 337 # In case value of PACKAGES is empty. 338 $(hide) touch $@ 339 340 .PHONY: apkcerts-list 341 apkcerts-list: $(APKCERTS_FILE) 342 343 ifneq (,$(TARGET_BUILD_APPS)) 344 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt) 345 endif 346 347 # ----------------------------------------------------------------- 348 # module info file 349 ifdef CREATE_MODULE_INFO_FILE 350 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt 351 $(info Generating $(MODULE_INFO_FILE)...) 352 $(shell rm -f $(MODULE_INFO_FILE)) 353 $(foreach m,$(ALL_MODULES), \ 354 $(shell echo "NAME=\"$(m)\"" \ 355 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \ 356 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \ 357 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \ 358 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE))) 359 endif 360 361 # ----------------------------------------------------------------- 362 363 # The dev key is used to sign this package, and as the key required 364 # for future OTA packages installed by this system. Actual product 365 # deliverables will be re-signed by hand. We expect this file to 366 # exist with the suffixes ".x509.pem" and ".pk8". 367 DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) 368 369 370 # Rules that need to be present for the all targets, even 371 # if they don't do anything. 372 .PHONY: systemimage 373 systemimage: 374 375 # ----------------------------------------------------------------- 376 377 .PHONY: event-log-tags 378 379 # Produce an event logs tag file for everything we know about, in order 380 # to properly allocate numbers. Then produce a file that's filtered 381 # for what's going to be installed. 382 383 all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt 384 385 event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags 386 387 # Include tags from all packages that we know about 388 all_event_log_tags_src := \ 389 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS))) 390 391 # PDK builds will already have a full list of tags that needs to get merged 392 # in with the ones from source 393 pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES))) 394 395 $(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) 396 $(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) 397 $(hide) mkdir -p $(dir $@) 398 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES) 399 400 # Include tags from all packages included in this product, plus all 401 # tags that are part of the system (ie, not in a vendor/ or device/ 402 # directory). 403 event_log_tags_src := \ 404 $(sort $(foreach m,\ 405 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \ 406 $(call module-names-for-tag-list,user), \ 407 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \ 408 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src))) 409 410 $(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file) 411 $(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file) 412 $(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) 413 $(hide) mkdir -p $(dir $@) 414 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES) 415 416 event-log-tags: $(event_log_tags_file) 417 418 ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file) 419 420 421 # ################################################################# 422 # Targets for boot/OS images 423 # ################################################################# 424 ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true) 425 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader 426 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true) 427 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader 428 else 429 INSTALLED_2NDBOOTLOADER_TARGET := 430 endif 431 else 432 INSTALLED_BOOTLOADER_MODULE := 433 INSTALLED_2NDBOOTLOADER_TARGET := 434 endif # TARGET_NO_BOOTLOADER 435 ifneq ($(strip $(TARGET_NO_KERNEL)),true) 436 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel 437 else 438 INSTALLED_KERNEL_TARGET := 439 endif 440 441 # ----------------------------------------------------------------- 442 # the ramdisk 443 INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ 444 $(ALL_PREBUILT) \ 445 $(ALL_COPIED_HEADERS) \ 446 $(ALL_GENERATED_SOURCES) \ 447 $(ALL_DEFAULT_INSTALLED_MODULES)) 448 449 BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img 450 451 # We just build this directly to the install location. 452 INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET) 453 $(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP) 454 $(call pretty,"Target ram disk: $@") 455 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@ 456 457 .PHONY: ramdisk-nodeps 458 ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP) 459 @echo "make $@: ignoring dependencies" 460 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET) 461 462 ifneq ($(strip $(TARGET_NO_KERNEL)),true) 463 464 # ----------------------------------------------------------------- 465 # the boot image, which is a collection of other images. 466 INTERNAL_BOOTIMAGE_ARGS := \ 467 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 468 --kernel $(INSTALLED_KERNEL_TARGET) \ 469 --ramdisk $(INSTALLED_RAMDISK_TARGET) 470 471 INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) 472 473 BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE)) 474 ifdef BOARD_KERNEL_CMDLINE 475 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 476 endif 477 478 BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE)) 479 ifdef BOARD_KERNEL_BASE 480 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 481 endif 482 483 BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE)) 484 ifdef BOARD_KERNEL_PAGESIZE 485 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE) 486 endif 487 488 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 489 490 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 491 tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg 492 INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image) 493 INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG) 494 $(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES) 495 $(call pretty,"Target boot image: $@") 496 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 497 498 .PHONY: bootimage-nodeps 499 bootimage-nodeps: $(MKEXT2IMG) 500 @echo "make $@: ignoring dependencies" 501 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) 502 503 else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) # TARGET_BOOTIMAGE_USE_EXT2 != true 504 505 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER) 506 $(call pretty,"Target boot image: $@") 507 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ 508 $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $@ 509 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 510 511 .PHONY: bootimage-nodeps 512 bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER) 513 @echo "make $@: ignoring dependencies" 514 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) 515 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $(INSTALLED_BOOTIMAGE_TARGET) 516 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 517 518 else # PRODUCT_SUPPORTS_VERITY != true 519 520 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) 521 $(call pretty,"Target boot image: $@") 522 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ 523 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 524 525 .PHONY: bootimage-nodeps 526 bootimage-nodeps: $(MKBOOTIMG) 527 @echo "make $@: ignoring dependencies" 528 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) 529 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) 530 531 endif # TARGET_BOOTIMAGE_USE_EXT2 532 533 else # TARGET_NO_KERNEL 534 # HACK: The top-level targets depend on the bootimage. Not all targets 535 # can produce a bootimage, though, and emulator targets need the ramdisk 536 # instead. Fake it out by calling the ramdisk the bootimage. 537 # TODO: make the emulator use bootimages, and make mkbootimg accept 538 # kernel-less inputs. 539 INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 540 endif 541 542 # ----------------------------------------------------------------- 543 # NOTICE files 544 # 545 # We are required to publish the licenses for all code under BSD, GPL and 546 # Apache licenses (and possibly other more exotic ones as well). We err on the 547 # side of caution, so the licenses for other third-party code are included here 548 # too. 549 # 550 # This needs to be before the systemimage rules, because it adds to 551 # ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files 552 # go into the systemimage. 553 554 .PHONY: notice_files 555 556 # Create the rule to combine the files into text and html forms 557 # $(1) - Plain text output file 558 # $(2) - HTML output file 559 # $(3) - File title 560 # $(4) - Directory to use. Notice files are all $(4)/src. Other 561 # directories in there will be used for scratch 562 # $(5) - Dependencies for the output files 563 # 564 # The algorithm here is that we go collect a hash for each of the notice 565 # files and write the names of the files that match that hash. Then 566 # to generate the real files, we go print out all of the files and their 567 # hashes. 568 # 569 # These rules are fairly complex, so they depend on this makefile so if 570 # it changes, they'll run again. 571 # 572 # TODO: We could clean this up so that we just record the locations of the 573 # original notice files instead of making rules to copy them somwehere. 574 # Then we could traverse that without quite as much bash drama. 575 define combine-notice-files 576 $(1) $(2): PRIVATE_MESSAGE := $(3) 577 $(1) $(2): PRIVATE_DIR := $(4) 578 $(1) : $(2) 579 $(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py 580 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src 581 notice_files: $(1) $(2) 582 endef 583 584 # TODO These intermediate NOTICE.txt/NOTICE.html files should go into 585 # TARGET_OUT_NOTICE_FILES now that the notice files are gathered from 586 # the src subdirectory. 587 588 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 589 target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 590 target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 591 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 592 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 593 594 ifndef TARGET_BUILD_APPS 595 kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 596 pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES)) 597 598 $(eval $(call combine-notice-files, \ 599 $(target_notice_file_txt), \ 600 $(target_notice_file_html), \ 601 "Notices for files contained in the filesystem images in this directory:", \ 602 $(TARGET_OUT_NOTICE_FILES), \ 603 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files))) 604 605 $(eval $(call combine-notice-files, \ 606 $(tools_notice_file_txt), \ 607 $(tools_notice_file_html), \ 608 "Notices for files contained in the tools directory:", \ 609 $(HOST_OUT_NOTICE_FILES), \ 610 $(ALL_DEFAULT_INSTALLED_MODULES))) 611 612 # Install the html file at /system/etc/NOTICE.html.gz. 613 # This is not ideal, but this is very late in the game, after a lot of 614 # the module processing has already been done -- in fact, we used the 615 # fact that all that has been done to get the list of modules that we 616 # need notice files for. 617 $(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP) 618 $(hide) $(MINIGZIP) -9 < $< > $@ 619 installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz 620 $(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP) 621 $(copy-file-to-target) 622 623 # if we've been run my mm, mmm, etc, don't reinstall this every time 624 ifeq ($(ONE_SHOT_MAKEFILE),) 625 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 626 endif 627 endif # TARGET_BUILD_APPS 628 629 # The kernel isn't really a module, so to get its module file in there, we 630 # make the target NOTICE files depend on this particular file too, which will 631 # then be in the right directory for the find in combine-notice-files to work. 632 $(kernel_notice_file): \ 633 prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \ 634 | $(ACP) 635 @echo Copying: $@ 636 $(hide) mkdir -p $(dir $@) 637 $(hide) $(ACP) $< $@ 638 639 640 # ----------------------------------------------------------------- 641 # Build a keystore with the authorized keys in it, used to verify the 642 # authenticity of downloaded OTA packages. 643 # 644 # This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come 645 # before the rules that use that variable to build the image. 646 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 647 $(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 648 $(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) 649 $(hide) rm -f $@ 650 $(hide) mkdir -p $(dir $@) 651 $(hide) zip -qj $@ $< 652 653 .PHONY: otacerts 654 otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip 655 656 657 # ################################################################# 658 # Targets for user images 659 # ################################################################# 660 661 INTERNAL_USERIMAGES_EXT_VARIANT := 662 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 663 INTERNAL_USERIMAGES_USE_EXT := true 664 INTERNAL_USERIMAGES_EXT_VARIANT := ext2 665 else 666 ifeq ($(TARGET_USERIMAGES_USE_EXT3),true) 667 INTERNAL_USERIMAGES_USE_EXT := true 668 INTERNAL_USERIMAGES_EXT_VARIANT := ext3 669 else 670 ifeq ($(TARGET_USERIMAGES_USE_EXT4),true) 671 INTERNAL_USERIMAGES_USE_EXT := true 672 INTERNAL_USERIMAGES_EXT_VARIANT := ext4 673 endif 674 endif 675 endif 676 677 # These options tell the recovery updater/installer how to mount the partitions writebale. 678 # <fstype>=<fstype_opts>[|<fstype_opts>]... 679 # fstype_opts := <opt>[,<opt>]... 680 # opt := <name>[=<value>] 681 # The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10 682 DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc 683 684 ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)) 685 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s 686 endif 687 688 ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true) 689 INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG) 690 INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK) 691 ifeq ($(TARGET_USERIMAGES_USE_F2FS),true) 692 INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS) 693 endif 694 else 695 INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2) 696 endif 697 698 INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS))) 699 700 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) 701 INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER) 702 endif 703 704 SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts 705 INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC) 706 707 # $(1): the path of the output dictionary file 708 # $(2): additional "key=value" pairs to append to the dictionary file. 709 define generate-userimage-prop-dictionary 710 $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1)) 711 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1)) 712 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 713 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1)) 714 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 715 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1)) 716 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) 717 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1)) 718 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1)) 719 $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1)) 720 $(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1)) 721 $(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1) 722 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1)) 723 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1)) 724 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(VERITY_SIGNER)" >> $(1)) 725 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1)) 726 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1)) 727 $(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);)) 728 endef 729 730 # ----------------------------------------------------------------- 731 # Recovery image 732 733 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 734 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 735 736 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 737 738 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 739 recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery 740 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 741 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 742 recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET) 743 recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery 744 recovery_resources_common := $(call include-path-for, recovery)/res 745 746 # Set recovery_density to the density bucket of the device. 747 recovery_density := unknown 748 ifneq (,$(PRODUCT_AAPT_PREF_CONFIG)) 749 # If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value. 750 recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG)) 751 else 752 # Otherwise, use the highest density that appears in PRODUCT_AAPT_CONFIG. 753 # Order is important here; we'll take the first one that's found. 754 recovery_densities := $(filter $(PRODUCT_AAPT_CONFIG_SP),xxxhdpi xxhdpi xhdpi hdpi tvdpi mdpi ldpi) 755 ifneq (,$(recovery_densities)) 756 recovery_density := $(word 1,$(recovery_densities)) 757 endif 758 endif 759 760 ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density))) 761 recovery_resources_common := $(recovery_resources_common)-$(recovery_density) 762 else 763 recovery_resources_common := $(recovery_resources_common)-xhdpi 764 endif 765 766 # Select the 18x32 font on high-density devices (xhdpi and up); and 767 # the 12x22 font on other devices. Note that the font selected here 768 # can be overridden for a particular device by putting a font.png in 769 # its private recovery resources. 770 771 ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density))) 772 recovery_font := $(call include-path-for, recovery)/fonts/18x32.png 773 else 774 recovery_font := $(call include-path-for, recovery)/fonts/12x22.png 775 endif 776 777 recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)) 778 recovery_resource_deps := $(shell find $(recovery_resources_common) \ 779 $(recovery_resources_private) -type f) 780 ifdef TARGET_RECOVERY_FSTAB 781 recovery_fstab := $(TARGET_RECOVERY_FSTAB) 782 else 783 recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab)) 784 endif 785 # Named '.dat' so we don't attempt to use imgdiff for patching it. 786 RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat 787 788 ifeq ($(recovery_resources_private),) 789 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) 790 endif 791 792 ifeq ($(recovery_fstab),) 793 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE)) 794 endif 795 796 INTERNAL_RECOVERYIMAGE_ARGS := \ 797 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 798 --kernel $(recovery_kernel) \ 799 --ramdisk $(recovery_ramdisk) 800 801 # Assumes this has already been stripped 802 ifdef BOARD_KERNEL_CMDLINE 803 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 804 endif 805 ifdef BOARD_KERNEL_BASE 806 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 807 endif 808 BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE)) 809 ifdef BOARD_KERNEL_PAGESIZE 810 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE) 811 endif 812 813 # Keys authorized to sign OTA packages this build will accept. The 814 # build always uses dev-keys for this; release packaging tools will 815 # substitute other keys for this one. 816 OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem 817 818 # Generate a file containing the keys that will be read by the 819 # recovery binary. 820 RECOVERY_INSTALL_OTA_KEYS := \ 821 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys 822 DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar 823 $(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS) 824 $(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS)) 825 $(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys) 826 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)" 827 @rm -rf $@ 828 @mkdir -p $(dir $@) 829 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@ 830 831 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \ 832 $(INSTALLED_RAMDISK_TARGET) \ 833 $(INSTALLED_BOOTIMAGE_TARGET) \ 834 $(recovery_binary) \ 835 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \ 836 $(INSTALLED_2NDBOOTLOADER_TARGET) \ 837 $(recovery_build_prop) $(recovery_resource_deps) \ 838 $(recovery_fstab) \ 839 $(RECOVERY_INSTALL_OTA_KEYS) 840 @echo ----- Making recovery image ------ 841 $(hide) rm -rf $(TARGET_RECOVERY_OUT) 842 $(hide) mkdir -p $(TARGET_RECOVERY_OUT) 843 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp 844 @echo Copying baseline ramdisk... 845 $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) 846 @echo Modifying ramdisk contents... 847 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc 848 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ 849 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy 850 $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy 851 $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 852 $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/ 853 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res 854 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/* 855 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res 856 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png 857 $(hide) $(foreach item,$(recovery_resources_private), \ 858 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/) 859 $(hide) $(foreach item,$(recovery_fstab), \ 860 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab) 861 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys 862 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \ 863 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop 864 $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk) 865 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ 866 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) 867 $(BOOT_SIGNER) /recovery $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $@ 868 endif 869 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)) 870 @echo ----- Made recovery image: $@ -------- 871 872 $(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) 873 $(hide) mkdir -p $(dir $@) 874 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@ 875 876 else 877 INSTALLED_RECOVERYIMAGE_TARGET := 878 RECOVERY_RESOURCE_ZIP := 879 endif 880 881 .PHONY: recoveryimage 882 recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP) 883 884 ifneq ($(BOARD_NAND_PAGE_SIZE),) 885 mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE) 886 else 887 mkyaffs2_extra_flags := 888 BOARD_NAND_PAGE_SIZE := 2048 889 endif 890 891 ifneq ($(BOARD_NAND_SPARE_SIZE),) 892 mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE) 893 else 894 BOARD_NAND_SPARE_SIZE := 64 895 endif 896 897 # ----------------------------------------------------------------- 898 # system image 899 # 900 # Remove overridden packages from $(ALL_PDK_FUSION_FILES) 901 PDK_FUSION_SYSIMG_FILES := \ 902 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \ 903 $(ALL_PDK_FUSION_FILES)) 904 905 INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 906 $(ALL_PREBUILT) \ 907 $(ALL_COPIED_HEADERS) \ 908 $(ALL_GENERATED_SOURCES) \ 909 $(ALL_DEFAULT_INSTALLED_MODULES) \ 910 $(PDK_FUSION_SYSIMG_FILES) \ 911 $(RECOVERY_RESOURCE_ZIP)) 912 913 FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS) 914 # ----------------------------------------------------------------- 915 # installed file list 916 # Depending on anything that $(BUILT_SYSTEMIMAGE) depends on. 917 # We put installed-files.txt ahead of image itself in the dependency graph 918 # so that we can get the size stat even if the build fails due to too large 919 # system image. 920 INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 921 $(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) 922 @echo Installed file list: $@ 923 @mkdir -p $(dir $@) 924 @rm -f $@ 925 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@ 926 927 .PHONY: installed-file-list 928 installed-file-list: $(INSTALLED_FILES_FILE) 929 930 $(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE)) 931 932 systemimage_intermediates := \ 933 $(call intermediates-dir-for,PACKAGING,systemimage) 934 BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img 935 936 # Create symlink /system/vendor to /vendor if necessary. 937 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 938 define create-system-vendor-symlink 939 $(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \ 940 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \ 941 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \ 942 exit 1; \ 943 fi 944 $(hide) ln -sf /vendor $(TARGET_OUT)/vendor 945 endef 946 else 947 define create-system-vendor-symlink 948 endef 949 endif 950 951 # $(1): output file 952 define build-systemimage-target 953 @echo "Target system fs image: $(1)" 954 $(call create-system-vendor-symlink) 955 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt 956 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \ 957 skip_fsck=true) 958 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 959 ./build/tools/releasetools/build_image.py \ 960 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) \ 961 || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\ 962 du -sm $(TARGET_OUT) 1>&2;\ 963 echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\ 964 mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \ 965 exit 1 ) 966 endef 967 968 $(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) 969 $(call build-systemimage-target,$@) 970 971 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 972 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 973 974 # The system partition needs room for the recovery image as well. We 975 # now store the recovery image as a binary patch using the boot image 976 # as the source (since they are very similar). Generate the patch so 977 # we can see how big it's going to be, and include that in the system 978 # image size check calculation. 979 ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) 980 intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch) 981 RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p 982 $(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \ 983 $(INSTALLED_BOOTIMAGE_TARGET) \ 984 $(HOST_OUT_EXECUTABLES)/imgdiff \ 985 $(HOST_OUT_EXECUTABLES)/bsdiff 986 @echo "Construct recovery from boot" 987 mkdir -p $(dir $@) 988 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@ 989 endif 990 991 992 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP) 993 @echo "Install system fs image: $@" 994 $(copy-file-to-target) 995 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) 996 997 systemimage: $(INSTALLED_SYSTEMIMAGE) 998 999 .PHONY: systemimage-nodeps snod 1000 systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \ 1001 | $(INTERNAL_USERIMAGES_DEPS) 1002 @echo "make $@: ignoring dependencies" 1003 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE)) 1004 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) 1005 1006 ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS))) 1007 ifeq (true,$(WITH_DEXPREOPT)) 1008 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.) 1009 endif 1010 endif 1011 1012 ####### 1013 ## system tarball 1014 define build-systemtarball-target 1015 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)") 1016 $(call create-system-vendor-symlink) 1017 $(MKTARBALL) $(FS_GET_STATS) \ 1018 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \ 1019 $(INSTALLED_SYSTEMTARBALL_TARGET) 1020 endef 1021 1022 ifndef SYSTEM_TARBALL_FORMAT 1023 SYSTEM_TARBALL_FORMAT := bz2 1024 endif 1025 1026 system_tar := $(PRODUCT_OUT)/system.tar 1027 INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT) 1028 $(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar) 1029 $(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES) 1030 $(build-systemtarball-target) 1031 1032 .PHONY: systemtarball-nodeps 1033 systemtarball-nodeps: $(FS_GET_STATS) \ 1034 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 1035 $(build-systemtarball-target) 1036 1037 .PHONY: stnod 1038 stnod: systemtarball-nodeps 1039 1040 ####### 1041 ## platform.zip: system, plus other files to be used in PDK fusion build, 1042 ## in a zip file 1043 ## 1044 ## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip. 1045 ## The variable will be typically set from BoardConfig.mk. 1046 ## Files under out dir will be rejected to prevent possible conflicts with other rules. 1047 PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)) 1048 INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip 1049 $(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) 1050 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)") 1051 $(hide) rm -f $@ 1052 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \ 1053 $(TARGET_COPY_OUT_SYSTEM) \ 1054 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \ 1055 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST)) 1056 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1057 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \ 1058 $(TARGET_COPY_OUT_VENDOR) 1059 endif 1060 ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),) 1061 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS) 1062 endif 1063 ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),) 1064 $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES) 1065 endif 1066 1067 .PHONY: platform 1068 platform: $(INSTALLED_PLATFORM_ZIP) 1069 1070 .PHONY: platform-java 1071 platform-java: platform 1072 1073 # Dist the platform.zip 1074 ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))) 1075 $(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP)) 1076 endif 1077 1078 ####### 1079 ## boot tarball 1080 define build-boottarball-target 1081 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)" 1082 $(hide) mkdir -p $(PRODUCT_OUT)/boot 1083 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/. 1084 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline 1085 $(hide) $(MKTARBALL) $(FS_GET_STATS) \ 1086 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \ 1087 $(INSTALLED_BOOTTARBALL_TARGET) 1088 endef 1089 1090 ifndef BOOT_TARBALL_FORMAT 1091 BOOT_TARBALL_FORMAT := bz2 1092 endif 1093 1094 boot_tar := $(PRODUCT_OUT)/boot.tar 1095 INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT) 1096 $(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar) 1097 $(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES) 1098 $(build-boottarball-target) 1099 1100 .PHONY: boottarball-nodeps btnod 1101 boottarball-nodeps btnod: $(FS_GET_STATS) \ 1102 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS)) 1103 $(build-boottarball-target) 1104 1105 1106 # ----------------------------------------------------------------- 1107 # data partition image 1108 INTERNAL_USERDATAIMAGE_FILES := \ 1109 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 1110 1111 # Don't build userdata.img if it's extfs but no partition size 1112 skip_userdata.img := 1113 ifdef INTERNAL_USERIMAGES_EXT_VARIANT 1114 ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE 1115 skip_userdata.img := true 1116 endif 1117 endif 1118 1119 ifneq ($(skip_userdata.img),true) 1120 userdataimage_intermediates := \ 1121 $(call intermediates-dir-for,PACKAGING,userdata) 1122 BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 1123 1124 define build-userdataimage-target 1125 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 1126 @mkdir -p $(TARGET_OUT_DATA) 1127 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt 1128 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true) 1129 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1130 ./build/tools/releasetools/build_image.py \ 1131 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) 1132 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE)) 1133 endef 1134 1135 # We just build this directly to the install location. 1136 INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) 1137 $(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \ 1138 $(INTERNAL_USERDATAIMAGE_FILES) 1139 $(build-userdataimage-target) 1140 1141 .PHONY: userdataimage-nodeps 1142 userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1143 $(build-userdataimage-target) 1144 1145 endif # not skip_userdata.img 1146 skip_userdata.img := 1147 1148 ####### 1149 ## data partition tarball 1150 define build-userdatatarball-target 1151 $(call pretty,"Target userdata fs tarball: " \ 1152 "$(INSTALLED_USERDATATARBALL_TARGET)") 1153 $(MKTARBALL) $(FS_GET_STATS) \ 1154 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \ 1155 $(INSTALLED_USERDATATARBALL_TARGET) 1156 endef 1157 1158 userdata_tar := $(PRODUCT_OUT)/userdata.tar 1159 INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2 1160 $(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar) 1161 $(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES) 1162 $(build-userdatatarball-target) 1163 1164 .PHONY: userdatatarball-nodeps 1165 userdatatarball-nodeps: $(FS_GET_STATS) 1166 $(build-userdatatarball-target) 1167 1168 1169 # ----------------------------------------------------------------- 1170 # cache partition image 1171 ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE 1172 INTERNAL_CACHEIMAGE_FILES := \ 1173 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 1174 1175 cacheimage_intermediates := \ 1176 $(call intermediates-dir-for,PACKAGING,cache) 1177 BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img 1178 1179 define build-cacheimage-target 1180 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)") 1181 @mkdir -p $(TARGET_OUT_CACHE) 1182 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt 1183 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true) 1184 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1185 ./build/tools/releasetools/build_image.py \ 1186 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) 1187 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE)) 1188 endef 1189 1190 # We just build this directly to the install location. 1191 INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET) 1192 $(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) 1193 $(build-cacheimage-target) 1194 1195 .PHONY: cacheimage-nodeps 1196 cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1197 $(build-cacheimage-target) 1198 1199 endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE 1200 1201 1202 # ----------------------------------------------------------------- 1203 # vendor partition image 1204 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1205 INTERNAL_VENDORIMAGE_FILES := \ 1206 $(filter $(TARGET_OUT_VENDOR)/%,\ 1207 $(ALL_DEFAULT_INSTALLED_MODULES)\ 1208 $(ALL_PDK_FUSION_FILES)) 1209 1210 # platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES). 1211 $(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES) 1212 1213 vendorimage_intermediates := \ 1214 $(call intermediates-dir-for,PACKAGING,vendor) 1215 BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img 1216 1217 define build-vendorimage-target 1218 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)") 1219 @mkdir -p $(TARGET_OUT_VENDOR) 1220 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt 1221 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true) 1222 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ 1223 ./build/tools/releasetools/build_image.py \ 1224 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) 1225 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE)) 1226 endef 1227 1228 # We just build this directly to the install location. 1229 INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET) 1230 $(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) 1231 $(build-vendorimage-target) 1232 1233 .PHONY: vendorimage-nodeps 1234 vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) 1235 $(build-vendorimage-target) 1236 1237 endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1238 1239 # ----------------------------------------------------------------- 1240 # host tools needed to build dist and OTA packages 1241 1242 DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ 1243 $(HOST_OUT_EXECUTABLES)/mkbootfs \ 1244 $(HOST_OUT_EXECUTABLES)/mkbootimg \ 1245 $(HOST_OUT_EXECUTABLES)/fs_config \ 1246 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \ 1247 $(HOST_OUT_EXECUTABLES)/zipalign \ 1248 $(HOST_OUT_EXECUTABLES)/bsdiff \ 1249 $(HOST_OUT_EXECUTABLES)/imgdiff \ 1250 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \ 1251 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \ 1252 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \ 1253 $(HOST_OUT_EXECUTABLES)/make_ext4fs \ 1254 $(HOST_OUT_EXECUTABLES)/simg2img \ 1255 $(HOST_OUT_EXECUTABLES)/e2fsck \ 1256 $(HOST_OUT_EXECUTABLES)/build_verity_tree \ 1257 $(HOST_OUT_EXECUTABLES)/verity_signer \ 1258 $(HOST_OUT_EXECUTABLES)/append2simg \ 1259 $(HOST_OUT_EXECUTABLES)/boot_signer 1260 1261 OTATOOLS := $(DISTTOOLS) \ 1262 $(HOST_OUT_EXECUTABLES)/aapt 1263 1264 .PHONY: otatools 1265 otatools: $(OTATOOLS) 1266 1267 # ----------------------------------------------------------------- 1268 # A zip of the directories that map to the target filesystem. 1269 # This zip can be used to create an OTA package or filesystem image 1270 # as a post-build step. 1271 # 1272 name := $(TARGET_PRODUCT) 1273 ifeq ($(TARGET_BUILD_TYPE),debug) 1274 name := $(name)_debug 1275 endif 1276 name := $(name)-target_files-$(FILE_NAME_TAG) 1277 1278 intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 1279 BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 1280 $(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 1281 $(BUILT_TARGET_FILES_PACKAGE): \ 1282 zip_root := $(intermediates)/$(name) 1283 1284 # $(1): Directory to copy 1285 # $(2): Location to copy it to 1286 # The "ls -A" is to prevent "acp s/* d" from failing if s is empty. 1287 define package_files-copy-root 1288 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 1289 mkdir -p $(2) && \ 1290 $(ACP) -rd $(strip $(1))/* $(2); \ 1291 fi 1292 endef 1293 1294 built_ota_tools := \ 1295 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \ 1296 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \ 1297 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \ 1298 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \ 1299 $(call intermediates-dir-for,EXECUTABLES,updater)/updater 1300 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools) 1301 1302 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION) 1303 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION) 1304 1305 ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),) 1306 # default to common dir for device vendor 1307 $(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common 1308 else 1309 $(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS) 1310 endif 1311 1312 # Depending on the various images guarantees that the underlying 1313 # directories are up-to-date. 1314 $(BUILT_TARGET_FILES_PACKAGE): \ 1315 $(INSTALLED_BOOTIMAGE_TARGET) \ 1316 $(INSTALLED_RADIOIMAGE_TARGET) \ 1317 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 1318 $(INSTALLED_SYSTEMIMAGE) \ 1319 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1320 $(INSTALLED_CACHEIMAGE_TARGET) \ 1321 $(INSTALLED_VENDORIMAGE_TARGET) \ 1322 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 1323 $(SELINUX_FC) \ 1324 $(built_ota_tools) \ 1325 $(APKCERTS_FILE) \ 1326 $(HOST_OUT_EXECUTABLES)/fs_config \ 1327 | $(ACP) 1328 @echo "Package target files: $@" 1329 $(hide) rm -rf $@ $(zip_root) 1330 $(hide) mkdir -p $(dir $@) $(zip_root) 1331 @# Components of the recovery image 1332 $(hide) mkdir -p $(zip_root)/RECOVERY 1333 $(hide) $(call package_files-copy-root, \ 1334 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK) 1335 ifdef INSTALLED_KERNEL_TARGET 1336 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel 1337 endif 1338 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1339 $(hide) $(ACP) \ 1340 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second 1341 endif 1342 ifdef BOARD_KERNEL_CMDLINE 1343 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline 1344 endif 1345 ifdef BOARD_KERNEL_BASE 1346 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base 1347 endif 1348 ifdef BOARD_KERNEL_PAGESIZE 1349 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize 1350 endif 1351 @# Components of the boot image 1352 $(hide) mkdir -p $(zip_root)/BOOT 1353 $(hide) $(call package_files-copy-root, \ 1354 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) 1355 ifdef INSTALLED_KERNEL_TARGET 1356 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 1357 endif 1358 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1359 $(hide) $(ACP) \ 1360 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 1361 endif 1362 ifdef BOARD_KERNEL_CMDLINE 1363 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 1364 endif 1365 ifdef BOARD_KERNEL_BASE 1366 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base 1367 endif 1368 ifdef BOARD_KERNEL_PAGESIZE 1369 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize 1370 endif 1371 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\ 1372 mkdir -p $(zip_root)/RADIO; \ 1373 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));) 1374 @# Contents of the system image 1375 $(hide) $(call package_files-copy-root, \ 1376 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) 1377 @# Contents of the data image 1378 $(hide) $(call package_files-copy-root, \ 1379 $(TARGET_OUT_DATA),$(zip_root)/DATA) 1380 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE 1381 @# Contents of the vendor image 1382 $(hide) $(call package_files-copy-root, \ 1383 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR) 1384 endif 1385 @# Extra contents of the OTA package 1386 $(hide) mkdir -p $(zip_root)/OTA/bin 1387 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/ 1388 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ 1389 @# Files that do not end up in any images, but are necessary to 1390 @# build them. 1391 $(hide) mkdir -p $(zip_root)/META 1392 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt 1393 $(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi 1394 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt 1395 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt 1396 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt 1397 ifdef BOARD_FLASH_BLOCK_SIZE 1398 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt 1399 endif 1400 ifdef BOARD_BOOTIMAGE_PARTITION_SIZE 1401 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt 1402 endif 1403 ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE 1404 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt 1405 endif 1406 ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS 1407 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used. 1408 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt 1409 else 1410 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt 1411 endif 1412 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt 1413 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt 1414 ifdef PRODUCT_EXTRA_RECOVERY_KEYS 1415 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt 1416 endif 1417 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt 1418 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt 1419 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt 1420 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt 1421 ifneq ($(OEM_THUMBPRINT_PROPERTIES),) 1422 # OTA scripts are only interested in fingerprint related properties 1423 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt 1424 endif 1425 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt) 1426 $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root) 1427 @# Zip everything up, preserving symlinks 1428 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 1429 @# Run fs_config on all the system, vendor, boot ramdisk, 1430 @# and recovery ramdisk files in the zip, and save the output 1431 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt 1432 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt 1433 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt 1434 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt 1435 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt) 1436 $(hide) ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@ 1437 1438 .PHONY: target-files-package 1439 target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 1440 1441 ifneq ($(filter $(MAKECMDGOALS),target-files-package),) 1442 $(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE)) 1443 endif 1444 1445 ifneq ($(TARGET_PRODUCT),sdk) 1446 ifeq ($(filter generic%,$(TARGET_DEVICE)),) 1447 ifneq ($(TARGET_NO_KERNEL),true) 1448 ifneq ($(recovery_fstab),) 1449 1450 # ----------------------------------------------------------------- 1451 # OTA update package 1452 1453 name := $(TARGET_PRODUCT) 1454 ifeq ($(TARGET_BUILD_TYPE),debug) 1455 name := $(name)_debug 1456 endif 1457 name := $(name)-ota-$(FILE_NAME_TAG) 1458 1459 INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1460 1461 $(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 1462 1463 $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) 1464 @echo "Package OTA: $@" 1465 $(hide) MKBOOTIMG=$(MKBOOTIMG) \ 1466 ./build/tools/releasetools/ota_from_target_files -v \ 1467 --block \ 1468 -p $(HOST_OUT) \ 1469 -k $(KEY_CERT_PAIR) \ 1470 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \ 1471 $(BUILT_TARGET_FILES_PACKAGE) $@ 1472 1473 .PHONY: otapackage 1474 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 1475 1476 endif # recovery_fstab is defined 1477 endif # TARGET_NO_KERNEL != true 1478 endif # TARGET_DEVICE != generic* 1479 endif # TARGET_PRODUCT != sdk 1480 1481 # ----------------------------------------------------------------- 1482 # The update package 1483 1484 name := $(TARGET_PRODUCT) 1485 ifeq ($(TARGET_BUILD_TYPE),debug) 1486 name := $(name)_debug 1487 endif 1488 name := $(name)-img-$(FILE_NAME_TAG) 1489 1490 INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1491 1492 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) 1493 @echo "Package: $@" 1494 $(hide) MKBOOTIMG=$(MKBOOTIMG) \ 1495 ./build/tools/releasetools/img_from_target_files -v \ 1496 -p $(HOST_OUT) \ 1497 $(BUILT_TARGET_FILES_PACKAGE) $@ 1498 1499 .PHONY: updatepackage 1500 updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET) 1501 1502 # ----------------------------------------------------------------- 1503 # A zip of the symbols directory. Keep the full paths to make it 1504 # more obvious where these files came from. 1505 # 1506 name := $(TARGET_PRODUCT) 1507 ifeq ($(TARGET_BUILD_TYPE),debug) 1508 name := $(name)_debug 1509 endif 1510 name := $(name)-symbols-$(FILE_NAME_TAG) 1511 1512 SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 1513 # For apps_only build we'll establish the dependency later in build/core/main.mk. 1514 ifndef TARGET_BUILD_APPS 1515 $(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 1516 endif 1517 $(SYMBOLS_ZIP): 1518 @echo "Package symbols: $@" 1519 $(hide) rm -rf $@ 1520 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) 1521 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED) 1522 1523 # ----------------------------------------------------------------- 1524 # A zip of the Android Apps. Not keeping full path so that we don't 1525 # include product names when distributing 1526 # 1527 name := $(TARGET_PRODUCT) 1528 ifeq ($(TARGET_BUILD_TYPE),debug) 1529 name := $(name)_debug 1530 endif 1531 name := $(name)-apps-$(FILE_NAME_TAG) 1532 1533 APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 1534 $(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 1535 @echo "Package apps: $@" 1536 $(hide) rm -rf $@ 1537 $(hide) mkdir -p $(dir $@) 1538 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*/*.apk $(TARGET_OUT_APPS_PRIVILEGED)/*/*.apk 1539 1540 1541 #------------------------------------------------------------------ 1542 # A zip of emma code coverage meta files. Generated for fully emma 1543 # instrumented build. 1544 # 1545 ifeq (true,$(EMMA_INSTRUMENT)) 1546 EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip 1547 # the dependency will be set up later in build/core/main.mk. 1548 $(EMMA_META_ZIP) : 1549 @echo "Collecting Emma coverage meta files." 1550 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \ 1551 zip -@ -q $@ 1552 1553 endif # EMMA_INSTRUMENT=true 1554 1555 #------------------------------------------------------------------ 1556 # A zip of Proguard obfuscation dictionary files. 1557 # Only for apps_only build. 1558 # 1559 ifdef TARGET_BUILD_APPS 1560 PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip 1561 # the dependency will be set up later in build/core/main.mk. 1562 $(PROGUARD_DICT_ZIP) : 1563 @echo "Packaging Proguard obfuscation dictionary files." 1564 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \ 1565 if [ -n "$$dict_files" ]; then \ 1566 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \ 1567 zip -q $@ $$dict_files $$unobfuscated_jars; \ 1568 else \ 1569 touch $(dir $@)/dummy; \ 1570 (cd $(dir $@) && zip -q $(notdir $@) dummy); \ 1571 zip -qd $@ dummy; \ 1572 rm $(dir $@)/dummy; \ 1573 fi 1574 1575 endif # TARGET_BUILD_APPS 1576 1577 # ----------------------------------------------------------------- 1578 # dalvik something 1579 .PHONY: dalvikfiles 1580 dalvikfiles: $(INTERNAL_DALVIK_MODULES) 1581 1582 # ----------------------------------------------------------------- 1583 # The emulator package 1584 ifeq ($(BUILD_EMULATOR),true) 1585 INTERNAL_EMULATOR_PACKAGE_FILES += \ 1586 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \ 1587 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \ 1588 $(INSTALLED_RAMDISK_TARGET) \ 1589 $(INSTALLED_SYSTEMIMAGE) \ 1590 $(INSTALLED_USERDATAIMAGE_TARGET) 1591 1592 name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 1593 1594 INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1595 1596 $(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 1597 @echo "Package: $@" 1598 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 1599 1600 endif 1601 # ----------------------------------------------------------------- 1602 # Old PDK stuffs, retired 1603 # The pdk package (Platform Development Kit) 1604 1605 #ifneq (,$(filter pdk,$(MAKECMDGOALS))) 1606 # include development/pdk/Pdk.mk 1607 #endif 1608 1609 1610 # ----------------------------------------------------------------- 1611 # The SDK 1612 1613 # The SDK includes host-specific components, so it belongs under HOST_OUT. 1614 sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT) 1615 1616 # Build a name that looks like: 1617 # 1618 # linux-x86 --> android-sdk_12345_linux-x86 1619 # darwin-x86 --> android-sdk_12345_mac-x86 1620 # windows-x86 --> android-sdk_12345_windows 1621 # 1622 sdk_name := android-sdk_$(FILE_NAME_TAG) 1623 ifeq ($(HOST_OS),darwin) 1624 INTERNAL_SDK_HOST_OS_NAME := mac 1625 else 1626 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) 1627 endif 1628 ifneq ($(HOST_OS),windows) 1629 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH) 1630 endif 1631 sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) 1632 1633 sdk_dep_file := $(sdk_dir)/sdk_deps.mk 1634 1635 ATREE_FILES := 1636 -include $(sdk_dep_file) 1637 1638 # if we don't have a real list, then use "everything" 1639 ifeq ($(strip $(ATREE_FILES)),) 1640 ATREE_FILES := \ 1641 $(ALL_PREBUILT) \ 1642 $(ALL_COPIED_HEADERS) \ 1643 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1644 $(INSTALLED_RAMDISK_TARGET) \ 1645 $(ALL_DOCS) \ 1646 $(ALL_SDK_FILES) 1647 endif 1648 1649 atree_dir := development/build 1650 1651 1652 sdk_atree_files := \ 1653 $(atree_dir)/sdk.exclude.atree \ 1654 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree 1655 1656 # development/build/sdk-android-<abi>.atree is used to differentiate 1657 # between architecture models (e.g. ARMv5TE versus ARMv7) when copying 1658 # files like the kernel image. We use TARGET_CPU_ABI because we don't 1659 # have a better way to distinguish between CPU models. 1660 ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree))) 1661 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree 1662 endif 1663 1664 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),) 1665 sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES) 1666 else 1667 sdk_atree_files += $(atree_dir)/sdk.atree 1668 endif 1669 1670 include $(BUILD_SYSTEM)/sdk_font.mk 1671 1672 deps := \ 1673 $(target_notice_file_txt) \ 1674 $(tools_notice_file_txt) \ 1675 $(OUT_DOCS)/offline-sdk-timestamp \ 1676 $(SYMBOLS_ZIP) \ 1677 $(INSTALLED_SYSTEMIMAGE) \ 1678 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1679 $(INSTALLED_RAMDISK_TARGET) \ 1680 $(INSTALLED_SDK_BUILD_PROP_TARGET) \ 1681 $(INSTALLED_BUILD_PROP_TARGET) \ 1682 $(ATREE_FILES) \ 1683 $(sdk_atree_files) \ 1684 $(HOST_OUT_EXECUTABLES)/atree \ 1685 $(HOST_OUT_EXECUTABLES)/line_endings \ 1686 $(SDK_FONT_DEPS) 1687 1688 INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip 1689 $(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name) 1690 $(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name) 1691 $(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file) 1692 $(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files) 1693 1694 # Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 1695 # 1696 #SDK_GNU_ERROR := true 1697 1698 $(INTERNAL_SDK_TARGET): $(deps) 1699 @echo "Package SDK: $@" 1700 $(hide) rm -rf $(PRIVATE_DIR) $@ 1701 $(hide) for f in $(target_gnu_MODULES); do \ 1702 if [ -f $$f ]; then \ 1703 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \ 1704 including GNU target $$f >&2; \ 1705 FAIL=$(SDK_GNU_ERROR); \ 1706 fi; \ 1707 done; \ 1708 if [ $$FAIL ]; then exit 1; fi 1709 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt 1710 $(hide) ( \ 1711 ATREE_STRIP="strip -x" \ 1712 $(HOST_OUT_EXECUTABLES)/atree \ 1713 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 1714 -m $(PRIVATE_DEP_FILE) \ 1715 -I . \ 1716 -I $(PRODUCT_OUT) \ 1717 -I $(HOST_OUT) \ 1718 -I $(TARGET_COMMON_OUT_ROOT) \ 1719 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \ 1720 -v "OUT_DIR=$(OUT_DIR)" \ 1721 -v "HOST_OUT=$(HOST_OUT)" \ 1722 -v "TARGET_ARCH=$(TARGET_ARCH)" \ 1723 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \ 1724 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \ 1725 -v "FONT_OUT=$(SDK_FONT_TEMP)" \ 1726 -o $(PRIVATE_DIR) && \ 1727 cp -f $(target_notice_file_txt) \ 1728 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \ 1729 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \ 1730 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ 1731 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \ 1732 chmod -R ug+rwX $(PRIVATE_DIR) && \ 1733 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \ 1734 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) 1735 1736 1737 # Is a Windows SDK requested? If so, we need some definitions from here 1738 # in order to find the Linux SDK used to create the Windows one. 1739 MAIN_SDK_NAME := $(sdk_name) 1740 MAIN_SDK_DIR := $(sdk_dir) 1741 MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET) 1742 ifneq ($(filter win_sdk,$(MAKECMDGOALS)),) 1743 include $(TOPDIR)development/build/tools/windows_sdk.mk 1744 endif 1745 1746 # ----------------------------------------------------------------- 1747 # Findbugs 1748 INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 1749 INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 1750 $(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 1751 @echo UnionBugs: $@ 1752 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \ 1753 > $@ 1754 $(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET) 1755 @echo ConvertXmlToText: $@ 1756 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \ 1757 $(INTERNAL_FINDBUGS_XML_TARGET) > $@ 1758 1759 # ----------------------------------------------------------------- 1760 # Findbugs 1761 1762 # ----------------------------------------------------------------- 1763 # These are some additional build tasks that need to be run. 1764 ifneq ($(dont_bother),true) 1765 include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 1766 -include $(sort $(wildcard vendor/*/build/tasks/*.mk)) 1767 -include $(sort $(wildcard device/*/build/tasks/*.mk)) 1768 # Also the project-specific tasks 1769 -include $(sort $(wildcard vendor/*/*/build/tasks/*.mk)) 1770 -include $(sort $(wildcard device/*/*/build/tasks/*.mk)) 1771 endif 1772 1773 # ----------------------------------------------------------------- 1774 # Create SDK repository packages. Must be done after tasks/* since 1775 # we need the addon rules defined. 1776 ifneq ($(sdk_repo_goal),) 1777 include $(TOPDIR)development/build/tools/sdk_repo.mk 1778 endif 1779