eliminate the need for -kb all

This commit is contained in:
Zach White 2021-06-26 16:06:36 -07:00
parent 50fdb2a52c
commit d3ed6fa8a4
2 changed files with 14 additions and 0 deletions

View file

@ -82,6 +82,9 @@ 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.
""" """
envs = {'REQUIRE_PLATFORM_KEY': ''} 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' silent = cli.config.compile.keyboard == 'all' or cli.config.compile.keyboard.startswith('all-') or cli.config.compile.keymap == 'all'
# Setup the environment # Setup the environment
@ -104,6 +107,11 @@ def compile(cli):
_, _, make_cmd = create_make_command(keyboard, keymap, 'clean', cli.config.compile.parallel, silent, **envs) _, _, make_cmd = create_make_command(keyboard, keymap, 'clean', cli.config.compile.parallel, silent, **envs)
cli.run(make_cmd, capture_output=False, stdin=DEVNULL) 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) # Determine the compile command(s)
commands = None commands = None
@ -128,6 +136,10 @@ def compile(cli):
if commands: if commands:
returncodes = [] returncodes = []
for keyboard, keymap, command in commands: 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() print()
cli.log.info('Building firmware for {fg_cyan}%s{fg_reset} with keymap {fg_cyan}%s', keyboard, keymap) 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)) cli.log.debug('Running make command: {fg_blue}%s', ' '.join(command))

View file

@ -1,5 +1,6 @@
"""Functions that help you work with QMK keymaps. """Functions that help you work with QMK keymaps.
""" """
from functools import lru_cache
import json import json
import sys import sys
from pathlib import Path from pathlib import Path
@ -306,6 +307,7 @@ def locate_keymap(keyboard, keymap):
return community_layout / 'keymap.c' return community_layout / 'keymap.c'
@lru_cache()
def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False): def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False):
"""List the available keymaps for a keyboard. """List the available keymaps for a keyboard.