summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate/config_h.py
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-08-18 21:52:41 +0100
committerGitHub <noreply@github.com>2021-08-18 21:52:41 +0100
commit2e734fb6b9e3480854b794218d381559aab431b7 (patch)
tree2bec5639b3dd200c640cd8c76b8c2b614f67e34b /lib/python/qmk/cli/generate/config_h.py
parent10fab4ec077354f41d19f01798a49e5864a189cd (diff)
downloadqmk_firmware-2e734fb6b9e3480854b794218d381559aab431b7.tar.gz
qmk_firmware-2e734fb6b9e3480854b794218d381559aab431b7.zip
Add config.h and rules.mk support for data driven keymaps (#12859)
* Add config.h and rules.mk support for data driven keymaps * tidy up after rebase * Rename key as it can contain more than just keyboard overrides * tidy up after rebase * Add validation
Diffstat (limited to 'lib/python/qmk/cli/generate/config_h.py')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index c0c148f1c0..ca7e14fe6b 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -5,11 +5,11 @@ from pathlib import Path
from dotty_dict import dotty
from milc import cli
-from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.info import info_json
-from qmk.json_schema import json_load
+from qmk.json_schema import json_load, validate
from qmk.keyboard import keyboard_completer, keyboard_folder
-from qmk.path import is_keyboard, normpath
+from qmk.keymap import locate_keymap
+from qmk.path import normpath
def direct_pins(direct_pins, postfix):
@@ -157,25 +157,22 @@ def generate_split_config(kb_info_json, config_h_lines):
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
-@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.')
+@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, required=True, help='Keyboard to generate config.h for.')
+@cli.argument('-km', '--keymap', arg_only=True, help='Keymap to generate config.h for.')
@cli.subcommand('Used by the make system to generate info_config.h from info.json', hidden=True)
-@automagic_keyboard
-@automagic_keymap
def generate_config_h(cli):
"""Generates the info_config.h file.
"""
- # Determine our keyboard(s)
- if not cli.config.generate_config_h.keyboard:
- cli.log.error('Missing parameter: --keyboard')
- cli.subcommands['info'].print_help()
- return False
-
- if not is_keyboard(cli.config.generate_config_h.keyboard):
- cli.log.error('Invalid keyboard: "%s"', cli.config.generate_config_h.keyboard)
- return False
+ # Determine our keyboard/keymap
+ if cli.args.keymap:
+ km = locate_keymap(cli.args.keyboard, cli.args.keymap)
+ km_json = json_load(km)
+ validate(km_json, 'qmk.keymap.v1')
+ kb_info_json = dotty(km_json.get('config', {}))
+ else:
+ kb_info_json = dotty(info_json(cli.args.keyboard))
# Build the info_config.h file.
- kb_info_json = dotty(info_json(cli.config.generate_config_h.keyboard))
config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.' ' */', '', '#pragma once']
generate_config_items(kb_info_json, config_h_lines)