Refactor vendor_boot v4 build logic and add more checks
Add more checks around BOARD_BOOT_HEADER_VERSION in board_config.mk.
Refactor generation logic of vendor_boot ramdisk fragments.
Consolidate initialization and validation check to its own section.
Adjust some variable names and initialization sequence so the follow-up
change can land more cleanly.
Rename variable name "dir" so that it don't collide with the Makefile
function "$(dir ...)".
Bug: 183395459
Test: Presubmit; Change should be no-op with respect to build artifacts.
Test: Modify BoardConfig of CF and m dist. Verify the vendor_boot.img
with unpack_bootimg.
Change-Id: I8785c40dd9f87f3797a56ada93e65939d27d0e9b
diff --git a/core/board_config.mk b/core/board_config.mk
index a739784..9ae597e 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -25,6 +25,7 @@
_board_strip_readonly_list += BOARD_HAVE_BLUETOOTH
_board_strip_readonly_list += BOARD_INSTALLER_CMDLINE
_board_strip_readonly_list += BOARD_KERNEL_CMDLINE
+_board_strip_readonly_list += BOARD_BOOT_HEADER_VERSION
_board_strip_readonly_list += BOARD_BOOTCONFIG
_board_strip_readonly_list += BOARD_KERNEL_BASE
_board_strip_readonly_list += BOARD_USES_GENERIC_AUDIO
@@ -828,7 +829,14 @@
ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
$(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if not building vendor_boot image)
endif
-endif
+else # BUILDING_VENDOR_BOOT_IMAGE
+ ifneq (,$(call math_lt,$(BOARD_BOOT_HEADER_VERSION),4))
+ ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
+ $(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if \
+ BOARD_BOOT_HEADER_VERSION is less than 4)
+ endif
+ endif
+endif # BUILDING_VENDOR_BOOT_IMAGE
ifneq ($(words $(BOARD_VENDOR_RAMDISK_FRAGMENTS)),$(words $(sort $(BOARD_VENDOR_RAMDISK_FRAGMENTS))))
$(error BOARD_VENDOR_RAMDISK_FRAGMENTS has duplicate entries: $(BOARD_VENDOR_RAMDISK_FRAGMENTS))