mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-07-24 23:55:25 -04:00
First pass of ruff check fixes (#26257)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
This will compile everything in parallel, for testing purposes.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from pathlib import Path
|
||||
@@ -37,19 +38,16 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool,
|
||||
|
||||
builddir.mkdir(parents=True, exist_ok=True)
|
||||
with open(makefile, "w") as f:
|
||||
# yapf: disable
|
||||
f.write(
|
||||
f"""\
|
||||
# fmt: off
|
||||
f.write("""\
|
||||
# This file is auto-generated by qmk mass-compile
|
||||
# Do not edit this file directly.
|
||||
all: print_failures
|
||||
.PHONY: all_targets print_failures
|
||||
print_failures: all_targets
|
||||
"""# noqa
|
||||
)
|
||||
""")
|
||||
if print_failures:
|
||||
f.write(
|
||||
f"""\
|
||||
f.write(f"""\
|
||||
@for f in $$(ls .build/failed.log.{os.getpid()}.* 2>/dev/null | sort); do \\
|
||||
echo; \\
|
||||
echo "======================================================================================"; \\
|
||||
@@ -58,9 +56,8 @@ print_failures: all_targets
|
||||
cat $$f; \\
|
||||
echo "------------------------------------------------------"; \\
|
||||
done
|
||||
"""# noqa
|
||||
)
|
||||
# yapf: enable
|
||||
""") # noqa: W191, E101
|
||||
# fmt: on
|
||||
for target in sorted(targets, key=lambda t: (t.keyboard, t.keymap)):
|
||||
keyboard_name = target.keyboard
|
||||
keymap_name = target.keymap
|
||||
@@ -78,9 +75,8 @@ print_failures: all_targets
|
||||
build_log += f".{extra_args}"
|
||||
failed_log += f".{extra_args}"
|
||||
target_suffix = f"_{extra_args}"
|
||||
# yapf: disable
|
||||
f.write(
|
||||
f"""\
|
||||
# fmt: off
|
||||
f.write(f"""\
|
||||
.PHONY: {target_filename}{target_suffix}_binary
|
||||
all_targets: {target_filename}{target_suffix}_binary
|
||||
{target_filename}{target_suffix}_binary:
|
||||
@@ -93,20 +89,17 @@ all_targets: {target_filename}{target_suffix}_binary
|
||||
|| {{ grep '\\[WARNINGS\\]' "{build_log}" >/dev/null 2>&1 && printf "Build %-64s \\e[1;33m[WARNINGS]\\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
|
||||
|| printf "Build %-64s \\e[1;32m[OK]\\e[0m\\n" "{keyboard_name}:{keymap_name}"
|
||||
@rm -f "{build_log}" || true
|
||||
"""# noqa
|
||||
)
|
||||
# yapf: enable
|
||||
""") # noqa: W191, E101
|
||||
# fmt: on
|
||||
|
||||
if no_temp:
|
||||
# yapf: disable
|
||||
f.write(
|
||||
f"""\
|
||||
# fmt: off
|
||||
f.write(f"""\
|
||||
@rm -rf "{builddir}/{target_filename}.elf" 2>/dev/null || true
|
||||
@rm -rf "{builddir}/{target_filename}.map" 2>/dev/null || true
|
||||
@rm -rf "{builddir}/obj_{target_filename}" || true
|
||||
"""# noqa
|
||||
)
|
||||
# yapf: enable
|
||||
""") # noqa: W191, E101
|
||||
# fmt: on
|
||||
f.write('\n')
|
||||
|
||||
cli.run([find_make(), *get_make_parallel_args(parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL)
|
||||
@@ -123,21 +116,12 @@ all_targets: {target_filename}{target_suffix}_binary
|
||||
@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
|
||||
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the commands to be run.")
|
||||
@cli.argument('-p', '--print-failures', arg_only=True, action='store_true', help="Print failed builds.")
|
||||
@cli.argument(
|
||||
'-f',
|
||||
'--filter',
|
||||
arg_only=True,
|
||||
action='append',
|
||||
default=[],
|
||||
help= # noqa: `format-python` and `pytest` don't agree here.
|
||||
"Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the formats 'features.rgblight=true' or 'exists(matrix_pins.direct)'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'." # noqa: `format-python` and `pytest` don't agree here.
|
||||
)
|
||||
@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the formats 'features.rgblight==true' or 'exists(matrix_pins.direct)'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'.") # fmt: off
|
||||
@cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.")
|
||||
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
|
||||
@cli.subcommand('Compile QMK Firmware for all keyboards.', hidden=False if cli.config.user.developer else True)
|
||||
def mass_compile(cli):
|
||||
"""Compile QMK Firmware against all keyboards.
|
||||
"""
|
||||
"""Compile QMK Firmware against all keyboards."""
|
||||
maybe_exit_config(should_exit=False, should_reraise=True)
|
||||
|
||||
if len(cli.args.builds) > 0:
|
||||
|
||||
Reference in New Issue
Block a user