[PATCH 1/2] qconfig: Add an way to select defconfigs without stdin
Simon Glass
sjg at chromium.org
Sun Oct 13 01:22:29 CEST 2024
Sometimes it is useful to process just one or two defconfigs and it is
convenient to do this just by listing them in the arguments. Add a -D
option for this.
Update the docs to avoid mentioning boards which have been removed.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
doc/develop/qconfig.rst | 7 +++++--
tools/qconfig.py | 23 +++++++++++++++--------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
index a18f32470ca..3b995355967 100644
--- a/doc/develop/qconfig.rst
+++ b/doc/develop/qconfig.rst
@@ -62,10 +62,13 @@ or::
grep -l X86 configs/* | ./tools/qconfig.py -s -d -
+or::
+
+ ./tools/qconfig.py -s -D $(grep -l X86 configs/*)
+
To process CONFIG_CMD_FPGAD only for a subset of configs based on path match::
- ls configs/{hrcon*,iocon*,strider*} | \
- ./tools/qconfig.py -C CONFIG_CMD_FPGAD -d -
+ ./tools/qconfig.py -C CONFIG_CMD_FPGAD -D configs/{amd_versal2,am68_sk}*
Finding boards with particular CONFIG combinations
diff --git a/tools/qconfig.py b/tools/qconfig.py
index 058d72cf4bc..c5a33412c8c 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -125,23 +125,26 @@ def get_matched_defconfig(line):
pattern = os.path.join('configs', line)
return glob.glob(pattern) + glob.glob(pattern + '_defconfig')
-def get_matched_defconfigs(defconfigs_file):
- """Get all the defconfig files that match the patterns in a file.
+def get_matched_defconfigs(defconfigs_in):
+ """Get all the defconfig files that match the patterns given.
Args:
- defconfigs_file (str): File containing a list of defconfigs to process,
- or '-' to read the list from stdin
+ defconfigs_file (str or list of str): File containing a list of
+ defconfigs to process, or '-' to read the list from stdin, or a
+ list of defconfig names
Returns:
list of str: A list of paths to defconfig files, with no duplicates
"""
defconfigs = []
with ExitStack() as stack:
- if defconfigs_file == '-':
+ if isinstance(defconfigs_in, list):
+ inf = defconfigs_in
+ elif defconfigs_in == '-':
inf = sys.stdin
- defconfigs_file = 'stdin'
+ defconfigs_in = 'stdin'
else:
- inf = stack.enter_context(open(defconfigs_file, encoding='utf-8'))
+ inf = stack.enter_context(open(defconfigs_in, encoding='utf-8'))
for i, line in enumerate(inf):
line = line.strip()
if not line:
@@ -150,7 +153,7 @@ def get_matched_defconfigs(defconfigs_file):
line = line.split(' ')[0] # handle 'git log' input
matched = get_matched_defconfig(line)
if not matched:
- print(f"warning: {defconfigs_file}:{i + 1}: no defconfig matched '{line}'",
+ print(f"warning: {defconfigs_in}:{i + 1}: no defconfig matched '{line}'",
file=sys.stderr)
defconfigs += matched
@@ -738,6 +741,8 @@ def move_config(args):
if args.defconfigs:
defconfigs = get_matched_defconfigs(args.defconfigs)
+ elif args.defconfiglist:
+ defconfigs = get_matched_defconfigs(args.defconfiglist)
else:
defconfigs = get_all_defconfigs()
@@ -1532,6 +1537,8 @@ doc/develop/moveconfig.rst for documentation.'''
help='a file containing a list of defconfigs to move, '
"one per line (for example 'snow_defconfig') "
"or '-' to read from stdin")
+ parser.add_argument('-D', '--defconfiglist', type=str, nargs='*',
+ help='list of defconfigs to move')
parser.add_argument('-e', '--exit-on-error', action='store_true',
default=False,
help='exit immediately on any error')
--
2.43.0
More information about the U-Boot
mailing list