diff mbox series

qconfig: Improve the documentation

Message ID 20261003-qconfigdoc-v1-1-9dac84b3ef75@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series qconfig: Improve the documentation | expand

Commit Message

Massimo Pegorer Oct. 3, 2026, 9:09 a.m. UTC
Specify where the database is created and under what name. Add text
value lookup examples, including quoting, escaping and regular
expression cases. Trivial fixes.

Signed-off-by: Massimo Pegorer <massimo.pegorer+oss@gmail.com>
---
 doc/develop/qconfig.rst | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)


---
base-commit: bd2f5794b7e24c62042abb1921f9c2039b920e02
change-id: 20261003-qconfigdoc-fe844c4f241f

Best regards,
--  
Massimo Pegorer <massimo.pegorer+oss@gmail.com>

Comments

Simon Glass Oct. 3, 2026, 2:12 p.m. UTC | #1
Hi Massimo,

On 2026-10-03T09:09:36, Massimo Pegorer <massimo.pegorer+oss@gmail.com> wrote:
> qconfig: Improve the documentation
>
> Specify where the database is created and under what name. Add text
> value lookup examples, including quoting, escaping and regular
> expression cases. Trivial fixes.
>
> Signed-off-by: Massimo Pegorer <massimo.pegorer+oss@gmail.com>
>
> doc/develop/qconfig.rst | 24 +++++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)

> diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
> @@ -26,9 +26,10 @@ How does it work?
> +in include/autoconf.mk.  The tool must be run at the top of source directory
> +where it stores the database file named qconfig.db.

Please can you reword this to '...at the top of the source directory,
where it stores the database in a file called qconfig.db'. The article
and comma are missing. Also, check_top_directory() runs for every
operation, not just -b, so this might fit better in its own short
paragraph than in the text about building the database.

> diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
> @@ -95,10 +96,23 @@ boards with an empty string for `CONFIG_DEFAULT_FDT_FILE`::
> +Text values can be looked for too, including regular expressions, but taking
> +care of needed quoting and escaping. E.g.::
> +
> +    ./tools/qconfig.py -f TPL_LDSCRIPT='"arch/arm/cpu/u-boot-spl.lds"'
> +    0 matches

The examples are useful, but nothing tells the reader why the first
one finds nothing. Please can you explain the rules they depend on:

1. The value is a Python regular expression and must match the whole
value, since defconfig_matches() uses fullmatch().
2. String values are stored with their double quotes, so the quotes
must be part of the pattern.
3. The stored value is the one from the Kconfig file, before
expansion. Here that is arch/$(ARCH)/cpu/u-boot-spl.lds, which is why
the literal arch/arm gives 0 matches.
4. Single quotes are needed so the shell passes the double quotes and
backslashes through unchanged.

Also, the text above uses 'For example' rather than 'E.g.', so it
would be good to match that. I would also say 'searched for' rather
than 'looked for'.

Since you are doing trivial fixes anyway, the earlier SCSI example
shows names with the _defconfig suffix, but do_find_config() strips
it. You could fix that output in this patch too.

Regards,
Simon
Massimo Pegorer Oct. 3, 2026, 4:57 p.m. UTC | #2
Hi Simon,

Il giorno sab 3 ott 2026 alle ore 16:12 Simon Glass ha scritto:
>
> Hi Massimo,
>
> On 2026-10-03T09:09:36, Massimo Pegorer <massimo.pegorer+oss@gmail.com> wrote:
> > qconfig: Improve the documentation
> >
> > Specify where the database is created and under what name. Add text
> > value lookup examples, including quoting, escaping and regular
> > expression cases. Trivial fixes.
> >
> > Signed-off-by: Massimo Pegorer <massimo.pegorer+oss@gmail.com>
> >
> > doc/develop/qconfig.rst | 24 +++++++++++++++++++-----
> >  1 file changed, 19 insertions(+), 5 deletions(-)
>
> > diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
> > @@ -26,9 +26,10 @@ How does it work?
> > +in include/autoconf.mk.  The tool must be run at the top of source directory
> > +where it stores the database file named qconfig.db.
>
> Please can you reword this to '...at the top of the source directory,
> where it stores the database in a file called qconfig.db'. The article
> and comma are missing. Also, check_top_directory() runs for every
> operation, not just -b, so this might fit better in its own short
> paragraph than in the text about building the database.

Sure, I'll try to follow your hints. Anyway I would prefer to keep named
instead of called, as it would sound too "volatile" to me.

>
> > diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
> > @@ -95,10 +96,23 @@ boards with an empty string for `CONFIG_DEFAULT_FDT_FILE`::
> > +Text values can be looked for too, including regular expressions, but taking
> > +care of needed quoting and escaping. E.g.::
> > +
> > +    ./tools/qconfig.py -f TPL_LDSCRIPT='"arch/arm/cpu/u-boot-spl.lds"'
> > +    0 matches
>
> The examples are useful, but nothing tells the reader why the first
> one finds nothing. Please can you explain the rules they depend on:
>
> 1. The value is a Python regular expression and must match the whole
> value, since defconfig_matches() uses fullmatch().
> 2. String values are stored with their double quotes, so the quotes
> must be part of the pattern.
> 3. The stored value is the one from the Kconfig file, before
> expansion. Here that is arch/$(ARCH)/cpu/u-boot-spl.lds, which is why
> the literal arch/arm gives 0 matches.
> 4. Single quotes are needed so the shell passes the double quotes and
> backslashes through unchanged.

I've got what you mean and I will add these info to help clarify. BTW the first
one founds nothing because no configuration uses - verbatim - that value for
TPL_LDSCRIPT, of course. Anyway, the comparison with the two others help to
catch the fact that expansion must not be considered.

>
> Also, the text above uses 'For example' rather than 'E.g.', so it
> would be good to match that. I would also say 'searched for' rather
> than 'looked for'.
>
> Since you are doing trivial fixes anyway, the earlier SCSI example
> shows names with the _defconfig suffix, but do_find_config() strips
> it. You could fix that output in this patch too.

I've tried to update the output also of the other examples of this section,
but unfortunately now SCSI ~BLK returns 0 matches, therefore I changed
the example in v2: see if it is ok, or if you prefer something else.

Thanks for the tool and the review!

Regards,
Massimo

>
> Regards,
> Simon
diff mbox series

Patch

diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
index a18f32470ca..e3b6d3cecc6 100644
--- a/doc/develop/qconfig.rst
+++ b/doc/develop/qconfig.rst
@@ -26,9 +26,10 @@  How does it work?
 
 When building a database (`-b`), this tool runs configuration and builds
 include/autoconf.mk for every defconfig.  The config options defined in Kconfig
-appear in the .config file (unless they are hidden because of unmet dependency.)
+appear in the .config file (unless they are hidden because of unmet dependency).
 On the other hand, the config options defined by board headers are seen
-in include/autoconf.mk.
+in include/autoconf.mk.  The tool must be run at the top of source directory
+where it stores the database file named qconfig.db.
 
 When resyncing defconfigs (`-s`) the .config is synced by "make savedefconfig"
 and the defconfig is updated with it.
@@ -81,7 +82,7 @@  Each term is CONFIG name, with or without a tilde (~) prefix. The tool searches
 for boards which match the CONFIG name, or do not match if tilde is used. For
 example, to find boards which enabled CONFIG_SCSI but not CONFIG_BLK::
 
-    tools/qconfig.py -f SCSI ~BLK
+    ./tools/qconfig.py -f SCSI ~BLK
     3 matches
     pg_wcom_seli8_defconfig highbank_defconfig pg_wcom_expu1_defconfig
 
@@ -95,10 +96,23 @@  boards with an empty string for `CONFIG_DEFAULT_FDT_FILE`::
 This finds boards which have a value for SYS_MAXARGS other than 64::
 
     ./tools/qconfig.py -f ~SYS_MAXARGS=64
-    cfg CONFIG_SYS_MAXARGS
     281 matches
     ...
 
+Text values can be looked for too, including regular expressions, but taking
+care of needed quoting and escaping. E.g.::
+
+    ./tools/qconfig.py -f TPL_LDSCRIPT='"arch/arm/cpu/u-boot-spl.lds"'
+    0 matches
+
+    ./tools/qconfig.py -f TPL_LDSCRIPT='"arch/.*/cpu/u-boot-spl.lds"'
+    22 matches
+    ...
+
+    ./tools/qconfig.py -f TPL_LDSCRIPT='"arch/\$\(ARCH\)/cpu/u-boot-spl.lds"'
+    22 matches
+    ...
+
 
 Finding implied CONFIGs
 -----------------------
@@ -245,4 +259,4 @@  Available options
 
 To see the complete list of supported options, run::
 
-  tools/qconfig.py -h
+    ./tools/qconfig.py -h