Add BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.

This variable indicates whether recovery resources are moved to
vendor_boot. If true:

- $OUT/recovery.img will not be built
- $OUT/recovery/root will be included in vendor_boot ramdisk

Bug: 156098440
Test: set to true and check output
Test: `m target-files-package` and manually inspect output
Change-Id: I56dda56bab7def1540f4fb506323e3e605620cd4
diff --git a/core/board_config.mk b/core/board_config.mk
index 73900a6..03d2b3e 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -103,9 +103,12 @@
 #   Update mechanism of the boot image is not enforced by this variable.
 # - BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE controls whether the recovery image
 #   contains a kernel or not.
+# - BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT controls whether ramdisk
+#   recovery resources are built to vendor_boot.
 _board_strip_readonly_list += \
   BOARD_USES_GENERIC_KERNEL_IMAGE \
   BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE \
+  BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT \
 
 _build_broken_var_list := \
   BUILD_BROKEN_DUP_RULES \
@@ -374,6 +377,9 @@
 ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),)
   ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
     BUILDING_RECOVERY_IMAGE := true
+  else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
+    # Set to true to build recovery resources for vendor_boot
+    BUILDING_RECOVERY_IMAGE := true
   else ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
     ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
       BUILDING_RECOVERY_IMAGE := true
@@ -761,3 +767,19 @@
     $(error Should not set BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE if not building recovery image)
   endif
 endif
+
+ifndef BUILDING_VENDOR_BOOT_IMAGE
+  ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
+    $(error Should not set BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT if not building vendor_boot image)
+  endif
+endif
+
+# If BOARD_USES_GENERIC_KERNEL_IMAGE is set, BOARD_USES_RECOVERY_AS_BOOT must not be set.
+# Devices without a dedicated recovery partition uses BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT to
+# build recovery into vendor_boot.
+ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
+  ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
+    $(error BOARD_USES_RECOVERY_AS_BOOT cannot be true if BOARD_USES_GENERIC_KERNEL_IMAGE is true. \
+      Use BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT instead)
+  endif
+endif