From 573db7a0eeddea94e692af85b90219d637567fc3 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 2 Apr 2024 00:48:30 +0100 Subject: [PATCH] Produce warning if keyboard is not configured via `keyboard.json` (#23321) --- lib/python/qmk/info.py | 28 ++++++++++++++++++++-------- 1 file 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)