aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/info.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/info.py')
-rw-r--r--lib/python/qmk/info.py51
1 files changed, 38 insertions, 13 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index 74a62721a3..d95fd3d799 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -99,6 +99,13 @@ def _validate_build_target(keyboard, info_data):
if info_file != keyboard_json_path:
_log_error(info_data, f'Invalid keyboard.json location detected: {info_file}.')
+ # No keyboard.json next to info.json
+ for conf_file in config_files:
+ if conf_file.name == 'keyboard.json':
+ info_file = conf_file.parent / 'info.json'
+ if info_file.exists():
+ _log_error(info_data, f'Invalid info.json location detected: {info_file}.')
+
# Moving forward keyboard.json should be used as a build target
if keyboard_json_count == 0:
_log_warning(info_data, 'Build marker "keyboard.json" not found.')
@@ -773,23 +780,24 @@ def find_keyboard_c(keyboard):
def _extract_led_config(info_data, keyboard):
"""Scan all <keyboard>.c files for led config
"""
- cols = info_data['matrix_size']['cols']
- rows = info_data['matrix_size']['rows']
-
for feature in ['rgb_matrix', 'led_matrix']:
if info_data.get('features', {}).get(feature, False) or feature in info_data:
-
# Only attempt search if dd led config is missing
if 'layout' not in info_data.get(feature, {}):
- # Process
- for file in find_keyboard_c(keyboard):
- try:
- ret = find_led_config(file, cols, rows)
- if ret:
- info_data[feature] = info_data.get(feature, {})
- info_data[feature]['layout'] = ret
- except Exception as e:
- _log_warning(info_data, f'led_config: {file.name}: {e}')
+ cols = info_data.get('matrix_size', {}).get('cols')
+ rows = info_data.get('matrix_size', {}).get('rows')
+ if cols and rows:
+ # Process
+ for file in find_keyboard_c(keyboard):
+ try:
+ ret = find_led_config(file, cols, rows)
+ if ret:
+ info_data[feature] = info_data.get(feature, {})
+ info_data[feature]['layout'] = ret
+ except Exception as e:
+ _log_warning(info_data, f'led_config: {file.name}: {e}')
+ else:
+ _log_warning(info_data, 'led_config: matrix size required to parse g_led_config')
if info_data[feature].get('layout', None) and not info_data[feature].get('led_count', None):
info_data[feature]['led_count'] = len(info_data[feature]['layout'])
@@ -1051,3 +1059,20 @@ def keymap_json(keyboard, keymap, force_layout=None):
_extract_config_h(kb_info_json, parse_config_h_file(keymap_config))
return kb_info_json
+
+
+def get_modules(keyboard, keymap_filename):
+ """Get the modules for a keyboard/keymap.
+ """
+ modules = []
+
+ kb_info_json = info_json(keyboard)
+ modules.extend(kb_info_json.get('modules', []))
+
+ if keymap_filename:
+ keymap_json = parse_configurator_json(keymap_filename)
+
+ if keymap_json:
+ modules.extend(keymap_json.get('modules', []))
+
+ return list(dict.fromkeys(modules)) # remove dupes