diff --git a/cabal.project b/cabal.project index d5ebcd4f21..aec50e4e9e 100644 --- a/cabal.project +++ b/cabal.project @@ -13,8 +13,8 @@ repository cardano-haskell-packages -- See CONTRIBUTING for information about these, including some Nix commands -- you need to run if you change them index-state: - , hackage.haskell.org 2024-03-05T09:38:08Z - , cardano-haskell-packages 2024-03-15T13:35:00Z + , hackage.haskell.org 2024-03-14T23:28:52Z + , cardano-haskell-packages 2024-03-14T22:56:07Z packages: cardano-cli diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 430ef1a00e..6935af27f1 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -111,7 +111,6 @@ library Cardano.CLI.EraBased.Run.TextView Cardano.CLI.EraBased.Run.Transaction Cardano.CLI.Helpers - Cardano.CLI.IO.GitRev Cardano.CLI.IO.Lazy Cardano.CLI.Json.Friendly Cardano.CLI.Legacy.Commands @@ -202,7 +201,7 @@ library , cardano-crypto-class ^>= 2.1.2 , cardano-crypto-wrapper ^>= 1.5.1 , cardano-data >= 1.1 - , cardano-git-rev + , cardano-git-rev ^>= 0.2.1 , cardano-ledger-byron >= 1.0.0.2 , cardano-ping ^>= 0.2.0.13 , cardano-prelude diff --git a/cardano-cli/src/Cardano/CLI/IO/GitRev.hs b/cardano-cli/src/Cardano/CLI/IO/GitRev.hs deleted file mode 100644 index 40585d68c8..0000000000 --- a/cardano-cli/src/Cardano/CLI/IO/GitRev.hs +++ /dev/null @@ -1,50 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE ForeignFunctionInterface #-} - -module Cardano.CLI.IO.GitRev - ( gitRev - ) where - -import Data.Text (Text) -import qualified Data.Text as T - -import Cardano.Git.RevFromGit (gitRevFromGit) -import GHC.Foreign (peekCStringLen) -import Foreign.C.String (CString) -import System.IO (utf8) -import System.IO.Unsafe (unsafeDupablePerformIO) - -foreign import ccall "&_cardano_git_rev" c_gitrev :: CString - -gitRev :: Text -gitRev | gitRevEmbed /= zeroRev = gitRevEmbed - | not (T.null fromGit) = fromGit - | not (T.null gitRevFromEnv) = gitRevFromEnv - | otherwise = zeroRev - where - -- Git revision embedded after compilation using - -- Data.FileEmbed.injectWith. If nothing has been injected, - -- this will be filled with 0 characters. - gitRevEmbed :: Text - gitRevEmbed = T.pack $ drop 28 $ unsafeDupablePerformIO (peekCStringLen utf8 (c_gitrev, 68)) - - -- Git revision found during compilation by running git. If - -- git could not be run, then this will be empty. -#if defined(arm_HOST_ARCH) - -- cross compiling to arm fails; due to a linker bug - fromGit = "" -#else - fromGit = T.strip (T.pack $(gitRevFromGit)) -#endif - - gitRevFromEnv :: Text -#if defined(__GIT_REV__) - gitRevFromEnv = T.pack __GIT_REV__ -#else - gitRevFromEnv = "" -#endif - -zeroRev :: Text -zeroRev = "0000000000000000000000000000000000000000" diff --git a/cardano-cli/src/Cardano/CLI/Run.hs b/cardano-cli/src/Cardano/CLI/Run.hs index 6b1d971881..ffef05dca9 100644 --- a/cardano-cli/src/Cardano/CLI/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Run.hs @@ -1,5 +1,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TemplateHaskell #-} -- | Dispatch for running all the CLI commands module Cardano.CLI.Run @@ -14,13 +15,13 @@ import Cardano.CLI.Byron.Run (ByronClientCmdError, renderByronClientCm runByronClientCommand) import Cardano.CLI.EraBased.Commands import Cardano.CLI.EraBased.Run -import Cardano.CLI.IO.GitRev (gitRev) import Cardano.CLI.Legacy.Commands import Cardano.CLI.Legacy.Run (runLegacyCmds) import Cardano.CLI.Render (customRenderHelp) import Cardano.CLI.Run.Ping (PingClientCmdError (..), PingCmd (..), renderPingClientCmdError, runPingCmd) import Cardano.CLI.Types.Errors.CmdError +import Cardano.Git.Rev (gitRev) import Control.Monad (forM_) import Control.Monad.IO.Unlift (MonadIO (..)) @@ -90,7 +91,7 @@ runDisplayVersion = do [ "cardano-cli ", renderVersion version , " - ", Text.pack os, "-", Text.pack arch , " - ", Text.pack compilerName, "-", renderVersion compilerVersion - , "\ngit rev ", gitRev + , "\ngit rev ", $(gitRev) ] where renderVersion = Text.pack . showVersion