{-# LANGUAGE CPP #-}
module Cryptol.Version (
commitHash
, commitShortHash
, commitBranch
, commitDirty
, ffiEnabled
, version
, displayVersion
) where
import Paths_cryptol
import qualified GitRev
import Data.Version (showVersion)
import Control.Monad (when)
commitHash :: String
commitHash :: String
commitHash = String
GitRev.hash
commitShortHash :: String
commitShortHash :: String
commitShortHash = Int -> String -> String
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
ffiEnabled :: Bool
#ifdef FFI_ENABLED
ffiEnabled :: Bool
ffiEnabled = Bool
True
#else
ffiEnabled = False
#endif
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 " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
ver)
String -> m ()
putLn (String
"Git commit " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
commitHash)
String -> m ()
putLn (String
" branch " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
commitBranch String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
dirtyLab)
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
ffiEnabled (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> m ()
putLn String
"FFI enabled"
where
dirtyLab :: String
dirtyLab | Bool
commitDirty = String
" (non-committed files present during build)"
| Bool
otherwise = String
""