build: tasks: kernel: Rework kernel fragments handling
* Since some time you can specify multiple configs when you prepare .config and they'll get merged to main one
* To use it inline:
TARGET_KERNEL_CONFIG := main_defconfig fragment1.config fragment2.config ...
* TARGET_KERNEL_ADDITIONAL_CONFIG has been nuked since it's superseed by this new logic
* kernelsavedefconfig will only use the base defconfig
Change-Id: I479c762a9235ed0ef6fcdc79b53e084d5e2d78a6
diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
index 64fcc20..a3aaaac 100644
--- a/build/tasks/kernel.mk
+++ b/build/tasks/kernel.mk
@@ -21,10 +21,11 @@
#
# These config vars are usually set in BoardConfig.mk:
#
-# TARGET_KERNEL_CONFIG = Kernel defconfig
+# TARGET_KERNEL_CONFIG = List of kernel defconfigs, first one being the base one,
+# while all the others are fragments that will be merged.
+# to main one in .config.
# TARGET_KERNEL_VARIANT_CONFIG = Variant defconfig, optional
# TARGET_KERNEL_SELINUX_CONFIG = SELinux defconfig, optional
-# TARGET_KERNEL_ADDITIONAL_CONFIG = Additional defconfig, optional
#
# TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to true
#
@@ -95,19 +96,13 @@
KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH)
endif
KERNEL_DEFCONFIG_DIR := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs
-KERNEL_DEFCONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_DEFCONFIG)
-RECOVERY_KERNEL_DEFCONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(RECOVERY_DEFCONFIG)
+ALL_KERNEL_DEFCONFIG_SRCS := $(foreach config,$(KERNEL_DEFCONFIG),$(KERNEL_DEFCONFIG_DIR)/$(config))
+ALL_RECOVERY_KERNEL_DEFCONFIG_SRCS := $(foreach config,$(RECOVERY_DEFCONFIG),$(KERNEL_DEFCONFIG_DIR)/$(config))
-ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),)
-KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG)
-KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_ADDITIONAL_CONFIG)
- ifeq ("$(wildcard $(KERNEL_ADDITIONAL_CONFIG_SRC))","")
- $(warning TARGET_KERNEL_ADDITIONAL_CONFIG '$(TARGET_KERNEL_ADDITIONAL_CONFIG)' doesn't exist)
- KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
- endif
-else
- KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
-endif
+BASE_KERNEL_DEFCONFIG := $(word 1, $(KERNEL_DEFCONFIG))
+BASE_KERNEL_DEFCONFIG_SRC := $(word 1, $(ALL_KERNEL_DEFCONFIG_SRCS))
+BASE_RECOVERY_KERNEL_DEFCONFIG := $(word 1, $(RECOVERY_DEFCONFIG))
+BASE_RECOVERY_KERNEL_DEFCONFIG_SRC := $(word 1, $(ALL_RECOVERY_KERNEL_DEFCONFIG_SRCS))
ifeq ($(TARGET_PREBUILT_KERNEL),)
ifeq ($(BOARD_KERNEL_IMAGE_NAME),)
@@ -263,8 +258,6 @@
# System tools are no longer allowed on 10+
PATH_OVERRIDE += $(TOOLS_PATH_OVERRIDE)
-KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config
-
# Internal implementation of make-kernel-target
# $(1): output path (The value passed to O=)
# $(2): target to build (eg. defconfig, modules, dtbo.img)
@@ -309,11 +302,6 @@
fi
# Create defconfig build artifact
$(call internal-make-kernel-target,$(1),savedefconfig)
- $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \
- echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \
- $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(1) $(1)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \
- $(call make-kernel-target,KCONFIG_ALLCONFIG=$(KERNEL_BUILD_OUT_PREFIX)$(1)/.config alldefconfig); \
- fi
endef
# Make a kernel target
@@ -399,10 +387,7 @@
$(KERNEL_OUT):
mkdir -p $(KERNEL_OUT)
-$(KERNEL_ADDITIONAL_CONFIG_OUT): $(KERNEL_OUT)
- $(hide) cmp -s $(KERNEL_ADDITIONAL_CONFIG_SRC) $@ || cp $(KERNEL_ADDITIONAL_CONFIG_SRC) $@;
-
-$(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT)
+$(KERNEL_CONFIG): $(ALL_KERNEL_DEFCONFIG_SRCS)
@echo "Building Kernel Config"
$(call make-kernel-config,$(KERNEL_OUT),$(KERNEL_DEFCONFIG))
@@ -442,8 +427,8 @@
.PHONY: kernelsavedefconfig alldefconfig
kernelsavedefconfig: $(KERNEL_OUT)
- $(call make-kernel-config,$(KERNEL_OUT),$(KERNEL_DEFCONFIG))
- cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC)
+ $(call make-kernel-config,$(KERNEL_OUT),$(BASE_KERNEL_DEFCONFIG))
+ cp $(KERNEL_OUT)/defconfig $(BASE_KERNEL_DEFCONFIG_SRC)
alldefconfig: $(KERNEL_OUT)
env KCONFIG_NOTIMESTAMP=true \
@@ -494,7 +479,7 @@
$(RECOVERY_KERNEL_OUT):
mkdir -p $(RECOVERY_KERNEL_OUT)
-$(RECOVERY_KERNEL_CONFIG): $(RECOVERY_KERNEL_DEFCONFIG_SRC)
+$(RECOVERY_KERNEL_CONFIG): $(ALL_RECOVERY_DEFCONFIG_SRCS)
@echo "Building Recovery Kernel Config"
$(call make-kernel-config,$(RECOVERY_KERNEL_OUT),$(RECOVERY_DEFCONFIG))