validate keyboard data with jsonschema
This commit is contained in:
parent
95cbcef34f
commit
ededff8556
4 changed files with 155 additions and 12 deletions
|
@ -39,7 +39,7 @@ def generate_info_json(cli):
|
|||
pared_down_json[key] = kb_info_json[key]
|
||||
|
||||
pared_down_json['layouts'] = {}
|
||||
if 'layouts' in pared_down_json:
|
||||
if 'layouts' in kb_info_json:
|
||||
for layout_name, layout in kb_info_json['layouts'].items():
|
||||
pared_down_json['layouts'][layout_name] = {}
|
||||
pared_down_json['layouts'][layout_name]['key_count'] = layout.get('key_count', len(layout['layout']))
|
||||
|
|
|
@ -6,6 +6,10 @@ from qmk.decorators import automagic_keyboard, automagic_keymap
|
|||
from qmk.info import info_json
|
||||
from qmk.path import is_keyboard, normpath
|
||||
|
||||
info_to_rules = {
|
||||
'bootloader': 'BOOTLOADER',
|
||||
'processor': 'MCU'
|
||||
}
|
||||
|
||||
@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")
|
||||
|
@ -30,6 +34,10 @@ def generate_rules_mk(cli):
|
|||
kb_info_json = info_json(cli.config.generate_rules_mk.keyboard)
|
||||
rules_mk_lines = ['# This file was generated by `qmk generate-rules-mk`. Do not edit or copy.', '']
|
||||
|
||||
# Bring in settings
|
||||
for info_key, rule_key in info_to_rules.items():
|
||||
rules_mk_lines.append(f'{rule_key} := {kb_info_json[info_key]}')
|
||||
|
||||
# Find features that should be enabled
|
||||
if 'features' in kb_info_json:
|
||||
for feature, enabled in kb_info_json['features'].items():
|
||||
|
@ -37,6 +45,11 @@ def generate_rules_mk(cli):
|
|||
enabled = 'yes' if enabled else 'no'
|
||||
rules_mk_lines.append(f'{feature}_ENABLE := {enabled}')
|
||||
|
||||
# Set the LED driver
|
||||
if 'led_matrix' in kb_info_json and 'driver' in kb_info_json['led_matrix']:
|
||||
driver = kb_info_json['led_matrix']['driver']
|
||||
rules_mk_lines.append(f'LED_MATRIX_DRIVER = {driver}')
|
||||
|
||||
# Add community layouts
|
||||
if 'community_layouts' in kb_info_json:
|
||||
rules_mk_lines.append(f'LAYOUTS = {" ".join(kb_info_json["community_layouts"])}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue