{-# LANGUAGE CPP #-}
module Cryptol.Version (
commitHash
, commitShortHash
, commitBranch
, commitDirty
, version
, displayVersion
) where
import Paths_cryptol
import qualified GitRev
import Data.Version (showVersion)
commitHash :: String
commitHash :: String
commitHash = String
GitRev.hash
commitShortHash :: String
commitShortHash :: String
commitShortHash = forall a. Int -> [a] -> [a]
take Int
7 String
GitRev.hash
commitBranch :: String
commitBranch :: String
commitBranch = String
GitRev.branch
commitDirty :: Bool
commitDirty :: Bool
commitDirty = Bool
GitRev.dirty
displayVersion :: Monad m => (String -> m ()) -> m ()
displayVersion :: forall (m :: * -> *). Monad m => (String -> m ()) -> m ()
displayVersion String -> m ()
putLn = do
let ver :: String
ver = Version -> String
showVersion Version
version
String -> m ()
putLn (String
"Cryptol " forall a. [a] -> [a] -> [a]
++ String
ver)
String -> m ()
putLn (String
"Git commit " forall a. [a] -> [a] -> [a]
++ String
commitHash)
String -> m ()
putLn (String
" branch " forall a. [a] -> [a] -> [a]
++ String
commitBranch forall a. [a] -> [a] -> [a]
++ String
dirtyLab)
#ifdef FFI_ENABLED
String -> m ()
putLn String
"FFI enabled"
#endif
where
dirtyLab :: String
dirtyLab | Bool
commitDirty = String
" (non-committed files present during build)"
| Bool
otherwise = String
""