[PATCH 07/13] qconfig: Allow buildman to obtain the qconfig database

Simon Glass sjg at chromium.org
Tue Jul 7 13:35:08 CEST 2026


Provide a convenience function for buildman to use, which builds the
database if needed, then returns it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/qconfig.py | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/tools/qconfig.py b/tools/qconfig.py
index 077d2fa4742..c8e5656e9d7 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -9,7 +9,7 @@ Author: Masahiro Yamada <yamada.masahiro at socionext.com>
 Author: Simon Glass <sjg at chromium.org>
 """
 
-from argparse import ArgumentParser
+from argparse import ArgumentParser, Namespace
 import collections
 from contextlib import ExitStack
 import doctest
@@ -1714,6 +1714,41 @@ def do_tests():
     return 0
 
 
+def ensure_database(threads):
+    """Return a qconfig database so that Kconfig options can be queried
+
+    If a database exists, it is assumed to be up-to-date. If not, one is built,
+    which can take a few minutes.
+
+    Args:
+        threads (int): Number of threads to use when processing
+
+    Returns:
+        tuple:
+            set of all config options seen (each a str)
+            set of all defconfigs seen (each a str)
+            dict of configs for each defconfig:
+                key: defconfig name, e.g. "MPC8548CDS_legacy_defconfig"
+                value: dict:
+                    key: CONFIG option
+                    value: Value of option
+            dict of defconfigs for each config:
+                key: CONFIG option
+                value: set of boards using that option
+    """
+    if not os.path.exists(CONFIG_DATABASE):
+        print(f'Building {CONFIG_DATABASE} database')
+        args = Namespace(build_db=True, verbose=False, force_sync=False,
+                         dry_run=False, exit_on_error=False, jobs=threads,
+                         git_ref=None, defconfigs=None, defconfiglist=None,
+                         nocolour=False)
+        config_db, progress = move_config(args)
+
+        write_db(config_db, progress)
+
+    return read_database()
+
+
 def main():
     """Main program"""
     parser, args = parse_args()
-- 
2.43.0



More information about the U-Boot mailing list