aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk
diff options
context:
space:
mode:
authorJoel Challis <[email protected]>2024-04-02 00:48:30 +0100
committerGitHub <[email protected]>2024-04-02 00:48:30 +0100
commit573db7a0eeddea94e692af85b90219d637567fc3 (patch)
treee5c0392d548cbc3be8f836d8816abd6ad7883f9a /lib/python/qmk
parent6f53d10960ffa405354393b987c670fd120492ed (diff)
downloadqmk_firmware-573db7a0eeddea94e692af85b90219d637567fc3.tar.gz
qmk_firmware-573db7a0eeddea94e692af85b90219d637567fc3.zip
Produce warning if keyboard is not configured via `keyboard.json` (#23321)
Diffstat (limited to 'lib/python/qmk')
-rw-r--r--lib/python/qmk/info.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index e463ac8ce7..ffc9d57d68 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -83,6 +83,25 @@ def _find_invalid_encoder_index(info_data):
return ret
+def _validate_build_target(keyboard, info_data):
+ """Non schema checks
+ """
+ keyboard_json_path = Path('keyboards') / keyboard / 'keyboard.json'
+ config_files = find_info_json(keyboard)
+
+ # keyboard.json can only exist at the deepest part of the tree
+ keyboard_json_count = 0
+ for info_file in config_files:
+ if info_file.name == 'keyboard.json':
+ keyboard_json_count += 1
+ if info_file != keyboard_json_path:
+ _log_error(info_data, f'Invalid keyboard.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.')
+
+
def _validate_layouts(keyboard, info_data): # noqa C901
"""Non schema checks
"""
@@ -181,6 +200,7 @@ def _validate(keyboard, info_data):
validate(info_data, 'qmk.api.keyboard.v1')
# Additional validation
+ _validate_build_target(keyboard, info_data)
_validate_layouts(keyboard, info_data)
_validate_keycodes(keyboard, info_data)
_validate_encoders(keyboard, info_data)
@@ -890,14 +910,6 @@ def merge_info_jsons(keyboard, info_data):
"""
config_files = find_info_json(keyboard)
- # keyboard.json can only exist at the deepest part of the tree
- keyboard_json_count = 0
- for index, info_file in enumerate(config_files):
- if Path(info_file).name == 'keyboard.json':
- keyboard_json_count += 1
- if index != 0 or keyboard_json_count > 1:
- _log_error(info_data, f'Invalid keyboard.json location detected: {info_file}.')
-
for info_file in config_files:
# Load and validate the JSON data
new_info_data = json_load(info_file)