summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/commands.py
diff options
context:
space:
mode:
authorzvecr <git@zvecr.com>2022-03-18 01:15:23 +0000
committerzvecr <git@zvecr.com>2022-03-18 01:15:23 +0000
commitbffb209eeeab1cc4d070217aa1bc65b6834cf42c (patch)
tree2506cb92da1ba71503f3b361a9d15e8085393457 /lib/python/qmk/commands.py
parent02655690f48ec64ba982499cd3272ee6076b73b3 (diff)
parente5823b56501598c39d3f57719cf32f344212ede6 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/commands.py')
-rw-r--r--lib/python/qmk/commands.py54
1 files changed, 17 insertions, 37 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index e38f17156a..49a344bab4 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -5,7 +5,6 @@ import sys
import shutil
from pathlib import Path
from subprocess import DEVNULL
-from time import strftime
from milc import cli
import jsonschema
@@ -14,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.
@@ -136,37 +133,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 = strftime(time_fmt)
-
- 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.
@@ -201,9 +167,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'
@@ -357,3 +320,20 @@ def in_virtualenv():
"""
active_prefix = getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix
return active_prefix != sys.prefix
+
+
+def dump_lines(output_file, lines, quiet=True):
+ """Handle dumping to stdout or file
+ Creates parent folders if required
+ """
+ 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)