diff options
author | Zach White <skullydazed@gmail.com> | 2020-12-01 12:52:02 -0800 |
---|---|---|
committer | Zach White <skullydazed@drpepper.org> | 2021-01-07 21:21:12 -0800 |
commit | ededff8556daff544633cb143cb6d939afd09014 (patch) | |
tree | fa7d69a513ec8f8d5dd23058c1ea650cb00944df /lib/python/qmk/cli/generate | |
parent | 95cbcef34fee3727a224fc13c727ea744fd869e7 (diff) | |
download | qmk_firmware-ededff8556daff544633cb143cb6d939afd09014.tar.gz qmk_firmware-ededff8556daff544633cb143cb6d939afd09014.zip |
validate keyboard data with jsonschema
Diffstat (limited to 'lib/python/qmk/cli/generate')
-rwxr-xr-x | lib/python/qmk/cli/generate/info_json.py | 2 | ||||
-rwxr-xr-x | lib/python/qmk/cli/generate/rules_mk.py | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py index 7e6654e45..fba4b1c01 100755 --- a/lib/python/qmk/cli/generate/info_json.py +++ b/lib/python/qmk/cli/generate/info_json.py | |||
@@ -39,7 +39,7 @@ def generate_info_json(cli): | |||
39 | pared_down_json[key] = kb_info_json[key] | 39 | pared_down_json[key] = kb_info_json[key] |
40 | 40 | ||
41 | pared_down_json['layouts'] = {} | 41 | pared_down_json['layouts'] = {} |
42 | if 'layouts' in pared_down_json: | 42 | if 'layouts' in kb_info_json: |
43 | for layout_name, layout in kb_info_json['layouts'].items(): | 43 | for layout_name, layout in kb_info_json['layouts'].items(): |
44 | pared_down_json['layouts'][layout_name] = {} | 44 | pared_down_json['layouts'][layout_name] = {} |
45 | pared_down_json['layouts'][layout_name]['key_count'] = layout.get('key_count', len(layout['layout'])) | 45 | pared_down_json['layouts'][layout_name]['key_count'] = layout.get('key_count', len(layout['layout'])) |
diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index 4268ae047..72ed3c45f 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py | |||
@@ -6,6 +6,10 @@ from qmk.decorators import automagic_keyboard, automagic_keymap | |||
6 | from qmk.info import info_json | 6 | from qmk.info import info_json |
7 | from qmk.path import is_keyboard, normpath | 7 | from qmk.path import is_keyboard, normpath |
8 | 8 | ||
9 | info_to_rules = { | ||
10 | 'bootloader': 'BOOTLOADER', | ||
11 | 'processor': 'MCU' | ||
12 | } | ||
9 | 13 | ||
10 | @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') | 14 | @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') |
11 | @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") | 15 | @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") |
@@ -30,6 +34,10 @@ def generate_rules_mk(cli): | |||
30 | kb_info_json = info_json(cli.config.generate_rules_mk.keyboard) | 34 | kb_info_json = info_json(cli.config.generate_rules_mk.keyboard) |
31 | rules_mk_lines = ['# This file was generated by `qmk generate-rules-mk`. Do not edit or copy.', ''] | 35 | rules_mk_lines = ['# This file was generated by `qmk generate-rules-mk`. Do not edit or copy.', ''] |
32 | 36 | ||
37 | # Bring in settings | ||
38 | for info_key, rule_key in info_to_rules.items(): | ||
39 | rules_mk_lines.append(f'{rule_key} := {kb_info_json[info_key]}') | ||
40 | |||
33 | # Find features that should be enabled | 41 | # Find features that should be enabled |
34 | if 'features' in kb_info_json: | 42 | if 'features' in kb_info_json: |
35 | for feature, enabled in kb_info_json['features'].items(): | 43 | for feature, enabled in kb_info_json['features'].items(): |
@@ -37,6 +45,11 @@ def generate_rules_mk(cli): | |||
37 | enabled = 'yes' if enabled else 'no' | 45 | enabled = 'yes' if enabled else 'no' |
38 | rules_mk_lines.append(f'{feature}_ENABLE := {enabled}') | 46 | rules_mk_lines.append(f'{feature}_ENABLE := {enabled}') |
39 | 47 | ||
48 | # Set the LED driver | ||
49 | if 'led_matrix' in kb_info_json and 'driver' in kb_info_json['led_matrix']: | ||
50 | driver = kb_info_json['led_matrix']['driver'] | ||
51 | rules_mk_lines.append(f'LED_MATRIX_DRIVER = {driver}') | ||
52 | |||
40 | # Add community layouts | 53 | # Add community layouts |
41 | if 'community_layouts' in kb_info_json: | 54 | if 'community_layouts' in kb_info_json: |
42 | rules_mk_lines.append(f'LAYOUTS = {" ".join(kb_info_json["community_layouts"])}') | 55 | rules_mk_lines.append(f'LAYOUTS = {" ".join(kb_info_json["community_layouts"])}') |