kernel: Handle kernel modules correctly

Place kernel module output in the correct location.
Perform depmod steps (copied from build-image-kernel-modules function in
build/make/core/Makefile).
See: https://source.android.com/devices/architecture/kernel/modular-kernels

Change-Id: I6e70012a5c1acdb276f9bee0d57631d2805f71ea
This commit is contained in:
Ethan Chen 2017-12-03 23:59:48 -08:00 committed by Rashed Abdel-Tawab
parent dc0dfc9501
commit bf38db2a5e

View file

@ -197,9 +197,13 @@ KERNEL_HEADERS_INSTALL_STAMP := $(KERNEL_OUT)/.headers_install_stamp
ifeq ($(NEED_KERNEL_MODULE_ROOT),true)
KERNEL_MODULES_INSTALL := root
KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT)/lib/modules
KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery)
KERNEL_MODULE_MOUNTPOINT :=
else
KERNEL_MODULES_INSTALL := system
KERNEL_MODULES_OUT := $(TARGET_OUT)/lib/modules
KERNEL_MODULES_INSTALL := $(TARGET_COPY_OUT_VENDOR)
KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR)/lib/modules
KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor)
KERNEL_MODULE_MOUNTPOINT := vendor
endif
TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX))
@ -248,6 +252,7 @@ $(KERNEL_OUT_STAMP):
$(hide) mkdir -p $(KERNEL_OUT)
$(hide) rm -rf $(KERNEL_MODULES_OUT)
$(hide) mkdir -p $(KERNEL_MODULES_OUT)
$(hide) rm -rf $(KERNEL_DEPMOD_STAGING_DIR)
$(hide) touch $@
KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config
@ -293,7 +298,11 @@ INSTALLED_KERNEL_MODULES:
$(KERNEL_TOOLCHAIN_PATH)strip --strip-unneeded $$f; \
mv $$f $(KERNEL_MODULES_OUT); \
done && \
rm -rf $$mpath; \
rm -rf $$mpath && \
mkdir -p $(KERNEL_DEPMOD_STAGING_DIR)/lib/modules/0.0/$(KERNEL_MODULE_MOUNTPOINT)/lib/modules && \
find $(KERNEL_MODULES_OUT) -name *.ko -exec cp {} $(KERNEL_DEPMOD_STAGING_DIR)/lib/modules/0.0/$(KERNEL_MODULE_MOUNTPOINT)/lib/modules \; && \
$(DEPMOD) -b $(KERNEL_DEPMOD_STAGING_DIR) 0.0 && \
sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(KERNEL_DEPMOD_STAGING_DIR)/lib/modules/0.0/modules.dep > $(KERNEL_MODULES_OUT)/modules.dep; \
fi
$(TARGET_KERNEL_MODULES): TARGET_KERNEL_BINARIES