Refactor build logic of boot-debug & vendor_boot-debug
Add PRODUCT variables
PRODUCT_BUILD_DEBUG_BOOT_IMAGE
PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE
as toggles to enable/disable building boot-debug & vendor_boot-debug.
Bug: 200945738
Test: m bootimage_debug
Change-Id: Ic032b8594f776f911d7b6345a97d64fed930d890
diff --git a/core/board_config.mk b/core/board_config.mk
index 53dbb92..8397ea7 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -439,6 +439,86 @@
endif
.KATI_READONLY := BUILDING_RAMDISK_IMAGE
+# Are we building a debug vendor_boot image
+BUILDING_DEBUG_VENDOR_BOOT_IMAGE :=
+# Can't build vendor_boot-debug.img if BOARD_BUILD_SYSTEM_ROOT_IMAGE is true,
+# because building debug vendor_boot image requires a ramdisk.
+ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
+ ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
+ $(warning PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE is true, but so is BOARD_BUILD_SYSTEM_ROOT_IMAGE. \
+ Skip building the debug vendor_boot image.)
+ endif
+# Can't build vendor_boot-debug.img if we're not building a ramdisk.
+else ifndef BUILDING_RAMDISK_IMAGE
+ ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
+ $(warning PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE is true, but we're not building a ramdisk image. \
+ Skip building the debug vendor_boot image.)
+ endif
+# Can't build vendor_boot-debug.img if we're not building a vendor_boot.img.
+else ifndef BUILDING_VENDOR_BOOT_IMAGE
+ ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
+ $(warning PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE is true, but we're not building a vendor_boot image. \
+ Skip building the debug vendor_boot image.)
+ endif
+else
+ ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),)
+ BUILDING_DEBUG_VENDOR_BOOT_IMAGE := true
+ else ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
+ BUILDING_DEBUG_VENDOR_BOOT_IMAGE := true
+ endif
+endif
+.KATI_READONLY := BUILDING_DEBUG_VENDOR_BOOT_IMAGE
+
+_has_boot_img_artifact :=
+ifneq ($(strip $(TARGET_NO_KERNEL)),true)
+ ifdef BUILDING_BOOT_IMAGE
+ _has_boot_img_artifact := true
+ endif
+ # BUILDING_RECOVERY_IMAGE && BOARD_USES_RECOVERY_AS_BOOT implies that
+ # recovery is being built with the file name *boot.img*, which still counts
+ # as "building boot.img".
+ ifdef BUILDING_RECOVERY_IMAGE
+ ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
+ _has_boot_img_artifact := true
+ endif
+ endif
+endif
+
+# Are we building a debug boot image
+BUILDING_DEBUG_BOOT_IMAGE :=
+# Can't build boot-debug.img if BOARD_BUILD_SYSTEM_ROOT_IMAGE is true,
+# because building debug boot image requires a ramdisk.
+ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
+ ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
+ $(warning PRODUCT_BUILD_DEBUG_BOOT_IMAGE is true, but so is BOARD_BUILD_SYSTEM_ROOT_IMAGE. \
+ Skip building the debug boot image.)
+ endif
+# Can't build boot-debug.img if we're not building a ramdisk.
+else ifndef BUILDING_RAMDISK_IMAGE
+ ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
+ $(warning PRODUCT_BUILD_DEBUG_BOOT_IMAGE is true, but we're not building a ramdisk image. \
+ Skip building the debug boot image.)
+ endif
+# Can't build boot-debug.img if we're not building a boot.img.
+else ifndef _has_boot_img_artifact
+ ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
+ $(warning PRODUCT_BUILD_DEBUG_BOOT_IMAGE is true, but we're not building a boot image. \
+ Skip building the debug boot image.)
+ endif
+else
+ ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),)
+ BUILDING_DEBUG_BOOT_IMAGE := true
+ # Don't build boot-debug.img if we're already building vendor_boot-debug.img.
+ ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
+ BUILDING_DEBUG_BOOT_IMAGE :=
+ endif
+ else ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
+ BUILDING_DEBUG_BOOT_IMAGE := true
+ endif
+endif
+.KATI_READONLY := BUILDING_DEBUG_BOOT_IMAGE
+_has_boot_img_artifact :=
+
# Are we building a userdata image
BUILDING_USERDATA_IMAGE :=
ifeq ($(PRODUCT_BUILD_USERDATA_IMAGE),)