|
|
@@ -5,8 +5,6 @@ import sys
|
|
|
import shutil
|
|
|
from pathlib import Path
|
|
|
from subprocess import DEVNULL
|
|
|
-from time import strftime
|
|
|
-from itertools import islice
|
|
|
|
|
|
from milc import cli
|
|
|
import jsonschema
|
|
|
@@ -15,8 +13,6 @@ import qmk.keymap
|
|
|
from qmk.constants import QMK_FIRMWARE, KEYBOARD_OUTPUT_PREFIX
|
|
|
from qmk.json_schema import json_load, validate
|
|
|
|
|
|
-time_fmt = '%Y-%m-%d-%H:%M:%S'
|
|
|
-
|
|
|
|
|
|
def _find_make():
|
|
|
"""Returns the correct make command for this environment.
|
|
|
@@ -140,37 +136,6 @@ def get_make_parallel_args(parallel=1):
|
|
|
return parallel_args
|
|
|
|
|
|
|
|
|
-def create_version_h(skip_git=False, skip_all=False):
|
|
|
- """Generate version.h contents
|
|
|
- """
|
|
|
- if skip_all:
|
|
|
- current_time = "1970-01-01-00:00:00"
|
|
|
- else:
|
|
|
- current_time = None
|
|
|
-
|
|
|
- if skip_git:
|
|
|
- git_version = "NA"
|
|
|
- chibios_version = "NA"
|
|
|
- chibios_contrib_version = "NA"
|
|
|
- else:
|
|
|
- git_version = get_git_version(current_time)
|
|
|
- chibios_version = get_git_version(current_time, "chibios", "os")
|
|
|
- chibios_contrib_version = get_git_version(current_time, "chibios-contrib", "os")
|
|
|
-
|
|
|
- version_h_lines = f"""/* This file was automatically generated. Do not edit or copy.
|
|
|
- */
|
|
|
-
|
|
|
-#pragma once
|
|
|
-
|
|
|
-#define QMK_VERSION "{git_version}"
|
|
|
-#define QMK_BUILDDATE "{current_time}"
|
|
|
-#define CHIBIOS_VERSION "{chibios_version}"
|
|
|
-#define CHIBIOS_CONTRIB_VERSION "{chibios_contrib_version}"
|
|
|
-"""
|
|
|
-
|
|
|
- return version_h_lines
|
|
|
-
|
|
|
-
|
|
|
def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_vars):
|
|
|
"""Convert a configurator export JSON file into a C file and then compile it.
|
|
|
|
|
|
@@ -205,9 +170,6 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va
|
|
|
keymap_dir.mkdir(exist_ok=True, parents=True)
|
|
|
keymap_c.write_text(c_text)
|
|
|
|
|
|
- version_h = Path('quantum/version.h')
|
|
|
- version_h.write_text(create_version_h())
|
|
|
-
|
|
|
# Return a command that can be run to make the keymap and flash if given
|
|
|
verbose = 'true' if cli.config.general.verbose else 'false'
|
|
|
color = 'true' if cli.config.general.color else 'false'
|
|
|
@@ -370,16 +332,18 @@ def get_chunks(it, size):
|
|
|
return iter(lambda: tuple(islice(it, size)), ())
|
|
|
|
|
|
|
|
|
-def dump_lines(output_file, lines):
|
|
|
+def dump_lines(output_file, lines, quiet=True):
|
|
|
"""Handle dumping to stdout or file
|
|
|
Creates parent folders if required
|
|
|
"""
|
|
|
- generated = '\n'.join(lines)
|
|
|
- if output_file:
|
|
|
- if output_file.name == '-':
|
|
|
- print(generated)
|
|
|
- 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(generated)
|
|
|
+ generated = '\n'.join(lines) + '\n'
|
|
|
+ if output_file and output_file.name != '-':
|
|
|
+ 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(generated, encoding='utf-8')
|
|
|
+
|
|
|
+ if not quiet:
|
|
|
+ cli.log.info(f'Wrote {output_file.name} to {output_file}.')
|
|
|
+ else:
|
|
|
+ print(generated)
|