[PATCH 1/2] 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 ---
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')

Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28 ---
tools/qconfig.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/tools/qconfig.py b/tools/qconfig.py index c5a33412c8c..ed12044f345 100755 --- a/tools/qconfig.py +++ b/tools/qconfig.py @@ -32,6 +32,8 @@ from buildman import bsettings from buildman import kconfiglib from buildman import toolchain from u_boot_pylib import terminal +from u_boot_pylib.terminal import tprint +from u_boot_pylib import tools
SHOW_GNU_MAKE = 'scripts/show-gnu-make' SLEEP_TIME=0.03 @@ -551,14 +553,25 @@ class Slot: orig_defconfig = os.path.join('configs', self.defconfig) new_defconfig = os.path.join(self.build_dir, 'defconfig') updated = not filecmp.cmp(orig_defconfig, new_defconfig) + success = True
if updated: - self.log.append( - self.col.build(self.col.BLUE, 'defconfig updated', bright=True)) + # Files with #include get mangled as savedefconfig doesn't know how to + # deal with them. Ignore them + success = b'#include' not in tools.read_file(orig_defconfig) + if success: + self.log.append( + self.col.build(self.col.BLUE, 'defconfig updated', + bright=True)) + else: + self.log.append( + self.col.build(self.col.RED, 'ignored due to #include', + bright=True)) + updated = False
if not self.args.dry_run and updated: shutil.move(new_defconfig, orig_defconfig) - self.finish(True) + self.finish(success)
def finish(self, success): """Display log along with progress and go to the idle state. @@ -1666,7 +1679,9 @@ def move_done(progress): """ col = progress.col if progress.failed: - print(col.build(col.RED, f'{progress.failure_msg}see {FAILED_LIST}', True)) + if progress.good: + tprint(f'{progress.good} OK, ', newline=False, colour=col.GREEN) + tprint(f'{progress.failure_msg}see {FAILED_LIST}', colour=col.RED) else: # Add enough spaces to overwrite the progress indicator print(col.build(

On Sat, Oct 12, 2024 at 05:22:30PM -0600, Simon Glass wrote:
Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
How about marking them as warnings? It may be good to re-sync configs/am62px_evm_a53_defconfig for example and then re-add the #include line, but configs/am62x_evm_a53_ethboot_defconfig on the other hand very much should not be resynced. Thanks for getting on this issue so quickly.

Hi Tom,
On Sun, 13 Oct 2024 at 10:15, Tom Rini trini@konsulko.com wrote:
On Sat, Oct 12, 2024 at 05:22:30PM -0600, Simon Glass wrote:
Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
How about marking them as warnings? It may be good to re-sync configs/am62px_evm_a53_defconfig for example and then re-add the #include line, but configs/am62x_evm_a53_ethboot_defconfig on the other hand very much should not be resynced. Thanks for getting on this issue so quickly.
Do you mean still do the resync, but show a warning? It does obliterate the old defconfig, but I suppose people can just not commit the changes. Is that what you are thinking?
Regards, SImon

On Mon, Oct 14, 2024 at 02:20:00PM -0600, Simon Glass wrote:
Hi Tom,
On Sun, 13 Oct 2024 at 10:15, Tom Rini trini@konsulko.com wrote:
On Sat, Oct 12, 2024 at 05:22:30PM -0600, Simon Glass wrote:
Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
How about marking them as warnings? It may be good to re-sync configs/am62px_evm_a53_defconfig for example and then re-add the #include line, but configs/am62x_evm_a53_ethboot_defconfig on the other hand very much should not be resynced. Thanks for getting on this issue so quickly.
Do you mean still do the resync, but show a warning? It does obliterate the old defconfig, but I suppose people can just not commit the changes. Is that what you are thinking?
No, sorry for being unclear. I was thinking it should NOT be resynced but counted as a warning not a failure.

Hi Tom,
On Mon, 14 Oct 2024 at 15:12, Tom Rini trini@konsulko.com wrote:
On Mon, Oct 14, 2024 at 02:20:00PM -0600, Simon Glass wrote:
Hi Tom,
On Sun, 13 Oct 2024 at 10:15, Tom Rini trini@konsulko.com wrote:
On Sat, Oct 12, 2024 at 05:22:30PM -0600, Simon Glass wrote:
Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
How about marking them as warnings? It may be good to re-sync configs/am62px_evm_a53_defconfig for example and then re-add the #include line, but configs/am62x_evm_a53_ethboot_defconfig on the other hand very much should not be resynced. Thanks for getting on this issue so quickly.
Do you mean still do the resync, but show a warning? It does obliterate the old defconfig, but I suppose people can just not commit the changes. Is that what you are thinking?
No, sorry for being unclear. I was thinking it should NOT be resynced but counted as a warning not a failure.
Well qconfig doesn't have the concept of a warning, or at least not in the title. How important is this?
Regards, Simon

On Mon, Oct 14, 2024 at 03:35:23PM -0600, Simon Glass wrote:
Hi Tom,
On Mon, 14 Oct 2024 at 15:12, Tom Rini trini@konsulko.com wrote:
On Mon, Oct 14, 2024 at 02:20:00PM -0600, Simon Glass wrote:
Hi Tom,
On Sun, 13 Oct 2024 at 10:15, Tom Rini trini@konsulko.com wrote:
On Sat, Oct 12, 2024 at 05:22:30PM -0600, Simon Glass wrote:
Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
How about marking them as warnings? It may be good to re-sync configs/am62px_evm_a53_defconfig for example and then re-add the #include line, but configs/am62x_evm_a53_ethboot_defconfig on the other hand very much should not be resynced. Thanks for getting on this issue so quickly.
Do you mean still do the resync, but show a warning? It does obliterate the old defconfig, but I suppose people can just not commit the changes. Is that what you are thinking?
No, sorry for being unclear. I was thinking it should NOT be resynced but counted as a warning not a failure.
Well qconfig doesn't have the concept of a warning, or at least not in the title. How important is this?
I assumed it was using the same status counter bar that buildman uses. If you can't easily do warning not error, OK.

Hi Tom,
On Mon, 14 Oct 2024 at 15:49, Tom Rini trini@konsulko.com wrote:
On Mon, Oct 14, 2024 at 03:35:23PM -0600, Simon Glass wrote:
Hi Tom,
On Mon, 14 Oct 2024 at 15:12, Tom Rini trini@konsulko.com wrote:
On Mon, Oct 14, 2024 at 02:20:00PM -0600, Simon Glass wrote:
Hi Tom,
On Sun, 13 Oct 2024 at 10:15, Tom Rini trini@konsulko.com wrote:
On Sat, Oct 12, 2024 at 05:22:30PM -0600, Simon Glass wrote:
Running "tools/qconfig.py -s" will re-sync files with #include in them and so un-#include them.
Ignore these and mark them as failures.
Signed-off-by: Simon Glass sjg@chromium.org Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
How about marking them as warnings? It may be good to re-sync configs/am62px_evm_a53_defconfig for example and then re-add the #include line, but configs/am62x_evm_a53_ethboot_defconfig on the other hand very much should not be resynced. Thanks for getting on this issue so quickly.
Do you mean still do the resync, but show a warning? It does obliterate the old defconfig, but I suppose people can just not commit the changes. Is that what you are thinking?
No, sorry for being unclear. I was thinking it should NOT be resynced but counted as a warning not a failure.
Well qconfig doesn't have the concept of a warning, or at least not in the title. How important is this?
I assumed it was using the same status counter bar that buildman uses. If you can't easily do warning not error, OK.
No, it's a completely different program, unfortunately.
Regards, Simon

:n Sat, Oct 12, 2024 at 05:22:29PM -0600, Simon Glass wrote:
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
Much handier than giving a file descriptor via <(shell cmd).
Reviewed-by: Tom Rini trini@konsulko.com
participants (2)
-
Simon Glass
-
Tom Rini