Skip to contentSkip to conversation

package/pkg-kconfig: introduce generic help (branch yem/kconfig-help)

PATCH In review Yann E. MORIN 3 participants 8 messages Jul 24, 2021 – Aug 5, 2021

lore
Share & tools
lore
#0 lore raw

cover package/pkg-kconfig: introduce generic help (branch yem/kconfig-help)

Hello All!

This is a counter-proposal to an eariler patch from Thomas, which adds and fixes help entries for kconfig packages:

    https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Compared to that patch, this series ointroduces a generic help generator for kconfig packages, and removes all existing custom help commands for those packages.

As a cherry on the cake, it adds a new configurator to uClibc, which as supported nconfig for some time now...

Regards,
Yann E. MORIN.

----------------------------------------------------------------
Yann E. MORIN (4):
package/pkg-kconfig: move defaults before calling pkg-generic package/pkg-kconfig: generate generic help
package: use the generic _HELP_CMDS for kconfig-based packages package/uclibc: add nconfig as a kconfig editor

 boot/barebox/barebox/barebox.mk         |  5 -----
 boot/uboot/uboot.mk                     |  6 -----
 docs/manual/adding-packages-kconfig.txt |  3 +++
 linux/linux.mk                          |  7 ------
 package/busybox/busybox.mk              |  5 +----
 package/pkg-kconfig.mk                  | 40 ++++++++++++++++++++++++++-------
 package/uclibc/uclibc.mk                |  5 +----
 7 files changed, 37 insertions(+), 34 deletions(-)
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/4 package/pkg-kconfig: move defaults before calling pkg-generic

Currently, we define the default values for kconfig-specific variables after we call into the generic package infrastructure.

So far, this was totally unconsequential, because there was no kconfig variable that could influence the generic parts. But conversely, there are generic variables that do influence the kconfig part (e.g. $(2)_DIR that is used in some dependency definitions), but none that do influence the kconfig variables.

However, we are going to add a new kconfig-related variable that will have an impact on the generic parts, so we will want that kconfig variable to be defined before calling into the generic infrastructure.

For consistency, move all the defaults before calling the generic infra.

Cc Thomas Petazzoni <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
---
 package/pkg-kconfig.mk | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
package/pkg-kconfig.mk +8 -8
index dd727b7200..49074f9220 100644
@@ -78,6 +78,14 @@ endef
 
 define inner-kconfig-package
 
+# Default values
+$(2)_MAKE ?= $$(MAKE)
+$(2)_KCONFIG_EDITORS ?= menuconfig
+$(2)_KCONFIG_OPTS ?=
+$(2)_KCONFIG_FIXUP_CMDS ?=
+$(2)_KCONFIG_FRAGMENT_FILES ?=
+$(2)_KCONFIG_DOTCONFIG ?= .config
+
 # Register the kconfig dependencies as regular dependencies, so that
 # they are also accounted for in the generated graphs.
 $(2)_DEPENDENCIES += $$($(2)_KCONFIG_DEPENDENCIES)
@@ -88,14 +96,6 @@ $(2)_DEPENDENCIES += $$($(2)_KCONFIG_DEPENDENCIES)
 # dependency expression
 $(call inner-generic-package,$(1),$(2),$(3),$(4))
 
-# Default values
-$(2)_MAKE ?= $$(MAKE)
-$(2)_KCONFIG_EDITORS ?= menuconfig
-$(2)_KCONFIG_OPTS ?=
-$(2)_KCONFIG_FIXUP_CMDS ?=
-$(2)_KCONFIG_FRAGMENT_FILES ?=
-$(2)_KCONFIG_DOTCONFIG ?= .config
-
 # Do not use $(2)_KCONFIG_DOTCONFIG as stamp file, because the package
 # buildsystem (e.g. linux >= 4.19) may touch it, thus rendering our
 # timestamps out of date, thus re-trigerring the build of the package.
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#2 lore raw

PATCH 2/4 package/pkg-kconfig: generate generic help

In reply to Yann E. MORIN

Currently, as Thomas pointed out [0], the help for kconfig packages is not consistently used and handled by the different packages.

This commit introduces a generic help text for kconfig packages, that is based on what the package declares:

- the list of kconfig editors it supports;

- whether it is possible to save back the configuration (impossible if

    the package uses an in-tree defconfig file);

- whether the package actually supports (loading and saving) defconfig files, by introducing a new variable a package can set if it does not (only busybox is known to be in that case).

That new help helper is only used if the package does not already define its own help, to be consistent with what we do for other _CMDS.

[0] http://lists.busybox.net/pipermail/buildroot/2021-July/313570.html

---
 docs/manual/adding-packages-kconfig.txt |  3 +++
 package/pkg-kconfig.mk                  | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
docs/manual/adding-packages-kconfig.txt +3 -0
index 8f40ea6099..a35681775f 100644
@@ -91,3 +91,6 @@ be set to suit the needs of the package under consideration:
 * +FOO_KCONFIG_DEPENDENCIES+: the list of packages (most probably, host
   packages) that need to be built before this package's kconfig is
   interpreted. Seldom used. By default, empty.
+
+* +FOO_KCONFIG_SUPPORTS_DEFCONFIG+: whether the package's kconfig system
+  supports using defconfig files; few packages do not. By default, 'YES'.
package/pkg-kconfig.mk +24 -0
index 49074f9220..715c3e04ec 100644
@@ -85,11 +85,35 @@ $(2)_KCONFIG_OPTS ?=
 $(2)_KCONFIG_FIXUP_CMDS ?=
 $(2)_KCONFIG_FRAGMENT_FILES ?=
 $(2)_KCONFIG_DOTCONFIG ?= .config
+$(2)_KCONFIG_SUPPORTS_DEFCONFIG ?= YES
 
 # Register the kconfig dependencies as regular dependencies, so that
 # they are also accounted for in the generated graphs.
 $(2)_DEPENDENCIES += $$($(2)_KCONFIG_DEPENDENCIES)
 
+# Generate the kconfig-related help: one entry for each editor.
+# Additionally, if the package is *not* using an in-tree defconfig
+# name, an entry for updating the package configuration file.
+ifndef $(2)_HELP_CMDS
+define $(2)_HELP_CMDS
+	$$(foreach editor, $$($(2)_KCONFIG_EDITORS), \
+		@printf '  %-22s - Run %s %s\n' $(1)-$$(editor) $(1) $$(editor)
+	)
+	$$(if $$($(2)_KCONFIG_DEFCONFIG),,\
+		$$(if $$(filter YES,$$($(2)_KCONFIG_SUPPORTS_DEFCONFIG)),\
+			@printf '  %-22s - Save the %s configuration as a defconfig file\n' \
+				$(1)-update-defconfig $(1)
+			@printf '  %-22s     to %s\n' '' $$($(2)_KCONFIG_FILE)
+			@printf '  %-22s     (or override with %s_KCONFIG_FILE)\n' '' $(2)
+		)
+		@printf '  %-22s - Save the %s configuration as a full .config file\n' \
+			$(1)-update-config $(1)
+		@printf '  %-22s     to %s\n' '' $$($(2)_KCONFIG_FILE)
+		@printf '  %-22s     (or override with %s_KCONFIG_FILE)\n' '' $(2)
+	)
+endef
+endif
+
 # Call the generic package infrastructure to generate the necessary
 # make targets.
 # Note: this must be done _before_ attempting to use $$($(2)_DIR) in a
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 2/4] package/pkg-kconfig: generate generic help

Quoted 52 lines · Yann E. MORIN

Currently, as Thomas pointed out [0], the help for kconfig packages is not consistently used and handled by the different packages.

This commit introduces a generic help text for kconfig packages, that is based on what the package declares:

- the list of kconfig editors it supports;

- whether it is possible to save back the configuration (impossible if

    the package uses an in-tree defconfig file);

- whether the package actually supports (loading and saving) defconfig files, by introducing a new variable a package can set if it does not (only busybox is known to be in that case).

That new help helper is only used if the package does not already define its own help, to be consistent with what we do for other _CMDS.

[0] http://lists.busybox.net/pipermail/buildroot/2021-July/313570.html

---
 docs/manual/adding-packages-kconfig.txt |  3 +++
 package/pkg-kconfig.mk                  | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
docs/manual/adding-packages-kconfig.txt +3 -0
index 8f40ea6099..a35681775f 100644
@@ -91,3 +91,6 @@ be set to suit the needs of the package under consideration:
 * +FOO_KCONFIG_DEPENDENCIES+: the list of packages (most probably, host
   packages) that need to be built before this package's kconfig is
   interpreted. Seldom used. By default, empty.
+
+* +FOO_KCONFIG_SUPPORTS_DEFCONFIG+: whether the package's kconfig system
+  supports using defconfig files; few packages do not. By default, 'YES'.
package/pkg-kconfig.mk +1 -0
index 49074f9220..715c3e04ec 100644
@@ -85,11 +85,35 @@ $(2)_KCONFIG_OPTS ?=
 $(2)_KCONFIG_FIXUP_CMDS ?=
 $(2)_KCONFIG_FRAGMENT_FILES ?=
 $(2)_KCONFIG_DOTCONFIG ?= .config
+$(2)_KCONFIG_SUPPORTS_DEFCONFIG ?= YES
 
 # Register the kconfig dependencies as regular dependencies, so that
 # they are also accounted for in the generated graphs.
 $(2)_DEPENDENCIES += $$($(2)_KCONFIG_DEPENDENCIES)

package/pkg-kconfig.mk $(2)_KCONFIG_OPTS ?= · line 102

Quoted 10 lines
package/pkg-kconfig.mk +9 -0
 
+# Generate the kconfig-related help: one entry for each editor.
+# Additionally, if the package is *not* using an in-tree defconfig
+# name, an entry for updating the package configuration file.
+ifndef $(2)_HELP_CMDS
+define $(2)_HELP_CMDS
+	$$(foreach editor, $$($(2)_KCONFIG_EDITORS), \
+		@printf '  %-22s - Run %s %s\n' $(1)-$$(editor) $(1) $$(editor)
+	)
+	$$(if $$($(2)_KCONFIG_DEFCONFIG),,\

We should probably also simply remove the -update-config and -update-defconfig
rules when _KCONFIG_DEFCONFIG is set. There's currently a condition for that in kconfig-package-update-config, but it's better to just not have the option at all. I may cook a patch for that.

package/pkg-kconfig.mk $(2)_KCONFIG_OPTS ?= · line 103

Quoted 1 line
package/pkg-kconfig.mk +1 -0
+		$$(if $$(filter YES,$$($(2)_KCONFIG_SUPPORTS_DEFCONFIG)),\

Now we have this variable, it would make sense to also make $(1)-savedefconfig
and $(1)-update-defconfig depend on it. I may cook a patch to do exactly that.

Regards,
Arnout

Quoted 7 lines
package/pkg-kconfig.mk +6 -0
+			@printf '  %-22s - Save the %s configuration as a defconfig file\n' \
+				$(1)-update-defconfig $(1)
+			@printf '  %-22s     to %s\n' '' $$($(2)_KCONFIG_FILE)
+			@printf '  %-22s     (or override with %s_KCONFIG_FILE)\n' '' $(2)
+		)
+		@printf '  %-22s - Save the %s configuration as a full .config file\n' \

package/pkg-kconfig.mk $(2)_KCONFIG_OPTS ?= · line 119

Quoted 10 lines
package/pkg-kconfig.mk +7 -0
+			$(1)-update-config $(1)
+		@printf '  %-22s     to %s\n' '' $$($(2)_KCONFIG_FILE)
+		@printf '  %-22s     (or override with %s_KCONFIG_FILE)\n' '' $(2)
+	)
+endef
+endif
+
 # Call the generic package infrastructure to generate the necessary
 # make targets.
 # Note: this must be done _before_ attempting to use $$($(2)_DIR) in a

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

PATCH 3/4 package: use the generic _HELP_CMDS for kconfig-based packages

In reply to Yann E. MORIN

As Thomas put it:

The <pkg>_HELP_CMDS variable allows packages using the kconfig-package infrastructure to display their specific targets related to the handling of their configuration.

However, it was not consistently used and handled by the different packages.

So, this commit switches all the kconfig-based package to use the generic help helper.

As a consequence:

- all kconfig packages now advetise their kconfig-related actions, where some were previously missing: at91bootstrap3, linux-backports, swupdate, xvisor;

- busybox advertises it does not support defconfig files;

- the 'foo-savedfconfig' action is no longer advertised: it is to be considered an internal implementation detail.

Cc Thomas Petazzoni <[email protected]>
---
 boot/barebox/barebox/barebox.mk | 5 -----
 boot/uboot/uboot.mk             | 6 ------
 linux/linux.mk                  | 7 -------
 package/busybox/busybox.mk      | 5 +----
 package/uclibc/uclibc.mk        | 4 ----
 5 files changed, 1 insertion(+), 26 deletions(-)
boot/barebox/barebox/barebox.mk +0 -5
index 39afb0fccb..6a5a80de34 100644
@@ -4,10 +4,5 @@
 #
 ################################################################################
 
-define BAREBOX_HELP_CMDS
-	@echo '  barebox-menuconfig     - Run barebox menuconfig'
-	@echo '  barebox-savedefconfig  - Run barebox savedefconfig'
-endef
-
 # Instantiate the barebox package
 $(eval $(barebox-package))
boot/uboot/uboot.mk +0 -6
index 9c2261963d..4f3c9b7c3a 100644
@@ -296,12 +296,6 @@ UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 # override again. In addition, host-ccache is not ready at kconfig
 # time, so use HOSTCC_NOCCACHE.
 UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTLDFLAGS=""
-define UBOOT_HELP_CMDS
-	@echo '  uboot-menuconfig       - Run U-Boot menuconfig'
-	@echo '  uboot-savedefconfig    - Run U-Boot savedefconfig'
-	@echo '  uboot-update-defconfig - Save the U-Boot configuration to the path specified'
-	@echo '                             by BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE'
-endef
 endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
 
 UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
linux/linux.mk +0 -7
index 1457228eb9..61fdc0c76c 100644
@@ -16,13 +16,6 @@ LINUX_CPE_ID_VENDOR = linux
 LINUX_CPE_ID_PRODUCT = linux_kernel
 LINUX_CPE_ID_PREFIX = cpe:2.3:o
 
-define LINUX_HELP_CMDS
-	@echo '  linux-menuconfig       - Run Linux kernel menuconfig'
-	@echo '  linux-savedefconfig    - Run Linux kernel savedefconfig'
-	@echo '  linux-update-defconfig - Save the Linux configuration to the path specified'
-	@echo '                             by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE'
-endef
-
 # Compute LINUX_SOURCE and LINUX_SITE from the configuration
 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_TARBALL),y)
 LINUX_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION))
package/busybox/busybox.mk +1 -4
index 413939e28d..68e0b8a72c 100644
@@ -11,10 +11,6 @@ BUSYBOX_LICENSE = GPL-2.0, bzip2-1.0.4
 BUSYBOX_LICENSE_FILES = LICENSE archival/libarchive/bz/LICENSE
 BUSYBOX_CPE_ID_VENDOR = busybox
 
-define BUSYBOX_HELP_CMDS
-	@echo '  busybox-menuconfig     - Run BusyBox menuconfig'
-endef
-
 BUSYBOX_CFLAGS = \
 	$(TARGET_CFLAGS)
 
@@ -107,6 +103,7 @@ ifndef BUSYBOX_CONFIG_FILE
 BUSYBOX_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG))
 endif
 
+BUSYBOX_KCONFIG_HAS_DEFCONFIG = NO
 BUSYBOX_KCONFIG_FILE = $(BUSYBOX_CONFIG_FILE)
 BUSYBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES))
 BUSYBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig
package/uclibc/uclibc.mk +0 -4
index a7c96684d0..5c17eea8dd 100644
@@ -13,10 +13,6 @@ UCLIBC_INSTALL_STAGING = YES
 UCLIBC_CPE_ID_VENDOR = uclibc-ng_project
 UCLIBC_CPE_ID_PRODUCT = uclibc-ng
 
-define UCLIBC_HELP_CMDS
-	@echo '  uclibc-menuconfig      - Run uClibc menuconfig'
-endef
-
 # uclibc is part of the toolchain so disable the toolchain dependency
 UCLIBC_ADD_TOOLCHAIN_DEPENDENCY = NO
 
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#5 lore raw

PATCH 4/4 package/uclibc: add nconfig as a kconfig editor

In reply to Yann E. MORIN
---
 package/uclibc/uclibc.mk | 1 +
 1 file changed, 1 insertion(+)
package/uclibc/uclibc.mk +1 -0
index 5c17eea8dd..180ed9951e 100644
@@ -26,6 +26,7 @@ ifndef UCLIBC_CONFIG_FILE
 UCLIBC_CONFIG_FILE = $(call qstrip,$(BR2_UCLIBC_CONFIG))
 endif
 
+UCLIBC_KCONFIG_EDITORS = menuconfig nconfig
 UCLIBC_KCONFIG_FILE = $(UCLIBC_CONFIG_FILE)
 UCLIBC_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_UCLIBC_CONFIG_FRAGMENT_FILES))
 
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 4/4] package/uclibc: add nconfig as a kconfig editor

Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Committed to 2021.02.x and 2021.05.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#7 lore raw
In reply to Yann E. MORIN
Quoted 5 lines · Yann E. MORIN

Hello All!

This is a counter-proposal to an eariler patch from Thomas, which adds and fixes help entries for kconfig packages:

Quoted 8 lines
    https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Compared to that patch, this series ointroduces a generic help generator for kconfig packages, and removes all existing custom help commands for those packages.

As a cherry on the cake, it adds a new configurator to uClibc, which as supported nconfig for some time now...

Series applied to master, thanks! I'll also mark Thomas's patch as Superseded.

Regards,
Arnout

Quoted 12 lines

Regards,
Yann E. MORIN.

----------------------------------------------------------------
Yann E. MORIN (4):
package/pkg-kconfig: move defaults before calling pkg-generic package/pkg-kconfig: generate generic help
package: use the generic _HELP_CMDS for kconfig-based packages package/uclibc: add nconfig as a kconfig editor

Quoted 9 lines
 boot/barebox/barebox/barebox.mk         |  5 -----
 boot/uboot/uboot.mk                     |  6 -----
 docs/manual/adding-packages-kconfig.txt |  3 +++
 linux/linux.mk                          |  7 ------
 package/busybox/busybox.mk              |  5 +----
 package/pkg-kconfig.mk                  | 40 ++++++++++++++++++++++++++-------
 package/uclibc/uclibc.mk                |  5 +----
 7 files changed, 37 insertions(+), 34 deletions(-)

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot