Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'Need at least one layout defined in info.json' check #19537

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@
"c_macro": {
"type": "boolean"
},
"json_layout": {
"type": "boolean"
},
"layout": {
"type": "array",
"items": {
Expand Down
5 changes: 4 additions & 1 deletion lib/python/qmk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _validate(keyboard, info_data):
community_layouts_names = list(map(lambda layout: f'LAYOUT_{layout}', community_layouts))

# Make sure we have at least one layout
if len(layouts) == 0:
if len(layouts) == 0 or all(not layout.get('json_layout', False) for layout in layouts.values()):
_log_error(info_data, 'No LAYOUTs defined! Need at least one layout defined in info.json.')

# Providing only LAYOUT_all "because I define my layouts in a 3rd party tool"
Expand Down Expand Up @@ -112,6 +112,7 @@ def info_json(keyboard):
for layout_name, layout_json in layouts.items():
if not layout_name.startswith('LAYOUT_kc'):
layout_json['c_macro'] = True
layout_json['json_layout'] = False
info_data['layouts'][layout_name] = layout_json

# Merge in the data from info.json, config.h, and rules.mk
Expand Down Expand Up @@ -818,13 +819,15 @@ def merge_info_jsons(keyboard, info_data):
msg = 'Number of keys for %s does not match! info.json specifies %d keys, C macro specifies %d'
_log_error(info_data, msg % (layout_name, len(layout['layout']), len(info_data['layouts'][layout_name]['layout'])))
else:
info_data['layouts'][layout_name]['json_layout'] = True
for new_key, existing_key in zip(layout['layout'], info_data['layouts'][layout_name]['layout']):
existing_key.update(new_key)
else:
if not all('matrix' in key_data.keys() for key_data in layout['layout']):
_log_error(info_data, f'Layout "{layout_name}" has no "matrix" definition in either "info.json" or "<keyboard>.h"!')
else:
layout['c_macro'] = False
layout['json_layout'] = True
info_data['layouts'][layout_name] = layout

# Update info_data with the new data
Expand Down