Skip to contentSkip to conversation

Kconfig: Fix various bugs

PATCH New Masahiro Yamada 3 participants 14 messages Sep 3, 2014 – Sep 17, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover Kconfig: Fix various bugs

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced various bugs.

We are trying to be user-friendly, not developer-friendly, but it causes my headache...

Masahiro Yamada (4):
kconfig: fix savedefconfig to output empty defconfig
kconfig: fix whitespace handling bug of savedefconfig
kconfig: fix savedefconfig to handle TPL correctly
kconfig: fix a bug of "make config"

 Makefile               |  2 +-
 scripts/multiconfig.sh | 44 +++++++++++++++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 12 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/4 kconfig: fix savedefconfig to output empty defconfig

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced a minor regression.

make alldefconfig; make savedefconfig
should create an empty 'defconfig'.

---

Changes in v2:
- Resend as a series.
- Change the commit subject

 scripts/multiconfig.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/multiconfig.sh +1 -0
index 4190798..785f563 100644
@@ -217,6 +217,7 @@ do_savedefconfig () {
 	done
 
 	rm -f defconfig
+	touch defconfig
 	for line in $output_lines
 	do
 		echo $line >> defconfig
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/4 kconfig: fix savedefconfig to output empty defconfig

Quoted 9 lines · Masahiro Yamada

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced a minor regression.

make alldefconfig; make savedefconfig
should create an empty 'defconfig'.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/ae5b9408/attachment.pgp>
#3 lore raw

PATCH v2 2/4 kconfig: fix whitespace handling bug of savedefconfig

In reply to Masahiro Yamada

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced another regression.

Shell usually handles whitespaces as separators,
so "make saveconfig" outputs

# CONFIG_FOO is not set

into:

#
CONFIG_FOO
is
not
set

Whitespaces should not be treated as separators here.

---

Changes in v2:
- Resend as a series
- Change the commit subject

 scripts/multiconfig.sh | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)
scripts/multiconfig.sh +29 -8
index 785f563..7606193 100644
@@ -170,7 +170,7 @@ do_savedefconfig () {
 	# backslashes as an escape character
 	while read -r line
 	do
-		output_lines="$output_lines $line"
+		output_lines="$output_lines%$line"
 	done < defconfig
 
 	for img in $subimages
@@ -185,43 +185,64 @@ do_savedefconfig () {
 			tmp=
 			match=
 
+			# "# CONFIG_FOO is not set" should not be divided.
+			# Use "%" as a separator, instead of a whitespace.
+			# "%" is unlikely to appear in defconfig context.
+			save_IFS=$IFS
+			IFS=%
 			# coalesce common lines together
 			for i in $output_lines
 			do
 				case "$i" in
 				"[+A-Z]*:$line")
-					tmp="$tmp $unmatched"
+					tmp="$tmp%$unmatched"
 					i=$(echo "$i" | \
 					    sed -e "s/^\([^:]\)*/\1$symbol/")
-					tmp="$tmp $i"
+					tmp="$tmp%$i"
 					match=1
 					;;
 				"$line")
-					tmp="$tmp $unmatched"
-					tmp="$tmp +$symbol:$i"
+					tmp="$tmp%$unmatched"
+					tmp="$tmp%+$symbol:$i"
 					match=1
 					;;
 				*)
-					tmp="$tmp $i"
+					tmp="$tmp%$i"
 					;;
 				esac
 			done
 
+			# Restore the default separator for the outer for loop.
+			IFS=$save_IFS
+
 			if [ "$match" ]; then
 				output_lines="$tmp"
 				unmatched=
 			else
-				unmatched="$unmatched $symbol:$line"
+				unmatched="$unmatched%$symbol:$line"
 			fi
 		done < defconfig
 	done
 
 	rm -f defconfig
 	touch defconfig
+
+	save_IFS=$IFS
+	IFS=%
+
 	for line in $output_lines
 	do
-		echo $line >> defconfig
+		case "$line" in
+		"")
+			# do not output blank lines
+			;;
+		*)
+			echo $line >> defconfig
+			;;
+		esac
 	done
+
+	IFS=$save_IFS
 }
 
 # Usage:
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/4 kconfig: fix whitespace handling bug of savedefconfig

Hi Masahiro,

Quoted 11 lines · Masahiro Yamada

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced another regression.

Shell usually handles whitespaces as separators,
so "make saveconfig" outputs

# CONFIG_FOO is not set

into:

Quoted 7 lines

#
CONFIG_FOO
is
not
set

Whitespaces should not be treated as separators here.

Oh dear...python is so much better at dealing with parameters and strings.

Quoted 2 lines

Regards,
Simon

#5 lore raw

PATCH v2 2/4 kconfig: fix whitespace handling bug of savedefconfig

Hi Simon,

2014-09-04 8:49 GMT+09:00 Simon Glass <[email protected]>:

Quoted 20 lines

Hi Masahiro,

Quoted 17 lines · Masahiro Yamada

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced another regression.

Shell usually handles whitespaces as separators,
so "make saveconfig" outputs

# CONFIG_FOO is not set

into:

#
CONFIG_FOO
is
not
set

Quoted 4 lines
Quoted 1 line

Whitespaces should not be treated as separators here.

Oh dear...python is so much better at dealing with parameters and strings.

Shell script is much more difficult than Python (and Perl) for text processing.

This is really unfortunate...

Signature · 2 lines
Best Regards
Masahiro Yamada
#6 lore raw

PATCH v2 2/4 kconfig: fix whitespace handling bug of savedefconfig

In reply to Masahiro Yamada
Quoted 17 lines · Masahiro Yamada

Commit 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script) introduced another regression.

Shell usually handles whitespaces as separators,
so "make saveconfig" outputs

# CONFIG_FOO is not set

into:

#
CONFIG_FOO
is
not
set

Quoted 4 lines

Whitespaces should not be treated as separators here.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/b65e3741/attachment.pgp>
#7 lore raw

PATCH v2 3/4 kconfig: fix savedefconfig to handle TPL correctly

In reply to Masahiro Yamada

Since 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script), "make savedefconfig" of TPL boards has not been working.

---

Changes in v2:
- Newly added

 scripts/multiconfig.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/multiconfig.sh +3 -3
index 7606193..a579042 100644
@@ -194,14 +194,14 @@ do_savedefconfig () {
 			for i in $output_lines
 			do
 				case "$i" in
-				"[+A-Z]*:$line")
+				[+A-Z]*:$line)
 					tmp="$tmp%$unmatched"
 					i=$(echo "$i" | \
-					    sed -e "s/^\([^:]\)*/\1$symbol/")
+					    sed -e "s/^\([^:]*\)/\1$symbol/")
 					tmp="$tmp%$i"
 					match=1
 					;;
-				"$line")
+				$line)
 					tmp="$tmp%$unmatched"
 					tmp="$tmp%+$symbol:$i"
 					match=1
Signature · 1 line
1.9.1
#10 lore raw

PATCH v2 3/4 kconfig: fix savedefconfig to handle TPL correctly

In reply to Masahiro Yamada
Quoted 7 lines · Masahiro Yamada

Since 3ff291f371fa9858426774f3732924bacb61ed1c (kconfig: convert Kconfig helper script into a shell script), "make savedefconfig" of TPL boards has not been working.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/7cf216f7/attachment.pgp>
#11 lore raw

PATCH v2 4/4 kconfig: fix a bug of "make config"

In reply to Masahiro Yamada

Since 3ff291f371fa9858426774f3732924bacb61ed1c
(kconfig: convert Kconfig helper script into a shell script), "make config" is not working because of a missing '$' before '(Q)'.

Besides, "make config" should be invoked via scripts/multiconfig.sh to avoid a warning message:
Kconfig:11:warning: environment variable KCONFIG_OBJDIR undefined

---

Changes in v2:
- Newly added

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index fdda3ec..fe7d98f 100644
@@ -458,7 +458,7 @@ KBUILD_DEFCONFIG := sandbox_defconfig
 export KBUILD_DEFCONFIG KBUILD_KCONFIG
 
 config: scripts_basic outputmakefile FORCE
-	(Q)$(MAKE) $(build)=scripts/kconfig $@
+	+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@
 
 %config: scripts_basic outputmakefile FORCE
 	+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@
Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 4/4 kconfig: fix a bug of "make config"

Quoted 9 lines · Masahiro Yamada

Since 3ff291f371fa9858426774f3732924bacb61ed1c
(kconfig: convert Kconfig helper script into a shell script), "make config" is not working because of a missing '$' before '(Q)'.

Besides, "make config" should be invoked via scripts/multiconfig.sh to avoid a warning message:
Kconfig:11:warning: environment variable KCONFIG_OBJDIR undefined

#13 lore raw

PATCH v2 4/4 kconfig: fix a bug of "make config"

In reply to Masahiro Yamada
Quoted 10 lines · Masahiro Yamada

Since 3ff291f371fa9858426774f3732924bacb61ed1c
(kconfig: convert Kconfig helper script into a shell script), "make config" is not working because of a missing '$' before '(Q)'.

Besides, "make config" should be invoked via scripts/multiconfig.sh to avoid a warning message:
Kconfig:11:warning: environment variable KCONFIG_OBJDIR undefined

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/58f822de/attachment.pgp>