Re: [PATCH 5/8] kconfig: Add support for merging defconfig fragments

"Chuck Lever" <[email protected]> Sun, 07 Dec 2025 11:25:18 -0500
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>

On Sat, Dec 6, 2025, at 11:56 AM, Luis Chamberlain wrote:
> Add support for composing defconfigs from base configurations and
> fragments using the + syntax. This allows users to combine a base
> defconfig with additional config fragments stored in defconfigs/configs/.
>
> The merge_config.sh script from the kernel is used to combine the
> configurations. Multiple fragments can be chained together.
>
> Example usage:
>   make defconfig-datacrunch-b200-or-less+myworkflow
>   make defconfig-aws+fstests+debug
>
> This enables modular configuration management where common settings
> can be shared across different base configurations.

\o/ !!

Reviewed-by: Chuck Lever <[email protected]>


> Generated-by: Claude AI
> Signed-off-by: Luis Chamberlain <[email protected]>
> ---
>  scripts/kconfig/kconfig.Makefile | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/kconfig.Makefile b/scripts/kconfig/kconfig.Makefile
> index 5d6db4b8..0113ffd3 100644
> --- a/scripts/kconfig/kconfig.Makefile
> +++ b/scripts/kconfig/kconfig.Makefile
> @@ -57,7 +57,25 @@ PHONY += $(simple-targets)
>  $(simple-targets): $(KCONFIG_DIR)/conf Kconfig
>  	$< --$@ Kconfig
> 
> +# Support merging config fragments with base defconfigs
> +# Usage: make defconfig-<base>+<fragment>
> +# Example: make defconfig-datacrunch-b200-or-less+myworkflow
> +#
> +# The fragment is looked up in defconfigs/configs/<fragment>.config
> +# Multiple fragments can be chained: make defconfig-base+frag1+frag2
>  defconfig-%:: $(KCONFIG_DIR)/conf include/config/project.release Kconfig
> -	@$< --defconfig=defconfigs/$(@:defconfig-%=%) Kconfig
> +	@STEM="$(@:defconfig-%=%)"; \
> +	if echo "$$STEM" | grep -q '+'; then \
> +		BASE=$$(echo "$$STEM" | cut -d'+' -f1); \
> +		FRAGS=$$(echo "$$STEM" | cut -d'+' -f2- | tr '+' ' '); \
> +		FRAG_FILES=""; \
> +		for f in $$FRAGS; do \
> +			FRAG_FILES="$$FRAG_FILES defconfigs/configs/$$f.config"; \
> +		done; \
> +		$(KCONFIG_DIR)/merge_config.sh -m -Q defconfigs/$$BASE $$FRAG_FILES && \
> +		$< --defconfig=.config Kconfig; \
> +	else \
> +		$< --defconfig=defconfigs/$$STEM Kconfig; \
> +	fi
> 
>  .PHONY: $(PHONY)
> -- 
> 2.51.0

-- 
Chuck Lever