From e0ad7594dd510f64debc26004a6d02b0b829770a Mon Sep 17 00:00:00 2001 From: Herbert Lange Date: Fri, 8 Aug 2025 17:36:03 +0200 Subject: add build time and git info to BuildInfo --- src/compiler/GF/Infra/BuildInfo.hs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/compiler/GF/Infra/BuildInfo.hs b/src/compiler/GF/Infra/BuildInfo.hs index f0230246b..2896a17fe 100644 --- a/src/compiler/GF/Infra/BuildInfo.hs +++ b/src/compiler/GF/Infra/BuildInfo.hs @@ -1,13 +1,35 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} + module GF.Infra.BuildInfo where import System.Info import Data.Version(showVersion) +import Language.Haskell.TH.Syntax +import Control.Monad.IO.Class +import Control.Exception +import Data.Time +import Data.Time.Format.ISO8601 +import System.Process + +-- Use Template Haskell to get compile time +buildTime :: String +buildTime = $(do + timeZone <- liftIO getCurrentTimeZone + time <- liftIO $ utcToLocalTime timeZone <$> getCurrentTime + return $ LitE $ StringL $ iso8601Show time ) + +-- Use Template Haskell to get current Git information +gitInfo :: String +gitInfo = $(do + info <- liftIO $ try $ readProcess "git" ["log", "--format=\"Commit %h Tag %(describe:tags=true)\"", "-1"] "" :: Q (Either SomeException String) + return $ LitE $ StringL $ either (\_ -> "unavailable") id info ) + {-# NOINLINE buildInfo #-} buildInfo = "Built on "++os++"/"++arch - ++" with "++compilerName++"-"++showVersion compilerVersion - ++", flags:" + ++" with "++compilerName++"-"++showVersion compilerVersion ++ " at " ++ buildTime ++ "\nGit info: " ++ gitInfo + ++"\nFlags:" #ifdef USE_INTERRUPT ++" interrupt" #endif -- cgit v1.2.3 From 1c4cde7c66d0583c40dbc69e63878e7ee52b8042 Mon Sep 17 00:00:00 2001 From: Herbert Lange Date: Fri, 8 Aug 2025 17:43:56 +0200 Subject: updating formating for git info --- src/compiler/GF/Infra/BuildInfo.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/compiler/GF/Infra/BuildInfo.hs b/src/compiler/GF/Infra/BuildInfo.hs index 2896a17fe..0e0103f3d 100644 --- a/src/compiler/GF/Infra/BuildInfo.hs +++ b/src/compiler/GF/Infra/BuildInfo.hs @@ -22,7 +22,7 @@ buildTime = $(do -- Use Template Haskell to get current Git information gitInfo :: String gitInfo = $(do - info <- liftIO $ try $ readProcess "git" ["log", "--format=\"Commit %h Tag %(describe:tags=true)\"", "-1"] "" :: Q (Either SomeException String) + info <- liftIO $ try $ readProcess "git" ["log", "--format=commit %h tag %(describe:tags=true)", "-1"] "" :: Q (Either SomeException String) return $ LitE $ StringL $ either (\_ -> "unavailable") id info ) {-# NOINLINE buildInfo #-} -- cgit v1.2.3 From 78beac759862d330a89a5479c5dab84e5d8cd526 Mon Sep 17 00:00:00 2001 From: Herbert Lange Date: Fri, 8 Aug 2025 18:02:59 +0200 Subject: change date/time formating --- src/compiler/GF/Infra/BuildInfo.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/compiler/GF/Infra/BuildInfo.hs b/src/compiler/GF/Infra/BuildInfo.hs index 0e0103f3d..13c101ec5 100644 --- a/src/compiler/GF/Infra/BuildInfo.hs +++ b/src/compiler/GF/Infra/BuildInfo.hs @@ -9,7 +9,6 @@ import Language.Haskell.TH.Syntax import Control.Monad.IO.Class import Control.Exception import Data.Time -import Data.Time.Format.ISO8601 import System.Process -- Use Template Haskell to get compile time @@ -17,7 +16,7 @@ buildTime :: String buildTime = $(do timeZone <- liftIO getCurrentTimeZone time <- liftIO $ utcToLocalTime timeZone <$> getCurrentTime - return $ LitE $ StringL $ iso8601Show time ) + return $ LitE $ StringL $ formatTime defaultTimeLocale "%F %T" time ) -- Use Template Haskell to get current Git information gitInfo :: String -- cgit v1.2.3 From 9e5701b13c61c4ff63df6beb9fa7200ba8a81f9f Mon Sep 17 00:00:00 2001 From: Herbert Lange Date: Fri, 8 Aug 2025 18:06:03 +0200 Subject: hide ambiguous function --- src/compiler/GF/Infra/BuildInfo.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/compiler/GF/Infra/BuildInfo.hs b/src/compiler/GF/Infra/BuildInfo.hs index 13c101ec5..1807b4031 100644 --- a/src/compiler/GF/Infra/BuildInfo.hs +++ b/src/compiler/GF/Infra/BuildInfo.hs @@ -8,7 +8,7 @@ import Data.Version(showVersion) import Language.Haskell.TH.Syntax import Control.Monad.IO.Class import Control.Exception -import Data.Time +import Data.Time hiding (buildTime) import System.Process -- Use Template Haskell to get compile time -- cgit v1.2.3