{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module BuildEnv.Config
(
BuildStrategy(..), RunStrategy(..)
, AsyncSem(..), semDescription
, Args, UnitArgs(..)
, Compiler(..), Cabal(..)
, IndexState(..)
, Paths(..), BuildPaths(..)
, PathUsability(..)
, canonicalizePaths
, TempDirPermanence(..)
, Verbosity(.., Quiet, Normal, Verbose, Debug)
, quietMsg, normalMsg, verboseMsg, debugMsg
, ghcVerbosity, ghcPkgVerbosity, cabalVerbosity, setupVerbosity
, Counter(..)
, Style(..), hostStyle
, pATHSeparator
) where
import Control.Monad
( when )
import Data.Kind
( Type )
import Data.IORef
( IORef )
import Data.Word
( Word16 )
import System.IO
( hFlush, stdout )
import System.FilePath
( dropDrive )
import Data.Text
( Text )
import qualified Data.Text as Text
( pack )
import qualified Data.Text.IO as Text
( putStrLn )
import Data.Time.Clock
( getCurrentTime )
import Data.Time.Format
( defaultTimeLocale, formatTime )
import BuildEnv.Path
data BuildStrategy
= Execute RunStrategy
| Script
{ BuildStrategy -> SymbolicPath CWD 'File
scriptPath :: !( SymbolicPath CWD File )
, BuildStrategy -> Bool
useVariables :: !Bool
}
deriving stock Int -> BuildStrategy -> ShowS
[BuildStrategy] -> ShowS
BuildStrategy -> String
(Int -> BuildStrategy -> ShowS)
-> (BuildStrategy -> String)
-> ([BuildStrategy] -> ShowS)
-> Show BuildStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildStrategy -> ShowS
showsPrec :: Int -> BuildStrategy -> ShowS
$cshow :: BuildStrategy -> String
show :: BuildStrategy -> String
$cshowList :: [BuildStrategy] -> ShowS
showList :: [BuildStrategy] -> ShowS
Show
data RunStrategy
= TopoSort
| Async
AsyncSem
deriving stock Int -> RunStrategy -> ShowS
[RunStrategy] -> ShowS
RunStrategy -> String
(Int -> RunStrategy -> ShowS)
-> (RunStrategy -> String)
-> ([RunStrategy] -> ShowS)
-> Show RunStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RunStrategy -> ShowS
showsPrec :: Int -> RunStrategy -> ShowS
$cshow :: RunStrategy -> String
show :: RunStrategy -> String
$cshowList :: [RunStrategy] -> ShowS
showList :: [RunStrategy] -> ShowS
Show
data AsyncSem
= NewQSem !Word16
| NewJSem !Word16
| ExistingJSem !String
deriving stock Int -> AsyncSem -> ShowS
[AsyncSem] -> ShowS
AsyncSem -> String
(Int -> AsyncSem -> ShowS)
-> (AsyncSem -> String) -> ([AsyncSem] -> ShowS) -> Show AsyncSem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AsyncSem -> ShowS
showsPrec :: Int -> AsyncSem -> ShowS
$cshow :: AsyncSem -> String
show :: AsyncSem -> String
$cshowList :: [AsyncSem] -> ShowS
showList :: [AsyncSem] -> ShowS
Show
semDescription :: AsyncSem -> Text
semDescription :: AsyncSem -> Text
semDescription = \case
NewQSem Word16
i -> Text
"-j" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (Word16 -> String
forall a. Show a => a -> String
show Word16
i)
NewJSem Word16
i -> Text
"--jsem " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (Word16 -> String
forall a. Show a => a -> String
show Word16
i)
ExistingJSem String
jsemName ->
Text
"--jsem " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack String
jsemName
type Args = [String]
data UnitArgs =
UnitArgs { UnitArgs -> Args
configureArgs :: !Args
, UnitArgs -> Maybe Args
mbHaddockArgs :: !(Maybe Args)
, UnitArgs -> Args
registerArgs :: !Args
}
deriving stock Int -> UnitArgs -> ShowS
[UnitArgs] -> ShowS
UnitArgs -> String
(Int -> UnitArgs -> ShowS)
-> (UnitArgs -> String) -> ([UnitArgs] -> ShowS) -> Show UnitArgs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnitArgs -> ShowS
showsPrec :: Int -> UnitArgs -> ShowS
$cshow :: UnitArgs -> String
show :: UnitArgs -> String
$cshowList :: [UnitArgs] -> ShowS
showList :: [UnitArgs] -> ShowS
Show
data Cabal = Cabal { Cabal -> AbsolutePath 'File
cabalPath :: !( AbsolutePath File )
, Cabal -> Args
globalCabalArgs :: !Args
}
deriving stock Int -> Cabal -> ShowS
[Cabal] -> ShowS
Cabal -> String
(Int -> Cabal -> ShowS)
-> (Cabal -> String) -> ([Cabal] -> ShowS) -> Show Cabal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cabal -> ShowS
showsPrec :: Int -> Cabal -> ShowS
$cshow :: Cabal -> String
show :: Cabal -> String
$cshowList :: [Cabal] -> ShowS
showList :: [Cabal] -> ShowS
Show
data Compiler =
Compiler { Compiler -> AbsolutePath 'File
ghcPath :: !( AbsolutePath File )
, Compiler -> AbsolutePath 'File
ghcPkgPath :: !( AbsolutePath File )
}
deriving stock Int -> Compiler -> ShowS
[Compiler] -> ShowS
Compiler -> String
(Int -> Compiler -> ShowS)
-> (Compiler -> String) -> ([Compiler] -> ShowS) -> Show Compiler
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Compiler -> ShowS
showsPrec :: Int -> Compiler -> ShowS
$cshow :: Compiler -> String
show :: Compiler -> String
$cshowList :: [Compiler] -> ShowS
showList :: [Compiler] -> ShowS
Show
newtype IndexState = IndexState Text
deriving newtype ( Int -> IndexState -> ShowS
[IndexState] -> ShowS
IndexState -> String
(Int -> IndexState -> ShowS)
-> (IndexState -> String)
-> ([IndexState] -> ShowS)
-> Show IndexState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IndexState -> ShowS
showsPrec :: Int -> IndexState -> ShowS
$cshow :: IndexState -> String
show :: IndexState -> String
$cshowList :: [IndexState] -> ShowS
showList :: [IndexState] -> ShowS
Show, IndexState -> IndexState -> Bool
(IndexState -> IndexState -> Bool)
-> (IndexState -> IndexState -> Bool) -> Eq IndexState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IndexState -> IndexState -> Bool
== :: IndexState -> IndexState -> Bool
$c/= :: IndexState -> IndexState -> Bool
/= :: IndexState -> IndexState -> Bool
Eq )
type Paths :: PathUsability -> Type
data Paths use
= Paths
{ forall (use :: PathUsability).
Paths use -> SymbolicPath Project ('Dir Fetch)
fetchDir :: !( SymbolicPath Project ( Dir Fetch ) )
, forall (use :: PathUsability). Paths use -> BuildPaths use
buildPaths :: BuildPaths use
}
deriving stock instance Show ( BuildPaths use ) => Show ( Paths use )
type BuildPaths :: PathUsability -> Type
data family BuildPaths use
data instance BuildPaths Raw
= RawBuildPaths
{ BuildPaths 'Raw -> SymbolicPath Project ('Dir Install)
rawDestDir :: !( SymbolicPath Project ( Dir Install ) )
, BuildPaths 'Raw -> SymbolicPath Project ('Dir Prefix)
rawPrefix :: !( SymbolicPath Project ( Dir Prefix ) )
}
deriving stock Int -> BuildPaths 'Raw -> ShowS
[BuildPaths 'Raw] -> ShowS
BuildPaths 'Raw -> String
(Int -> BuildPaths 'Raw -> ShowS)
-> (BuildPaths 'Raw -> String)
-> ([BuildPaths 'Raw] -> ShowS)
-> Show (BuildPaths 'Raw)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildPaths 'Raw -> ShowS
showsPrec :: Int -> BuildPaths 'Raw -> ShowS
$cshow :: BuildPaths 'Raw -> String
show :: BuildPaths 'Raw -> String
$cshowList :: [BuildPaths 'Raw] -> ShowS
showList :: [BuildPaths 'Raw] -> ShowS
Show
data instance BuildPaths ForPrep
= BuildPathsForPrep
{ BuildPaths 'ForPrep -> Compiler
compilerForPrep :: !Compiler
, BuildPaths 'ForPrep -> AbsolutePath ('Dir Install)
installDir :: !( AbsolutePath ( Dir Install ) )
}
deriving stock Int -> BuildPaths 'ForPrep -> ShowS
[BuildPaths 'ForPrep] -> ShowS
BuildPaths 'ForPrep -> String
(Int -> BuildPaths 'ForPrep -> ShowS)
-> (BuildPaths 'ForPrep -> String)
-> ([BuildPaths 'ForPrep] -> ShowS)
-> Show (BuildPaths 'ForPrep)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildPaths 'ForPrep -> ShowS
showsPrec :: Int -> BuildPaths 'ForPrep -> ShowS
$cshow :: BuildPaths 'ForPrep -> String
show :: BuildPaths 'ForPrep -> String
$cshowList :: [BuildPaths 'ForPrep] -> ShowS
showList :: [BuildPaths 'ForPrep] -> ShowS
Show
data instance BuildPaths ForBuild
= BuildPaths
{ BuildPaths 'ForBuild -> Compiler
compiler :: !Compiler
, BuildPaths 'ForBuild -> AbsolutePath ('Dir Prefix)
prefix :: !( AbsolutePath ( Dir Prefix ) )
, BuildPaths 'ForBuild -> AbsolutePath ('Dir Install)
installDir :: !( AbsolutePath ( Dir Install ) )
, BuildPaths 'ForBuild -> AbsolutePath ('Dir Logs)
logDir :: !( AbsolutePath ( Dir Logs ) )
}
deriving stock Int -> BuildPaths 'ForBuild -> ShowS
[BuildPaths 'ForBuild] -> ShowS
BuildPaths 'ForBuild -> String
(Int -> BuildPaths 'ForBuild -> ShowS)
-> (BuildPaths 'ForBuild -> String)
-> ([BuildPaths 'ForBuild] -> ShowS)
-> Show (BuildPaths 'ForBuild)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildPaths 'ForBuild -> ShowS
showsPrec :: Int -> BuildPaths 'ForBuild -> ShowS
$cshow :: BuildPaths 'ForBuild -> String
show :: BuildPaths 'ForBuild -> String
$cshowList :: [BuildPaths 'ForBuild] -> ShowS
showList :: [BuildPaths 'ForBuild] -> ShowS
Show
data PathUsability
= Raw
| ForPrep
| ForBuild
canonicalizePaths :: Compiler
-> BuildStrategy
-> SymbolicPath CWD ( Dir Project)
-> Paths Raw
-> IO ( Paths ForPrep, Paths ForBuild )
canonicalizePaths :: Compiler
-> BuildStrategy
-> SymbolicPath CWD ('Dir Project)
-> Paths 'Raw
-> IO (Paths 'ForPrep, Paths 'ForBuild)
canonicalizePaths Compiler
compiler BuildStrategy
buildStrat SymbolicPath CWD ('Dir Project)
workDir
( Paths
{ $sel:fetchDir:Paths :: forall (use :: PathUsability).
Paths use -> SymbolicPath Project ('Dir Fetch)
fetchDir = SymbolicPath Project ('Dir Fetch)
fetchDir
, $sel:buildPaths:Paths :: forall (use :: PathUsability). Paths use -> BuildPaths use
buildPaths = RawBuildPaths { SymbolicPath Project ('Dir Prefix)
$sel:rawPrefix:RawBuildPaths :: BuildPaths 'Raw -> SymbolicPath Project ('Dir Prefix)
rawPrefix :: SymbolicPath Project ('Dir Prefix)
rawPrefix, SymbolicPath Project ('Dir Install)
$sel:rawDestDir:RawBuildPaths :: BuildPaths 'Raw -> SymbolicPath Project ('Dir Install)
rawDestDir :: SymbolicPath Project ('Dir Install)
rawDestDir } } )
= do
AbsolutePath ('Dir Prefix)
prefix <- SymbolicPath CWD ('Dir Project)
-> SymbolicPath Project ('Dir Prefix)
-> IO (AbsolutePath ('Dir Prefix))
forall dir (to :: FileOrDir).
SymbolicPath CWD ('Dir dir)
-> SymbolicPath dir to -> IO (AbsolutePath to)
makeAbsolute SymbolicPath CWD ('Dir Project)
workDir SymbolicPath Project ('Dir Prefix)
rawPrefix
AbsolutePath ('Dir Install)
installDir <- SymbolicPath CWD ('Dir Project)
-> SymbolicPath Project ('Dir Install)
-> IO (AbsolutePath ('Dir Install))
forall dir (to :: FileOrDir).
SymbolicPath CWD ('Dir dir)
-> SymbolicPath dir to -> IO (AbsolutePath to)
makeAbsolute SymbolicPath CWD ('Dir Project)
workDir ( SymbolicPath Project ('Dir Install)
-> AbsolutePath ('Dir Prefix)
-> SymbolicPath Project ('Dir Install)
mkInstallDir SymbolicPath Project ('Dir Install)
rawDestDir AbsolutePath ('Dir Prefix)
prefix )
AbsolutePath ('Dir Logs)
logDir <- case BuildStrategy
buildStrat of
Script {} -> AbsolutePath ('Dir Logs) -> IO (AbsolutePath ('Dir Logs))
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AbsolutePath ('Dir Logs) -> IO (AbsolutePath ('Dir Logs)))
-> AbsolutePath ('Dir Logs) -> IO (AbsolutePath ('Dir Logs))
forall a b. (a -> b) -> a -> b
$ String -> AbsolutePath ('Dir Logs)
forall (to :: FileOrDir). String -> AbsolutePath to
mkAbsolutePath String
"${LOGDIR}"
Execute {} -> do
UTCTime
time <- IO UTCTime
getCurrentTime
SymbolicPath CWD ('Dir Project)
-> SymbolicPath Project ('Dir Logs)
-> IO (AbsolutePath ('Dir Logs))
forall dir (to :: FileOrDir).
SymbolicPath CWD ('Dir dir)
-> SymbolicPath dir to -> IO (AbsolutePath to)
makeAbsolute SymbolicPath CWD ('Dir Project)
workDir
( String -> SymbolicPath Project ('Dir Logs)
forall from (to :: FileOrDir). String -> SymbolicPath from to
mkSymbolicPath (String -> SymbolicPath Project ('Dir Logs))
-> String -> SymbolicPath Project ('Dir Logs)
forall a b. (a -> b) -> a -> b
$ String
"logs" String -> ShowS
forall p q r. PathLike p q r => p -> q -> r
</> TimeLocale -> String -> UTCTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%0Y-%m-%d_%H-%M-%S" UTCTime
time )
let forBuild :: Paths 'ForBuild
forBuild = case BuildStrategy
buildStrat of
Script { Bool
$sel:useVariables:Execute :: BuildStrategy -> Bool
useVariables :: Bool
useVariables }
| Bool
useVariables
-> Paths { $sel:fetchDir:Paths :: SymbolicPath Project ('Dir Fetch)
fetchDir = String -> SymbolicPath Project ('Dir Fetch)
forall from (to :: FileOrDir). String -> SymbolicPath from to
mkSymbolicPath String
"${SOURCES}"
, $sel:buildPaths:Paths :: BuildPaths 'ForBuild
buildPaths =
BuildPaths
{ $sel:prefix:BuildPaths :: AbsolutePath ('Dir Prefix)
prefix = String -> AbsolutePath ('Dir Prefix)
forall (to :: FileOrDir). String -> AbsolutePath to
mkAbsolutePath String
"${PREFIX}"
, $sel:installDir:BuildPaths :: AbsolutePath ('Dir Install)
installDir = String -> AbsolutePath ('Dir Install)
forall (to :: FileOrDir). String -> AbsolutePath to
mkAbsolutePath (String -> AbsolutePath ('Dir Install))
-> String -> AbsolutePath ('Dir Install)
forall a b. (a -> b) -> a -> b
$ String
"${DESTDIR}" String -> ShowS
forall p q r. PathLike p q r => p -> q -> r
</> String
"${PREFIX}"
, AbsolutePath ('Dir Logs)
$sel:logDir:BuildPaths :: AbsolutePath ('Dir Logs)
logDir :: AbsolutePath ('Dir Logs)
logDir
, $sel:compiler:BuildPaths :: Compiler
compiler =
Compiler { $sel:ghcPath:Compiler :: AbsolutePath 'File
ghcPath = String -> AbsolutePath 'File
forall (to :: FileOrDir). String -> AbsolutePath to
mkAbsolutePath String
"${GHC}"
, $sel:ghcPkgPath:Compiler :: AbsolutePath 'File
ghcPkgPath = String -> AbsolutePath 'File
forall (to :: FileOrDir). String -> AbsolutePath to
mkAbsolutePath String
"${GHCPKG}" } } }
BuildStrategy
_don'tUseVars ->
Paths { SymbolicPath Project ('Dir Fetch)
$sel:fetchDir:Paths :: SymbolicPath Project ('Dir Fetch)
fetchDir :: SymbolicPath Project ('Dir Fetch)
fetchDir
, $sel:buildPaths:Paths :: BuildPaths 'ForBuild
buildPaths =
BuildPaths { Compiler
$sel:compiler:BuildPaths :: Compiler
compiler :: Compiler
compiler, AbsolutePath ('Dir Prefix)
$sel:prefix:BuildPaths :: AbsolutePath ('Dir Prefix)
prefix :: AbsolutePath ('Dir Prefix)
prefix, AbsolutePath ('Dir Install)
$sel:installDir:BuildPaths :: AbsolutePath ('Dir Install)
installDir :: AbsolutePath ('Dir Install)
installDir, AbsolutePath ('Dir Logs)
$sel:logDir:BuildPaths :: AbsolutePath ('Dir Logs)
logDir :: AbsolutePath ('Dir Logs)
logDir } }
(Paths 'ForPrep, Paths 'ForBuild)
-> IO (Paths 'ForPrep, Paths 'ForBuild)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Paths 'ForPrep, Paths 'ForBuild)
-> IO (Paths 'ForPrep, Paths 'ForBuild))
-> (Paths 'ForPrep, Paths 'ForBuild)
-> IO (Paths 'ForPrep, Paths 'ForBuild)
forall a b. (a -> b) -> a -> b
$
( Paths { SymbolicPath Project ('Dir Fetch)
$sel:fetchDir:Paths :: SymbolicPath Project ('Dir Fetch)
fetchDir :: SymbolicPath Project ('Dir Fetch)
fetchDir
, $sel:buildPaths:Paths :: BuildPaths 'ForPrep
buildPaths =
BuildPathsForPrep { $sel:compilerForPrep:BuildPathsForPrep :: Compiler
compilerForPrep = Compiler
compiler, AbsolutePath ('Dir Install)
$sel:installDir:BuildPathsForPrep :: AbsolutePath ('Dir Install)
installDir :: AbsolutePath ('Dir Install)
installDir } }
, Paths 'ForBuild
forBuild )
mkInstallDir :: SymbolicPath Project ( Dir Install )
-> AbsolutePath ( Dir Prefix )
-> SymbolicPath Project ( Dir Install )
mkInstallDir :: SymbolicPath Project ('Dir Install)
-> AbsolutePath ('Dir Prefix)
-> SymbolicPath Project ('Dir Install)
mkInstallDir SymbolicPath Project ('Dir Install)
destDir AbsolutePath ('Dir Prefix)
prefix =
SymbolicPath Project ('Dir Install)
destDir SymbolicPath Project ('Dir Install)
-> RelativePath Install ('Dir Install)
-> SymbolicPath Project ('Dir Install)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Install ('Dir Install)
forall from (to :: FileOrDir). String -> RelativePath from to
mkRelativePath ( ShowS
dropDrive ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ AbsolutePath ('Dir Prefix) -> String
forall (to :: FileOrDir). AbsolutePath to -> String
getAbsolutePath AbsolutePath ('Dir Prefix)
prefix )
data TempDirPermanence
= DeleteTempDirs
| Don'tDeleteTempDirs
deriving stock Int -> TempDirPermanence -> ShowS
[TempDirPermanence] -> ShowS
TempDirPermanence -> String
(Int -> TempDirPermanence -> ShowS)
-> (TempDirPermanence -> String)
-> ([TempDirPermanence] -> ShowS)
-> Show TempDirPermanence
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TempDirPermanence -> ShowS
showsPrec :: Int -> TempDirPermanence -> ShowS
$cshow :: TempDirPermanence -> String
show :: TempDirPermanence -> String
$cshowList :: [TempDirPermanence] -> ShowS
showList :: [TempDirPermanence] -> ShowS
Show
newtype Verbosity = Verbosity Int
deriving newtype (Verbosity -> Verbosity -> Bool
(Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool) -> Eq Verbosity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Verbosity -> Verbosity -> Bool
== :: Verbosity -> Verbosity -> Bool
$c/= :: Verbosity -> Verbosity -> Bool
/= :: Verbosity -> Verbosity -> Bool
Eq, Eq Verbosity
Eq Verbosity =>
(Verbosity -> Verbosity -> Ordering)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Verbosity)
-> (Verbosity -> Verbosity -> Verbosity)
-> Ord Verbosity
Verbosity -> Verbosity -> Bool
Verbosity -> Verbosity -> Ordering
Verbosity -> Verbosity -> Verbosity
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Verbosity -> Verbosity -> Ordering
compare :: Verbosity -> Verbosity -> Ordering
$c< :: Verbosity -> Verbosity -> Bool
< :: Verbosity -> Verbosity -> Bool
$c<= :: Verbosity -> Verbosity -> Bool
<= :: Verbosity -> Verbosity -> Bool
$c> :: Verbosity -> Verbosity -> Bool
> :: Verbosity -> Verbosity -> Bool
$c>= :: Verbosity -> Verbosity -> Bool
>= :: Verbosity -> Verbosity -> Bool
$cmax :: Verbosity -> Verbosity -> Verbosity
max :: Verbosity -> Verbosity -> Verbosity
$cmin :: Verbosity -> Verbosity -> Verbosity
min :: Verbosity -> Verbosity -> Verbosity
Ord, Integer -> Verbosity
Verbosity -> Verbosity
Verbosity -> Verbosity -> Verbosity
(Verbosity -> Verbosity -> Verbosity)
-> (Verbosity -> Verbosity -> Verbosity)
-> (Verbosity -> Verbosity -> Verbosity)
-> (Verbosity -> Verbosity)
-> (Verbosity -> Verbosity)
-> (Verbosity -> Verbosity)
-> (Integer -> Verbosity)
-> Num Verbosity
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: Verbosity -> Verbosity -> Verbosity
+ :: Verbosity -> Verbosity -> Verbosity
$c- :: Verbosity -> Verbosity -> Verbosity
- :: Verbosity -> Verbosity -> Verbosity
$c* :: Verbosity -> Verbosity -> Verbosity
* :: Verbosity -> Verbosity -> Verbosity
$cnegate :: Verbosity -> Verbosity
negate :: Verbosity -> Verbosity
$cabs :: Verbosity -> Verbosity
abs :: Verbosity -> Verbosity
$csignum :: Verbosity -> Verbosity
signum :: Verbosity -> Verbosity
$cfromInteger :: Integer -> Verbosity
fromInteger :: Integer -> Verbosity
Num)
deriving stock Int -> Verbosity -> ShowS
[Verbosity] -> ShowS
Verbosity -> String
(Int -> Verbosity -> ShowS)
-> (Verbosity -> String)
-> ([Verbosity] -> ShowS)
-> Show Verbosity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Verbosity -> ShowS
showsPrec :: Int -> Verbosity -> ShowS
$cshow :: Verbosity -> String
show :: Verbosity -> String
$cshowList :: [Verbosity] -> ShowS
showList :: [Verbosity] -> ShowS
Show
verbosityFlag :: Verbosity -> String
verbosityFlag :: Verbosity -> String
verbosityFlag ( Verbosity Int
i )
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0
= String
"-v0"
| Bool
otherwise
= String
"-v" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
i
pattern Quiet, Normal, Verbose, Debug :: Verbosity
pattern $mQuiet :: forall {r}. Verbosity -> ((# #) -> r) -> ((# #) -> r) -> r
$bQuiet :: Verbosity
Quiet = Verbosity 0
pattern $mNormal :: forall {r}. Verbosity -> ((# #) -> r) -> ((# #) -> r) -> r
$bNormal :: Verbosity
Normal = Verbosity 1
pattern $mVerbose :: forall {r}. Verbosity -> ((# #) -> r) -> ((# #) -> r) -> r
$bVerbose :: Verbosity
Verbose = Verbosity 2
pattern $mDebug :: forall {r}. Verbosity -> ((# #) -> r) -> ((# #) -> r) -> r
$bDebug :: Verbosity
Debug = Verbosity 3
quietMsg, normalMsg, verboseMsg, debugMsg :: Verbosity -> Text -> IO ()
quietMsg :: Verbosity -> Text -> IO ()
quietMsg Verbosity
v Text
msg = Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Verbosity
v Verbosity -> Verbosity -> Bool
forall a. Ord a => a -> a -> Bool
>= Verbosity
Quiet ) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Text -> IO ()
putMsg Text
msg
normalMsg :: Verbosity -> Text -> IO ()
normalMsg Verbosity
v Text
msg = Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Verbosity
v Verbosity -> Verbosity -> Bool
forall a. Ord a => a -> a -> Bool
>= Verbosity
Normal ) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Text -> IO ()
putMsg Text
msg
verboseMsg :: Verbosity -> Text -> IO ()
verboseMsg Verbosity
v Text
msg = Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Verbosity
v Verbosity -> Verbosity -> Bool
forall a. Ord a => a -> a -> Bool
>= Verbosity
Verbose) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Text -> IO ()
putMsg Text
msg
debugMsg :: Verbosity -> Text -> IO ()
debugMsg Verbosity
v Text
msg = Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Verbosity
v Verbosity -> Verbosity -> Bool
forall a. Ord a => a -> a -> Bool
>= Verbosity
Debug ) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Text -> IO ()
putMsg Text
msg
putMsg :: Text -> IO ()
putMsg :: Text -> IO ()
putMsg Text
msg = do
Text -> IO ()
Text.putStrLn Text
msg
Handle -> IO ()
hFlush Handle
stdout
ghcVerbosity, ghcPkgVerbosity, cabalVerbosity, setupVerbosity
:: Verbosity -> String
ghcVerbosity :: Verbosity -> String
ghcVerbosity = Verbosity -> String
verbosityFlag (Verbosity -> String)
-> (Verbosity -> Verbosity) -> Verbosity -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Ord a => a -> a -> a
min Verbosity
maxGhcVerbosity (Verbosity -> Verbosity)
-> (Verbosity -> Verbosity) -> Verbosity -> Verbosity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Num a => a -> a -> a
subtract Verbosity
1
ghcPkgVerbosity :: Verbosity -> String
ghcPkgVerbosity = Verbosity -> String
verbosityFlag (Verbosity -> String)
-> (Verbosity -> Verbosity) -> Verbosity -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Ord a => a -> a -> a
min Verbosity
maxGhcPkgVerbosity (Verbosity -> Verbosity)
-> (Verbosity -> Verbosity) -> Verbosity -> Verbosity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Num a => a -> a -> a
subtract Verbosity
1
cabalVerbosity :: Verbosity -> String
cabalVerbosity = Verbosity -> String
verbosityFlag (Verbosity -> String)
-> (Verbosity -> Verbosity) -> Verbosity -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Ord a => a -> a -> a
min Verbosity
maxCabalVerbosity (Verbosity -> Verbosity)
-> (Verbosity -> Verbosity) -> Verbosity -> Verbosity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Num a => a -> a -> a
subtract Verbosity
1
setupVerbosity :: Verbosity -> String
setupVerbosity = Verbosity -> String
verbosityFlag (Verbosity -> String)
-> (Verbosity -> Verbosity) -> Verbosity -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Ord a => a -> a -> a
min Verbosity
maxSetupVerbosity (Verbosity -> Verbosity)
-> (Verbosity -> Verbosity) -> Verbosity -> Verbosity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Verbosity -> Verbosity -> Verbosity
forall a. Num a => a -> a -> a
subtract Verbosity
1
maxGhcVerbosity, maxGhcPkgVerbosity, maxCabalVerbosity, maxSetupVerbosity
:: Verbosity
maxGhcVerbosity :: Verbosity
maxGhcVerbosity = Int -> Verbosity
Verbosity Int
3
maxGhcPkgVerbosity :: Verbosity
maxGhcPkgVerbosity = Int -> Verbosity
Verbosity Int
2
maxCabalVerbosity :: Verbosity
maxCabalVerbosity = Int -> Verbosity
Verbosity Int
3
maxSetupVerbosity :: Verbosity
maxSetupVerbosity = Verbosity
maxCabalVerbosity
data Counter =
Counter
{ Counter -> IORef Word
counterRef :: !( IORef Word )
, Counter -> Word
counterMax :: !Word
}
data Style
= PosixStyle
| WinStyle
pATHSeparator :: Style -> String
pATHSeparator :: Style -> String
pATHSeparator Style
PosixStyle = String
":"
pATHSeparator Style
WinStyle = String
";"
hostStyle :: Style
hostStyle :: Style
hostStyle =
#if defined(mingw32_HOST_OS)
WinStyle
#else
Style
PosixStyle
#endif