scripts/findconf | 22 ++++++++++++ scripts/kconfig/.gitignore | 1 + scripts/kconfig/Makefile | 7 +++- scripts/kconfig/findconf.c | 74 ++++++++++++++++++++++++++++++++++++++ scripts/kconfig/lkc.h | 1 + scripts/kconfig/menu.c | 2 +- 6 files changed, 105 insertions(+), 2 deletions(-) create mode 100755 scripts/findconf create mode 100644 scripts/kconfig/findconf.c
scripts/findconf provides menuconfig's search functionality as a
standalone, non-interactive command, somewhat in the spirit of
scripts/config. It is meant to be useful for tasks like getting a
quick overview of symbol dependencies or determining which Kconfig
file to edit for a given symbol, without having to fire up one of the
interactive config programs.
It accepts a single command-line flag, '-v', which causes it to also
print the help text of each matching result.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---
This works a bit differently from [gmnq]conf in that it accepts (and
requires) arguments, but I couldn't see an easy/obvious way of passing
command-line args through the makefile infrastructure that invokes
those, so the wrapper script passes things to it via environment
variables instead. Suggestions welcome if there's a nicer way of
achieving that.
scripts/findconf | 22 ++++++++++++
scripts/kconfig/.gitignore | 1 +
scripts/kconfig/Makefile | 7 +++-
scripts/kconfig/findconf.c | 74 ++++++++++++++++++++++++++++++++++++++
scripts/kconfig/lkc.h | 1 +
scripts/kconfig/menu.c | 2 +-
6 files changed, 105 insertions(+), 2 deletions(-)
create mode 100755 scripts/findconf
create mode 100644 scripts/kconfig/findconf.c
diff --git a/scripts/findconf b/scripts/findconf
new file mode 100755
index 000000000000..c59132548082
--- /dev/null
+++ b/scripts/findconf
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Find Kconfig symbols matching one or more regexen. Pass '-v' to
+# also show help text.
+
+if [ "$1" = "-v" ]; then
+ export FINDCONF_SHOW_HELP=1
+ shift
+fi
+
+if [ $# = 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+ echo >&$(($# ? 1 : 2)) "Usage: $(basename $0) [-v] REGEX [REGEX ...]"
+ exit $((!$#))
+fi
+
+n=0
+for q in "$@"; do
+ export FINDCONF_QUERY_$((n++))="$q"
+done
+
+exec make findconfig
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index 500e7424b3ef..a3ea0600c731 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
/conf
+/findconf
/[gmnq]conf
/[gmnq]conf-cfg
/qconf-moc.cc
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index b8ef0fb4bbef..99e48b2d8563 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -35,6 +35,7 @@ menuconfig-prog := mconf
nconfig-prog := nconf
gconfig-prog := gconf
xconfig-prog := qconf
+findconfig-prog := findconf
define config_rule
PHONY += $(1)
@@ -45,7 +46,7 @@ PHONY += build_$(1)
build_$(1): $(obj)/$($(1)-prog)
endef
-$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c))))
+$(foreach c, config menuconfig nconfig gconfig xconfig findconfig, $(eval $(call config_rule,$(c))))
PHONY += localmodconfig localyesconfig
localyesconfig localmodconfig: $(obj)/conf
@@ -155,6 +156,10 @@ HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
hostprogs += conf
conf-objs := conf.o $(common-objs)
+# findconf: standalone non-interactive config-symbol search
+hostprogs += findconf
+findconf-objs := findconf.o $(common-objs)
+
# nconf: Used for the nconfig target based on ncurses
hostprogs += nconf
nconf-objs := nconf.o nconf.gui.o $(common-objs)
diff --git a/scripts/kconfig/findconf.c b/scripts/kconfig/findconf.c
new file mode 100644
index 000000000000..786408c97eab
--- /dev/null
+++ b/scripts/kconfig/findconf.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Zev Weiss <zev@bewilderbeest.net>
+ *
+ * Kconfig symbol search a la carte.
+ */
+#include "lkc.h"
+
+static bool query(const char *q)
+{
+ unsigned int i;
+ const char *help;
+ struct gstr res;
+ struct symbol **sym_arr, *sym;
+ struct property *prop;
+
+ sym_arr = sym_re_search(q);
+
+ if (!sym_arr) {
+ printf("%s: no matches found.\n", q);
+ return false;
+ }
+
+ for (i = 0; sym_arr[i]; i++) {
+ sym = sym_arr[i];
+ res = str_new();
+ get_symbol_str(&res, sym, NULL);
+ printf("%s", str_get(&res));
+ str_free(&res);
+
+ if (getenv("FINDCONF_SHOW_HELP")) {
+ for_all_properties(sym, prop, P_SYMBOL) {
+ if (prop->menu) {
+ help = menu_get_help(prop->menu);
+ if (help && *help)
+ printf("%s\n", help);
+ }
+ }
+ }
+ }
+
+ free(sym_arr);
+
+ return true;
+}
+
+int main(int argc, char **argv)
+{
+ unsigned int i = 0;
+ char qvar[32];
+ bool found = false;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s KCONFIG\n", argv[0]);
+ exit(1);
+ }
+
+ conf_parse(argv[1]);
+ conf_read(NULL);
+
+ for (;;) {
+ snprintf(qvar, sizeof(qvar), "FINDCONF_QUERY_%u", i++);
+ if (!getenv(qvar))
+ break;
+ found = query(getenv(qvar)) || found;
+ }
+
+ if (i == 1) {
+ fprintf(stderr, "FINDCONF_QUERY_0 not set\n");
+ return 1;
+ }
+
+ return !found;
+}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index fa8c010aa683..b4730f580dee 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -102,6 +102,7 @@ struct menu *menu_get_root_menu(struct menu *menu);
struct menu *menu_get_parent_menu(struct menu *menu);
bool menu_has_help(struct menu *menu);
const char *menu_get_help(struct menu *menu);
+void get_symbol_str(struct gstr *r, struct symbol *sym, struct list_head *head);
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
void menu_get_ext_help(struct menu *menu, struct gstr *help);
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 3d6f7cba8846..4b990c73e431 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -800,7 +800,7 @@ static void get_symbol_props_str(struct gstr *r, struct symbol *sym,
/*
* head is optional and may be NULL
*/
-static void get_symbol_str(struct gstr *r, struct symbol *sym,
+void get_symbol_str(struct gstr *r, struct symbol *sym,
struct list_head *head)
{
struct property *prop;
--
2.36.1
Hi-- On 6/8/22 02:54, Zev Weiss wrote: > scripts/findconf provides menuconfig's search functionality as a > standalone, non-interactive command, somewhat in the spirit of > scripts/config. It is meant to be useful for tasks like getting a > quick overview of symbol dependencies or determining which Kconfig > file to edit for a given symbol, without having to fire up one of the > interactive config programs. > > It accepts a single command-line flag, '-v', which causes it to also > print the help text of each matching result. > > Signed-off-by: Zev Weiss <zev@bewilderbeest.net> > --- I can see how this could be useful. It's a little easier to use than what I currently do: $ findconfig DRM_HISI_HIBMC ./drivers/gpu/drm/hisilicon/hibmc/Kconfig:2:config DRM_HISI_HIBMC then $EDITOR that_Kconfig_file In testing, I am seeing this: # # using defaults found in /boot/config-5.3.18-150300.59.63-default # .config:421:warning: symbol value 'm' invalid for I8K .config:2335:warning: symbol value 'm' invalid for MTD_NAND_ECC_SW_HAMMING .config:2484:warning: symbol value 'm' invalid for PVPANIC .config:8671:warning: symbol value 'm' invalid for INTERCONNECT .config:9369:warning: symbol value 'm' invalid for CRYPTO_ARCH_HAVE_LIB_BLAKE2S .config:9370:warning: symbol value 'm' invalid for CRYPTO_LIB_BLAKE2S_GENERIC .config:9653:warning: symbol value '1' invalid for KASAN_STACK How do I specify/choose a .config file to be used? Oh, use KCONFIG_CONFIG=filename Please update (add) usage/help text in scripts/kconfig/Makefile. > > This works a bit differently from [gmnq]conf in that it accepts (and > requires) arguments, but I couldn't see an easy/obvious way of passing > command-line args through the makefile infrastructure that invokes > those, so the wrapper script passes things to it via environment > variables instead. Suggestions welcome if there's a nicer way of > achieving that. > > scripts/findconf | 22 ++++++++++++ > scripts/kconfig/.gitignore | 1 + > scripts/kconfig/Makefile | 7 +++- > scripts/kconfig/findconf.c | 74 ++++++++++++++++++++++++++++++++++++++ > scripts/kconfig/lkc.h | 1 + > scripts/kconfig/menu.c | 2 +- > 6 files changed, 105 insertions(+), 2 deletions(-) > create mode 100755 scripts/findconf > create mode 100644 scripts/kconfig/findconf.c > thanks. -- ~Randy
On Wed, Jun 08, 2022 at 07:48:44PM PDT, Randy Dunlap wrote: >Hi-- > >On 6/8/22 02:54, Zev Weiss wrote: >> scripts/findconf provides menuconfig's search functionality as a >> standalone, non-interactive command, somewhat in the spirit of >> scripts/config. It is meant to be useful for tasks like getting a >> quick overview of symbol dependencies or determining which Kconfig >> file to edit for a given symbol, without having to fire up one of the >> interactive config programs. >> >> It accepts a single command-line flag, '-v', which causes it to also >> print the help text of each matching result. >> >> Signed-off-by: Zev Weiss <zev@bewilderbeest.net> >> --- > >I can see how this could be useful. >It's a little easier to use than what I currently do: > >$ findconfig DRM_HISI_HIBMC >./drivers/gpu/drm/hisilicon/hibmc/Kconfig:2:config DRM_HISI_HIBMC I'm guessing 'findconfig' here is some personal shell alias/function/script? (I can't see any references to it in the kernel source tree.) > >then $EDITOR that_Kconfig_file > > >In testing, I am seeing this: > ># ># using defaults found in /boot/config-5.3.18-150300.59.63-default ># >.config:421:warning: symbol value 'm' invalid for I8K >.config:2335:warning: symbol value 'm' invalid for MTD_NAND_ECC_SW_HAMMING >.config:2484:warning: symbol value 'm' invalid for PVPANIC >.config:8671:warning: symbol value 'm' invalid for INTERCONNECT >.config:9369:warning: symbol value 'm' invalid for CRYPTO_ARCH_HAVE_LIB_BLAKE2S >.config:9370:warning: symbol value 'm' invalid for CRYPTO_LIB_BLAKE2S_GENERIC >.config:9653:warning: symbol value '1' invalid for KASAN_STACK > This I assume is just due to the contents of your .config file relative to the current Kconfig definitions and not a problem with anything in this patch? >How do I specify/choose a .config file to be used? > >Oh, use KCONFIG_CONFIG=filename > Ah, I guess that'd be a nice thing to add a flag for to the wrapper script -- I'll include that in v2. > >Please update (add) usage/help text in scripts/kconfig/Makefile. > Ack, will do. Thanks for the review! Zev
On 6/8/22 20:46, Zev Weiss wrote: > On Wed, Jun 08, 2022 at 07:48:44PM PDT, Randy Dunlap wrote: >> Hi-- >> >> On 6/8/22 02:54, Zev Weiss wrote: >>> scripts/findconf provides menuconfig's search functionality as a >>> standalone, non-interactive command, somewhat in the spirit of >>> scripts/config. It is meant to be useful for tasks like getting a >>> quick overview of symbol dependencies or determining which Kconfig >>> file to edit for a given symbol, without having to fire up one of the >>> interactive config programs. >>> >>> It accepts a single command-line flag, '-v', which causes it to also >>> print the help text of each matching result. >>> >>> Signed-off-by: Zev Weiss <zev@bewilderbeest.net> >>> --- >> >> I can see how this could be useful. >> It's a little easier to use than what I currently do: >> >> $ findconfig DRM_HISI_HIBMC >> ./drivers/gpu/drm/hisilicon/hibmc/Kconfig:2:config DRM_HISI_HIBMC > > I'm guessing 'findconfig' here is some personal shell > alias/function/script? (I can't see any references to it in the kernel > source tree.) > Yes, it's just local. >> >> then $EDITOR that_Kconfig_file >> >> >> In testing, I am seeing this: >> >> # >> # using defaults found in /boot/config-5.3.18-150300.59.63-default >> # >> .config:421:warning: symbol value 'm' invalid for I8K >> .config:2335:warning: symbol value 'm' invalid for >> MTD_NAND_ECC_SW_HAMMING >> .config:2484:warning: symbol value 'm' invalid for PVPANIC >> .config:8671:warning: symbol value 'm' invalid for INTERCONNECT >> .config:9369:warning: symbol value 'm' invalid for >> CRYPTO_ARCH_HAVE_LIB_BLAKE2S >> .config:9370:warning: symbol value 'm' invalid for >> CRYPTO_LIB_BLAKE2S_GENERIC >> .config:9653:warning: symbol value '1' invalid for KASAN_STACK >> > > This I assume is just due to the contents of your .config file relative > to the current Kconfig definitions and not a problem with anything in > this patch? There is no .config file in the linux/ source tree at the top level. I use O=build_dir for all builds. > >> How do I specify/choose a .config file to be used? >> >> Oh, use KCONFIG_CONFIG=filename >> > > Ah, I guess that'd be a nice thing to add a flag for to the wrapper > script -- I'll include that in v2. > >> >> Please update (add) usage/help text in scripts/kconfig/Makefile. >> > > Ack, will do. > > > Thanks for the review! > > > Zev >
On Thu, Jun 9, 2022 at 12:49 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
>
>
> On 6/8/22 20:46, Zev Weiss wrote:
> > On Wed, Jun 08, 2022 at 07:48:44PM PDT, Randy Dunlap wrote:
> >> Hi--
> >>
> >> On 6/8/22 02:54, Zev Weiss wrote:
> >>> scripts/findconf provides menuconfig's search functionality as a
> >>> standalone, non-interactive command, somewhat in the spirit of
> >>> scripts/config. It is meant to be useful for tasks like getting a
> >>> quick overview of symbol dependencies or determining which Kconfig
> >>> file to edit for a given symbol, without having to fire up one of the
> >>> interactive config programs.
> >>>
> >>> It accepts a single command-line flag, '-v', which causes it to also
> >>> print the help text of each matching result.
> >>>
> >>> Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
> >>> ---
> >>
> >> I can see how this could be useful.
> >> It's a little easier to use than what I currently do:
> >>
> >> $ findconfig DRM_HISI_HIBMC
> >> ./drivers/gpu/drm/hisilicon/hibmc/Kconfig:2:config DRM_HISI_HIBMC
> >
> > I'm guessing 'findconfig' here is some personal shell
> > alias/function/script? (I can't see any references to it in the kernel
> > source tree.)
> >
>
> Yes, it's just local.
>
> >>
> >> then $EDITOR that_Kconfig_file
> >>
> >>
> >> In testing, I am seeing this:
> >>
> >> #
> >> # using defaults found in /boot/config-5.3.18-150300.59.63-default
> >> #
> >> .config:421:warning: symbol value 'm' invalid for I8K
> >> .config:2335:warning: symbol value 'm' invalid for
> >> MTD_NAND_ECC_SW_HAMMING
> >> .config:2484:warning: symbol value 'm' invalid for PVPANIC
> >> .config:8671:warning: symbol value 'm' invalid for INTERCONNECT
> >> .config:9369:warning: symbol value 'm' invalid for
> >> CRYPTO_ARCH_HAVE_LIB_BLAKE2S
> >> .config:9370:warning: symbol value 'm' invalid for
> >> CRYPTO_LIB_BLAKE2S_GENERIC
> >> .config:9653:warning: symbol value '1' invalid for KASAN_STACK
> >>
> >
> > This I assume is just due to the contents of your .config file relative
> > to the current Kconfig definitions and not a problem with anything in
> > this patch?
>
> There is no .config file in the linux/ source tree at the top level.
> I use O=build_dir for all builds.
>
> >
> >> How do I specify/choose a .config file to be used?
> >>
> >> Oh, use KCONFIG_CONFIG=filename
> >>
> >
> > Ah, I guess that'd be a nice thing to add a flag for to the wrapper
> > script -- I'll include that in v2.
> >
> >>
> >> Please update (add) usage/help text in scripts/kconfig/Makefile.
> >>
> >
> > Ack, will do.
> >
> >
> > Thanks for the review!
> >
> >
> > Zev
> >
Another idea might be to add the following to
scripts/kconfig/Makefile:
@@ -77,7 +76,13 @@ PHONY += $(simple-targets)
$(simple-targets): $(obj)/conf
$(Q)$< $(silent) --$@ $(Kconfig)
-PHONY += savedefconfig defconfig
+PHONY += findconfig savedefconfig defconfig
+
+findconfig: $(obj)/conf
+ $(Q)$< $(silent) --$@=$(KCONFIG_FIND) $(Kconfig)
+
+%_findconfig: $(obj)/conf
+ $(Q)$< $(silent) --findconfig=$* $(Kconfig)
savedefconfig: $(obj)/conf
$(Q)$< $(silent) --$@=defconfig $(Kconfig)
Instead of adding a separate program for this,
you can modify scripts/kconfig/conf.c
- add 'findconfig' to enum input_mode
- add 'findconfig' to long_opts[]
- add 'case findconfig' to main() function
Then, you can do
$ make findconfig KCONFIG_FIND=DRM_HISI_HIBMC
or
$ make DRM_HISI_HIBMC_findconfig
as a shorthand.
scripts/findconf is unneeded
but you can put your own script in ~/bin
if you want to save your typing even more.
--
Best Regards
Masahiro Yamada
On Wed, Jun 08, 2022 at 10:47:08PM PDT, Masahiro Yamada wrote: >On Thu, Jun 9, 2022 at 12:49 PM Randy Dunlap <rdunlap@infradead.org> wrote: >> >> >> >> On 6/8/22 20:46, Zev Weiss wrote: >> > On Wed, Jun 08, 2022 at 07:48:44PM PDT, Randy Dunlap wrote: >> >> Hi-- >> >> >> >> On 6/8/22 02:54, Zev Weiss wrote: >> >>> scripts/findconf provides menuconfig's search functionality as a >> >>> standalone, non-interactive command, somewhat in the spirit of >> >>> scripts/config. It is meant to be useful for tasks like getting a >> >>> quick overview of symbol dependencies or determining which Kconfig >> >>> file to edit for a given symbol, without having to fire up one of the >> >>> interactive config programs. >> >>> >> >>> It accepts a single command-line flag, '-v', which causes it to also >> >>> print the help text of each matching result. >> >>> >> >>> Signed-off-by: Zev Weiss <zev@bewilderbeest.net> >> >>> --- >> >> >> >> I can see how this could be useful. >> >> It's a little easier to use than what I currently do: >> >> >> >> $ findconfig DRM_HISI_HIBMC >> >> ./drivers/gpu/drm/hisilicon/hibmc/Kconfig:2:config DRM_HISI_HIBMC >> > >> > I'm guessing 'findconfig' here is some personal shell >> > alias/function/script? (I can't see any references to it in the kernel >> > source tree.) >> > >> >> Yes, it's just local. >> >> >> >> >> then $EDITOR that_Kconfig_file >> >> >> >> >> >> In testing, I am seeing this: >> >> >> >> # >> >> # using defaults found in /boot/config-5.3.18-150300.59.63-default >> >> # >> >> .config:421:warning: symbol value 'm' invalid for I8K >> >> .config:2335:warning: symbol value 'm' invalid for >> >> MTD_NAND_ECC_SW_HAMMING >> >> .config:2484:warning: symbol value 'm' invalid for PVPANIC >> >> .config:8671:warning: symbol value 'm' invalid for INTERCONNECT >> >> .config:9369:warning: symbol value 'm' invalid for >> >> CRYPTO_ARCH_HAVE_LIB_BLAKE2S >> >> .config:9370:warning: symbol value 'm' invalid for >> >> CRYPTO_LIB_BLAKE2S_GENERIC >> >> .config:9653:warning: symbol value '1' invalid for KASAN_STACK >> >> >> > >> > This I assume is just due to the contents of your .config file relative >> > to the current Kconfig definitions and not a problem with anything in >> > this patch? >> >> There is no .config file in the linux/ source tree at the top level. >> I use O=build_dir for all builds. >> >> > >> >> How do I specify/choose a .config file to be used? >> >> >> >> Oh, use KCONFIG_CONFIG=filename >> >> >> > >> > Ah, I guess that'd be a nice thing to add a flag for to the wrapper >> > script -- I'll include that in v2. >> > >> >> >> >> Please update (add) usage/help text in scripts/kconfig/Makefile. >> >> >> > >> > Ack, will do. >> > >> > >> > Thanks for the review! >> > >> > >> > Zev >> > > > > > > > > > >Another idea might be to add the following to >scripts/kconfig/Makefile: > > > >@@ -77,7 +76,13 @@ PHONY += $(simple-targets) > $(simple-targets): $(obj)/conf > $(Q)$< $(silent) --$@ $(Kconfig) > >-PHONY += savedefconfig defconfig >+PHONY += findconfig savedefconfig defconfig >+ >+findconfig: $(obj)/conf >+ $(Q)$< $(silent) --$@=$(KCONFIG_FIND) $(Kconfig) >+ >+%_findconfig: $(obj)/conf >+ $(Q)$< $(silent) --findconfig=$* $(Kconfig) > > savedefconfig: $(obj)/conf > $(Q)$< $(silent) --$@=defconfig $(Kconfig) > > > > > >Instead of adding a separate program for this, >you can modify scripts/kconfig/conf.c > > - add 'findconfig' to enum input_mode > - add 'findconfig' to long_opts[] > - add 'case findconfig' to main() function > > > >Then, you can do > >$ make findconfig KCONFIG_FIND=DRM_HISI_HIBMC > > or > >$ make DRM_HISI_HIBMC_findconfig > > as a shorthand. > > >scripts/findconf is unneeded >but you can put your own script in ~/bin >if you want to save your typing even more. > Hmm, interesting idea -- it seems a bit more awkward to use though, and if everyone who makes much use of it is likely to be writing their own little ad-hoc wrapper script anyway, it seems like we might as well do that once and check it in? The current approach also provides support for multi-query searches, which while it isn't critical is slightly more convenient than running it multiple times or cramming everything into a single combined regex (analogous to grep's '-e' flag). That said, if you and/or others have a strong preference for doing it via a make target I could rearrange it to work that way instead. Thanks, Zev
On Thu, Jun 9, 2022 at 8:19 PM Zev Weiss <zev@bewilderbeest.net> wrote: > > On Wed, Jun 08, 2022 at 10:47:08PM PDT, Masahiro Yamada wrote: > >On Thu, Jun 9, 2022 at 12:49 PM Randy Dunlap <rdunlap@infradead.org> wrote: > >> > >> > >> > >> On 6/8/22 20:46, Zev Weiss wrote: > >> > On Wed, Jun 08, 2022 at 07:48:44PM PDT, Randy Dunlap wrote: > >> >> Hi-- > >> >> > >> >> On 6/8/22 02:54, Zev Weiss wrote: > >> >>> scripts/findconf provides menuconfig's search functionality as a > >> >>> standalone, non-interactive command, somewhat in the spirit of > >> >>> scripts/config. It is meant to be useful for tasks like getting a > >> >>> quick overview of symbol dependencies or determining which Kconfig > >> >>> file to edit for a given symbol, without having to fire up one of the > >> >>> interactive config programs. > >> >>> > >> >>> It accepts a single command-line flag, '-v', which causes it to also > >> >>> print the help text of each matching result. > >> >>> > >> >>> Signed-off-by: Zev Weiss <zev@bewilderbeest.net> > >> >>> --- > >> >> > >> >> I can see how this could be useful. > >> >> It's a little easier to use than what I currently do: > >> >> > >> >> $ findconfig DRM_HISI_HIBMC > >> >> ./drivers/gpu/drm/hisilicon/hibmc/Kconfig:2:config DRM_HISI_HIBMC > >> > > >> > I'm guessing 'findconfig' here is some personal shell > >> > alias/function/script? (I can't see any references to it in the kernel > >> > source tree.) > >> > > >> > >> Yes, it's just local. > >> > >> >> > >> >> then $EDITOR that_Kconfig_file > >> >> > >> >> > >> >> In testing, I am seeing this: > >> >> > >> >> # > >> >> # using defaults found in /boot/config-5.3.18-150300.59.63-default > >> >> # > >> >> .config:421:warning: symbol value 'm' invalid for I8K > >> >> .config:2335:warning: symbol value 'm' invalid for > >> >> MTD_NAND_ECC_SW_HAMMING > >> >> .config:2484:warning: symbol value 'm' invalid for PVPANIC > >> >> .config:8671:warning: symbol value 'm' invalid for INTERCONNECT > >> >> .config:9369:warning: symbol value 'm' invalid for > >> >> CRYPTO_ARCH_HAVE_LIB_BLAKE2S > >> >> .config:9370:warning: symbol value 'm' invalid for > >> >> CRYPTO_LIB_BLAKE2S_GENERIC > >> >> .config:9653:warning: symbol value '1' invalid for KASAN_STACK > >> >> > >> > > >> > This I assume is just due to the contents of your .config file relative > >> > to the current Kconfig definitions and not a problem with anything in > >> > this patch? > >> > >> There is no .config file in the linux/ source tree at the top level. > >> I use O=build_dir for all builds. > >> > >> > > >> >> How do I specify/choose a .config file to be used? > >> >> > >> >> Oh, use KCONFIG_CONFIG=filename > >> >> > >> > > >> > Ah, I guess that'd be a nice thing to add a flag for to the wrapper > >> > script -- I'll include that in v2. > >> > > >> >> > >> >> Please update (add) usage/help text in scripts/kconfig/Makefile. > >> >> > >> > > >> > Ack, will do. > >> > > >> > > >> > Thanks for the review! > >> > > >> > > >> > Zev > >> > > > > > > > > > > > > > > > > > > >Another idea might be to add the following to > >scripts/kconfig/Makefile: > > > > > > > >@@ -77,7 +76,13 @@ PHONY += $(simple-targets) > > $(simple-targets): $(obj)/conf > > $(Q)$< $(silent) --$@ $(Kconfig) > > > >-PHONY += savedefconfig defconfig > >+PHONY += findconfig savedefconfig defconfig > >+ > >+findconfig: $(obj)/conf > >+ $(Q)$< $(silent) --$@=$(KCONFIG_FIND) $(Kconfig) > >+ > >+%_findconfig: $(obj)/conf > >+ $(Q)$< $(silent) --findconfig=$* $(Kconfig) > > > > savedefconfig: $(obj)/conf > > $(Q)$< $(silent) --$@=defconfig $(Kconfig) > > > > > > > > > > > >Instead of adding a separate program for this, > >you can modify scripts/kconfig/conf.c > > > > - add 'findconfig' to enum input_mode > > - add 'findconfig' to long_opts[] > > - add 'case findconfig' to main() function > > > > > > > >Then, you can do > > > >$ make findconfig KCONFIG_FIND=DRM_HISI_HIBMC > > > > or > > > >$ make DRM_HISI_HIBMC_findconfig > > > > as a shorthand. > > > > > >scripts/findconf is unneeded > >but you can put your own script in ~/bin > >if you want to save your typing even more. > > > > Hmm, interesting idea -- it seems a bit more awkward to use though, and > if everyone who makes much use of it is likely to be writing their own > little ad-hoc wrapper script anyway, it seems like we might as well do > that once and check it in? > > The current approach also provides support for multi-query searches, > which while it isn't critical is slightly more convenient than running > it multiple times or cramming everything into a single combined regex > (analogous to grep's '-e' flag). > > That said, if you and/or others have a strong preference for doing it > via a make target I could rearrange it to work that way instead. > Hmm, OK. Then, let's keep scripts/findconfig. But, I'd like to pass the regex pattern via the --findconfig= option. In the shell script, can you do some conversion? > Thanks, > Zev > -- Best Regards Masahiro Yamada
© 2016 - 2026 Red Hat, Inc.