diff --git a/git_version.py b/git_version.py new file mode 100644 index 0000000..0618de8 --- /dev/null +++ b/git_version.py @@ -0,0 +1,33 @@ +import sys +from io import StringIO +import subprocess + +# Redirect stdout to an in-memory buffer +result_buffer = StringIO() +sys.stdout = result_buffer + +subprocess.run(["git", "describe", "--abbrev=6", "--dirty", "--always", "--tags"]) + +# Get the captured output +git_version = result_buffer.getvalue() + +# Restore stdout +sys.stdout = sys.__stdout__ + +''' +import sys +from io import StringIO + +# Redirect stdout to an in-memory buffer +result_buffer = StringIO() +sys.stdout = result_buffer + +# Print something +print("This is a test") + +# Get the captured output +captured_output = result_buffer.getvalue() + +# Restore stdout +sys.stdout = sys.__stdout__ +''' diff --git a/platformio.ini b/platformio.ini index 9254dce..d32ff3b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,6 +36,12 @@ lib_deps = paulstoffregen/Time@^1.6.0 lib_ignore = Time +;extra_scripts = git_version.py + +build_flags = + -DGIT_VERSION git_version + + ; Add / remove the following two lines for separate fonts partition in flash ; after changes: ; - pio run --target=upload (uploads partition table) @@ -45,5 +51,6 @@ lib_ignore = Time ; Then everything should be "back to normal" ; extra_scripts = post:scripts/makefontpartition.py + git_version.py ;board_build.partitions = partition-fonts.csv