From 65a9ae4a0c9c90b00ddca915f283c633e6cc20ad Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 19 Oct 2022 01:35:28 +0100 Subject: [PATCH 1/3] Correctly build keymap.json containing additional config --- lib/python/qmk/commands.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 9c0a5dce56e7..25b65edf1940 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -2,6 +2,7 @@ """ import os import sys +import json import shutil from pathlib import Path @@ -134,12 +135,11 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va target = f'{keyboard_filesafe}_{user_keymap["keymap"]}' keyboard_output = Path(f'{KEYBOARD_OUTPUT_PREFIX}{keyboard_filesafe}') keymap_output = Path(f'{keyboard_output}_{user_keymap["keymap"]}') - c_text = qmk.keymap.generate_c(user_keymap) keymap_dir = keymap_output / 'src' - keymap_c = keymap_dir / 'keymap.c' + keymap_json = keymap_dir / 'keymap.json' keymap_dir.mkdir(exist_ok=True, parents=True) - keymap_c.write_text(c_text) + keymap_json.write_text(json.dumps(user_keymap)) # Return a command that can be run to make the keymap and flash if given verbose = 'true' if cli.config.general.verbose else 'false' @@ -175,7 +175,7 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va f'MAIN_KEYMAP_PATH_3={keymap_output}', f'MAIN_KEYMAP_PATH_4={keymap_output}', f'MAIN_KEYMAP_PATH_5={keymap_output}', - f'KEYMAP_C={keymap_c}', + f'KEYMAP_JSON={keymap_json}', f'KEYMAP_PATH={keymap_dir}', f'VERBOSE={verbose}', f'COLOR={color}', From 3c4eb88230a8e67a61de604f5502e8903e3814f1 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 19 Oct 2022 01:38:23 +0100 Subject: [PATCH 2/3] Fix lint issues --- lib/python/qmk/commands.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 25b65edf1940..0bc29070a134 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -9,7 +9,6 @@ from milc import cli import jsonschema -import qmk.keymap from qmk.constants import KEYBOARD_OUTPUT_PREFIX from qmk.json_schema import json_load, validate From e71bf4d2dd1ff0297f7bfc7e0c32515bef0e9ca9 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 19 Oct 2022 02:40:18 +0100 Subject: [PATCH 3/3] Also fix file encoding --- lib/python/qmk/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 0bc29070a134..2ab506c710b9 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -138,7 +138,7 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va keymap_json = keymap_dir / 'keymap.json' keymap_dir.mkdir(exist_ok=True, parents=True) - keymap_json.write_text(json.dumps(user_keymap)) + keymap_json.write_text(json.dumps(user_keymap), encoding='utf-8') # Return a command that can be run to make the keymap and flash if given verbose = 'true' if cli.config.general.verbose else 'false'