diff --git a/lib/python/qmk/cli/compile.py b/lib/python/qmk/cli/compile.py index 66f55981ee..5ffae74ed1 100755 --- a/lib/python/qmk/cli/compile.py +++ b/lib/python/qmk/cli/compile.py @@ -82,6 +82,9 @@ def compile(cli): If a keyboard and keymap are provided this command will build a firmware based on that. """ envs = {'REQUIRE_PLATFORM_KEY': ''} + if cli.config.compile.keyboard is None: + cli.config.compile.keyboard = '' + silent = cli.config.compile.keyboard == 'all' or cli.config.compile.keyboard.startswith('all-') or cli.config.compile.keymap == 'all' # Setup the environment @@ -104,6 +107,11 @@ def compile(cli): _, _, make_cmd = create_make_command(keyboard, keymap, 'clean', cli.config.compile.parallel, silent, **envs) cli.run(make_cmd, capture_output=False, stdin=DEVNULL) + # If -f has been specified without a keyboard target, assume -kb all + if cli.args.filter and not cli.args.keyboard: + cli.log.debug('--filter supplied without --keyboard, assuming --keyboard all.') + cli.config.compile.keyboard = 'all' + # Determine the compile command(s) commands = None @@ -128,6 +136,10 @@ def compile(cli): if commands: returncodes = [] for keyboard, keymap, command in commands: + if keymap not in list_keymaps(keyboard): + cli.log.debug('Skipping keyboard %s, no %s keymap found.', keyboard, keymap) + continue + print() cli.log.info('Building firmware for {fg_cyan}%s{fg_reset} with keymap {fg_cyan}%s', keyboard, keymap) cli.log.debug('Running make command: {fg_blue}%s', ' '.join(command)) diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 992b280296..ea3eb94fae 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py @@ -1,5 +1,6 @@ """Functions that help you work with QMK keymaps. """ +from functools import lru_cache import json import sys from pathlib import Path @@ -306,6 +307,7 @@ def locate_keymap(keyboard, keymap): return community_layout / 'keymap.c' +@lru_cache() def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False): """List the available keymaps for a keyboard.