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