Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d4dc44f authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Michael Bestas
Browse files

Add BOARD_CUSTOM_BOOTIMG_MK support

This is a combination of 2 commits.
This is the 1st commit message:

    Add BOARD_CUSTOM_BOOTIMG_MK support

    Simplified version of the previous implementation. Recovery's ramdisk
    is spun off from the main recovery target again to allow overriding
    just the image-generation step

    [mikeioannina]: Squash cm-13.0 changes and adapt to N

    Change-Id: I058d214f0cf2d05b7621b369ef1f8a983c3ac258

This is the commit message #2:

    build: Handle custom boot images properly

    When a pre-built image should be used, it should be stored in the
    target files zip so that it can be used with external signing
    processes.

    Original-Change-Id: I2661af9ac58af30bb9314b552775046d3abf44e0
    Change-Id: I10b3bd0bb33489b8ffb26d16d002f8dd6ff405ad

[aleasto]
  Rewritten for R, where the recovery ramdisk is created via
  make dependencies, rather than $(call)s

Change-Id: I058d214f0cf2d05b7621b369ef1f8a983c3ac258
parent 00ed066b
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -1249,6 +1249,8 @@ INTERNAL_MKBOOTIMG_VERSION_ARGS := \
ifdef BUILDING_BOOT_IMAGE
INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)

ifndef BOARD_CUSTOM_BOOTIMG_MK

ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)

@@ -1319,6 +1321,7 @@ bootimage-nodeps: $(MKBOOTIMG)
	$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))

endif # TARGET_BOOTIMAGE_USE_EXT2
endif # BOARD_CUSTOM_BOOTIMG_MK not defined
endif # BUILDING_BOOT_IMAGE

else # TARGET_NO_KERNEL == "true"
@@ -1928,6 +1931,7 @@ IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(r

recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
recovery_uncompressed_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.cpio
recovery_resources_common := $(call include-path-for, recovery)/res

# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
@@ -2191,7 +2195,7 @@ ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
  BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
endif

$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
$(recovery_uncompressed_ramdisk): $(MKBOOTFS) \
	    $(INTERNAL_ROOT_FILES) \
	    $(INSTALLED_RAMDISK_TARGET) \
	    $(INTERNAL_RECOVERYIMAGE_FILES) \
@@ -2226,7 +2230,13 @@ $(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
	  cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
	ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
	$(BOARD_RECOVERY_IMAGE_PREPARE)
	$(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
	@echo ----- Making uncompressed recovery ramdisk ------
	$(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) > $@

$(recovery_ramdisk): $(recovery_uncompressed_ramdisk) $(COMPRESSION_COMMAND_DEPS)
	@echo ----- Making compressed recovery ramdisk ------
	$(COMPRESSION_COMMAND) < $(recovery_uncompressed_ramdisk) > $@


# $(1): output file
# $(2): kernel file
@@ -2285,8 +2295,12 @@ $(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
	$(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
endif # BOARD_USES_RECOVERY_AS_BOOT

ifndef BOARD_CUSTOM_BOOTIMG_MK
$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
	$(call build-recoveryimage-target, $@, $(recovery_kernel))
else
INTERNAL_RECOVERYIMAGE_ARGS += --kernel $(recovery_kernel)
endif # BOARD_CUSTOM_BOOTIMG_MK

ifdef RECOVERY_RESOURCE_ZIP
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
@@ -2315,6 +2329,11 @@ ifneq ($(BOARD_NAND_SPARE_SIZE),)
$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
endif

ifdef BOARD_CUSTOM_BOOTIMG_MK
include $(BOARD_CUSTOM_BOOTIMG_MK)
endif


ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
# -----------------------------------------------------------------
# the debug ramdisk, which is the original ramdisk plus additional
@@ -4707,6 +4726,12 @@ ifdef BOARD_KERNEL_PAGESIZE
endif
	echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
ifdef BOARD_CUSTOM_BOOTIMG
	@# Prebuilt boot images
	$(hide) mkdir -p $(zip_root)/BOOTABLE_IMAGES
	$(hide) $(ACP) $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/BOOTABLE_IMAGES/
	$(hide) $(ACP) $(INSTALLED_RECOVERYIMAGE_TARGET) $(zip_root)/BOOTABLE_IMAGES/
endif
ifdef BUILDING_SYSTEM_IMAGE
	@# Contents of the system image
	$(hide) $(call package_files-copy-root, \