Allow the git revision to be specified with -d:git_revision_override=xxxxxx

This commit is contained in:
Zahary Karadjov 2023-03-30 19:59:36 +03:00
parent b4d731a1cc
commit 499b870a1a
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 20 additions and 2 deletions

View File

@ -9,7 +9,7 @@
{.push raises: [].}
import strutils
import std/[strutils, compilesettings]
when not defined(nimscript):
import times
@ -22,7 +22,25 @@ const
versionBlob* = "stateofus" # Single word - ends up in the default graffiti
gitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0..5]
## You can override this if you are building the
## sources outside the git tree of Nimbus:
git_revision_override* {.strdefine.} =
when querySetting(SingleValueSetting.command) == "check":
# The staticExec call below returns an empty string
# when `nim check` is used and this leads to a faux
# compile-time error.
# We work-around the problem with this override and
# save some time in executing the external command.
"123456"
else:
""
gitRevisionLong* = when git_revision_override.len == 0:
staticExec "git rev-parse --short HEAD"
else:
git_revision_override
gitRevision* = strip(gitRevisionLong)[0..5]
nimFullBanner* = staticExec("nim --version")
nimBanner* = staticExec("nim --version | grep Version")