* [PATCH 1/3] scripts/config: be case-sensitive on config option symbols
@ 2012-06-06 22:29 Yann E. MORIN
2012-06-06 22:29 ` [PATCH 2/3] scripts/config: allow alternate prefix to config option symbol Yann E. MORIN
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Yann E. MORIN @ 2012-06-06 22:29 UTC (permalink / raw)
To: linux-kbuild; +Cc: Andi Kleen, Michal Marek, Yann E. MORIN
Currently, scripts/config mangles the config option symbols to always
be upper-case.
While the Linux kernel almost exclusively uses upper-case symbols, there
are still a few symbols with lower-case which this script can not handle:
$ grep -r -E '^[[:space:]]*config[[:space:]]+[^:space:]]*[[:lower:]]' .
./arch/powerpc/platforms/8xx/Kconfig:config 8xx_COPYBACK
./arch/powerpc/platforms/8xx/Kconfig:config 8xx_GPIO
./arch/powerpc/platforms/8xx/Kconfig:config 8xx_CPU6
./arch/powerpc/platforms/8xx/Kconfig:config 8xx_CPU15
./arch/powerpc/platforms/Kconfig.cputype:config 6xx
./arch/powerpc/platforms/Kconfig.cputype:config 8xx
./arch/powerpc/platforms/Kconfig.cputype:config 4xx
./arch/powerpc/Kconfig:config 4xx_SOC
./drivers/watchdog/Kconfig:config 8xxx_WDT
Also, other projects that use kconfig may allow for lower- or mixed-case
symbols, and may find easier to reuse this script than implement each
their own (potentially flawed) logic. For such a use-case, see:
http://marc.info/?l=linux-kbuild&m=133409932115848&w=2
With this patch, if the KCONFIG_CASE environment variable is set to (with
no quotes):
- 'upper': force symbols to upper-case
- 'lower': force symbols to lower-case
The default if KCONFIG_CASE is not set, or is set and empty, or is set to
any other value, is to not change the symbol's case.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
scripts/config | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/scripts/config b/scripts/config
index ed6653e..5bae72d 100755
--- a/scripts/config
+++ b/scripts/config
@@ -29,7 +29,11 @@ options:
--file .config file to change (default .config)
config doesn't check the validity of the .config file. This is done at next
- make time.
+make time.
+
+If the variable KCONFIG_CASE is set in the environment to either 'upper' or
+'lower', option symbols will be forced to the corresponding case. Any other
+value (or if it is not set) leaves the symbol's case unchanged.
EOL
exit 1
}
@@ -44,7 +48,14 @@ checkarg() {
ARG="${ARG/CONFIG_/}"
;;
esac
- ARG="`echo $ARG | tr a-z A-Z`"
+ case "${KCONFIG_CASE}" in
+ upper)
+ ARG="`echo $ARG | tr a-z A-Z`"
+ ;;
+ lower)
+ ARG="`echo $ARG | tr A-Z a-z`"
+ ;;
+ esac
}
set_var() {
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/3] scripts/config: allow alternate prefix to config option symbol
2012-06-06 22:29 [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Yann E. MORIN
@ 2012-06-06 22:29 ` Yann E. MORIN
2012-06-06 22:29 ` [PATCH 3/3] scripts/config: add option to undef a symbol Yann E. MORIN
2012-06-07 2:54 ` [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Andi Kleen
2 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2012-06-06 22:29 UTC (permalink / raw)
To: linux-kbuild; +Cc: Andi Kleen, Michal Marek, Yann E. MORIN
While the Linux kernel uses 'CONFIG_' as a prefix to the config options
symbols, many projects that use kconfig may use different prefixes, or
even none at all.
If the CONFIG_ environment variable is set, use it as the prefix (empty
is a valid prefix). Otherwise, use the default prefix 'CONFIG_'.
This matches the support for alternate prefixes in scripts/kconfig/lkc.h,
which uses the same logic (albeit with a C define instead of an environment
variable).
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
scripts/config | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/scripts/config b/scripts/config
index 5bae72d..09bd4ec 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,6 +1,9 @@
#!/bin/bash
# Manipulate options in a .config file from the command line
+# If no prefix forced, use the default CONFIG_
+CONFIG_="${CONFIG_-CONFIG_}"
+
usage() {
cat >&2 <<EOL
Manipulate options in a .config file from the command line.
@@ -44,8 +47,8 @@ checkarg() {
usage
fi
case "$ARG" in
- CONFIG_*)
- ARG="${ARG/CONFIG_/}"
+ ${CONFIG_}*)
+ ARG="${ARG/${CONFIG_}/}"
;;
esac
case "${KCONFIG_CASE}" in
@@ -106,37 +109,37 @@ while [ "$1" != "" ] ; do
esac
case "$CMD" in
--enable|-e)
- set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
;;
--disable|-d)
- set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
+ set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
;;
--module|-m)
- set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
;;
--set-str)
# sed swallows one level of escaping, so we need double-escaping
- set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\""
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
shift
;;
--set-val)
- set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
shift
;;
--state|-s)
- if grep -q "# CONFIG_$ARG is not set" $FN ; then
+ if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
echo n
else
- V="$(grep "^CONFIG_$ARG=" $FN)"
+ V="$(grep "^${CONFIG_}$ARG=" $FN)"
if [ $? != 0 ] ; then
echo undef
else
- V="${V/#CONFIG_$ARG=/}"
+ V="${V/#${CONFIG_}$ARG=/}"
V="${V/#\"/}"
V="${V/%\"/}"
V="${V/\\\"/\"}"
@@ -146,15 +149,15 @@ while [ "$1" != "" ] ; do
;;
--enable-after|-E)
- set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
+ set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
;;
--disable-after|-D)
- set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
+ set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
;;
--module-after|-M)
- set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
+ set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
;;
# undocumented because it ignores --file (fixme)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/3] scripts/config: add option to undef a symbol
2012-06-06 22:29 [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Yann E. MORIN
2012-06-06 22:29 ` [PATCH 2/3] scripts/config: allow alternate prefix to config option symbol Yann E. MORIN
@ 2012-06-06 22:29 ` Yann E. MORIN
2012-06-07 2:54 ` [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Andi Kleen
2 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2012-06-06 22:29 UTC (permalink / raw)
To: linux-kbuild; +Cc: Andi Kleen, Michal Marek, Yann E. MORIN
It is currently possible to enable, disable or modularise
a symbol. Also, an undefined symbol is reported as such.
Add a new command to undefine a symbol, by removing the
corresponding line from the .config file.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
scripts/config | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/scripts/config b/scripts/config
index 09bd4ec..b75aea9 100755
--- a/scripts/config
+++ b/scripts/config
@@ -17,6 +17,7 @@ commands:
Set option to "string"
--set-val option value
Set option to value
+ --undefine|-u option Undefine option
--state|-s option Print state of option (n,y,m,undef)
--enable-after|-E beforeopt option
@@ -75,6 +76,12 @@ set_var() {
fi
}
+undef_var() {
+ local name=$1
+
+ sed -ri "/^($name=|# $name is not set)/d" "$FN"
+}
+
if [ "$1" = "--file" ]; then
FN="$2"
if [ "$FN" = "" ] ; then
@@ -130,6 +137,9 @@ while [ "$1" != "" ] ; do
set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
shift
;;
+ --undefine|-u)
+ undef_var "${CONFIG_}$ARG"
+ ;;
--state|-s)
if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
--
1.7.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/3] scripts/config: be case-sensitive on config option symbols
2012-06-06 22:29 [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Yann E. MORIN
2012-06-06 22:29 ` [PATCH 2/3] scripts/config: allow alternate prefix to config option symbol Yann E. MORIN
2012-06-06 22:29 ` [PATCH 3/3] scripts/config: add option to undef a symbol Yann E. MORIN
@ 2012-06-07 2:54 ` Andi Kleen
2012-06-07 18:06 ` Yann E. MORIN
2 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2012-06-07 2:54 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild, Andi Kleen, Michal Marek
> With this patch, if the KCONFIG_CASE environment variable is set to (with
> no quotes):
> - 'upper': force symbols to upper-case
> - 'lower': force symbols to lower-case
That's ugly. How about a emacs style heuristic. When the config symbol
is mixed case do not change the symbol?
-Andi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] scripts/config: be case-sensitive on config option symbols
2012-06-07 2:54 ` [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Andi Kleen
@ 2012-06-07 18:06 ` Yann E. MORIN
2012-06-07 18:17 ` Andi Kleen
0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2012-06-07 18:06 UTC (permalink / raw)
To: linux-kbuild; +Cc: Andi Kleen, Michal Marek
Andi, All,
On Thursday 07 June 2012 04:54:17 Andi Kleen wrote:
> > With this patch, if the KCONFIG_CASE environment variable is set to (with
> > no quotes):
> > - 'upper': force symbols to upper-case
> > - 'lower': force symbols to lower-case
>
> That's ugly. How about a emacs style heuristic. When the config symbol
> is mixed case do not change the symbol?
Such a heuristic would still break with some of the symbols used in the Linux
tree:
./arch/powerpc/platforms/Kconfig.cputype:config 6xx
./arch/powerpc/platforms/Kconfig.cputype:config 8xx
./arch/powerpc/platforms/Kconfig.cputype:config 4xx
Not to say about other projects which may use lower-case only symbols.
What about adding an option to keep the case as-is:
--keep-case|-k Keep symbol's case (dont' upper-case it)
Ideally, we could also add (I'd make a separate patch for that):
--upper-case|-U Upper-case the symbol
--lower-case|-l Lower-case the symbol
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/3] scripts/config: be case-sensitive on config option symbols
2012-06-07 18:06 ` Yann E. MORIN
@ 2012-06-07 18:17 ` Andi Kleen
2012-06-07 21:49 ` Yann E. MORIN
0 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2012-06-07 18:17 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild, Andi Kleen, Michal Marek
> What about adding an option to keep the case as-is:
> --keep-case|-k Keep symbol's case (dont' upper-case it)
That's fine.
-Andi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] scripts/config: be case-sensitive on config option symbols
2012-06-07 18:17 ` Andi Kleen
@ 2012-06-07 21:49 ` Yann E. MORIN
0 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2012-06-07 21:49 UTC (permalink / raw)
To: linux-kbuild; +Cc: Andi Kleen, Michal Marek
Andi, All,
On Thursday 07 June 2012 20:17:50 Andi Kleen wrote:
> > What about adding an option to keep the case as-is:
> > --keep-case|-k Keep symbol's case (dont' upper-case it)
>
> That's fine.
OK, good. I'll code this tonight, and post an updated series.
Thank you!
For my information, what was the requirement for mangling the symbol in the
first place?
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-06-07 21:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-06 22:29 [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Yann E. MORIN
2012-06-06 22:29 ` [PATCH 2/3] scripts/config: allow alternate prefix to config option symbol Yann E. MORIN
2012-06-06 22:29 ` [PATCH 3/3] scripts/config: add option to undef a symbol Yann E. MORIN
2012-06-07 2:54 ` [PATCH 1/3] scripts/config: be case-sensitive on config option symbols Andi Kleen
2012-06-07 18:06 ` Yann E. MORIN
2012-06-07 18:17 ` Andi Kleen
2012-06-07 21:49 ` Yann E. MORIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).