From f913f126b4662a299eceae37fea6829979e6b65c Mon Sep 17 00:00:00 2001 From: zvecr Date: Thu, 7 Jul 2022 16:48:18 +0100 Subject: [PATCH] Add in some defaults to info.json payload --- .../qmk/xap/gen_firmware/blob_generator.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/python/qmk/xap/gen_firmware/blob_generator.py b/lib/python/qmk/xap/gen_firmware/blob_generator.py index 13e19688dfa..3d592426657 100644 --- a/lib/python/qmk/xap/gen_firmware/blob_generator.py +++ b/lib/python/qmk/xap/gen_firmware/blob_generator.py @@ -2,22 +2,38 @@ """ import json import gzip +from pathlib import Path from qmk.info import keymap_json from qmk.commands import get_chunks, dump_lines +from qmk.json_schema import deep_update, json_load from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE -def generate_blob(output_file, keyboard, keymap): - # Build the info.json file +def _build_info(keyboard, keymap): + """Build the xap version of info.json + """ + defaults_json = json_load(Path('data/mappings/xap_defaults.json')) km_info_json = keymap_json(keyboard, keymap) + info_json = {} + deep_update(info_json, defaults_json) + deep_update(info_json, km_info_json) + # TODO: Munge to XAP requirements - del km_info_json['config_h_features'] + del info_json['config_h_features'] + + return info_json + + +def generate_blob(output_file, keyboard, keymap): + """Generate XAP payload + """ + info_json = _build_info(keyboard, keymap) # Minify - str_data = json.dumps(km_info_json, separators=(',', ':')) + str_data = json.dumps(info_json, separators=(',', ':')) # Compress compressed = gzip.compress(str_data.encode("utf-8"), compresslevel=9)