Browse Source

eliminate the need for -kb all

Zach White 5 years ago
parent
commit
d3ed6fa8a4
2 changed files with 14 additions and 0 deletions
  1. 12 0
      lib/python/qmk/cli/compile.py
  2. 2 0
      lib/python/qmk/keymap.py

+ 12 - 0
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))

+ 2 - 0
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.