diff --git a/lib/python/qmk/xap/gen_firmware/header_generator.py b/lib/python/qmk/xap/gen_firmware/header_generator.py index ea299b18f5..bb0df05959 100755 --- a/lib/python/qmk/xap/gen_firmware/header_generator.py +++ b/lib/python/qmk/xap/gen_firmware/header_generator.py @@ -3,6 +3,7 @@ import re from fnvhash import fnv1a_32 +from qmk.commands import dump_lines from qmk.git import git_get_version from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE from qmk.xap.common import latest_xap_defs, route_conditions @@ -119,18 +120,5 @@ def generate_header(output_file, keyboard): _append_route_capabilities(lines, xap_defs) lines.append('') - # Generate the full output - xap_generated_inl = '\n'.join(lines) + dump_lines(output_file, lines) - # Clean up newlines - while "\n\n\n" in xap_generated_inl: - xap_generated_inl = xap_generated_inl.replace("\n\n\n", "\n\n") - - if output_file: - if output_file.name == '-': - print(xap_generated_inl) - else: - output_file.parent.mkdir(parents=True, exist_ok=True) - if output_file.exists(): - output_file.replace(output_file.parent / (output_file.name + '.bak')) - output_file.write_text(xap_generated_inl) diff --git a/lib/python/qmk/xap/gen_firmware/inline_generator.py b/lib/python/qmk/xap/gen_firmware/inline_generator.py index a78d2f357e..8563bfdc69 100755 --- a/lib/python/qmk/xap/gen_firmware/inline_generator.py +++ b/lib/python/qmk/xap/gen_firmware/inline_generator.py @@ -1,6 +1,7 @@ """This script generates the XAP protocol generated header to be compiled into QMK. """ from qmk.casing import to_snake +from qmk.commands import dump_lines from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE from qmk.xap.common import latest_xap_defs, route_conditions @@ -217,18 +218,4 @@ def generate_inline(output_file): # Add all the generated code _append_routing_tables(lines, xap_defs) - # Generate the full output - xap_generated_inl = '\n'.join(lines) - - # Clean up newlines - while "\n\n\n" in xap_generated_inl: - xap_generated_inl = xap_generated_inl.replace("\n\n\n", "\n\n") - - if output_file: - if output_file.name == '-': - print(xap_generated_inl) - else: - output_file.parent.mkdir(parents=True, exist_ok=True) - if output_file.exists(): - output_file.replace(output_file.parent / (output_file.name + '.bak')) - output_file.write_text(xap_generated_inl) + dump_lines(output_file, lines)