Support BOARD_SYSTEM_DLKM_SRC build config
In aosp/2323114 , BOARD_SYSTEM_DLKM_SRC is removed in favor of
BOARD_SYSTEM_KERNEL_MODULES . However, BOARD_SYSTEM_DLKM_SRC preserves
directory structure of input kernel modules, where as
BOARD_SYSTEM_KERNEL_MODULES flattens everything by copying all modules
into the same directory. This causes some issues as vendor_dlkm that
depend on system_dlkm modules now need to update their modules.dep file
due to changes in path. For backward compatibility, add support
for BOARD_SYSTEM_DLKM_SRC .
When both BOARD_SYSTEM_DLKM_SRC and BOARD_SYSTEM_KERNEL_MODULES are
set, BOARD_SYSTEM_KERNEL_MODULES will be preferred. The priority is arbitrary,
but we need a defined ordering to prevent double copying.
Test: th
Bug: 267014648
Change-Id: Ib2f5229af02ea2b7c0d96da70afed9118f484c97
diff --git a/core/Makefile b/core/Makefile
index 0503c35..03bc18b 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -596,6 +596,19 @@
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(kmd)))))
+ifeq ($(BOARD_SYSTEM_KERNEL_MODULES),)
+ifneq ($(BOARD_SYSTEM_DLKM_SRC),)
+ifneq ($(wildcard $(BOARD_SYSTEM_DLKM_SRC)/*),)
+ SYSTEM_KERNEL_MODULES := $(call find-files-in-subdirs,$(BOARD_SYSTEM_DLKM_SRC),*.ko,.)
+ SRC_SYSTEM_KERNEL_MODULES := $(patsubst %,$(BOARD_SYSTEM_DLKM_SRC)/%,$(SYSTEM_KERNEL_MODULES))
+ DST_SYSTEM_KERNEL_MODULES := $(patsubst %,:$(TARGET_OUT_SYSTEM_DLKM)/%,$(SYSTEM_KERNEL_MODULES))
+ SYSTEM_KERNEL_MODULE_COPY_PAIRS := $(join $(SRC_SYSTEM_KERNEL_MODULES),$(DST_SYSTEM_KERNEL_MODULES))
+ ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(SYSTEM_KERNEL_MODULE_COPY_PAIRS))
+endif
+endif
+endif
+
+
# -----------------------------------------------------------------
# Cert-to-package mapping. Used by the post-build signing tools.
# Use a macro to add newline to each echo command