Re: [PATCH v2 0/2] kbuild: Show Kconfig fragments in "help"

From: Nicolas Schier
Date: Tue Aug 29 2023 - 16:09:18 EST


On Tue, Aug 29, 2023 at 11:57:19PM +0900 Masahiro Yamada wrote:
> On Tue, Aug 29, 2023 at 3:55 PM Nicolas Schier <nicolas@xxxxxxxxx> wrote:
> >
> > On Mon 28 Aug 2023 16:17:07 GMT, Michael Ellerman wrote:
> > > Masahiro Yamada <masahiroy@xxxxxxxxxx> writes:
> > > > On Sat, Aug 26, 2023 at 4:55 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> > > >>
> > > >> Hi,
> > > >>
> > > >> This is my series to show *.config targets in the "help" target so these
> > > >> various topics can be more easily discoverd.
> > > >>
> > > >> v2:
> > > >> - split .fragment from .config to hide "internal" fragments
> > > >
> > > > Please do not do this churn.
> > >
> > > That was my idea :}
> > >
> > > > Like Randy, I did not get "why" part quiet well,
> > > > but if you are eager about this,
> > > > you can show help message only when the following
> > > > ("# Help:" prefix for example) is found in the first line.
> > > >
> > > > # Help: blah blah
> > > > # other comment
> > >
> > > I did think of that, but wasn't sure how to do it in make.
> >
> > Something like this should do it:
> >
> > @grep -Hnm1 -e '^# Help:' $(foreach f, $(sort $(notdir $(call configfiles,*.config))), $(firstword $(call configfiles,$(f)))) | \
> > while read loc dummy helptext; do \
> > tmp="$${loc%:#}"; file="$${tmp%:*}"; line="$${tmp##*:}"; \
> > [ "$${line}" = "1" ] && \
> > printf " %-25s - %s\\n" "$${file##*/}" "$${helptext}"; \
> > done
> >
> > but this neither beautiful nor elegant it likes to be improved.
> >
> > Kind regards,
> > Nicolas
>
>
>
>
> The attached patch will work too.
>
> I dropped the "in the first line" restriction
> because SPDX might be placed in the first line
> of config fragments.
>
>
>
> --
> Best Regards
> Masahiro Yamada

> diff --git a/Makefile b/Makefile
> index e21bf66af6fd..23cd62a5ff05 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1552,7 +1552,6 @@ help:
> @echo ' mrproper - Remove all generated files + config + various backup files'
> @echo ' distclean - mrproper + remove editor backup and patch files'
> @echo ''
> - @echo 'Configuration targets:'
> @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
> @echo ''
> @echo 'Other generic targets:'
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index fdc2e3abd615..c4b2a8a19fc8 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -335,9 +335,5 @@ define archhelp
> echo ' bzdisk/fdimage*/hdimage/isoimage also accept:'
> echo ' FDARGS="..." arguments for the booted kernel'
> echo ' FDINITRD=file initrd for the booted kernel'
> - echo ''
> - echo ' kvm_guest.config - Enable Kconfig items for running this kernel as a KVM guest'
> - echo ' xen.config - Enable Kconfig items for running this kernel as a Xen guest'
> - echo ' x86_debug.config - Enable tip tree debugging options for testing'
>
> endef
> diff --git a/kernel/configs/kvm_guest.config b/kernel/configs/kvm_guest.config
> index 208481d91090..d0877063d925 100644
> --- a/kernel/configs/kvm_guest.config
> +++ b/kernel/configs/kvm_guest.config
> @@ -1,3 +1,4 @@
> +# Help: Bootable as a KVM guest
> CONFIG_NET=y
> CONFIG_NET_CORE=y
> CONFIG_NETDEVICES=y
> diff --git a/kernel/configs/x86_debug.config b/kernel/configs/x86_debug.config
> index 6fac5b405334..35f48671b8d5 100644
> --- a/kernel/configs/x86_debug.config
> +++ b/kernel/configs/x86_debug.config
> @@ -1,3 +1,4 @@
> +# Help: Debugging options for tip tree testing
> CONFIG_X86_DEBUG_FPU=y
> CONFIG_LOCK_STAT=y
> CONFIG_DEBUG_VM=y
> diff --git a/kernel/configs/xen.config b/kernel/configs/xen.config
> index 436f806aa1ed..6878b9a49be8 100644
> --- a/kernel/configs/xen.config
> +++ b/kernel/configs/xen.config
> @@ -1,3 +1,5 @@
> +# Help: Bootable as a Xen guest
> +#
> # global stuff - these enable us to allow some
> # of the not so generic stuff below for xen
> CONFIG_PARAVIRT=y
> diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
> index af1c96198f49..e72c5ee659a9 100644
> --- a/scripts/kconfig/Makefile
> +++ b/scripts/kconfig/Makefile
> @@ -93,11 +93,13 @@ endif
> %_defconfig: $(obj)/conf
> $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
>
> -configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
> +configfiles = $(wildcard $(srctree)/kernel/configs/$(1) $(srctree)/arch/$(SRCARCH)/configs/$(1))
> +all-config-fragments = $(call configfiles,*)
> +config-fragments = $(call configfiles,$@)
>
> %.config: $(obj)/conf
> - $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
> - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
> + $(if $(config-fragments),, $(error $@ fragment does not exists on this architecture))
> + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(config-fragments)
> $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
>
> PHONY += tinyconfig
> @@ -115,6 +117,7 @@ clean-files += tests/.cache
>
> # Help text used by make help
> help:
> + @echo 'Configuration targets:'
> @echo ' config - Update current config utilising a line-oriented program'
> @echo ' nconfig - Update current config utilising a ncurses menu based program'
> @echo ' menuconfig - Update current config utilising a menu based program'
> @@ -141,6 +144,12 @@ help:
> @echo ' default value without prompting'
> @echo ' tinyconfig - Configure the tiniest possible kernel'
> @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
> + @echo ''
> + @echo 'Configuration topic targets:'
> + @$(foreach f, $(all-config-fragments), \
> + if help=$$(grep -m1 '^# Help: ' $(f)); then \
> + printf ' %-25s - %s\n' '$(notdir $(f))' "$${help#*: }"; \
> + fi;)

thanks, this looks much better, and SPDX is a good point.

Kind regards,
Nicolas

Attachment: signature.asc
Description: PGP signature