Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
8ea8b80b85
|
@ -9,7 +9,7 @@ from milc import cli
|
||||||
import qmk.path
|
import qmk.path
|
||||||
from qmk.decorators import automagic_keyboard, automagic_keymap
|
from qmk.decorators import automagic_keyboard, automagic_keymap
|
||||||
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json, build_environment
|
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json, build_environment
|
||||||
from qmk.keyboard import keyboard_completer, keyboard_folder
|
from qmk.keyboard import keyboard_completer, keyboard_folder_or_all, is_all_keyboards
|
||||||
from qmk.keymap import keymap_completer, locate_keymap
|
from qmk.keymap import keymap_completer, locate_keymap
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def _is_keymap_target(keyboard, keymap):
|
||||||
|
|
||||||
|
|
||||||
@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export to compile')
|
@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export to compile')
|
||||||
@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='The keyboard to build a firmware for. Ignored when a configurator export is supplied.')
|
@cli.argument('-kb', '--keyboard', type=keyboard_folder_or_all, completer=keyboard_completer, help='The keyboard to build a firmware for. Ignored when a configurator export is supplied.')
|
||||||
@cli.argument('-km', '--keymap', completer=keymap_completer, help='The keymap to build a firmware for. Ignored when a configurator export is supplied.')
|
@cli.argument('-km', '--keymap', completer=keymap_completer, help='The keymap to build a firmware for. Ignored when a configurator export is supplied.')
|
||||||
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
|
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
|
||||||
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
|
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
|
||||||
|
@ -40,6 +40,13 @@ def compile(cli):
|
||||||
|
|
||||||
If a keyboard and keymap are provided this command will build a firmware based on that.
|
If a keyboard and keymap are provided this command will build a firmware based on that.
|
||||||
"""
|
"""
|
||||||
|
if is_all_keyboards(cli.args.keyboard):
|
||||||
|
from .mass_compile import mass_compile
|
||||||
|
cli.args.builds = []
|
||||||
|
cli.args.filter = []
|
||||||
|
cli.args.no_temp = False
|
||||||
|
return mass_compile(cli)
|
||||||
|
|
||||||
# Build the environment vars
|
# Build the environment vars
|
||||||
envs = build_environment(cli.args.env)
|
envs = build_environment(cli.args.env)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ from qmk.search import search_keymap_targets
|
||||||
@cli.argument('-t', '--no-temp', arg_only=True, action='store_true', help="Remove temporary files during build.")
|
@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('-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('-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(
|
@cli.argument(
|
||||||
'-f',
|
'-f',
|
||||||
'--filter',
|
'--filter',
|
||||||
|
@ -47,47 +48,52 @@ def mass_compile(cli):
|
||||||
if len(targets) == 0:
|
if len(targets) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
builddir.mkdir(parents=True, exist_ok=True)
|
if cli.args.dry_run:
|
||||||
with open(makefile, "w") as f:
|
cli.log.info('Compilation targets:')
|
||||||
for target in sorted(targets):
|
for target in sorted(targets):
|
||||||
keyboard_name = target[0]
|
cli.log.info(f"{{fg_cyan}}qmk compile -kb {target[0]} -km {target[1]}{{fg_reset}}")
|
||||||
keymap_name = target[1]
|
else:
|
||||||
keyboard_safe = keyboard_name.replace('/', '_')
|
builddir.mkdir(parents=True, exist_ok=True)
|
||||||
build_log = f"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
|
with open(makefile, "w") as f:
|
||||||
failed_log = f"{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
|
for target in sorted(targets):
|
||||||
# yapf: disable
|
keyboard_name = target[0]
|
||||||
f.write(
|
keymap_name = target[1]
|
||||||
f"""\
|
keyboard_safe = keyboard_name.replace('/', '_')
|
||||||
all: {keyboard_safe}_{keymap_name}_binary
|
build_log = f"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
|
||||||
{keyboard_safe}_{keymap_name}_binary:
|
failed_log = f"{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
|
||||||
@rm -f "{build_log}" || true
|
|
||||||
@echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{build_log}"
|
|
||||||
+@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/builddefs/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{keymap_name}" COLOR=true SILENT=false {' '.join(cli.args.env)} \\
|
|
||||||
>>"{build_log}" 2>&1 \\
|
|
||||||
|| cp "{build_log}" "{failed_log}"
|
|
||||||
@{{ grep '\[ERRORS\]' "{build_log}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
|
|
||||||
|| {{ 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
|
|
||||||
|
|
||||||
if cli.args.no_temp:
|
|
||||||
# yapf: disable
|
# yapf: disable
|
||||||
f.write(
|
f.write(
|
||||||
f"""\
|
f"""\
|
||||||
@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.elf" 2>/dev/null || true
|
all: {keyboard_safe}_{keymap_name}_binary
|
||||||
@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.map" 2>/dev/null || true
|
{keyboard_safe}_{keymap_name}_binary:
|
||||||
@rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{keymap_name}" || true
|
@rm -f "{build_log}" || true
|
||||||
"""# noqa
|
@echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{build_log}"
|
||||||
|
+@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/builddefs/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{keymap_name}" COLOR=true SILENT=false {' '.join(cli.args.env)} \\
|
||||||
|
>>"{build_log}" 2>&1 \\
|
||||||
|
|| cp "{build_log}" "{failed_log}"
|
||||||
|
@{{ grep '\[ERRORS\]' "{build_log}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
|
||||||
|
|| {{ 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
|
# 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)
|
if cli.args.no_temp:
|
||||||
|
# yapf: disable
|
||||||
|
f.write(
|
||||||
|
f"""\
|
||||||
|
@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.elf" 2>/dev/null || true
|
||||||
|
@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.map" 2>/dev/null || true
|
||||||
|
@rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{keymap_name}" || true
|
||||||
|
"""# noqa
|
||||||
|
)
|
||||||
|
# yapf: enable
|
||||||
|
f.write('\n')
|
||||||
|
|
||||||
# Check for failures
|
cli.run([make_cmd, *get_make_parallel_args(cli.args.parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL)
|
||||||
failures = [f for f in builddir.glob(f'failed.log.{os.getpid()}.*')]
|
|
||||||
if len(failures) > 0:
|
# Check for failures
|
||||||
return False
|
failures = [f for f in builddir.glob(f'failed.log.{os.getpid()}.*')]
|
||||||
|
if len(failures) > 0:
|
||||||
|
return False
|
||||||
|
|
|
@ -30,9 +30,29 @@ BOX_DRAWING_CHARACTERS = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class AllKeyboards:
|
||||||
|
"""Represents all keyboards.
|
||||||
|
"""
|
||||||
|
def __str__(self):
|
||||||
|
return 'all'
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'all'
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return isinstance(other, AllKeyboards)
|
||||||
|
|
||||||
|
|
||||||
base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
|
base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
|
||||||
|
|
||||||
|
|
||||||
|
def is_all_keyboards(keyboard):
|
||||||
|
"""Returns True if the keyboard is an AllKeyboards object.
|
||||||
|
"""
|
||||||
|
return isinstance(keyboard, AllKeyboards)
|
||||||
|
|
||||||
|
|
||||||
def find_keyboard_from_dir():
|
def find_keyboard_from_dir():
|
||||||
"""Returns a keyboard name based on the user's current directory.
|
"""Returns a keyboard name based on the user's current directory.
|
||||||
"""
|
"""
|
||||||
|
@ -86,6 +106,18 @@ def keyboard_folder(keyboard):
|
||||||
return keyboard
|
return keyboard
|
||||||
|
|
||||||
|
|
||||||
|
def keyboard_folder_or_all(keyboard):
|
||||||
|
"""Returns the actual keyboard folder.
|
||||||
|
|
||||||
|
This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard.
|
||||||
|
If the supplied argument is "all", it returns an AllKeyboards object.
|
||||||
|
"""
|
||||||
|
if keyboard == 'all':
|
||||||
|
return AllKeyboards()
|
||||||
|
|
||||||
|
return keyboard_folder(keyboard)
|
||||||
|
|
||||||
|
|
||||||
def _find_name(path):
|
def _find_name(path):
|
||||||
"""Determine the keyboard name by stripping off the base_path and rules.mk.
|
"""Determine the keyboard name by stripping off the base_path and rules.mk.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue