{-# LANGUAGE NoImplicitPrelude #-}
module Stack.Options.BuildMonoidParser where
import qualified Data.Text as T
import Distribution.Parsec (eitherParsec)
import Options.Applicative
import Options.Applicative.Builder.Extra
import Stack.Build (splitObjsWarning)
import Stack.Prelude
import Stack.Options.BenchParser
import Stack.Options.TestParser
import Stack.Options.HaddockParser
import Stack.Options.Utils
import Stack.Types.Config.Build
buildOptsMonoidParser :: GlobalOptsContext -> Parser BuildOptsMonoid
buildOptsMonoidParser :: GlobalOptsContext -> Parser BuildOptsMonoid
buildOptsMonoidParser GlobalOptsContext
hide0 =
Any
-> Any
-> Any
-> FirstFalse
-> FirstFalse
-> FirstTrue
-> FirstTrue
-> FirstFalse
-> HaddockOptsMonoid
-> FirstFalse
-> First Bool
-> FirstFalse
-> FirstTrue
-> FirstFalse
-> FirstFalse
-> FirstFalse
-> First Bool
-> FirstFalse
-> FirstFalse
-> FirstFalse
-> TestOptsMonoid
-> FirstFalse
-> BenchmarkOptsMonoid
-> FirstFalse
-> First CabalVerbosity
-> FirstFalse
-> [Text]
-> FirstTrue
-> First Text
-> BuildOptsMonoid
BuildOptsMonoid forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Any
trace' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Any
profile forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Any
noStrip forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstFalse
libProfiling forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
exeProfiling forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstTrue
libStripping forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstTrue
exeStripping forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
haddock forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser HaddockOptsMonoid
haddockOptsParser Bool
hideBool forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstFalse
openHaddocks forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (First Bool)
haddockDeps forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
haddockInternal forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstTrue
haddockHyperlinkSource forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
copyBins forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
copyCompilerTool forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstFalse
preFetch forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (First Bool)
keepGoing forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
keepTmpFiles forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
forceDirty forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstFalse
tests forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser TestOptsMonoid
testOptsParser Bool
hideBool forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
benches forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Bool -> Parser BenchmarkOptsMonoid
benchOptsParser Bool
hideBool forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
reconfigure forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (First CabalVerbosity)
cabalVerbose forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser FirstFalse
splitObjs forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser [Text]
skipComponents forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Parser FirstTrue
interleavedOutput forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (First Text)
ddumpDir
where
hideBool :: Bool
hideBool = GlobalOptsContext
hide0 forall a. Eq a => a -> a -> Bool
/= GlobalOptsContext
BuildCmdGlobalOpts
hide :: Mod f a
hide =
forall (f :: * -> *) a. Bool -> Mod f a
hideMods Bool
hideBool
hideExceptGhci :: Mod f a
hideExceptGhci =
forall (f :: * -> *) a. Bool -> Mod f a
hideMods (GlobalOptsContext
hide0 forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [GlobalOptsContext
BuildCmdGlobalOpts, GlobalOptsContext
GhciCmdGlobalOpts])
trace' :: Parser Any
trace' = Bool -> Any
Any forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall a. a -> a -> Mod FlagFields a -> Parser a
flag
Bool
False
Bool
True
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"trace" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help
String
"Enable profiling in libraries, executables, etc. \
\for all expressions and generate a backtrace on \
\exception" forall a. Semigroup a => a -> a -> a
<>
forall {f :: * -> *} {a}. Mod f a
hideExceptGhci)
profile :: Parser Any
profile = Bool -> Any
Any forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall a. a -> a -> Mod FlagFields a -> Parser a
flag
Bool
False
Bool
True
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"profile" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help
String
"profiling in libraries, executables, etc. \
\for all expressions and generate a profiling report\
\ in tests or benchmarks" forall a. Semigroup a => a -> a -> a
<>
forall {f :: * -> *} {a}. Mod f a
hideExceptGhci)
noStrip :: Parser Any
noStrip = Bool -> Any
Any forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall a. a -> a -> Mod FlagFields a -> Parser a
flag
Bool
False
Bool
True
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"no-strip" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help
String
"Disable DWARF debugging symbol stripping in libraries, \
\executables, etc. for all expressions, producing \
\larger executables but allowing the use of standard \
\debuggers/profiling tools/other utilities that use \
\debugging symbols." forall a. Semigroup a => a -> a -> a
<>
forall {f :: * -> *} {a}. Mod f a
hideExceptGhci)
libProfiling :: Parser FirstFalse
libProfiling =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"library-profiling"
String
"library profiling for TARGETs and all its dependencies"
forall {f :: * -> *} {a}. Mod f a
hide
exeProfiling :: Parser FirstFalse
exeProfiling =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"executable-profiling"
String
"executable profiling for TARGETs and all its dependencies"
forall {f :: * -> *} {a}. Mod f a
hide
libStripping :: Parser FirstTrue
libStripping =
String -> String -> Mod FlagFields FirstTrue -> Parser FirstTrue
firstBoolFlagsTrue
String
"library-stripping"
String
"library stripping for TARGETs and all its dependencies"
forall {f :: * -> *} {a}. Mod f a
hide
exeStripping :: Parser FirstTrue
exeStripping =
String -> String -> Mod FlagFields FirstTrue -> Parser FirstTrue
firstBoolFlagsTrue
String
"executable-stripping"
String
"executable stripping for TARGETs and all its dependencies"
forall {f :: * -> *} {a}. Mod f a
hide
haddock :: Parser FirstFalse
haddock =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"haddock"
String
"generating Haddocks the package(s) in this directory/configuration"
forall {f :: * -> *} {a}. Mod f a
hide
openHaddocks :: Parser FirstFalse
openHaddocks =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"open"
String
"opening the local Haddock documentation in the browser"
forall {f :: * -> *} {a}. Mod f a
hide
haddockDeps :: Parser (First Bool)
haddockDeps =
String
-> String -> Mod FlagFields (Maybe Bool) -> Parser (First Bool)
firstBoolFlagsNoDefault
String
"haddock-deps"
String
"building Haddocks for dependencies (default: true if building Haddocks, false otherwise)"
forall {f :: * -> *} {a}. Mod f a
hide
haddockInternal :: Parser FirstFalse
haddockInternal =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"haddock-internal"
String
"building Haddocks for internal modules (like cabal haddock --internal)"
forall {f :: * -> *} {a}. Mod f a
hide
haddockHyperlinkSource :: Parser FirstTrue
haddockHyperlinkSource =
String -> String -> Mod FlagFields FirstTrue -> Parser FirstTrue
firstBoolFlagsTrue
String
"haddock-hyperlink-source"
String
"building hyperlinked source for Haddock (like haddock --hyperlinked-source)"
forall {f :: * -> *} {a}. Mod f a
hide
copyBins :: Parser FirstFalse
copyBins =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"copy-bins"
String
"copying binaries to local-bin (see 'stack path')"
forall {f :: * -> *} {a}. Mod f a
hide
copyCompilerTool :: Parser FirstFalse
copyCompilerTool =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"copy-compiler-tool"
String
"copying binaries of targets to compiler-tools-bin (see 'stack path')"
forall {f :: * -> *} {a}. Mod f a
hide
keepGoing :: Parser (First Bool)
keepGoing =
String
-> String -> Mod FlagFields (Maybe Bool) -> Parser (First Bool)
firstBoolFlagsNoDefault
String
"keep-going"
String
"continue running after a step fails (default: false for build, true for test/bench)"
forall {f :: * -> *} {a}. Mod f a
hide
keepTmpFiles :: Parser FirstFalse
keepTmpFiles =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"keep-tmp-files"
String
"keep intermediate files and build directories"
forall {f :: * -> *} {a}. Mod f a
hide
preFetch :: Parser FirstFalse
preFetch =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"prefetch"
String
"Fetch packages necessary for the build immediately, useful with --dry-run"
forall {f :: * -> *} {a}. Mod f a
hide
forceDirty :: Parser FirstFalse
forceDirty =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"force-dirty"
String
"Force treating all local packages as having dirty files (useful for cases where stack can't detect a file change"
forall {f :: * -> *} {a}. Mod f a
hide
tests :: Parser FirstFalse
tests =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"test"
String
"testing the package(s) in this directory/configuration"
forall {f :: * -> *} {a}. Mod f a
hideExceptGhci
benches :: Parser FirstFalse
benches =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"bench"
String
"benchmarking the package(s) in this directory/configuration"
forall {f :: * -> *} {a}. Mod f a
hideExceptGhci
reconfigure :: Parser FirstFalse
reconfigure =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"reconfigure"
String
"Perform the configure step even if unnecessary. Useful in some corner cases with custom Setup.hs files"
forall {f :: * -> *} {a}. Mod f a
hide
cabalVerbose :: Parser (First CabalVerbosity)
cabalVerbose = Bool -> Parser (First CabalVerbosity)
cabalVerbosityOptsParser Bool
hideBool
splitObjs :: Parser FirstFalse
splitObjs =
String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"split-objs"
(String
"Enable split-objs, to reduce output size (at the cost of build time). " forall a. [a] -> [a] -> [a]
++ String
splitObjsWarning)
forall {f :: * -> *} {a}. Mod f a
hide
skipComponents :: Parser [Text]
skipComponents = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
(forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
String -> Text
T.pack
(forall s. IsString s => Mod OptionFields s -> Parser s
strOption
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"skip" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help String
"Skip given component (can be specified multiple times)" forall a. Semigroup a => a -> a -> a
<>
forall {f :: * -> *} {a}. Mod f a
hide)))
interleavedOutput :: Parser FirstTrue
interleavedOutput =
String -> String -> Mod FlagFields FirstTrue -> Parser FirstTrue
firstBoolFlagsTrue
String
"interleaved-output"
String
"Print concurrent GHC output to the console with a prefix for the package name"
forall {f :: * -> *} {a}. Mod f a
hide
ddumpDir :: Parser (First Text)
ddumpDir =
forall (f :: * -> *) a. Alternative f => f a -> f (First a)
optionalFirst
(forall s. IsString s => Mod OptionFields s -> Parser s
strOption
(forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"ddump-dir" forall a. Semigroup a => a -> a -> a
<>
forall (f :: * -> *) a. String -> Mod f a
help String
"Specify output ddump-files" forall a. Semigroup a => a -> a -> a
<>
forall {f :: * -> *} {a}. Mod f a
hide))
cabalVerbosityOptsParser :: Bool -> Parser (First CabalVerbosity)
cabalVerbosityOptsParser :: Bool -> Parser (First CabalVerbosity)
cabalVerbosityOptsParser Bool
hide =
Bool -> Parser (First CabalVerbosity)
cabalVerbosityParser Bool
hide forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> Parser (First CabalVerbosity)
cabalVerboseParser Bool
hide
cabalVerbosityParser :: Bool -> Parser (First CabalVerbosity)
cabalVerbosityParser :: Bool -> Parser (First CabalVerbosity)
cabalVerbosityParser Bool
hide =
let pCabalVerbosity :: Parser CabalVerbosity
pCabalVerbosity = forall a. ReadM a -> Mod OptionFields a -> Parser a
option (forall a. (String -> Either String a) -> ReadM a
eitherReader forall a. Parsec a => String -> Either String a
eitherParsec)
( forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"cabal-verbosity"
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"VERBOSITY"
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. String -> Mod f a
help String
"Cabal verbosity (accepts Cabal's numerical and extended syntax)"
forall a. Semigroup a => a -> a -> a
<> forall (f :: * -> *) a. Bool -> Mod f a
hideMods Bool
hide)
in forall a. Maybe a -> First a
First forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser CabalVerbosity
pCabalVerbosity
cabalVerboseParser :: Bool -> Parser (First CabalVerbosity)
cabalVerboseParser :: Bool -> Parser (First CabalVerbosity)
cabalVerboseParser Bool
hide =
let pVerboseFlag :: Parser FirstFalse
pVerboseFlag = String -> String -> Mod FlagFields FirstFalse -> Parser FirstFalse
firstBoolFlagsFalse
String
"cabal-verbose"
String
"Ask Cabal to be verbose in its output"
(forall (f :: * -> *) a. Bool -> Mod f a
hideMods Bool
hide)
in FirstFalse -> First CabalVerbosity
toFirstCabalVerbosity forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser FirstFalse
pVerboseFlag