kernel: Ensure dtb(o) always get rebuilt

* AOSP build system is not aware of dtb(o) source update, and thus
   won't rebuild the images, results in outdated artifact.
 * Convert DTB(O)_OUT to make targets and make the images depend on them
   to address the issue. This makes AOSP build system be aware of
   their timestamp changes and re-execute recipes depending on them.
   Finally, it's up to kernel's build system to decide actions to take.

Test: m dtb(o)image and observe dtb(o).img get rebuilt
Change-Id: I197e7d2d3e013ded0e555fc22bb6a1200d40df9c
This commit is contained in:
dianlujitao 2022-06-12 18:50:34 +08:00 committed by Michael Bestas
parent 9955cd657b
commit 709371be5e

View File

@ -440,35 +440,41 @@ include $(BOARD_CUSTOM_DTBOIMG_MK)
else
MKDTIMG := $(HOST_OUT_EXECUTABLES)/mkdtimg$(HOST_EXECUTABLE_SUFFIX)
MKDTBOIMG := $(HOST_OUT_EXECUTABLES)/mkdtboimg.py$(HOST_EXECUTABLE_SUFFIX)
$(BOARD_PREBUILT_DTBOIMAGE): $(DTC) $(MKDTIMG) $(MKDTBOIMG)
ifeq ($(BOARD_KERNEL_SEPARATED_DTBO),true)
$(DTBO_OUT):
mkdir -p $(DTBO_OUT)
$(BOARD_PREBUILT_DTBOIMAGE): $(DTC) $(MKDTIMG) $(MKDTBOIMG) $(DTBO_OUT)
$(BOARD_PREBUILT_DTBOIMAGE):
@echo "Building dtbo.img"
rm -rf $(DTBO_OUT)
$(hide) find $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtbo" | xargs rm -f
$(call make-dtbo-target,$(KERNEL_DEFCONFIG))
ifeq ($(BOARD_KERNEL_SEPARATED_DTBO),true)
$(call make-dtbo-target,dtbs)
ifdef BOARD_DTBO_CFG
$(MKDTBOIMG) cfg_create $@ $(BOARD_DTBO_CFG) -d $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts
else
$(MKDTBOIMG) create $@ --page_size=$(BOARD_KERNEL_PAGESIZE) $(shell find $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtbo" | sort)
endif
endif # BOARD_DTBO_CFG
else
$(BOARD_PREBUILT_DTBOIMAGE):
@echo "Building dtbo.img"
$(call make-dtbo-target,$(KERNEL_DEFCONFIG))
$(call make-dtbo-target,dtbo.img)
endif # BOARD_KERNEL_SEPARATED_DTBO
$(hide) touch -c $(DTBO_OUT)
endif # BOARD_CUSTOM_DTBOIMG_MK
endif # TARGET_NEEDS_DTBOIMAGE/BOARD_KERNEL_SEPARATED_DTBO
ifeq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true)
ifeq ($(BOARD_PREBUILT_DTBIMAGE_DIR),)
$(INSTALLED_DTBIMAGE_TARGET): $(DTC)
$(DTB_OUT):
mkdir -p $(DTB_OUT)
$(INSTALLED_DTBIMAGE_TARGET): $(DTC) $(DTB_OUT)
@echo "Building dtb.img"
rm -rf $(DTB_OUT)
$(hide) find $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtb" | xargs rm -f
$(call make-dtb-target,$(KERNEL_DEFCONFIG))
$(call make-dtb-target,dtbs)
cat $(shell find $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtb" | sort) > $@
$(hide) touch -c $(DTB_OUT)
endif # !BOARD_PREBUILT_DTBIMAGE_DIR
endif # BOARD_INCLUDE_DTB_IN_BOOTIMG