Skip to content

Commit

Permalink
embed git describe for version
Browse files Browse the repository at this point in the history
  • Loading branch information
sullyj3 committed Aug 2, 2024
1 parent 6909b8f commit 488c998
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Sand/SandDaemon.lean
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import «Sand».Basic
import «Sand».Time
import «Sand».Message
import «Sand».Version
import Batteries

open System (FilePath)
Expand Down Expand Up @@ -204,7 +205,7 @@ def envFd : IO (Option UInt32) := OptionT.run do
def systemdSockFd : UInt32 := 3

def SandDaemon.main (_args : List String) : IO α := do
IO.eprintln "Starting Sand daemon."
IO.eprintln s!"Starting Sand daemon {Sand.version}"

let fd ← match ← envFd with
| none => do
Expand Down
19 changes: 19 additions & 0 deletions src/Sand/Version.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Lean

open Lean.Elab.Term
open Lean.Elab (throwUnsupportedSyntax)
open Lean.Syntax (mkStrLit)
open Lean (Expr)

private def getVersion : IO String :=
String.trimRight <$> IO.Process.run { cmd := "git", args := #["describe"] }

syntax (name := versionStr) "version_str" : term

@[term_elab versionStr]
private def elabVersionStr : TermElab
| `(version_str), _ => do
return Expr.lit <| .strVal (← getVersion)
| _, _ => throwUnsupportedSyntax

def Sand.version : String := version_str

0 comments on commit 488c998

Please sign in to comment.