qconfig: Add an way to select defconfigs without stdin

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@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Simon Glass
2024-10-12 17:22:29 -06:00
parent 1492937d63
commit 4da27e4529
2 changed files with 20 additions and 10 deletions

View File

@@ -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

View File

@@ -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()
@@ -1530,6 +1535,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')