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