File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,8 @@ library
158158 json >= 0.9.1 && <= 0.11 ,
159159 parallel >= 3.2.1.1 && < 3.3 ,
160160 process >= 1.4.3 && < 1.7 ,
161- time >= 1.6.0 && <= 1.12.2
161+ time >= 1.6.0 && <= 1.12.2 ,
162+ template-haskell >= 2.13.0.0
162163
163164 hs-source-dirs : src/compiler
164165 exposed-modules :
Original file line number Diff line number Diff line change 11{-# LANGUAGE CPP #-}
2+ {-# LANGUAGE TemplateHaskell #-}
3+
24module GF.Infra.BuildInfo where
35import System.Info
46import Data.Version (showVersion )
57
8+ import Language.Haskell.TH.Syntax
9+ import Control.Monad.IO.Class
10+ import Control.Exception
11+ import Data.Time hiding (buildTime )
12+ import System.Process
13+
14+ -- Use Template Haskell to get compile time
15+ buildTime :: String
16+ buildTime = $ (do
17+ timeZone <- liftIO getCurrentTimeZone
18+ time <- liftIO $ utcToLocalTime timeZone <$> getCurrentTime
19+ return $ LitE $ StringL $ formatTime defaultTimeLocale " %F %T" time )
20+
21+ -- Use Template Haskell to get current Git information
22+ gitInfo :: String
23+ gitInfo = $ (do
24+ info <- liftIO $ try $ readProcess " git" [" log" , " --format=commit %h tag %(describe:tags=true)" , " -1" ] " " :: Q (Either SomeException String )
25+ return $ LitE $ StringL $ either (\ _ -> " unavailable" ) id info )
26+
627{-# NOINLINE buildInfo #-}
728buildInfo =
829 " Built on " ++ os++ " /" ++ arch
9- ++ " with " ++ compilerName++ " -" ++ showVersion compilerVersion
10- ++ " , flags :"
30+ ++ " with " ++ compilerName++ " -" ++ showVersion compilerVersion ++ " at " ++ buildTime ++ " \n Git info: " ++ gitInfo
31+ ++ " \n Flags :"
1132#ifdef USE_INTERRUPT
1233 ++ " interrupt"
1334#endif
You can’t perform that action at this time.
0 commit comments