merge_config.sh: Replace prefix CONFIG_ with any prefix
PATCH 1/1 merge_config.sh: Replace prefix CONFIG_ with any prefix
merge_config.sh expect prefix from kernel: CONFIG_. There some other projects using kconfig with different prefixes (e.g. buildroot: BR2_ prefix). While there could be some option to specify config prefix [1] [2], IMHO it's better to not specify prefix (expect just any prefix).
[1] http://patchwork.ozlabs.org/patch/824051/
[2] https://patchwork.ozlabs.org/patch/988890/
---
NOTE: I deliberately left prefix CONFIG_ in comment:
# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
Kind regards,
Petr
--- scripts/kconfig/merge_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +1 -1
@@ -99,7 +99,7 @@ if [ ! -r "$INITFILE" ]; then fi MERGE_LIST=$* -SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" +SED_CONFIG_EXP="s/^\(# \)\{0,1\}\([A-Z0-9_]\+_[a-zA-Z0-9_]*\)[= ].*/\2/p" TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base"
Signature · 1 line
2.19.1
Quoted 7 lines · Petr Vorel
merge_config.shexpect prefix from kernel:CONFIG_. There some other projects using kconfig with different prefixes (e.g. buildroot:BR2_prefix). While there could be some option to specify config prefix [1] [2], IMHO it's better to not specify prefix (expect just any prefix).
Quoted 8 lines
[1] http://patchwork.ozlabs.org/patch/824051/
[2] https://patchwork.ozlabs.org/patch/988890/Signed-off-by Petr Vorel <[email protected]>Suggested-by Marcel Patzlaff <[email protected]>---
NOTE: I deliberately left prefixCONFIG_in comment:
# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
I'd like to filter "CONFIG_", "BR2_", or whatever specified prefix.
Some fragment files (e.g. arch/x86/configs/xen.config) have comment lines.
Matching '# ' + arbitrary string
might hit comment lines accidentally.
The kconfig binary checks the environment variable 'CONFIG_' to override the default prefix:
https://github.com/torvalds/linux/blob/v4.19/scripts/kconfig/lkc.h#L28
For similarity, how about doing in the same way in merge_config.sh ?
Does the following work for you ?
(you can pass CONFIG_=BR2_ to merge_config.sh)
scripts/kconfig/merge_config.sh +5 -1
@@ -90,6 +90,10 @@ if [ -z "$KCONFIG_CONFIG" ]; then fi fi +# Check the environment variable "CONFIG_" for the config option prefix. +# If unset, the default is "CONFIG_". +: ${CONFIG_=CONFIG_} + INITFILE=$1 shift;
@@ -99,7 +103,7 @@ if [ ! -r "$INITFILE" ]; then fi MERGE_LIST=$* -SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" +SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_}[a-zA-Z0-9_]*\)[= ].*/\2/p" TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base"
--
Best Regards
Masahiro Yamada
Petr Vorel
Reviewed-byHi Masahiro,
thanks for a quick review and patch.
Quoted 7 lines
I'd like to filter "
CONFIG_", "BR2_", or whatever specified prefix.Some fragment files (e.g.
arch/x86/configs/xen.config) have comment lines.Matching '# ' + arbitrary string
might hit comment lines accidentally.
Make sense.
Quoted 3 lines
The kconfig binary checks the environment variable '
CONFIG_' to override the default prefix:
https://github.com/torvalds/linux/blob/v4.19/scripts/kconfig/lkc.h#L28
What a crazy variable name. But we're not going to change it.
Quoted 1 line
For similarity, how about doing in the same way in
merge_config.sh?
Make sense to keep the same approach.
Quoted 2 lines
Does the following work for you ?
(you can pass CONFIG_=BR2_ tomerge_config.sh)
Patch is good (with one note bellow).
Could you push your patch into your tree?
Or going to post a patch? If not here is mine:
scripts/kconfig/merge_config.sh if [ -z "$KCONFIG_CONFIG" ]; then · line 95
Quoted 11 lines
scripts/kconfig/merge_config.sh +3
-0@@ -90,6 +90,10 @@ if [ -z "$KCONFIG_CONFIG" ]; then fi fi +# Check the environment variable "CONFIG_" for the config option prefix. +# If unset, the default is "CONFIG_". +: ${CONFIG_=CONFIG_}
Although I guess this could be less cryptic:
CONFIG_="${CONFIG_:-CONFIG_}"
but too verbose, so I'm for your variant.
...
scripts/kconfig/merge_config.sh if [ ! -r "$INITFILE" ]; then · line 107
Quoted 4 lines
scripts/kconfig/merge_config.sh +1
-1MERGE_LIST=$* -SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" +SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_}[a-zA-Z0-9_]*\)[= ].*/\2/p" TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
Kind regards,
Petr
Hi Petr,
Quoted 22 lines · Petr Vorel
Hi Masahiro,
thanks for a quick review and patch.
Quoted 7 lines
I'd like to filter "
CONFIG_", "BR2_", or whatever specified prefix.Some fragment files (e.g.
arch/x86/configs/xen.config) have comment lines.Matching '# ' + arbitrary string
might hit comment lines accidentally.Make sense.
Quoted 3 lines
The kconfig binary checks the environment variable '
CONFIG_' to override the default prefix:
https://github.com/torvalds/linux/blob/v4.19/scripts/kconfig/lkc.h#L28What a crazy variable name. But we're not going to change it.
Quoted 1 line
For similarity, how about doing in the same way in
merge_config.sh?Make sense to keep the same approach.
Quoted 8 lines
Quoted 2 lines
Does the following work for you ?
(you can pass CONFIG_=BR2_ tomerge_config.sh)Patch is good (with one note bellow).
Reviewed-by Petr Vorel <[email protected]>Could you push your patch into your tree?
Or going to post a patch? If not here is mine:
Please send v2 with the commit log properly filled.
I will take my credit as Suggested-by.
Quoted 8 lines
Quoted 7 lines
scripts/kconfig/merge_config.sh +0
-0@@ -90,6 +90,10 @@ if [ -z "$KCONFIG_CONFIG" ]; then fi fi
Quoted 5 lines
scripts/kconfig/merge_config.sh if [ -z "$KCONFIG_CONFIG" ]; then · line 95
Quoted 3 lines
scripts/kconfig/merge_config.sh +3
-0+# Check the environment variable "CONFIG_" for the config option prefix. +# If unset, the default is "CONFIG_". +: ${CONFIG_=CONFIG_}Although I guess this could be less cryptic:
CONFIG_="${CONFIG_:-CONFIG_}"
You should not use the colon
because we want to allow the environment variable 'CONFIG_' being set as empty.
In fact, Buildroot uses empty prefix instead of "BR2_". In my understanding, Buildroot just has a convention where symbols in Config.in files start with "BR2_".
So, in order to make your idea even less cryptic, how about this?
CONFIG_PREFIX=${CONFIG_-CONFIG_}
Then,
SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
Signature · 2 lines
Best Regards Masahiro Yamada
Hi Masahiro,
Quoted 1 line
Please send v2 with the commit log properly filled.
OK I'll do.
Quoted 1 line
I will take my credit as Suggested-by.
Sure :).
Quoted 9 lines
Quoted 5 lines
scripts/kconfig/merge_config.sh if [ -z "$KCONFIG_CONFIG" ]; then · line 95
Quoted 3 lines
scripts/kconfig/merge_config.sh +3
-0+# Check the environment variable "CONFIG_" for the config option prefix. +# If unset, the default is "CONFIG_". +: ${CONFIG_=CONFIG_}Although I guess this could be less cryptic:
CONFIG_="${CONFIG_:-CONFIG_}"You should not use the colon
because we want to allow the environment variable 'CONFIG_' being set as empty.
How about having default 'CONFIG_' and if it's empty change it to '[A-Z0-9_]\+' ? I know, it's different from C definition in lkc.h, but IMHO it'd make sense. But I guess you prefer your suggestion CONFIG_PREFIX=${CONFIG_-CONFIG_}
Quoted 3 lines
In fact, Buildroot uses empty prefix instead of "
BR2_". In my understanding, Buildroot just has a convention where symbols in Config.in files start with "BR2_".
IMHO buildroot uses 'BR2_' prefix. That's what we want to use with merge_config.sh.
Kind regards,
Petr
Quoted 15 lines · Petr Vorel
Hi Masahiro,
Quoted 1 line
Please send v2 with the commit log properly filled.
OK I'll do.
Quoted 1 line
I will take my credit as Suggested-by.
Sure :).
Quoted 5 lines
Quoted 5 lines
scripts/kconfig/merge_config.sh if [ -z "$KCONFIG_CONFIG" ]; then · line 95
Quoted 3 lines
scripts/kconfig/merge_config.sh +3
-0+# Check the environment variable "CONFIG_" for the config option prefix. +# If unset, the default is "CONFIG_". +: ${CONFIG_=CONFIG_}Although I guess this could be less cryptic:
CONFIG_="${CONFIG_:-CONFIG_}"
Quoted 5 lines
Quoted 3 lines
You should not use the colon
because we want to allow the environment variable 'CONFIG_' being set as empty.How about having default '
CONFIG_' and if it's empty change it to '[A-Z0-9_]\+' ?
No, I'd like to have the same rule for prefix.
Quoted 2 lines
I know, it's different from C definition in
lkc.h, but IMHO it'd
make sense. But I guess you prefer your suggestionCONFIG_PREFIX=${CONFIG_-CONFIG_}
Yeah, I prefer this.
Quoted 5 lines
Quoted 3 lines
In fact, Buildroot uses empty prefix instead of "
BR2_". In my understanding, Buildroot just has a convention where symbols in Config.in files start with "BR2_".IMHO buildroot uses '
BR2_' prefix. That's what we want to use withmerge_config.sh.
Yes, you can use 'BR2_' prefix for merge_config.
I just wanted to point out that
Buildroot's own patch specifies the prefix as empty wrt the kconfig binary.
Quoted 3 lines
Kind regards,
Petr
Signature · 2 lines
Best Regards Masahiro Yamada