aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoel Challis <[email protected]>2024-06-30 03:39:49 +0100
committerGitHub <[email protected]>2024-06-30 03:39:49 +0100
commit3ffe8d917a7c43e56b11ada82ac57b86003719a3 (patch)
tree11b361a1cf7946247643c04cec0127fc34939df5 /lib
parent12379dc1ebd5bb1257eed5f7400510ee535d5d50 (diff)
downloadqmk_firmware-3ffe8d917a7c43e56b11ada82ac57b86003719a3.tar.gz
qmk_firmware-3ffe8d917a7c43e56b11ada82ac57b86003719a3.zip
Fix 'qmk new-keyboard' processing of development_board (#23996)
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/cli/new/keyboard.py34
1 files changed, 12 insertions, 22 deletions
diff --git a/lib/python/qmk/cli/new/keyboard.py b/lib/python/qmk/cli/new/keyboard.py
index 56bd05e1e3..b84b130f8e 100644
--- a/lib/python/qmk/cli/new/keyboard.py
+++ b/lib/python/qmk/cli/new/keyboard.py
@@ -14,7 +14,7 @@ from qmk.git import git_get_username
from qmk.json_schema import load_jsonschema
from qmk.path import keyboard
from qmk.json_encoders import InfoJSONEncoder
-from qmk.json_schema import deep_update, json_load
+from qmk.json_schema import deep_update
from qmk.constants import MCU2BOOTLOADER, QMK_FIRMWARE
COMMUNITY = Path('layouts/default/')
@@ -78,7 +78,7 @@ def replace_string(src, token, value):
src.write_text(src.read_text().replace(token, value))
-def augment_community_info(src, dest):
+def augment_community_info(config, src, dest):
"""Splice in any additional data into info.json
"""
info = json.loads(src.read_text())
@@ -86,6 +86,7 @@ def augment_community_info(src, dest):
# merge community with template
deep_update(info, template)
+ deep_update(info, config)
# avoid assumptions on macro name by using the first available
first_layout = next(iter(info["layouts"].values()))["layout"]
@@ -105,7 +106,7 @@ def augment_community_info(src, dest):
for item in first_layout:
item["matrix"] = [int(item["y"]), int(item["x"])]
- # finally write out the updated info.json
+ # finally write out the updated json
dest.write_text(json.dumps(info, cls=InfoJSONEncoder, sort_keys=True))
@@ -212,15 +213,12 @@ def new_keyboard(cli):
default_layout = cli.args.layout if cli.args.layout else prompt_layout()
mcu = cli.args.type if cli.args.type else prompt_mcu()
- # Preprocess any development_board presets
+ config = {}
if mcu in dev_boards:
- defaults_map = json_load(Path('data/mappings/defaults.hjson'))
- board = defaults_map['development_board'][mcu]
-
- mcu = board['processor']
- bootloader = board['bootloader']
+ config['development_board'] = mcu
else:
- bootloader = select_default_bootloader(mcu)
+ config['processor'] = mcu
+ config['bootloader'] = select_default_bootloader(mcu)
detach_layout = False
if default_layout == 'none of the above':
@@ -231,17 +229,9 @@ def new_keyboard(cli):
'YEAR': str(date.today().year),
'KEYBOARD': kb_name,
'USER_NAME': user_name,
- 'REAL_NAME': real_name,
- 'LAYOUT': default_layout,
- 'MCU': mcu,
- 'BOOTLOADER': bootloader
+ 'REAL_NAME': real_name
}
- if cli.config.general.verbose:
- cli.log.info("Creating keyboard with:")
- for key, value in tokens.items():
- cli.echo(f" {key.ljust(10)}: {value}")
-
# begin with making the deepest folder in the tree
keymaps_path = keyboard(kb_name) / 'keymaps/'
keymaps_path.mkdir(parents=True)
@@ -256,7 +246,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) / 'keyboard.json')
+ augment_community_info(config, community_info, keyboard(kb_name) / 'keyboard.json')
# detach community layout and rename to just "LAYOUT"
if detach_layout:
@@ -265,5 +255,5 @@ def new_keyboard(cli):
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}}.")
- cli.log.info(f'Project Location: {{fg_cyan}}{QMK_FIRMWARE}/{keyboard(kb_name)}{{fg_reset}},')
- cli.log.info("{{fg_yellow}}Now update the config files to match the hardware!{{fg_reset}}")
+ cli.log.info(f'Project Location: {{fg_cyan}}{QMK_FIRMWARE}/{keyboard(kb_name)}{{fg_reset}}.')
+ cli.log.info("{fg_yellow}Now update the config files to match the hardware!{fg_reset}")