summaryrefslogtreecommitdiff
path: root/lib/python/qmk
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2025-09-10 02:35:01 +1000
committerGitHub <noreply@github.com>2025-09-09 17:35:01 +0100
commitf6f627d07fe6acf54e88bfba2e41688e3eb58444 (patch)
tree9ef8400ba5ce0e86551efbb9dae7ad531814d867 /lib/python/qmk
parent4fc14c2712b149e37673ed3130377778336f6447 (diff)
Print build failures with `qmk mass-compile` and `qmk userspace-compile` if requested (`-p`/`--print-failures`) (#25518)
Diffstat (limited to 'lib/python/qmk')
-rwxr-xr-xlib/python/qmk/cli/mass_compile.py31
-rw-r--r--lib/python/qmk/cli/userspace/compile.py3
2 files changed, 30 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/mass_compile.py b/lib/python/qmk/cli/mass_compile.py
index 4c4669d451..e71280f482 100755
--- a/lib/python/qmk/cli/mass_compile.py
+++ b/lib/python/qmk/cli/mass_compile.py
@@ -16,7 +16,7 @@ from qmk.build_targets import BuildTarget, JsonKeymapBuildTarget
16from qmk.util import maybe_exit_config 16from qmk.util import maybe_exit_config
17 17
18 18
19def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool, no_temp: bool, parallel: int, **env): 19def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool, no_temp: bool, parallel: int, print_failures: bool, **env):
20 if len(targets) == 0: 20 if len(targets) == 0:
21 return 21 return
22 22
@@ -37,6 +37,30 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool,
37 37
38 builddir.mkdir(parents=True, exist_ok=True) 38 builddir.mkdir(parents=True, exist_ok=True)
39 with open(makefile, "w") as f: 39 with open(makefile, "w") as f:
40 # yapf: disable
41 f.write(
42 f"""\
43# This file is auto-generated by qmk mass-compile
44# Do not edit this file directly.
45all: print_failures
46.PHONY: all_targets print_failures
47print_failures: all_targets
48"""# noqa
49 )
50 if print_failures:
51 f.write(
52 f"""\
53 @for f in $$(ls .build/failed.log.{os.getpid()}.* 2>/dev/null | sort); do \\
54 echo; \\
55 echo "======================================================================================"; \\
56 echo "Failed build log: $$f"; \\
57 echo "------------------------------------------------------"; \\
58 cat $$f; \\
59 echo "------------------------------------------------------"; \\
60 done
61"""# noqa
62 )
63 # yapf: enable
40 for target in sorted(targets, key=lambda t: (t.keyboard, t.keymap)): 64 for target in sorted(targets, key=lambda t: (t.keyboard, t.keymap)):
41 keyboard_name = target.keyboard 65 keyboard_name = target.keyboard
42 keymap_name = target.keymap 66 keymap_name = target.keymap
@@ -58,7 +82,7 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool,
58 f.write( 82 f.write(
59 f"""\ 83 f"""\
60.PHONY: {target_filename}{target_suffix}_binary 84.PHONY: {target_filename}{target_suffix}_binary
61all: {target_filename}{target_suffix}_binary 85all_targets: {target_filename}{target_suffix}_binary
62{target_filename}{target_suffix}_binary: 86{target_filename}{target_suffix}_binary:
63 @rm -f "{build_log}" || true 87 @rm -f "{build_log}" || true
64 @echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{build_log}" 88 @echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{build_log}"
@@ -98,6 +122,7 @@ all: {target_filename}{target_suffix}_binary
98@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.") 122@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
99@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.") 123@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
100@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the commands to be run.") 124@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the commands to be run.")
125@cli.argument('-p', '--print-failures', arg_only=True, action='store_true', help="Print failed builds.")
101@cli.argument( 126@cli.argument(
102 '-f', 127 '-f',
103 '--filter', 128 '--filter',
@@ -123,4 +148,4 @@ def mass_compile(cli):
123 else: 148 else:
124 targets = search_keymap_targets([('all', cli.config.mass_compile.keymap)], cli.args.filter) 149 targets = search_keymap_targets([('all', cli.config.mass_compile.keymap)], cli.args.filter)
125 150
126 return mass_compile_targets(targets, cli.args.clean, cli.args.dry_run, cli.args.no_temp, cli.config.mass_compile.parallel, **build_environment(cli.args.env)) 151 return mass_compile_targets(targets, cli.args.clean, cli.args.dry_run, cli.args.no_temp, cli.config.mass_compile.parallel, cli.args.print_failures, **build_environment(cli.args.env))
diff --git a/lib/python/qmk/cli/userspace/compile.py b/lib/python/qmk/cli/userspace/compile.py
index f164ca2ef1..64fa3ed0c9 100644
--- a/lib/python/qmk/cli/userspace/compile.py
+++ b/lib/python/qmk/cli/userspace/compile.py
@@ -20,6 +20,7 @@ def _extra_arg_setter(target, extra_args):
20@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.") 20@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
21@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.") 21@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
22@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the commands to be run.") 22@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the commands to be run.")
23@cli.argument('-p', '--print-failures', arg_only=True, action='store_true', help="Print failed builds.")
23@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.") 24@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
24@cli.subcommand('Compiles the build targets specified in userspace `qmk.json`.') 25@cli.subcommand('Compiles the build targets specified in userspace `qmk.json`.')
25def userspace_compile(cli): 26def userspace_compile(cli):
@@ -42,4 +43,4 @@ def userspace_compile(cli):
42 if len(keyboard_keymap_targets) > 0: 43 if len(keyboard_keymap_targets) > 0:
43 build_targets.extend(search_keymap_targets(keyboard_keymap_targets)) 44 build_targets.extend(search_keymap_targets(keyboard_keymap_targets))
44 45
45 return mass_compile_targets(list(set(build_targets)), cli.args.clean, cli.args.dry_run, cli.config.userspace_compile.no_temp, cli.config.userspace_compile.parallel, **build_environment(cli.args.env)) 46 return mass_compile_targets(list(set(build_targets)), cli.args.clean, cli.args.dry_run, cli.config.userspace_compile.no_temp, cli.config.userspace_compile.parallel, cli.args.print_failures, **build_environment(cli.args.env))