diff --git a/.gitignore b/.gitignore index ca9f00a733..35b128606d 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ quantum/version.h # DD config at wrong location /keyboards/**/keymaps/*/info.json +/keyboards/**/keymaps/*/keyboard.json # Old-style QMK Makefiles /keyboards/**/Makefile diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk index f17171fe20..0b9ab8849f 100644 --- a/builddefs/build_keyboard.mk +++ b/builddefs/build_keyboard.mk @@ -119,7 +119,7 @@ MAIN_KEYMAP_PATH_3 := $(KEYBOARD_PATH_3)/keymaps/$(KEYMAP) MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP) MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP) -# Pull in rules from info.json +# Pull in rules from DD keyboard config INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(INTERMEDIATE_OUTPUT)/src/info_rules.mk) include $(INFO_RULES_MK) @@ -221,7 +221,7 @@ include $(BUILDDEFS_PATH)/converters.mk MCU_ORIG := $(MCU) include $(wildcard $(PLATFORM_PATH)/*/mcu_selection.mk) -# PLATFORM_KEY should be detected in info.json via key 'processor' (or rules.mk 'MCU') +# PLATFORM_KEY should be detected in DD keyboard config via key 'processor' (or rules.mk 'MCU') ifeq ($(PLATFORM_KEY),) $(call CATASTROPHIC_ERROR,Platform not defined) endif @@ -335,38 +335,54 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","") POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h endif -# Pull in stuff from info.json -INFO_JSON_FILES := +# Create dependencies on DD keyboard config - structure validated elsewhere +DD_CONFIG_FILES := ifneq ("$(wildcard $(KEYBOARD_PATH_1)/info.json)","") - INFO_JSON_FILES += $(KEYBOARD_PATH_1)/info.json + DD_CONFIG_FILES += $(KEYBOARD_PATH_1)/info.json endif ifneq ("$(wildcard $(KEYBOARD_PATH_2)/info.json)","") - INFO_JSON_FILES += $(KEYBOARD_PATH_2)/info.json + DD_CONFIG_FILES += $(KEYBOARD_PATH_2)/info.json endif ifneq ("$(wildcard $(KEYBOARD_PATH_3)/info.json)","") - INFO_JSON_FILES += $(KEYBOARD_PATH_3)/info.json + DD_CONFIG_FILES += $(KEYBOARD_PATH_3)/info.json endif ifneq ("$(wildcard $(KEYBOARD_PATH_4)/info.json)","") - INFO_JSON_FILES += $(KEYBOARD_PATH_4)/info.json + DD_CONFIG_FILES += $(KEYBOARD_PATH_4)/info.json endif ifneq ("$(wildcard $(KEYBOARD_PATH_5)/info.json)","") - INFO_JSON_FILES += $(KEYBOARD_PATH_5)/info.json + DD_CONFIG_FILES += $(KEYBOARD_PATH_5)/info.json +endif + +ifneq ("$(wildcard $(KEYBOARD_PATH_1)/keyboard.json)","") + DD_CONFIG_FILES += $(KEYBOARD_PATH_1)/keyboard.json +endif +ifneq ("$(wildcard $(KEYBOARD_PATH_2)/keyboard.json)","") + DD_CONFIG_FILES += $(KEYBOARD_PATH_2)/keyboard.json +endif +ifneq ("$(wildcard $(KEYBOARD_PATH_3)/keyboard.json)","") + DD_CONFIG_FILES += $(KEYBOARD_PATH_3)/keyboard.json +endif +ifneq ("$(wildcard $(KEYBOARD_PATH_4)/keyboard.json)","") + DD_CONFIG_FILES += $(KEYBOARD_PATH_4)/keyboard.json +endif +ifneq ("$(wildcard $(KEYBOARD_PATH_5)/keyboard.json)","") + DD_CONFIG_FILES += $(KEYBOARD_PATH_5)/keyboard.json endif CONFIG_H += $(INTERMEDIATE_OUTPUT)/src/info_config.h KEYBOARD_SRC += $(INTERMEDIATE_OUTPUT)/src/default_keyboard.c -$(INTERMEDIATE_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES) +$(INTERMEDIATE_OUTPUT)/src/info_config.h: $(DD_CONFIG_FILES) @$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD) $(eval CMD=$(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --output $(INTERMEDIATE_OUTPUT)/src/info_config.h) @$(BUILD_CMD) -$(INTERMEDIATE_OUTPUT)/src/default_keyboard.c: $(INFO_JSON_FILES) +$(INTERMEDIATE_OUTPUT)/src/default_keyboard.c: $(DD_CONFIG_FILES) @$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD) $(eval CMD=$(QMK_BIN) generate-keyboard-c --quiet --keyboard $(KEYBOARD) --output $(INTERMEDIATE_OUTPUT)/src/default_keyboard.c) @$(BUILD_CMD) -$(INTERMEDIATE_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES) +$(INTERMEDIATE_OUTPUT)/src/default_keyboard.h: $(DD_CONFIG_FILES) @$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD) $(eval CMD=$(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --include $(FOUND_KEYBOARD_H) --output $(INTERMEDIATE_OUTPUT)/src/default_keyboard.h) @$(BUILD_CMD) diff --git a/data/templates/keyboard/config.h b/data/templates/keyboard/config.h deleted file mode 100644 index b15c8d31f1..0000000000 --- a/data/templates/keyboard/config.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright %YEAR% %REAL_NAME% (@%USER_NAME%) -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -/* - * Feature disable options - * These options are also useful to firmware size reduction. - */ - -/* disable debug print */ -//#define NO_DEBUG - -/* disable print */ -//#define NO_PRINT - -/* disable action features */ -//#define NO_ACTION_LAYER -//#define NO_ACTION_TAPPING -//#define NO_ACTION_ONESHOT diff --git a/data/templates/keyboard/info.json b/data/templates/keyboard/keyboard.json similarity index 100% rename from data/templates/keyboard/info.json rename to data/templates/keyboard/keyboard.json diff --git a/data/templates/keyboard/rules.mk b/data/templates/keyboard/rules.mk deleted file mode 100644 index 6e7633bfe0..0000000000 --- a/data/templates/keyboard/rules.mk +++ /dev/null @@ -1 +0,0 @@ -# This file intentionally left blank diff --git a/keyboards/zvecr/zv48/f401/info.json b/keyboards/zvecr/zv48/f401/keyboard.json similarity index 100% rename from keyboards/zvecr/zv48/f401/info.json rename to keyboards/zvecr/zv48/f401/keyboard.json diff --git a/keyboards/zvecr/zv48/f401/rules.mk b/keyboards/zvecr/zv48/f401/rules.mk deleted file mode 100644 index 4df55cd220..0000000000 --- a/keyboards/zvecr/zv48/f401/rules.mk +++ /dev/null @@ -1,3 +0,0 @@ -# Disable unsupported hardware -AUDIO_SUPPORTED = no -BACKLIGHT_SUPPORTED = no diff --git a/lib/python/qmk/cli/generate/make_dependencies.py b/lib/python/qmk/cli/generate/make_dependencies.py index 9b695e907d..331132a20f 100755 --- a/lib/python/qmk/cli/generate/make_dependencies.py +++ b/lib/python/qmk/cli/generate/make_dependencies.py @@ -18,10 +18,11 @@ from qmk.path import normpath, FileType @cli.argument('-km', '--keymap', completer=keymap_completer, help='The keymap to build a firmware for. Ignored when a configurator export is supplied.') @cli.subcommand('Generates the list of dependencies associated with a keyboard build and its generated files.', hidden=True) def generate_make_dependencies(cli): - """Generates the list of dependent info.json, rules.mk, and config.h files for a keyboard. + """Generates the list of dependent config files for a keyboard. """ interesting_files = [ 'info.json', + 'keyboard.json', 'rules.mk', 'post_rules.mk', 'config.h', diff --git a/lib/python/qmk/cli/new/keyboard.py b/lib/python/qmk/cli/new/keyboard.py index cb50acf8bb..700afc96a6 100644 --- a/lib/python/qmk/cli/new/keyboard.py +++ b/lib/python/qmk/cli/new/keyboard.py @@ -251,7 +251,7 @@ def new_keyboard(cli): # merge in infos community_info = Path(COMMUNITY / f'{default_layout}/info.json') - augment_community_info(community_info, keyboard(kb_name) / community_info.name) + augment_community_info(community_info, keyboard(kb_name) / 'keyboard.json') cli.log.info(f'{{fg_green}}Created a new keyboard called {{fg_cyan}}{kb_name}{{fg_green}}.{{fg_reset}}') cli.log.info(f"Build Command: {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.") diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 13588abdb8..2449284668 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -863,7 +863,17 @@ def unknown_processor_rules(info_data, rules): def merge_info_jsons(keyboard, info_data): """Return a merged copy of all the info.json files for a keyboard. """ - for info_file in find_info_json(keyboard): + 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) @@ -921,7 +931,7 @@ def find_info_json(keyboard): base_path = Path('keyboards') keyboard_path = base_path / keyboard keyboard_parent = keyboard_path.parent - info_jsons = [keyboard_path / 'info.json'] + info_jsons = [keyboard_path / 'info.json', keyboard_path / 'keyboard.json'] # Add DEFAULT_FOLDER before parents, if present rules = rules_mk(keyboard) @@ -933,6 +943,7 @@ def find_info_json(keyboard): if keyboard_parent == base_path: break info_jsons.append(keyboard_parent / 'info.json') + info_jsons.append(keyboard_parent / 'keyboard.json') keyboard_parent = keyboard_parent.parent # Return a list of the info.json files that actually exist diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index b56505d649..0fcc2e868d 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -166,9 +166,9 @@ def keyboard_folder_or_all(keyboard): def _find_name(path): - """Determine the keyboard name by stripping off the base_path and rules.mk. + """Determine the keyboard name by stripping off the base_path and filename. """ - return path.replace(base_path, "").replace(os.path.sep + "rules.mk", "") + return path.replace(base_path, "").rsplit(os.path.sep, 1)[0] def keyboard_completer(prefix, action, parser, parsed_args): @@ -181,8 +181,10 @@ def list_keyboards(resolve_defaults=True): """Returns a list of all keyboards - optionally processing any DEFAULT_FOLDER. """ # We avoid pathlib here because this is performance critical code. - kb_wildcard = os.path.join(base_path, "**", "rules.mk") - paths = [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path] + paths = [] + for marker in ['rules.mk', 'keyboard.json']: + kb_wildcard = os.path.join(base_path, "**", marker) + paths += [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path] found = map(_find_name, paths) if resolve_defaults: diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py index 74364ee04b..85a8f48c4f 100644 --- a/lib/python/qmk/path.py +++ b/lib/python/qmk/path.py @@ -15,8 +15,9 @@ def is_keyboard(keyboard_name): if keyboard_name: keyboard_path = QMK_FIRMWARE / 'keyboards' / keyboard_name rules_mk = keyboard_path / 'rules.mk' + keyboard_json = keyboard_path / 'keyboard.json' - return rules_mk.exists() + return rules_mk.exists() or keyboard_json.exists() def under_qmk_firmware(path=Path(os.environ['ORIG_CWD'])):