diff options
| author | Nick Brassel <nick@tzarc.org> | 2023-01-19 10:56:15 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-19 10:56:15 +1100 |
| commit | 4723f308adb7d1d4a4136722e2f576a398695559 (patch) | |
| tree | 85abc46a4a56a21f4d4da0d5e45699fefd0dfade /lib/python/qmk/cli/multibuild.py | |
| parent | 88ec588ae7f6d36b23578135cde8b7a5160ff8b7 (diff) | |
Remove CLI commands: `multibuild`, `cformat`, `fileformat`, `pyformat`. (#19629)
Diffstat (limited to 'lib/python/qmk/cli/multibuild.py')
| -rwxr-xr-x | lib/python/qmk/cli/multibuild.py | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/lib/python/qmk/cli/multibuild.py b/lib/python/qmk/cli/multibuild.py deleted file mode 100755 index 22b68f43c8..0000000000 --- a/lib/python/qmk/cli/multibuild.py +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | """Compile all keyboards. | ||
| 2 | |||
| 3 | This will compile everything in parallel, for testing purposes. | ||
| 4 | """ | ||
| 5 | import os | ||
| 6 | import re | ||
| 7 | from pathlib import Path | ||
| 8 | from subprocess import DEVNULL | ||
| 9 | |||
| 10 | from milc import cli | ||
| 11 | |||
| 12 | from qmk.constants import QMK_FIRMWARE | ||
| 13 | from qmk.commands import _find_make, get_make_parallel_args | ||
| 14 | import qmk.keyboard | ||
| 15 | import qmk.keymap | ||
| 16 | |||
| 17 | |||
| 18 | def _make_rules_mk_filter(key, value): | ||
| 19 | def _rules_mk_filter(keyboard_name): | ||
| 20 | rules_mk = qmk.keyboard.rules_mk(keyboard_name) | ||
| 21 | return True if key in rules_mk and rules_mk[key].lower() == str(value).lower() else False | ||
| 22 | |||
| 23 | return _rules_mk_filter | ||
| 24 | |||
| 25 | |||
| 26 | def _is_split(keyboard_name): | ||
| 27 | rules_mk = qmk.keyboard.rules_mk(keyboard_name) | ||
| 28 | return True if 'SPLIT_KEYBOARD' in rules_mk and rules_mk['SPLIT_KEYBOARD'].lower() == 'yes' else False | ||
| 29 | |||
| 30 | |||
| 31 | @cli.argument('-t', '--no-temp', arg_only=True, action='store_true', help="Remove temporary files during build.") | ||
| 32 | @cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.") | ||
| 33 | @cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.") | ||
| 34 | @cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Supported format is 'SPLIT_KEYBOARD=yes'. May be passed multiple times.") | ||
| 35 | @cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.") | ||
| 36 | @cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.") | ||
| 37 | @cli.subcommand('Compile QMK Firmware for all keyboards.', hidden=False if cli.config.user.developer else True) | ||
| 38 | def multibuild(cli): | ||
| 39 | """Compile QMK Firmware against all keyboards. | ||
| 40 | """ | ||
| 41 | |||
| 42 | make_cmd = _find_make() | ||
| 43 | if cli.args.clean: | ||
| 44 | cli.run([make_cmd, 'clean'], capture_output=False, stdin=DEVNULL) | ||
| 45 | |||
| 46 | builddir = Path(QMK_FIRMWARE) / '.build' | ||
| 47 | makefile = builddir / 'parallel_kb_builds.mk' | ||
| 48 | |||
| 49 | keyboard_list = qmk.keyboard.list_keyboards() | ||
| 50 | |||
| 51 | filter_re = re.compile(r'^(?P<key>[A-Z0-9_]+)\s*=\s*(?P<value>[^#]+)$') | ||
| 52 | for filter_txt in cli.args.filter: | ||
| 53 | f = filter_re.match(filter_txt) | ||
| 54 | if f is not None: | ||
| 55 | keyboard_list = filter(_make_rules_mk_filter(f.group('key'), f.group('value')), keyboard_list) | ||
| 56 | |||
| 57 | keyboard_list = list(sorted(keyboard_list)) | ||
| 58 | |||
| 59 | if len(keyboard_list) == 0: | ||
| 60 | return | ||
| 61 | |||
| 62 | builddir.mkdir(parents=True, exist_ok=True) | ||
| 63 | with open(makefile, "w") as f: | ||
| 64 | for keyboard_name in keyboard_list: | ||
| 65 | if qmk.keymap.locate_keymap(keyboard_name, cli.args.keymap) is not None: | ||
| 66 | keyboard_safe = keyboard_name.replace('/', '_') | ||
| 67 | # yapf: disable | ||
| 68 | f.write( | ||
| 69 | f"""\ | ||
| 70 | all: {keyboard_safe}_binary | ||
| 71 | {keyboard_safe}_binary: | ||
| 72 | @rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}" || true | ||
| 73 | @echo "Compiling QMK Firmware for target: '{keyboard_name}:{cli.args.keymap}'..." >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" | ||
| 74 | +@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/builddefs/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{cli.args.keymap}" COLOR=true SILENT=false {' '.join(cli.args.env)} \\ | ||
| 75 | >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" 2>&1 \\ | ||
| 76 | || cp "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" "{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}" | ||
| 77 | @{{ grep '\[ERRORS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\ | ||
| 78 | || {{ grep '\[WARNINGS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\ | ||
| 79 | || printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" | ||
| 80 | @rm -f "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" || true | ||
| 81 | """# noqa | ||
| 82 | ) | ||
| 83 | # yapf: enable | ||
| 84 | |||
| 85 | if cli.args.no_temp: | ||
| 86 | # yapf: disable | ||
| 87 | f.write( | ||
| 88 | f"""\ | ||
| 89 | @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.elf" 2>/dev/null || true | ||
| 90 | @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.map" 2>/dev/null || true | ||
| 91 | @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.hex" 2>/dev/null || true | ||
| 92 | @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.bin" 2>/dev/null || true | ||
| 93 | @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.uf2" 2>/dev/null || true | ||
| 94 | @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}" || true | ||
| 95 | @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{cli.args.keymap}" || true | ||
| 96 | """# noqa | ||
| 97 | ) | ||
| 98 | # yapf: enable | ||
| 99 | f.write('\n') | ||
| 100 | |||
| 101 | cli.run([make_cmd, *get_make_parallel_args(cli.args.parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL) | ||
| 102 | |||
| 103 | # Check for failures | ||
| 104 | failures = [f for f in builddir.glob(f'failed.log.{os.getpid()}.*')] | ||
| 105 | if len(failures) > 0: | ||
| 106 | return False | ||
