2024-05-29 07:20:50 +00:00
|
|
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
2022-03-27 11:21:15 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
2024-05-29 07:20:50 +00:00
|
|
|
import
|
2024-11-01 14:29:38 +00:00
|
|
|
std/[strformat, strutils, os, sequtils],
|
|
|
|
stew/byteutils, ./compile_info
|
2024-05-29 07:20:50 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
sourcePath = currentSourcePath.rsplit({DirSep, AltSep}, 1)[0]
|
|
|
|
nimbusRevision {.strdefine.} = "00000000"
|
|
|
|
|
|
|
|
static:
|
|
|
|
doAssert(nimbusRevision.len == 8, "nimbusRevision must consist of 8 characters")
|
|
|
|
doAssert(nimbusRevision.allIt(it in HexDigits), "nimbusRevision should contains only hex chars")
|
|
|
|
|
|
|
|
proc gitFolderExists(path: string): bool {.compileTime.} =
|
|
|
|
# walk up parent folder to find `.git` folder
|
|
|
|
var currPath = sourcePath
|
|
|
|
while true:
|
|
|
|
if dirExists(currPath & "/.git"):
|
|
|
|
return true
|
|
|
|
let parts = splitPath(currPath)
|
|
|
|
if parts.tail.len == 0: break
|
|
|
|
currPath = parts.head
|
|
|
|
false
|
2022-03-27 11:21:15 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
NimbusName* = "nimbus-eth1"
|
|
|
|
## project name string
|
|
|
|
|
|
|
|
NimbusMajor*: int = 0
|
|
|
|
## is the major number of Nimbus' version.
|
|
|
|
|
|
|
|
NimbusMinor*: int = 1
|
|
|
|
## is the minor number of Nimbus' version.
|
|
|
|
|
|
|
|
NimbusPatch*: int = 0
|
|
|
|
## is the patch number of Nimbus' version.
|
|
|
|
|
|
|
|
NimbusVersion* = $NimbusMajor & "." & $NimbusMinor & "." & $NimbusPatch
|
|
|
|
## is the version of Nimbus as a string.
|
|
|
|
|
2024-05-29 07:20:50 +00:00
|
|
|
# strip: remove spaces
|
|
|
|
# --short=8: ensure we get 8 chars of commit hash
|
|
|
|
# -C sourcePath: get the correct git hash no matter where the current dir is.
|
|
|
|
GitRevision* = if gitFolderExists(sourcePath):
|
|
|
|
# only using git if the parent dir is a git repo.
|
|
|
|
strip(staticExec("git -C " & strutils.escape(sourcePath) &
|
|
|
|
" rev-parse --short=8 HEAD"))
|
|
|
|
else:
|
|
|
|
# otherwise we use revision number given by build system.
|
|
|
|
# e.g. user download from release tarball, or Github zip download.
|
|
|
|
nimbusRevision
|
|
|
|
|
|
|
|
GitRevisionBytes* = hexToByteArray[4](GitRevision)
|
|
|
|
|
2024-06-14 08:08:44 +00:00
|
|
|
FullVersionStr* = "v" & NimbusVersion & "-" & GitRevision
|
2024-11-01 14:29:38 +00:00
|
|
|
|
|
|
|
ClientId* = &"{NimbusName}/{FullVersionStr}/{hostOS}-{hostCPU}/Nim-{NimVersion}/{VmName}"
|
2024-11-06 02:01:25 +00:00
|
|
|
|
|
|
|
ShortClientId* = NimbusName & "/" & FullVersionStr
|
|
|
|
|