All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] package/pkg-kconfig: fix bad config with per-package-dirs
@ 2022-11-24 10:44 Arnout Vandecappelle
  0 siblings, 0 replies; only message in thread
From: Arnout Vandecappelle @ 2022-11-24 10:44 UTC (permalink / raw)
  To: buildroot

commit: https://git.buildroot.net/buildroot/commit/?id=fb449c72cd6a2983e1d9ebffcd6b0f87fbe7df96
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

If BR2_PER_PACKAGE_DIRECTORIES is enabled and Buildroot is using
HOST_MAKE for a Kconfig package. The $(1)_KCONFIG_RULES does not work
correctly, and kconfig-package-regen-dot-config will always run the
'oldconfig' target.

This is because $(1)_KCONFIG_RULES expands before the first recipe line
of .stamp_dotconfig. $(1)_KCONFIG_RULES attempts to call $(HOST_MAKE),
which requires that the per-package/<pkg>/host directory has been setup.
But that directory is not setup until a later recipe line. This results
in $(1)_KCONFIG_RULES silently failing, and so always configuring with
'oldconfig'.

Fix the issue by calling the command as part of the recipe, so
$(HOST_MAKE) will be ready in time. As the comment on $(1)_KCONFIG_RULES
describes, we should not use backticks. Use an intermediary file to
store the output of the command, so that backticks are not needed.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
---
 package/pkg-kconfig.mk | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
index 32dcfea0bc..f4f35bf96a 100644
--- a/package/pkg-kconfig.mk
+++ b/package/pkg-kconfig.mk
@@ -45,11 +45,16 @@ endef
 # only, as this can fail in complex cases.
 # $(1): the name of the package in upper-case letters
 define kconfig-package-regen-dot-config
-	$(if $(filter olddefconfig,$($(1)_KCONFIG_RULES)),
-		$(Q)$($(1)_KCONFIG_MAKE) olddefconfig,
-		$(if $(filter oldnoconfig,$($(1)_KCONFIG_RULES)),
-			$(Q)$($(1)_KCONFIG_MAKE) oldnoconfig,
-			$(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig)))
+	$(Q)[ -e $($(1)_DIR)/.br_regen_dot_config ] || \
+		$($(1)_KCONFIG_MAKE) -pn config 2>/dev/null \
+		| sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d' >$($(1)_DIR)/.br_regen_dot_config
+	$(Q)if grep -q '\bolddefconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \
+		$($(1)_KCONFIG_MAKE) olddefconfig; \
+	elif grep -q '\boldnoconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \
+		$($(1)_KCONFIG_MAKE) oldnoconfig; \
+	else \
+		yes "" | $($(1)_KCONFIG_MAKE) oldconfig; \
+	fi
 endef
 
 # Macro to create a .config file where all given fragments are merged into.
@@ -147,19 +152,6 @@ $(2)_KCONFIG_MAKE = \
 	$$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \
 		$$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS)
 
-# $(2)_KCONFIG_MAKE may already rely on shell expansion. As the $() syntax
-# of the shell conflicts with Make's own syntax, this means that backticks
-# are used with those shell constructs. Unfortunately, the backtick syntax
-# does not nest, and we need to use Make instead of the shell to handle
-# conditions.
-
-# A recursively expanded variable is necessary, to be sure that the shell
-# command is called when the rule is processed during the build and not
-# when the rule is created when parsing all packages.
-$(2)_KCONFIG_RULES = \
-	$$(shell $$($(2)_KCONFIG_MAKE) -pn config 2>/dev/null | \
-		sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d')
-
 # 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
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-05 12:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 10:44 [Buildroot] [git commit] package/pkg-kconfig: fix bad config with per-package-dirs Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.