Skip to contentSkip to conversation

kconfig-package: add support for config fragments

PATCH New Floris Bos 4 participants 16 messages Apr 28, 2015 – May 21, 2015

lore
Share & tools
lore

Floris Bos

author
#0 lore raw

PATCH v2 1/5 kconfig-package: add support for config fragments

Adds functionality to the kconfig infrastructure to merge additional configuration fragment files to the main configuration file of kconfig packages, using support/kconfig/merge_config.sh

Typical use-case is when you want your configuration to be kept in sync with an upstream (def)config file, but do require some minor local modifications.

Disables -update-config and -update-defconfig targets when fragment files are set.

---
v2:

- use shell commands to print error message when update-(def)config target is used while fragment files are set.

- document changes to kconfig infrastructure.

---
 docs/manual/adding-packages-kconfig.txt | 11 +++++++++++
 package/pkg-kconfig.mk                  | 14 ++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)
docs/manual/adding-packages-kconfig.txt +11 -0
index e87d393..dc9ea11 100644
@@ -36,6 +36,12 @@ This snippet creates the following make targets:
 
 * +foo-update-config+, which copies the configuration back to the source
   configuration file.
+  It is not possible to use this target when fragment files are set.
+
+* +foo-update-defconfig+, which copies the configuration back to the source
+  configuration file. The configuration file will only list the
+  options that differ from the default values.
+  It is not possible to use this target when fragment files are set.
 
 and ensures that the source configuration file is copied to the build
 directory at the right moment.
@@ -46,6 +52,11 @@ be set to suit the needs of the package under consideration:
 * +FOO_KCONFIG_EDITORS+: a space-separated list of kconfig editors to
   support, for example 'menuconfig xconfig'. By default, 'menuconfig'.
 
+* +FOO_KCONFIG_FRAGMENT_FILES+: a space-separated list of configuration
+  fragment files that are merged to the main configuration file.
+  Fragment files are typically used when there is a desire to stay in sync
+  with an upstream (def)config file, with some minor modifications.
+
 * +FOO_KCONFIG_OPTS+: extra options to pass when calling the kconfig
   editors. This may need to include '$(FOO_MAKE_OPTS)', for example. By
   default, empty.
package/pkg-kconfig.mk +10 -4
index 8361064..21fbfdb 100644
@@ -35,18 +35,20 @@ $(call inner-generic-package,$(1),$(2),$(3),$(4))
 $(2)_KCONFIG_EDITORS ?= menuconfig
 $(2)_KCONFIG_OPTS ?=
 $(2)_KCONFIG_FIXUP_CMDS ?=
+$(2)_KCONFIG_FRAGMENT_FILES ?=
 
 # The config file could be in-tree, so before depending on it the package should
 # be extracted (and patched) first
 $$($(2)_KCONFIG_FILE): | $(1)-patch
 
-# The .config file is obtained by copying it from the specified source
-# configuration file, after the package has been patched.
+# The specified source configuration file and any additional configuration file
+# fragments are merged together to .config, after the package has been patched.
 # Since the file could be a defconfig file it needs to be expanded to a
 # full .config first. We use 'make oldconfig' because this can be safely
 # done even when the package does not support defconfigs.
-$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE)
-	$$(INSTALL) -m 0644 $$($(2)_KCONFIG_FILE) $$($(2)_DIR)/.config
+$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
+	support/kconfig/merge_config.sh -m -O $$(@D) \
+		$$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
 	@yes "" | $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
 		$$($(2)_KCONFIG_OPTS) oldconfig
 
@@ -87,6 +89,8 @@ $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # Even though we could use 'cp --preserve-timestamps' here, the separate
 # cp and 'touch --reference' is used for symmetry with $(1)-update-defconfig.
 $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
+	$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+		echo "Unable to perform $(1)-update-config when fragment files are set"; exit 1)
 	cp -f $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 	touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
@@ -95,6 +99,8 @@ $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # $(1)-update-config, the reference for 'touch' is _not_ the file from which
 # we copy.
 $(1)-update-defconfig: $(1)-savedefconfig
+	$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+		echo "Unable to perform $(1)-update-defconfig when fragment files are set"; exit 1)
 	cp -f $$($(2)_DIR)/defconfig $$($(2)_KCONFIG_FILE)
 	touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v2 2/5 linux: add option to specify config fragments

---
 linux/Config.in | 6 ++++++
 linux/linux.mk  | 1 +
 2 files changed, 7 insertions(+)
linux/Config.in +6 -0
index 0ab9f26..ac483c1 100644
@@ -164,6 +164,12 @@ config BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
 	  Note: this can be a defconfig file or a complete .config file,
 	  which can later be saved back with make linux-update-(def)config.
 
+config BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
+	string "Additional configuration fragment files"
+	help
+	  A space-separated list of kernel configuration fragment files,
+	  that will be merged to the main kernel configuration file.
+
 #
 # Binary format
 #
linux/linux.mk +1 -0
index 0c348da..694061e 100644
@@ -175,6 +175,7 @@ KERNEL_SOURCE_CONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))
 endif
 
 LINUX_KCONFIG_FILE = $(KERNEL_SOURCE_CONFIG)
+LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
 
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 2/5 linux: add option to specify config fragments

Quoted 11 lines · Floris Bos
---
 linux/Config.in | 6 ++++++
 linux/linux.mk  | 1 +
 2 files changed, 7 insertions(+)
linux/Config.in +0 -0
index 0ab9f26..ac483c1 100644

linux/Config.in config BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE · line 171

Quoted 8 lines
linux/Config.in +5 -0
@@ -164,6 +164,12 @@ config BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
 	  Note: this can be a defconfig file or a complete .config file,
 	  which can later be saved back with make linux-update-(def)config.
 
+config BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
+	string "Additional configuration fragment files"
+	help
+	  A space-separated list of kernel configuration fragment files,
+	  that will be merged to the main kernel configuration file.

Oh, of course we'll still need this additional config option, because the main
defconfig could be in-tree while the fragments are external. Silly me.

I'll come back to the first patch.

This one already gets my

Regards,
Arnout

Quoted 17 lines
linux/Config.in +1 -0
+
 #
 # Binary format
 #
linux/linux.mk +1 -0
index 0c348da..694061e 100644
@@ -175,6 +175,7 @@ KERNEL_SOURCE_CONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))
 endif
 
 LINUX_KCONFIG_FILE = $(KERNEL_SOURCE_CONFIG)
+LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#3 lore raw

PATCH v2 2/5 linux: add option to specify config fragments

In reply to Floris Bos
Quoted 1 line · Floris Bos

(see previous patch)

Regards,
Arnout

Quoted 35 lines
---
 linux/Config.in | 6 ++++++
 linux/linux.mk  | 1 +
 2 files changed, 7 insertions(+)
linux/Config.in +6 -0
index 0ab9f26..ac483c1 100644
@@ -164,6 +164,12 @@ config BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
 	  Note: this can be a defconfig file or a complete .config file,
 	  which can later be saved back with make linux-update-(def)config.
 
+config BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
+	string "Additional configuration fragment files"
+	help
+	  A space-separated list of kernel configuration fragment files,
+	  that will be merged to the main kernel configuration file.
+
 #
 # Binary format
 #
linux/linux.mk +1 -0
index 0c348da..694061e 100644
@@ -175,6 +175,7 @@ KERNEL_SOURCE_CONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))
 endif
 
 LINUX_KCONFIG_FILE = $(KERNEL_SOURCE_CONFIG)
+LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#4 lore raw

PATCH v2 2/5 linux: add option to specify config fragments

Quoted 6 lines · Arnout Vandecappelle
Quoted 1 line · Floris Bos

(see previous patch)

together with v2 1/5 of this patch series

Quoted 52 lines

Regards,
Arnout

Quoted 28 lines
---
 linux/Config.in | 6 ++++++
 linux/linux.mk  | 1 +
 2 files changed, 7 insertions(+)
linux/Config.in +6 -0
index 0ab9f26..ac483c1 100644
@@ -164,6 +164,12 @@ config BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
        Note: this can be a defconfig file or a complete .config file,
        which can later be saved back with make linux-update-(def)config.
 
+config BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
+     string "Additional configuration fragment files"
+     help
+       A space-separated list of kernel configuration fragment files,
+       that will be merged to the main kernel configuration file.
+
 #
 # Binary format
 #
linux/linux.mk +0 -0
index 0c348da..694061e 100644

linux/linux.mk KERNEL_SOURCE_CONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE)) · line 181

Quoted 7 lines
linux/linux.mk +1 -0
@@ -175,6 +175,7 @@ KERNEL_SOURCE_CONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))
 endif
 
 LINUX_KCONFIG_FILE = $(KERNEL_SOURCE_CONFIG)
+LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
 

--

Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

author
#5 lore raw

PATCH v2 3/5 busybox: add option to specify config fragments

In reply to Floris Bos
---
 package/busybox/Config.in  | 6 ++++++
 package/busybox/busybox.mk | 1 +
 2 files changed, 7 insertions(+)
package/busybox/Config.in +6 -0
index b4f949f..6847a60 100644
@@ -20,6 +20,12 @@ config BR2_PACKAGE_BUSYBOX_CONFIG
 
 	  Most people will just use the default BusyBox configuration file.
 
+config BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES
+	string "Additional BusyBox configuration fragment files"
+	help
+	  A space-separated list of configuration fragment files,
+	  that will be merged to the main BusyBox configuration file.
+
 config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	bool "Show packages that are also provided by busybox"
 	help
package/busybox/busybox.mk +1 -0
index 1ce508a..090e174 100644
@@ -46,6 +46,7 @@ ifndef BUSYBOX_CONFIG_FILE
 endif
 
 BUSYBOX_KCONFIG_FILE = $(BUSYBOX_CONFIG_FILE)
+BUSYBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES))
 BUSYBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig
 BUSYBOX_KCONFIG_OPTS = $(BUSYBOX_MAKE_OPTS)
 
Signature · 1 line
2.1.4
#6 lore raw

PATCH v2 3/5 busybox: add option to specify config fragments

Quoted 1 line · Floris Bos

Not tested but obviously correct :-)

Regards,
Arnout

Quoted 35 lines
---
 package/busybox/Config.in  | 6 ++++++
 package/busybox/busybox.mk | 1 +
 2 files changed, 7 insertions(+)
package/busybox/Config.in +6 -0
index b4f949f..6847a60 100644
@@ -20,6 +20,12 @@ config BR2_PACKAGE_BUSYBOX_CONFIG
 
 	  Most people will just use the default BusyBox configuration file.
 
+config BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES
+	string "Additional BusyBox configuration fragment files"
+	help
+	  A space-separated list of configuration fragment files,
+	  that will be merged to the main BusyBox configuration file.
+
 config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	bool "Show packages that are also provided by busybox"
 	help
package/busybox/busybox.mk +1 -0
index 1ce508a..090e174 100644
@@ -46,6 +46,7 @@ ifndef BUSYBOX_CONFIG_FILE
 endif
 
 BUSYBOX_KCONFIG_FILE = $(BUSYBOX_CONFIG_FILE)
+BUSYBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES))
 BUSYBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig
 BUSYBOX_KCONFIG_OPTS = $(BUSYBOX_MAKE_OPTS)
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
author
#7 lore raw

PATCH v2 4/5 uclibc: add option to specify config fragments

In reply to Floris Bos
---
 package/uclibc/Config.in | 6 ++++++
 package/uclibc/uclibc.mk | 1 +
 2 files changed, 7 insertions(+)
package/uclibc/Config.in +6 -0
index b5525e5..dd23853 100644
@@ -86,6 +86,12 @@ config BR2_UCLIBC_CONFIG
 	  See also docs/README in this package.
 	  If unsure, use the default.
 
+config BR2_UCLIBC_CONFIG_FRAGMENT_FILES
+	string "Additional uClibc configuration fragment files"
+	help
+	  A space-separated list of configuration fragment files,
+	  that will be merged to the main uClibc configuration file.
+
 config BR2_TOOLCHAIN_BUILDROOT_INET_RPC
 	bool "Enable RPC support"
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
package/uclibc/uclibc.mk +1 -0
index ce9b2b4..b9dce7e 100644
@@ -42,6 +42,7 @@ UCLIBC_CONFIG_FILE = $(call qstrip,$(BR2_UCLIBC_CONFIG))
 endif
 
 UCLIBC_KCONFIG_FILE = $(UCLIBC_CONFIG_FILE)
+UCLIBC_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_UCLIBC_CONFIG_FRAGMENT_FILES))
 
 UCLIBC_KCONFIG_OPTS = \
 	$(UCLIBC_MAKE_FLAGS) \
Signature · 1 line
2.1.4
#8 lore raw

PATCH v2 4/5 uclibc: add option to specify config fragments

Quoted 1 line · Floris Bos

Regards,
Arnout

Quoted 35 lines
---
 package/uclibc/Config.in | 6 ++++++
 package/uclibc/uclibc.mk | 1 +
 2 files changed, 7 insertions(+)
package/uclibc/Config.in +6 -0
index b5525e5..dd23853 100644
@@ -86,6 +86,12 @@ config BR2_UCLIBC_CONFIG
 	  See also docs/README in this package.
 	  If unsure, use the default.
 
+config BR2_UCLIBC_CONFIG_FRAGMENT_FILES
+	string "Additional uClibc configuration fragment files"
+	help
+	  A space-separated list of configuration fragment files,
+	  that will be merged to the main uClibc configuration file.
+
 config BR2_TOOLCHAIN_BUILDROOT_INET_RPC
 	bool "Enable RPC support"
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
package/uclibc/uclibc.mk +1 -0
index ce9b2b4..b9dce7e 100644
@@ -42,6 +42,7 @@ UCLIBC_CONFIG_FILE = $(call qstrip,$(BR2_UCLIBC_CONFIG))
 endif
 
 UCLIBC_KCONFIG_FILE = $(UCLIBC_CONFIG_FILE)
+UCLIBC_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_UCLIBC_CONFIG_FRAGMENT_FILES))
 
 UCLIBC_KCONFIG_OPTS = \
 	$(UCLIBC_MAKE_FLAGS) \
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
author
#9 lore raw

PATCH v2 5/5 barebox: add option to specify config fragments

In reply to Floris Bos
---
 boot/barebox/Config.in  | 6 ++++++
 boot/barebox/barebox.mk | 1 +
 2 files changed, 7 insertions(+)
boot/barebox/Config.in +6 -0
index 48431bd..dbe79e9 100644
@@ -91,6 +91,12 @@ config BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
 	help
 	  Path to the barebox configuration file
 
+config BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES
+	string "Additional configuration fragment files"
+	help
+	  A space-separated list of configuration fragment files,
+	  that will be merged to the main Barebox configuration file.
+
 config BR2_TARGET_BAREBOX_BAREBOXENV
 	bool "bareboxenv tool in target"
 	help
boot/barebox/barebox.mk +1 -0
index 54f52bb..5095ffa 100644
@@ -60,6 +60,7 @@ BAREBOX_SOURCE_CONFIG = $(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE))
 endif
 
 BAREBOX_KCONFIG_FILE = $(BAREBOX_SOURCE_CONFIG)
+BAREBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES))
 BAREBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 BAREBOX_KCONFIG_OPTS = $(BAREBOX_MAKE_FLAGS)
 
Signature · 1 line
2.1.4
#10 lore raw

PATCH v2 5/5 barebox: add option to specify config fragments

Quoted 1 line · Floris Bos

Regards,
Arnout

Quoted 35 lines
---
 boot/barebox/Config.in  | 6 ++++++
 boot/barebox/barebox.mk | 1 +
 2 files changed, 7 insertions(+)
boot/barebox/Config.in +6 -0
index 48431bd..dbe79e9 100644
@@ -91,6 +91,12 @@ config BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
 	help
 	  Path to the barebox configuration file
 
+config BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES
+	string "Additional configuration fragment files"
+	help
+	  A space-separated list of configuration fragment files,
+	  that will be merged to the main Barebox configuration file.
+
 config BR2_TARGET_BAREBOX_BAREBOXENV
 	bool "bareboxenv tool in target"
 	help
boot/barebox/barebox.mk +1 -0
index 54f52bb..5095ffa 100644
@@ -60,6 +60,7 @@ BAREBOX_SOURCE_CONFIG = $(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE))
 endif
 
 BAREBOX_KCONFIG_FILE = $(BAREBOX_SOURCE_CONFIG)
+BAREBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES))
 BAREBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 BAREBOX_KCONFIG_OPTS = $(BAREBOX_MAKE_FLAGS)
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#11 lore raw

PATCH v2 1/5 kconfig-package: add support for config fragments

In reply to Floris Bos
Quoted 12 lines · Floris Bos

Adds functionality to the kconfig infrastructure to merge additional configuration fragment files to the main configuration file of kconfig packages, using support/kconfig/merge_config.sh

Typical use-case is when you want your configuration to be kept in sync with an upstream (def)config file, but do require some minor local modifications.

Disables -update-config and -update-defconfig targets when fragment files are set.

[snip]

docs/manual/adding-packages-kconfig.txt be set to suit the needs of the package under consideration: · line 58

Quoted 4 lines
docs/manual/adding-packages-kconfig.txt +4 -0
+* +FOO_KCONFIG_FRAGMENT_FILES+: a space-separated list of configuration
+  fragment files that are merged to the main configuration file.
+  Fragment files are typically used when there is a desire to stay in sync
+  with an upstream (def)config file, with some minor modifications.

I should have noticed this in the first iteration, but why do we need an
additional config option for this? We could just rename _KCONFIG_FILE to _KCONFIG_FILES and update the help texts to explain that the files may consist of fragments.

Quoted 9 lines
docs/manual/adding-packages-kconfig.txt +1 -0
+
 * +FOO_KCONFIG_OPTS+: extra options to pass when calling the kconfig
   editors. This may need to include '$(FOO_MAKE_OPTS)', for example. By
   default, empty.
package/pkg-kconfig.mk +0 -0
index 8361064..21fbfdb 100644

package/pkg-kconfig.mk $(call inner-generic-package,$(1),$(2),$(3),$(4)) · line 42

Quoted 8 lines
package/pkg-kconfig.mk +1 -0
@@ -35,18 +35,20 @@ $(call inner-generic-package,$(1),$(2),$(3),$(4))
 $(2)_KCONFIG_EDITORS ?= menuconfig
 $(2)_KCONFIG_OPTS ?=
 $(2)_KCONFIG_FIXUP_CMDS ?=
+$(2)_KCONFIG_FRAGMENT_FILES ?=
 
 # The config file could be in-tree, so before depending on it the package should
 # be extracted (and patched) first
 $$($(2)_KCONFIG_FILE): | $(1)-patch

The fragments could also be in-tree, in theory.

Not that it matters in practice because it is only relevant for the .config
dependency.

Quoted 17 lines
package/pkg-kconfig.mk +5 -4
-# The .config file is obtained by copying it from the specified source
-# configuration file, after the package has been patched.
+# The specified source configuration file and any additional configuration file
+# fragments are merged together to .config, after the package has been patched.
 # Since the file could be a defconfig file it needs to be expanded to a
 # full .config first. We use 'make oldconfig' because this can be safely
 # done even when the package does not support defconfigs.
-$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE)
-	$$(INSTALL) -m 0644 $$($(2)_KCONFIG_FILE) $$($(2)_DIR)/.config
+$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
+	support/kconfig/merge_config.sh -m -O $$(@D) \
+		$$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
 	@yes "" | $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
 		$$($(2)_KCONFIG_OPTS) oldconfig
 

package/pkg-kconfig.mk $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done · line 92

Quoted 4 lines
package/pkg-kconfig.mk +1 -0
@@ -87,6 +89,8 @@ $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # Even though we could use 'cp --preserve-timestamps' here, the separate
 # cp and 'touch --reference' is used for symmetry with $(1)-update-defconfig.
 $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
+	$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \

So this could be

	$$(if $$(word 2,$$($(2)_KCONFIG_FILES)), \

Regards,
Arnout

Quoted 14 lines
package/pkg-kconfig.mk +3 -0
+		echo "Unable to perform $(1)-update-config when fragment files are set"; exit 1)
 	cp -f $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 	touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
@@ -95,6 +99,8 @@ $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # $(1)-update-config, the reference for 'touch' is _not_ the file from which
 # we copy.
 $(1)-update-defconfig: $(1)-savedefconfig
+	$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+		echo "Unable to perform $(1)-update-defconfig when fragment files are set"; exit 1)
 	cp -f $$($(2)_DIR)/defconfig $$($(2)_KCONFIG_FILE)
 	touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
author
#12 lore raw

PATCH v2 1/5 kconfig-package: add support for config fragments

Quoted 15 lines · Arnout Vandecappelle
Quoted 12 lines · Floris Bos

Adds functionality to the kconfig infrastructure to merge additional configuration fragment files to the main configuration file of kconfig packages, using support/kconfig/merge_config.sh

Typical use-case is when you want your configuration to be kept in sync with an upstream (def)config file, but do require some minor local modifications.

Disables -update-config and -update-defconfig targets when fragment files are set.

[snip]

Quoted 8 lines

docs/manual/adding-packages-kconfig.txt be set to suit the needs of the package under consideration: · line 58

Quoted 4 lines
docs/manual/adding-packages-kconfig.txt +4 -0
+* +FOO_KCONFIG_FRAGMENT_FILES+: a space-separated list of configuration
+  fragment files that are merged to the main configuration file.
+  Fragment files are typically used when there is a desire to stay in sync
+  with an upstream (def)config file, with some minor modifications.

I should have noticed this in the first iteration, but why do we need an
additional config option for this? We could just rename _KCONFIG_FILE to _KCONFIG_FILES and update the help texts to explain that the files may consist of fragments.

Has been briefly discussed during the first iteration. Main problem is _KCONFIG_FILE is not just a source file, but also a destination file for the update-config and update-defconfig targets.

Signature · 3 lines
Yours sincerely,

Floris Bos
#13 lore raw

PATCH v2 1/5 kconfig-package: add support for config fragments

In reply to Floris Bos
Quoted 4 lines · Floris Bos

Adds functionality to the kconfig infrastructure to merge additional configuration fragment files to the main configuration file of kconfig packages, using support/kconfig/merge_config.sh

Quoted 8 lines

Typical use-case is when you want your configuration to be kept in sync with an upstream (def)config file, but do require some minor local modifications.

Disables -update-config and -update-defconfig targets when fragment files are set.

Some trivial feedback below, with that:

Build test of linux-configure after applying patch 2, verified that the config
options in the fragment end up in the configuration, checked that linux-update-{def,}config errors out with fragment and works without fragments,

When the fragment file doesn't exist, you get:

make: *** No rule to make target 'test_fragment', needed by '/home/arnout/src/buildroot/output/build/linux-3.15.10/.config'. Stop.

which is good enough for me.

Quoted 18 lines

---
v2:

- use shell commands to print error message when update-(def)config target is used while fragment files are set.

- document changes to kconfig infrastructure.

---
 docs/manual/adding-packages-kconfig.txt | 11 +++++++++++
 package/pkg-kconfig.mk                  | 14 ++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)
docs/manual/adding-packages-kconfig.txt +0 -0
index e87d393..dc9ea11 100644

docs/manual/adding-packages-kconfig.txt This snippet creates the following make targets: · line 39

Quoted 4 lines
docs/manual/adding-packages-kconfig.txt +1 -0
@@ -36,6 +36,12 @@ This snippet creates the following make targets:
 
 * +foo-update-config+, which copies the configuration back to the source
   configuration file.
+  It is not possible to use this target when fragment files are set.

There is not reason to start a new line - in the generated manual, the line
split will vanish anyway.

docs/manual/adding-packages-kconfig.txt This snippet creates the following make targets: · line 43

Quoted 4 lines
docs/manual/adding-packages-kconfig.txt +4 -0
+
+* +foo-update-defconfig+, which copies the configuration back to the source
+  configuration file. The configuration file will only list the
+  options that differ from the default values.

Word wrapping is a bit weird here.

Quoted 46 lines
docs/manual/adding-packages-kconfig.txt +6 -0
+  It is not possible to use this target when fragment files are set.
 
 and ensures that the source configuration file is copied to the build
 directory at the right moment.
@@ -46,6 +52,11 @@ be set to suit the needs of the package under consideration:
 * +FOO_KCONFIG_EDITORS+: a space-separated list of kconfig editors to
   support, for example 'menuconfig xconfig'. By default, 'menuconfig'.
 
+* +FOO_KCONFIG_FRAGMENT_FILES+: a space-separated list of configuration
+  fragment files that are merged to the main configuration file.
+  Fragment files are typically used when there is a desire to stay in sync
+  with an upstream (def)config file, with some minor modifications.
+
 * +FOO_KCONFIG_OPTS+: extra options to pass when calling the kconfig
   editors. This may need to include '$(FOO_MAKE_OPTS)', for example. By
   default, empty.
package/pkg-kconfig.mk +6 -4
index 8361064..21fbfdb 100644
@@ -35,18 +35,20 @@ $(call inner-generic-package,$(1),$(2),$(3),$(4))
 $(2)_KCONFIG_EDITORS ?= menuconfig
 $(2)_KCONFIG_OPTS ?=
 $(2)_KCONFIG_FIXUP_CMDS ?=
+$(2)_KCONFIG_FRAGMENT_FILES ?=
 
 # The config file could be in-tree, so before depending on it the package should
 # be extracted (and patched) first
 $$($(2)_KCONFIG_FILE): | $(1)-patch
 
-# The .config file is obtained by copying it from the specified source
-# configuration file, after the package has been patched.
+# The specified source configuration file and any additional configuration file
+# fragments are merged together to .config, after the package has been patched.
 # Since the file could be a defconfig file it needs to be expanded to a
 # full .config first. We use 'make oldconfig' because this can be safely
 # done even when the package does not support defconfigs.
-$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE)
-	$$(INSTALL) -m 0644 $$($(2)_KCONFIG_FILE) $$($(2)_DIR)/.config
+$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
+	support/kconfig/merge_config.sh -m -O $$(@D) \
+		$$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
 	@yes "" | $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
 		$$($(2)_KCONFIG_OPTS) oldconfig
 

package/pkg-kconfig.mk $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done · line 93

Quoted 5 lines
package/pkg-kconfig.mk +2 -0
@@ -87,6 +89,8 @@ $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # Even though we could use 'cp --preserve-timestamps' here, the separate
 # cp and 'touch --reference' is used for symmetry with $(1)-update-defconfig.
 $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
+	$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+		echo "Unable to perform $(1)-update-config when fragment files are set"; exit 1)

There should be an @ in front of this, otherwise you see the error twice.

package/pkg-kconfig.mk $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done · line 103

Quoted 9 lines
package/pkg-kconfig.mk +2 -0
 	cp -f $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 	touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
@@ -95,6 +99,8 @@ $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # $(1)-update-config, the reference for 'touch' is _not_ the file from which
 # we copy.
 $(1)-update-defconfig: $(1)-savedefconfig
+	$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+		echo "Unable to perform $(1)-update-defconfig when fragment files are set"; exit 1)

And here.

Regards,
Arnout

Quoted 4 lines
package/pkg-kconfig.mk +0 -0
 	cp -f $$($(2)_DIR)/defconfig $$($(2)_KCONFIG_FILE)
 	touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#14 lore raw

PATCH v2 1/5 kconfig-package: add support for config fragments

Quoted 9 lines · Arnout Vandecappelle
Quoted 8 lines · Floris Bos

Adds functionality to the kconfig infrastructure to merge additional configuration fragment files to the main configuration file of kconfig packages, using support/kconfig/merge_config.sh

Typical use-case is when you want your configuration to be kept in sync with an upstream (def)config file, but do require some minor local modifications.

Quoted 8 lines
Quoted 4 lines

Disables -update-config and -update-defconfig targets when fragment files are set.

Some trivial feedback below, with that:

together with patch 2/5 of this series: kernel fragment ending up in
config; make targets error out when fragments were set and fine when not

Quoted 106 lines
Quoted 17 lines

---
v2:

- use shell commands to print error message when update-(def)config target is used while fragment files are set.

- document changes to kconfig infrastructure.

---
 docs/manual/adding-packages-kconfig.txt | 11 +++++++++++
 package/pkg-kconfig.mk                  | 14 ++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)
docs/manual/adding-packages-kconfig.txt +0 -0
index e87d393..dc9ea11 100644

docs/manual/adding-packages-kconfig.txt This snippet creates the following make targets: · line 39

Quoted 4 lines
docs/manual/adding-packages-kconfig.txt +1 -0
@@ -36,6 +36,12 @@ This snippet creates the following make targets:
 
 * +foo-update-config+, which copies the configuration back to the source
   configuration file.
+  It is not possible to use this target when fragment files are set.

There is not reason to start a new line - in the generated manual, the line
split will vanish anyway.

docs/manual/adding-packages-kconfig.txt This snippet creates the following make targets: · line 43

Quoted 4 lines
docs/manual/adding-packages-kconfig.txt +4 -0
+
+* +foo-update-defconfig+, which copies the configuration back to the source
+  configuration file. The configuration file will only list the
+  options that differ from the default values.

Word wrapping is a bit weird here.

Quoted 46 lines
docs/manual/adding-packages-kconfig.txt +6 -0
+  It is not possible to use this target when fragment files are set.
 
 and ensures that the source configuration file is copied to the build
 directory at the right moment.
@@ -46,6 +52,11 @@ be set to suit the needs of the package under consideration:
 * +FOO_KCONFIG_EDITORS+: a space-separated list of kconfig editors to
   support, for example 'menuconfig xconfig'. By default, 'menuconfig'.
 
+* +FOO_KCONFIG_FRAGMENT_FILES+: a space-separated list of configuration
+  fragment files that are merged to the main configuration file.
+  Fragment files are typically used when there is a desire to stay in sync
+  with an upstream (def)config file, with some minor modifications.
+
 * +FOO_KCONFIG_OPTS+: extra options to pass when calling the kconfig
   editors. This may need to include '$(FOO_MAKE_OPTS)', for example. By
   default, empty.
package/pkg-kconfig.mk +6 -4
index 8361064..21fbfdb 100644
@@ -35,18 +35,20 @@ $(call inner-generic-package,$(1),$(2),$(3),$(4))
 $(2)_KCONFIG_EDITORS ?= menuconfig
 $(2)_KCONFIG_OPTS ?=
 $(2)_KCONFIG_FIXUP_CMDS ?=
+$(2)_KCONFIG_FRAGMENT_FILES ?=
 
 # The config file could be in-tree, so before depending on it the package should
 # be extracted (and patched) first
 $$($(2)_KCONFIG_FILE): | $(1)-patch
 
-# The .config file is obtained by copying it from the specified source
-# configuration file, after the package has been patched.
+# The specified source configuration file and any additional configuration file
+# fragments are merged together to .config, after the package has been patched.
 # Since the file could be a defconfig file it needs to be expanded to a
 # full .config first. We use 'make oldconfig' because this can be safely
 # done even when the package does not support defconfigs.
-$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE)
-     $$(INSTALL) -m 0644 $$($(2)_KCONFIG_FILE) $$($(2)_DIR)/.config
+$$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
+     support/kconfig/merge_config.sh -m -O $$(@D) \
+             $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
      @yes "" | $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
              $$($(2)_KCONFIG_OPTS) oldconfig
 

package/pkg-kconfig.mk $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done · line 93

Quoted 5 lines
package/pkg-kconfig.mk +2 -0
@@ -87,6 +89,8 @@ $(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # Even though we could use 'cp --preserve-timestamps' here, the separate
 # cp and 'touch --reference' is used for symmetry with $(1)-update-defconfig.
 $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
+     $$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+             echo "Unable to perform $(1)-update-config when fragment files are set"; exit 1)

There should be an @ in front of this, otherwise you see the error twice.

package/pkg-kconfig.mk $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done · line 103

Quoted 9 lines
package/pkg-kconfig.mk +2 -0
      cp -f $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
      touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
@@ -95,6 +99,8 @@ $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # $(1)-update-config, the reference for 'touch' is _not_ the file from which
 # we copy.
 $(1)-update-defconfig: $(1)-savedefconfig
+     $$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \
+             echo "Unable to perform $(1)-update-defconfig when fragment files are set"; exit 1)

And here.

Regards,
Arnout

Quoted 4 lines
package/pkg-kconfig.mk +0 -0
      cp -f $$($(2)_DIR)/defconfig $$($(2)_KCONFIG_FILE)
      touch --reference $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
 
#15 lore raw

PATCH v2 1/5 kconfig-package: add support for config fragments

In reply to Floris Bos

Dear Floris Bos,

Quoted 8 lines · Floris Bos

Adds functionality to the kconfig infrastructure to merge additional configuration fragment files to the main configuration file of kconfig packages, using support/kconfig/merge_config.sh

Typical use-case is when you want your configuration to be kept in sync with an upstream (def)config file, but do require some minor local modifications.

Quoted 7 lines

Disables -update-config and -update-defconfig targets when fragment files are set.

---
v2:

Entire series applied to the next branch!

On the first patch, I've fixed the minor issues pointed by Arnout:

[Thomas: take into account comments made by Arnout:
- Minor fixes in the documentation changes
- Add @ before the tests done in the $(1)-update-config and $(1)-update-defconfig targets.]

Thanks a lot for your work on this topic!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com