-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1be523
commit ba8b244
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
------------------------------------------------------------------------------ | ||
-- | | ||
-- Module : Build | ||
-- Description : build information | ||
-- Copyright : Copyright (c) 2021-2024 Travis Cardwell | ||
-- License : MIT | ||
------------------------------------------------------------------------------ | ||
|
||
{-# LANGUAGE CPP #-} | ||
|
||
module Build | ||
( version | ||
) where | ||
|
||
-- https://hackage.haskell.org/package/base | ||
import Control.Monad ((<=<)) | ||
import qualified Data.Char as Char | ||
import qualified Data.List as List | ||
import qualified Data.Version | ||
import System.IO.Error (tryIOError) | ||
import qualified System.Info | ||
|
||
-- http://hackage.haskell.org/package/template-haskell | ||
import Language.Haskell.TH (ExpQ, runIO, stringE) | ||
|
||
-- (lsupg) | ||
import qualified LsUpg | ||
|
||
------------------------------------------------------------------------------ | ||
|
||
-- | Compiler version string (internal) | ||
-- | ||
-- The full compiler version is used when it is available. | ||
compilerVersion :: String | ||
compilerVersion = Data.Version.showVersion | ||
#if MIN_VERSION_base (4,15,0) | ||
System.Info.fullCompilerVersion | ||
#else | ||
System.Info.compilerVersion | ||
#endif | ||
|
||
------------------------------------------------------------------------------ | ||
|
||
-- | Version string with build information when built on Alpine | ||
-- | ||
-- @since 0.4.0.0 | ||
version :: ExpQ | ||
version = stringE <=< runIO $ do | ||
mAlpineVersion <- | ||
either (const Nothing) (Just . List.dropWhileEnd Char.isSpace) <$> | ||
tryIOError (readFile "/etc/alpine-release") | ||
pure $ case mAlpineVersion of | ||
Just alpineVersion -> unwords | ||
[ LsUpg.version | ||
, "built on Alpine" | ||
, alpineVersion | ||
, "using" | ||
, System.Info.compilerName | ||
, compilerVersion | ||
] | ||
Nothing -> LsUpg.version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters