diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/qmk/cli/__init__.py | 4 | ||||
-rwxr-xr-x | lib/python/qmk/cli/cformat.py | 28 | ||||
-rwxr-xr-x | lib/python/qmk/cli/fileformat.py | 23 | ||||
-rwxr-xr-x | lib/python/qmk/cli/multibuild.py | 106 | ||||
-rwxr-xr-x | lib/python/qmk/cli/pyformat.py | 24 |
5 files changed, 0 insertions, 185 deletions
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py index 16edf88ad6..778eccada8 100644 --- a/lib/python/qmk/cli/__init__.py +++ b/lib/python/qmk/cli/__init__.py @@ -34,13 +34,11 @@ subcommands = [ 'qmk.cli.bux', 'qmk.cli.c2json', 'qmk.cli.cd', - 'qmk.cli.cformat', 'qmk.cli.chibios.confmigrate', 'qmk.cli.clean', 'qmk.cli.compile', 'qmk.cli.docs', 'qmk.cli.doctor', - 'qmk.cli.fileformat', 'qmk.cli.flash', 'qmk.cli.format.c', 'qmk.cli.format.json', @@ -75,11 +73,9 @@ subcommands = [ 'qmk.cli.list.layouts', 'qmk.cli.mass_compile', 'qmk.cli.migrate', - 'qmk.cli.multibuild', 'qmk.cli.new.keyboard', 'qmk.cli.new.keymap', 'qmk.cli.painter', - 'qmk.cli.pyformat', 'qmk.cli.pytest', 'qmk.cli.via2json', ] diff --git a/lib/python/qmk/cli/cformat.py b/lib/python/qmk/cli/cformat.py deleted file mode 100755 index 9d0ecaeba3..0000000000 --- a/lib/python/qmk/cli/cformat.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Point people to the new command name. -""" -import sys -from pathlib import Path - -from milc import cli - - -@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Flag only, don't automatically format.") -@cli.argument('-b', '--base-branch', default='origin/master', help='Branch to compare to diffs to.') -@cli.argument('-a', '--all-files', arg_only=True, action='store_true', help='Format all core files.') -@cli.argument('--core-only', arg_only=True, action='store_true', help='Format core files only.') -@cli.argument('files', nargs='*', arg_only=True, help='Filename(s) to format.') -@cli.subcommand('Pointer to the new command name: qmk format-c.', hidden=True) -def cformat(cli): - """Pointer to the new command name: qmk format-c. - """ - cli.log.warning('"qmk cformat" has been renamed to "qmk format-c". Please use the new command in the future.') - argv = [sys.executable, *sys.argv] - argv[argv.index('cformat')] = 'format-c' - script_path = Path(argv[1]) - script_path_exe = Path(f'{argv[1]}.exe') - - if not script_path.exists() and script_path_exe.exists(): - # For reasons I don't understand ".exe" is stripped from the script name on windows. - argv[1] = str(script_path_exe) - - return cli.run(argv, capture_output=False).returncode diff --git a/lib/python/qmk/cli/fileformat.py b/lib/python/qmk/cli/fileformat.py deleted file mode 100755 index cee4ba1acd..0000000000 --- a/lib/python/qmk/cli/fileformat.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Point people to the new command name. -""" -import sys -from pathlib import Path - -from milc import cli - - -@cli.subcommand('Pointer to the new command name: qmk format-text.', hidden=True) -def fileformat(cli): - """Pointer to the new command name: qmk format-text. - """ - cli.log.warning('"qmk fileformat" has been renamed to "qmk format-text". Please use the new command in the future.') - argv = [sys.executable, *sys.argv] - argv[argv.index('fileformat')] = 'format-text' - script_path = Path(argv[1]) - script_path_exe = Path(f'{argv[1]}.exe') - - if not script_path.exists() and script_path_exe.exists(): - # For reasons I don't understand ".exe" is stripped from the script name on windows. - argv[1] = str(script_path_exe) - - return cli.run(argv, capture_output=False).returncode 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 @@ -"""Compile all keyboards. - -This will compile everything in parallel, for testing purposes. -""" -import os -import re -from pathlib import Path -from subprocess import DEVNULL - -from milc import cli - -from qmk.constants import QMK_FIRMWARE -from qmk.commands import _find_make, get_make_parallel_args -import qmk.keyboard -import qmk.keymap - - -def _make_rules_mk_filter(key, value): - def _rules_mk_filter(keyboard_name): - rules_mk = qmk.keyboard.rules_mk(keyboard_name) - return True if key in rules_mk and rules_mk[key].lower() == str(value).lower() else False - - return _rules_mk_filter - - -def _is_split(keyboard_name): - rules_mk = qmk.keyboard.rules_mk(keyboard_name) - return True if 'SPLIT_KEYBOARD' in rules_mk and rules_mk['SPLIT_KEYBOARD'].lower() == 'yes' else False - - -@cli.argument('-t', '--no-temp', arg_only=True, action='store_true', help="Remove temporary files during build.") -@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.") -@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.") -@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.") -@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 multibuild(cli): - """Compile QMK Firmware against all keyboards. - """ - - make_cmd = _find_make() - if cli.args.clean: - cli.run([make_cmd, 'clean'], capture_output=False, stdin=DEVNULL) - - builddir = Path(QMK_FIRMWARE) / '.build' - makefile = builddir / 'parallel_kb_builds.mk' - - keyboard_list = qmk.keyboard.list_keyboards() - - filter_re = re.compile(r'^(?P<key>[A-Z0-9_]+)\s*=\s*(?P<value>[^#]+)$') - for filter_txt in cli.args.filter: - f = filter_re.match(filter_txt) - if f is not None: - keyboard_list = filter(_make_rules_mk_filter(f.group('key'), f.group('value')), keyboard_list) - - keyboard_list = list(sorted(keyboard_list)) - - if len(keyboard_list) == 0: - return - - builddir.mkdir(parents=True, exist_ok=True) - with open(makefile, "w") as f: - for keyboard_name in keyboard_list: - if qmk.keymap.locate_keymap(keyboard_name, cli.args.keymap) is not None: - keyboard_safe = keyboard_name.replace('/', '_') - # yapf: disable - f.write( - f"""\ -all: {keyboard_safe}_binary -{keyboard_safe}_binary: - @rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}" || true - @echo "Compiling QMK Firmware for target: '{keyboard_name}:{cli.args.keymap}'..." >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" - +@$(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)} \\ - >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" 2>&1 \\ - || cp "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" "{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}" - @{{ 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}" ; }} \\ - || {{ 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}" ; }} \\ - || printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" - @rm -f "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" || true -"""# noqa - ) - # yapf: enable - - if cli.args.no_temp: - # yapf: disable - f.write( - f"""\ - @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.elf" 2>/dev/null || true - @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.map" 2>/dev/null || true - @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.hex" 2>/dev/null || true - @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.bin" 2>/dev/null || true - @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.uf2" 2>/dev/null || true - @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}" || true - @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{cli.args.keymap}" || true -"""# noqa - ) - # yapf: enable - f.write('\n') - - cli.run([make_cmd, *get_make_parallel_args(cli.args.parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL) - - # Check for failures - failures = [f for f in builddir.glob(f'failed.log.{os.getpid()}.*')] - if len(failures) > 0: - return False diff --git a/lib/python/qmk/cli/pyformat.py b/lib/python/qmk/cli/pyformat.py deleted file mode 100755 index c624f74aeb..0000000000 --- a/lib/python/qmk/cli/pyformat.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Point people to the new command name. -""" -import sys -from pathlib import Path - -from milc import cli - - -@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually format.") -@cli.subcommand('Pointer to the new command name: qmk format-python.', hidden=False if cli.config.user.developer else True) -def pyformat(cli): - """Pointer to the new command name: qmk format-python. - """ - cli.log.warning('"qmk pyformat" has been renamed to "qmk format-python". Please use the new command in the future.') - argv = [sys.executable, *sys.argv] - argv[argv.index('pyformat')] = 'format-python' - script_path = Path(argv[1]) - script_path_exe = Path(f'{argv[1]}.exe') - - if not script_path.exists() and script_path_exe.exists(): - # For reasons I don't understand ".exe" is stripped from the script name on windows. - argv[1] = str(script_path_exe) - - return cli.run(argv, capture_output=False).returncode |