Skip to content

Commit

Permalink
feat: commit hash (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: DevMiner <[email protected]>
Co-authored-by: nekomona <[email protected]>
  • Loading branch information
3 people authored Oct 13, 2023
1 parent a3d4321 commit 14f2752
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
9 changes: 7 additions & 2 deletions platformio-tools.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ lib_deps=
https://github.com/SlimeVR/base64_arduino.git
monitor_speed = 115200
framework = arduino
build_flags = -O2 -std=gnu++17
build_unflags = -Os -std=gnu++11
build_flags =
!python scripts/get_git_commit.py
-O2
-std=gnu++17
build_unflags =
-Os
-std=gnu++11

[env:BOARD_SLIMEVR]
platform = espressif8266 @ 4.2.0
Expand Down
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ monitor_filters = colorize
;monitor_rts = 0
;monitor_dtr = 0
framework = arduino
build_flags =
build_flags =
!python scripts/get_git_commit.py
;If you want to set hardcoded WiFi SSID and password, uncomment and edit the lines below
;To uncomment, only remove ";" and leave the two spaces in front of the tags
; '" - quotes are necessary!
Expand Down
19 changes: 19 additions & 0 deletions scripts/get_git_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import subprocess
import os

revision = ""

env_rev = os.environ.get("GIT_REV")
if not env_rev is None and env_rev != "":
revision = env_rev
else:
try:
revision = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
.strip()
.decode("utf-8")
)
except Exception:
revision = "NOT_GIT"

print(f"'-DGIT_REV=\"{revision}\"'")
3 changes: 3 additions & 0 deletions src/serial/serialcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ namespace SerialCommands {

if (parser->equalCmdParam(1, "INFO")) {
printState();

// We don't want to print this on every timed state output
logger.info("Git commit: %s", GIT_REV);
}

if (parser->equalCmdParam(1, "CONFIG")) {
Expand Down

0 comments on commit 14f2752

Please sign in to comment.