{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Distribution.Client.Main (main) where
import Distribution.Client.Setup
( ActAsSetupFlags (..)
, BuildFlags (..)
, CheckFlags (..)
, CommonSetupFlags (..)
, ConfigExFlags (..)
, ConfigFlags (..)
, FetchFlags (..)
, FreezeFlags (..)
, GetFlags (..)
, GlobalFlags (..)
, InfoFlags (..)
, InitFlags (initHcPath, initVerbosity)
, InstallFlags (..)
, ListFlags (..)
, ReportFlags (..)
, UploadFlags (..)
, UserConfigFlags (..)
, actAsSetupCommand
, benchmarkCommand
, buildCommand
, checkCommand
, cleanCommand
, configCompilerAux'
, configPackageDB'
, configureExCommand
, copyCommand
, defaultConfigExFlags
, defaultInstallFlags
, fetchCommand
, filterCommonFlags
, formatCommand
, freezeCommand
, genBoundsCommand
, getCommand
, globalCommand
, haddockCommand
, infoCommand
, initCommand
, installCommand
, listCommand
, listNeedsCompiler
, manpageCommand
, reconfigureCommand
, registerCommand
, replCommand
, reportCommand
, runCommand
, testCommand
, unpackCommand
, uploadCommand
, userConfigCommand
, withRepoContext
)
import Distribution.Simple.Setup
( BenchmarkFlags (..)
, CleanFlags (..)
, CopyFlags (..)
, Flag
, HaddockFlags (..)
, HaddockTarget (..)
, HscolourFlags (..)
, RegisterFlags (..)
, ReplFlags (..)
, TestFlags (..)
, defaultHaddockFlags
, flagToMaybe
, fromFlag
, fromFlagOrDefault
, hscolourCommand
, toFlag
, pattern Flag
, pattern NoFlag
)
import Distribution.Client.Compat.Prelude hiding (get)
import Prelude ()
import Distribution.Client.Config
( SavedConfig (..)
, createDefaultConfigFile
, defaultConfigFile
, getConfigFilePath
, loadConfig
, userConfigDiff
, userConfigUpdate
)
import qualified Distribution.Client.List as List
( info
, list
)
import Distribution.Client.SetupWrapper
( SetupScriptOptions (..)
, defaultSetupScriptOptions
, setupWrapper
)
import Distribution.Client.Targets
( readUserTargets
)
import qualified Distribution.Client.CmdBench as CmdBench
import qualified Distribution.Client.CmdBuild as CmdBuild
import qualified Distribution.Client.CmdClean as CmdClean
import qualified Distribution.Client.CmdConfigure as CmdConfigure
import qualified Distribution.Client.CmdExec as CmdExec
import qualified Distribution.Client.CmdFreeze as CmdFreeze
import qualified Distribution.Client.CmdGenBounds as CmdGenBounds
import qualified Distribution.Client.CmdHaddock as CmdHaddock
import qualified Distribution.Client.CmdHaddockProject as CmdHaddockProject
import qualified Distribution.Client.CmdInstall as CmdInstall
import Distribution.Client.CmdLegacy
import qualified Distribution.Client.CmdListBin as CmdListBin
import qualified Distribution.Client.CmdOutdated as CmdOutdated
import qualified Distribution.Client.CmdPath as CmdPath
import qualified Distribution.Client.CmdRepl as CmdRepl
import qualified Distribution.Client.CmdRun as CmdRun
import qualified Distribution.Client.CmdSdist as CmdSdist
import qualified Distribution.Client.CmdTarget as CmdTarget
import qualified Distribution.Client.CmdTest as CmdTest
import qualified Distribution.Client.CmdUpdate as CmdUpdate
import Distribution.Client.Check as Check (check)
import Distribution.Client.Configure (configure, writeConfigFlags)
import Distribution.Client.Fetch (fetch)
import Distribution.Client.Freeze (freeze)
import Distribution.Client.GenBounds (genBounds)
import Distribution.Client.Install (install)
import Distribution.Client.Get (get)
import Distribution.Client.Init (initCmd)
import Distribution.Client.Manpage (manpageCmd)
import Distribution.Client.ManpageFlags (ManpageFlags (..))
import Distribution.Client.Nix
( nixInstantiate
, nixShell
)
import Distribution.Client.Reconfigure (Check (..), reconfigure)
import Distribution.Client.Run (run, splitRunArgs)
import Distribution.Client.Sandbox
( findSavedDistPref
, loadConfigOrSandboxConfig
, updateInstallDirs
)
import Distribution.Client.Signal
( installTerminationHandler
)
import Distribution.Client.Tar (createTarGzFile)
import Distribution.Client.Types.Credentials (Password (..))
import qualified Distribution.Client.Upload as Upload
import Distribution.Client.Utils
( determineNumJobs
, relaxEncodingErrors
)
import Distribution.Client.Version
( cabalInstallGitInfo
, cabalInstallVersion
)
import Distribution.Package (packageId)
import Distribution.PackageDescription
( BuildType (..)
, Executable (..)
, buildable
)
import Distribution.Client.Errors
import Distribution.Compat.ResponseFile
import qualified Distribution.Make as Make
import Distribution.PackageDescription.PrettyPrint
( writeGenericPackageDescription
)
import qualified Distribution.Simple as Simple
import Distribution.Simple.Build
( startInterpreter
)
import Distribution.Simple.Command
( Command
, CommandParse (..)
, CommandSpec (..)
, CommandType (..)
, CommandUI (..)
, commandAddAction
, commandFromSpec
, commandShowOptions
, commandsRunWithFallback
, defaultCommandFallback
, hiddenCommand
)
import Distribution.Simple.Compiler (PackageDBStack, interpretPackageDBStack)
import Distribution.Simple.Configure
( ConfigStateFileError (..)
, configCompilerAuxEx
, getPersistBuildConfig
, interpretPackageDbFlags
, tryGetPersistBuildConfig
)
import qualified Distribution.Simple.LocalBuildInfo as LBI
import Distribution.Simple.PackageDescription (readGenericPackageDescription)
import Distribution.Simple.Program
( configureAllKnownPrograms
, defaultProgramDb
, defaultProgramSearchPath
, findProgramOnSearchPath
, getProgramInvocationOutput
, simpleProgramInvocation
)
import Distribution.Simple.Program.Db (reconfigurePrograms)
import qualified Distribution.Simple.Setup as Cabal
import Distribution.Simple.Utils
( cabalGitInfo
, cabalVersion
, createDirectoryIfMissingVerbose
, dieNoVerbosity
, dieWithException
, findPackageDesc
, info
, notice
, topHandler
, tryFindPackageDesc
, warn
)
import Distribution.Text
( display
)
import qualified Distribution.Types.UnqualComponentName as Make
import Distribution.Utils.Path hiding
( (<.>)
, (</>)
)
import Distribution.Verbosity as Verbosity
( normal
)
import Distribution.Version
( Version
, mkVersion
, orLaterVersion
)
import Control.Exception (AssertionFailed, assert, try)
import Data.Monoid (Any (..))
import System.Directory
( doesFileExist
, withCurrentDirectory
)
import System.Environment (getEnvironment, getExecutablePath, getProgName)
import System.FilePath
( dropExtension
, splitExtension
, takeExtension
, (<.>)
, (</>)
)
import System.IO
( BufferMode (LineBuffering)
, hPutStrLn
, hSetBuffering
, stderr
, stdout
)
import System.Process (createProcess, env, proc, waitForProcess)
main :: [String] -> IO ()
main :: [[Char]] -> IO ()
main [[Char]]
args = do
IO ()
installTerminationHandler
Handle -> BufferMode -> IO ()
hSetBuffering Handle
stdout BufferMode
LineBuffering
Handle -> IO ()
relaxEncodingErrors Handle
stdout
Handle -> IO ()
relaxEncodingErrors Handle
stderr
let ([[Char]]
args0, [[Char]]
args1) = ([Char] -> Bool) -> [[Char]] -> ([[Char]], [[Char]])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break ([Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
"--") [[Char]]
args
[[Char]] -> IO ()
mainWorker ([[Char]] -> IO ()) -> IO [[Char]] -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ([[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ [[Char]]
args1) ([[Char]] -> [[Char]]) -> IO [[Char]] -> IO [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [[Char]] -> IO [[Char]]
expandResponse [[Char]]
args0
warnIfAssertionsAreEnabled :: IO ()
warnIfAssertionsAreEnabled :: IO ()
warnIfAssertionsAreEnabled =
Bool -> IO () -> IO ()
forall a. HasCallStack => Bool -> a -> a
assert Bool
False (() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
IO () -> (AssertionFailed -> IO ()) -> IO ()
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`catch` (\(AssertionFailed
_e :: AssertionFailed) -> Handle -> [Char] -> IO ()
hPutStrLn Handle
stderr [Char]
assertionsEnabledMsg)
where
assertionsEnabledMsg :: [Char]
assertionsEnabledMsg =
[Char]
"Warning: this is a debug build of cabal-install with assertions enabled."
mainWorker :: [String] -> IO ()
mainWorker :: [[Char]] -> IO ()
mainWorker [[Char]]
args = do
IO () -> IO ()
forall a. IO a -> IO a
topHandler (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
command <- CommandUI GlobalFlags
-> [Command (GlobalFlags -> IO ())]
-> ([Command (GlobalFlags -> IO ())]
-> [Char] -> [[Char]] -> IO (CommandParse (GlobalFlags -> IO ())))
-> [[Char]]
-> IO
(CommandParse (GlobalFlags, CommandParse (GlobalFlags -> IO ())))
forall a action.
CommandUI a
-> [Command action]
-> ([Command action]
-> [Char] -> [[Char]] -> IO (CommandParse action))
-> [[Char]]
-> IO (CommandParse (a, CommandParse action))
commandsRunWithFallback ([Command (GlobalFlags -> IO ())] -> CommandUI GlobalFlags
forall action. [Command action] -> CommandUI GlobalFlags
globalCommand [Command (GlobalFlags -> IO ())]
commands) [Command (GlobalFlags -> IO ())]
commands [Command (GlobalFlags -> IO ())]
-> [Char] -> [[Char]] -> IO (CommandParse (GlobalFlags -> IO ()))
delegateToExternal [[Char]]
args
case command of
CommandHelp [Char] -> [Char]
help -> ([Char] -> [Char]) -> IO ()
printGlobalHelp [Char] -> [Char]
help
CommandList [[Char]]
opts -> [[Char]] -> IO ()
printOptionsList [[Char]]
opts
CommandErrors [[Char]]
errs -> [[Char]] -> IO ()
forall {a}. [[Char]] -> IO a
printErrors [[Char]]
errs
CommandReadyToGo (GlobalFlags
globalFlags, CommandParse (GlobalFlags -> IO ())
commandParse) ->
case CommandParse (GlobalFlags -> IO ())
commandParse of
CommandParse (GlobalFlags -> IO ())
_
| Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (GlobalFlags -> Flag Bool
globalVersion GlobalFlags
globalFlags) ->
IO ()
printVersion
| Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (GlobalFlags -> Flag Bool
globalNumericVersion GlobalFlags
globalFlags) ->
IO ()
printNumericVersion
CommandHelp [Char] -> [Char]
help -> ([Char] -> [Char]) -> IO ()
printCommandHelp [Char] -> [Char]
help
CommandList [[Char]]
opts -> [[Char]] -> IO ()
printOptionsList [[Char]]
opts
CommandErrors [[Char]]
errs -> do
case [[Char]]
args of
[] -> [[Char]] -> IO ()
forall {a}. [[Char]] -> IO a
printErrors [[Char]]
errs
[Char]
script : [[Char]]
scriptArgs ->
[Char] -> IO Bool
CmdRun.validScript [Char]
script IO Bool -> (Bool -> IO ()) -> IO ()
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
False -> [[Char]] -> IO ()
forall {a}. [[Char]] -> IO a
printErrors [[Char]]
errs
Bool
True -> do
IO ()
warnIfAssertionsAreEnabled
[Char] -> [[Char]] -> IO ()
CmdRun.handleShebang [Char]
script [[Char]]
scriptArgs
CommandReadyToGo GlobalFlags -> IO ()
action -> do
IO ()
warnIfAssertionsAreEnabled
GlobalFlags -> IO ()
action GlobalFlags
globalFlags
where
delegateToExternal
:: [Command Action]
-> String
-> [String]
-> IO (CommandParse Action)
delegateToExternal :: [Command (GlobalFlags -> IO ())]
-> [Char] -> [[Char]] -> IO (CommandParse (GlobalFlags -> IO ()))
delegateToExternal [Command (GlobalFlags -> IO ())]
commands' [Char]
name [[Char]]
cmdArgs = do
mCommand <- Verbosity
-> ProgramSearchPath -> [Char] -> IO (Maybe ([Char], [[Char]]))
findProgramOnSearchPath Verbosity
normal ProgramSearchPath
defaultProgramSearchPath ([Char]
"cabal-" [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
name)
case mCommand of
Just ([Char]
exec, [[Char]]
_) -> CommandParse (GlobalFlags -> IO ())
-> IO (CommandParse (GlobalFlags -> IO ()))
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((GlobalFlags -> IO ()) -> CommandParse (GlobalFlags -> IO ())
forall flags. flags -> CommandParse flags
CommandReadyToGo ((GlobalFlags -> IO ()) -> CommandParse (GlobalFlags -> IO ()))
-> (GlobalFlags -> IO ()) -> CommandParse (GlobalFlags -> IO ())
forall a b. (a -> b) -> a -> b
$ \GlobalFlags
_ -> [Char] -> [Char] -> [[Char]] -> IO ()
callExternal [Char]
exec [Char]
name [[Char]]
cmdArgs)
Maybe ([Char], [[Char]])
Nothing -> [Command (GlobalFlags -> IO ())]
-> [Char] -> [[Char]] -> IO (CommandParse (GlobalFlags -> IO ()))
forall action.
[Command action] -> [Char] -> [[Char]] -> IO (CommandParse action)
defaultCommandFallback [Command (GlobalFlags -> IO ())]
commands' [Char]
name [[Char]]
cmdArgs
callExternal :: String -> String -> [String] -> IO ()
callExternal :: [Char] -> [Char] -> [[Char]] -> IO ()
callExternal [Char]
exec [Char]
name [[Char]]
cmdArgs = do
cur_env <- IO [([Char], [Char])]
getEnvironment
cabal_exe <- getExecutablePath
let new_env = ([Char]
"CABAL", [Char]
cabal_exe) ([Char], [Char]) -> [([Char], [Char])] -> [([Char], [Char])]
forall a. a -> [a] -> [a]
: [([Char], [Char])]
cur_env
result <- try $ createProcess ((proc exec (name : cmdArgs)){env = Just new_env})
case result of
Left SomeException
ex -> [[Char]] -> IO ()
forall {a}. [[Char]] -> IO a
printErrors [[Char]
"Error executing external command: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ SomeException -> [Char]
forall a. Show a => a -> [Char]
show (SomeException
ex :: SomeException)]
Right (Maybe Handle
_, Maybe Handle
_, Maybe Handle
_, ProcessHandle
ph) -> ProcessHandle -> IO ExitCode
waitForProcess ProcessHandle
ph IO ExitCode -> (ExitCode -> IO ()) -> IO ()
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ExitCode -> IO ()
forall a. ExitCode -> IO a
exitWith
printCommandHelp :: ([Char] -> [Char]) -> IO ()
printCommandHelp [Char] -> [Char]
help = do
pname <- IO [Char]
getProgName
putStr (help pname)
printGlobalHelp :: ([Char] -> [Char]) -> IO ()
printGlobalHelp [Char] -> [Char]
help = do
pname <- IO [Char]
getProgName
configFile <- defaultConfigFile
putStr (help pname)
putStr $
"\nYou can edit the cabal configuration file to set defaults:\n"
++ " "
++ configFile
++ "\n"
exists <- doesFileExist configFile
unless exists $
putStrLn $
"This file will be generated with sensible "
++ "defaults if you run 'cabal update'."
printOptionsList :: [[Char]] -> IO ()
printOptionsList = [Char] -> IO ()
putStr ([Char] -> IO ()) -> ([[Char]] -> [Char]) -> [[Char]] -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Char]] -> [Char]
unlines
printErrors :: [[Char]] -> IO a
printErrors [[Char]]
errs = [Char] -> IO a
forall a. [Char] -> IO a
dieNoVerbosity ([Char] -> IO a) -> [Char] -> IO a
forall a b. (a -> b) -> a -> b
$ [Char] -> [[Char]] -> [Char]
forall a. [a] -> [[a]] -> [a]
intercalate [Char]
"\n" [[Char]]
errs
printNumericVersion :: IO ()
printNumericVersion = [Char] -> IO ()
putStrLn ([Char] -> IO ()) -> [Char] -> IO ()
forall a b. (a -> b) -> a -> b
$ Version -> [Char]
forall a. Pretty a => a -> [Char]
display Version
cabalInstallVersion
printVersion :: IO ()
printVersion =
[Char] -> IO ()
putStrLn ([Char] -> IO ()) -> [Char] -> IO ()
forall a b. (a -> b) -> a -> b
$
[Char]
"cabal-install version "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Version -> [Char]
forall a. Pretty a => a -> [Char]
display Version
cabalInstallVersion
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
cabalInstallGitInfo
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"\ncompiled using version "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Version -> [Char]
forall a. Pretty a => a -> [Char]
display Version
cabalVersion
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" of the Cabal library "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
cabalGitInfo'
where
cabalGitInfo' :: [Char]
cabalGitInfo'
| [Char]
cabalGitInfo [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
cabalInstallGitInfo = [Char]
"(in-tree)"
| Bool
otherwise = [Char]
cabalGitInfo
commands :: [Command (GlobalFlags -> IO ())]
commands = (CommandSpec (GlobalFlags -> IO ())
-> Command (GlobalFlags -> IO ()))
-> [CommandSpec (GlobalFlags -> IO ())]
-> [Command (GlobalFlags -> IO ())]
forall a b. (a -> b) -> [a] -> [b]
map CommandSpec (GlobalFlags -> IO ())
-> Command (GlobalFlags -> IO ())
forall a. CommandSpec a -> Command a
commandFromSpec [CommandSpec (GlobalFlags -> IO ())]
commandSpecs
commandSpecs :: [CommandSpec (GlobalFlags -> IO ())]
commandSpecs =
[ CommandUI ListFlags
-> (ListFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI ListFlags
listCommand ListFlags -> [[Char]] -> GlobalFlags -> IO ()
listAction
, CommandUI InfoFlags
-> (InfoFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI InfoFlags
infoCommand InfoFlags -> [[Char]] -> GlobalFlags -> IO ()
infoAction
, CommandUI FetchFlags
-> (FetchFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI FetchFlags
fetchCommand FetchFlags -> [[Char]] -> GlobalFlags -> IO ()
fetchAction
, CommandUI GetFlags
-> (GetFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI GetFlags
getCommand GetFlags -> [[Char]] -> GlobalFlags -> IO ()
getAction
, CommandUI GetFlags
-> (GetFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI GetFlags
unpackCommand GetFlags -> [[Char]] -> GlobalFlags -> IO ()
unpackAction
, CommandUI CheckFlags
-> (CheckFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI CheckFlags
checkCommand CheckFlags -> [[Char]] -> GlobalFlags -> IO ()
checkAction
, CommandUI UploadFlags
-> (UploadFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI UploadFlags
uploadCommand UploadFlags -> [[Char]] -> GlobalFlags -> IO ()
uploadAction
, CommandUI ReportFlags
-> (ReportFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI ReportFlags
reportCommand ReportFlags -> [[Char]] -> GlobalFlags -> IO ()
reportAction
, CommandUI InitFlags
-> (InitFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI InitFlags
initCommand InitFlags -> [[Char]] -> GlobalFlags -> IO ()
initAction
, CommandUI UserConfigFlags
-> (UserConfigFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI UserConfigFlags
userConfigCommand UserConfigFlags -> [[Char]] -> GlobalFlags -> IO ()
userConfigAction
, CommandUI (NixStyleFlags PathFlags)
-> (NixStyleFlags PathFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI (NixStyleFlags PathFlags)
CmdPath.pathCommand NixStyleFlags PathFlags -> [[Char]] -> GlobalFlags -> IO ()
CmdPath.pathAction
, CommandUI HscolourFlags
-> (HscolourFlags -> CommonSetupFlags)
-> CommandSpec (GlobalFlags -> IO ())
forall flags.
Monoid flags =>
CommandUI flags
-> (flags -> CommonSetupFlags)
-> CommandSpec (GlobalFlags -> IO ())
wrapperCmd CommandUI HscolourFlags
hscolourCommand HscolourFlags -> CommonSetupFlags
hscolourCommonFlags
, CommandUI (Flag Verbosity)
-> (Flag Verbosity -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
hiddenCmd CommandUI (Flag Verbosity)
formatCommand Flag Verbosity -> [[Char]] -> GlobalFlags -> IO ()
formatAction
, CommandUI ActAsSetupFlags
-> (ActAsSetupFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
hiddenCmd CommandUI ActAsSetupFlags
actAsSetupCommand ActAsSetupFlags -> [[Char]] -> GlobalFlags -> IO ()
actAsSetupAction
, CommandUI ManpageFlags
-> (ManpageFlags -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
hiddenCmd CommandUI ManpageFlags
manpageCommand ([CommandSpec (GlobalFlags -> IO ())]
-> ManpageFlags -> [[Char]] -> GlobalFlags -> IO ()
forall action.
[CommandSpec action]
-> ManpageFlags -> [[Char]] -> GlobalFlags -> IO ()
manpageAction [CommandSpec (GlobalFlags -> IO ())]
commandSpecs)
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> CommandSpec (GlobalFlags -> IO ())
forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI (NixStyleFlags ())
CmdListBin.listbinCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdListBin.listbinAction
]
[CommandSpec (GlobalFlags -> IO ())]
-> [CommandSpec (GlobalFlags -> IO ())]
-> [CommandSpec (GlobalFlags -> IO ())]
forall a. [a] -> [a] -> [a]
++ [[CommandSpec (GlobalFlags -> IO ())]]
-> [CommandSpec (GlobalFlags -> IO ())]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdConfigure.configureCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdConfigure.configureAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdUpdate.updateCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdUpdate.updateAction
, CommandUI (NixStyleFlags BuildFlags)
-> (NixStyleFlags BuildFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags BuildFlags)
CmdBuild.buildCommand NixStyleFlags BuildFlags -> [[Char]] -> GlobalFlags -> IO ()
CmdBuild.buildAction
, CommandUI (NixStyleFlags ReplFlags)
-> (NixStyleFlags ReplFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ReplFlags)
CmdRepl.replCommand NixStyleFlags ReplFlags -> [[Char]] -> GlobalFlags -> IO ()
CmdRepl.replAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdFreeze.freezeCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdFreeze.freezeAction
, CommandUI (NixStyleFlags ClientHaddockFlags)
-> (NixStyleFlags ClientHaddockFlags
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ClientHaddockFlags)
CmdHaddock.haddockCommand NixStyleFlags ClientHaddockFlags
-> [[Char]] -> GlobalFlags -> IO ()
CmdHaddock.haddockAction
, CommandUI HaddockProjectFlags
-> (HaddockProjectFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd
CommandUI HaddockProjectFlags
CmdHaddockProject.haddockProjectCommand
HaddockProjectFlags -> [[Char]] -> GlobalFlags -> IO ()
CmdHaddockProject.haddockProjectAction
, CommandUI (NixStyleFlags ClientInstallFlags)
-> (NixStyleFlags ClientInstallFlags
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ClientInstallFlags)
CmdInstall.installCommand NixStyleFlags ClientInstallFlags
-> [[Char]] -> GlobalFlags -> IO ()
CmdInstall.installAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdRun.runCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdRun.runAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdTest.testCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdTest.testAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdBench.benchCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdBench.benchAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdExec.execCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdExec.execAction
, CommandUI (ProjectFlags, CleanFlags)
-> ((ProjectFlags, CleanFlags) -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (ProjectFlags, CleanFlags)
CmdClean.cleanCommand (ProjectFlags, CleanFlags) -> [[Char]] -> GlobalFlags -> IO ()
CmdClean.cleanAction
, CommandUI (ProjectFlags, SdistFlags)
-> ((ProjectFlags, SdistFlags) -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (ProjectFlags, SdistFlags)
CmdSdist.sdistCommand (ProjectFlags, SdistFlags) -> [[Char]] -> GlobalFlags -> IO ()
CmdSdist.sdistAction
, CommandUI (NixStyleFlags ())
-> (NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags ())
CmdTarget.targetCommand NixStyleFlags () -> [[Char]] -> GlobalFlags -> IO ()
CmdTarget.targetAction
, CommandUI (NixStyleFlags GenBoundsFlags)
-> (NixStyleFlags GenBoundsFlags
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags GenBoundsFlags)
CmdGenBounds.genBoundsCommand NixStyleFlags GenBoundsFlags -> [[Char]] -> GlobalFlags -> IO ()
CmdGenBounds.genBoundsAction
, CommandUI (NixStyleFlags OutdatedFlags)
-> (NixStyleFlags OutdatedFlags
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
newCmd CommandUI (NixStyleFlags OutdatedFlags)
CmdOutdated.outdatedCommand NixStyleFlags OutdatedFlags -> [[Char]] -> GlobalFlags -> IO ()
CmdOutdated.outdatedAction
, CommandUI (ConfigFlags, ConfigExFlags)
-> ((ConfigFlags, ConfigExFlags)
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand (ConfigFlags, ConfigExFlags) -> [[Char]] -> GlobalFlags -> IO ()
configureAction
, CommandUI FreezeFlags
-> (FreezeFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI FreezeFlags
genBoundsCommand FreezeFlags -> [[Char]] -> GlobalFlags -> IO ()
genBoundsAction
, CommandUI BuildFlags
-> (BuildFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI BuildFlags
buildCommand BuildFlags -> [[Char]] -> GlobalFlags -> IO ()
buildAction
, CommandUI ReplFlags
-> (ReplFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI ReplFlags
replCommand ReplFlags -> [[Char]] -> GlobalFlags -> IO ()
replAction
, CommandUI FreezeFlags
-> (FreezeFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI FreezeFlags
freezeCommand FreezeFlags -> [[Char]] -> GlobalFlags -> IO ()
freezeAction
, CommandUI HaddockFlags
-> (HaddockFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI HaddockFlags
haddockCommand HaddockFlags -> [[Char]] -> GlobalFlags -> IO ()
haddockAction
, CommandUI
(ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
BenchmarkFlags)
-> ((ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags,
TestFlags, BenchmarkFlags)
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI
(ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
BenchmarkFlags)
installCommand (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
BenchmarkFlags)
-> [[Char]] -> GlobalFlags -> IO ()
installAction
, CommandUI BuildFlags
-> (BuildFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI BuildFlags
runCommand BuildFlags -> [[Char]] -> GlobalFlags -> IO ()
runAction
, CommandUI (BuildFlags, TestFlags)
-> ((BuildFlags, TestFlags) -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI (BuildFlags, TestFlags)
testCommand (BuildFlags, TestFlags) -> [[Char]] -> GlobalFlags -> IO ()
testAction
, CommandUI (BuildFlags, BenchmarkFlags)
-> ((BuildFlags, BenchmarkFlags)
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI (BuildFlags, BenchmarkFlags)
benchmarkCommand (BuildFlags, BenchmarkFlags) -> [[Char]] -> GlobalFlags -> IO ()
benchmarkAction
, CommandUI CleanFlags
-> (CleanFlags -> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI CleanFlags
cleanCommand CleanFlags -> [[Char]] -> GlobalFlags -> IO ()
cleanAction
, CommandUI CopyFlags
-> (CopyFlags -> CommonSetupFlags)
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags.
Monoid flags =>
CommandUI flags
-> (flags -> CommonSetupFlags)
-> [CommandSpec (GlobalFlags -> IO ())]
legacyWrapperCmd CommandUI CopyFlags
copyCommand CopyFlags -> CommonSetupFlags
copyCommonFlags
, CommandUI RegisterFlags
-> (RegisterFlags -> CommonSetupFlags)
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags.
Monoid flags =>
CommandUI flags
-> (flags -> CommonSetupFlags)
-> [CommandSpec (GlobalFlags -> IO ())]
legacyWrapperCmd CommandUI RegisterFlags
registerCommand RegisterFlags -> CommonSetupFlags
registerCommonFlags
, CommandUI (ConfigFlags, ConfigExFlags)
-> ((ConfigFlags, ConfigExFlags)
-> [[Char]] -> GlobalFlags -> IO ())
-> [CommandSpec (GlobalFlags -> IO ())]
forall flags globals action.
HasVerbosity flags =>
CommandUI flags
-> (flags -> [[Char]] -> globals -> IO action)
-> [CommandSpec (globals -> IO action)]
legacyCmd CommandUI (ConfigFlags, ConfigExFlags)
reconfigureCommand (ConfigFlags, ConfigExFlags) -> [[Char]] -> GlobalFlags -> IO ()
reconfigureAction
]
type Action = GlobalFlags -> IO ()
regularCmd
:: CommandUI flags
-> (flags -> [String] -> action)
-> CommandSpec action
regularCmd :: forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
regularCmd CommandUI flags
ui flags -> [[Char]] -> action
action =
CommandUI flags
-> (CommandUI flags -> Command action)
-> CommandType
-> CommandSpec action
forall action flags.
CommandUI flags
-> (CommandUI flags -> Command action)
-> CommandType
-> CommandSpec action
CommandSpec CommandUI flags
ui (((CommandUI flags
-> (flags -> [[Char]] -> action) -> Command action)
-> (flags -> [[Char]] -> action)
-> CommandUI flags
-> Command action
forall a b c. (a -> b -> c) -> b -> a -> c
flip CommandUI flags -> (flags -> [[Char]] -> action) -> Command action
forall flags action.
CommandUI flags -> (flags -> [[Char]] -> action) -> Command action
commandAddAction) flags -> [[Char]] -> action
action) CommandType
NormalCommand
hiddenCmd
:: CommandUI flags
-> (flags -> [String] -> action)
-> CommandSpec action
hiddenCmd :: forall flags action.
CommandUI flags
-> (flags -> [[Char]] -> action) -> CommandSpec action
hiddenCmd CommandUI flags
ui flags -> [[Char]] -> action
action =
CommandUI flags
-> (CommandUI flags -> Command action)
-> CommandType
-> CommandSpec action
forall action flags.
CommandUI flags
-> (CommandUI flags -> Command action)
-> CommandType
-> CommandSpec action
CommandSpec
CommandUI flags
ui
(\CommandUI flags
ui' -> Command action -> Command action
forall action. Command action -> Command action
hiddenCommand (CommandUI flags -> (flags -> [[Char]] -> action) -> Command action
forall flags action.
CommandUI flags -> (flags -> [[Char]] -> action) -> Command action
commandAddAction CommandUI flags
ui' flags -> [[Char]] -> action
action))
CommandType
HiddenCommand
wrapperCmd
:: Monoid flags
=> CommandUI flags
-> (flags -> CommonSetupFlags)
-> CommandSpec Action
wrapperCmd :: forall flags.
Monoid flags =>
CommandUI flags
-> (flags -> CommonSetupFlags)
-> CommandSpec (GlobalFlags -> IO ())
wrapperCmd CommandUI flags
ui flags -> CommonSetupFlags
getCommonFlags =
CommandUI flags
-> (CommandUI flags -> Command (GlobalFlags -> IO ()))
-> CommandType
-> CommandSpec (GlobalFlags -> IO ())
forall action flags.
CommandUI flags
-> (CommandUI flags -> Command action)
-> CommandType
-> CommandSpec action
CommandSpec CommandUI flags
ui (\CommandUI flags
ui' -> CommandUI flags
-> (flags -> CommonSetupFlags) -> Command (GlobalFlags -> IO ())
forall flags.
Monoid flags =>
CommandUI flags
-> (flags -> CommonSetupFlags) -> Command (GlobalFlags -> IO ())
wrapperAction CommandUI flags
ui' flags -> CommonSetupFlags
getCommonFlags) CommandType
NormalCommand
wrapperAction
:: Monoid flags
=> CommandUI flags
-> (flags -> CommonSetupFlags)
-> Command Action
wrapperAction :: forall flags.
Monoid flags =>
CommandUI flags
-> (flags -> CommonSetupFlags) -> Command (GlobalFlags -> IO ())
wrapperAction CommandUI flags
command flags -> CommonSetupFlags
getCommonFlags =
CommandUI flags
-> (flags -> [[Char]] -> GlobalFlags -> IO ())
-> Command (GlobalFlags -> IO ())
forall flags action.
CommandUI flags -> (flags -> [[Char]] -> action) -> Command action
commandAddAction
CommandUI flags
command
{ commandDefaultFlags = mempty
}
((flags -> [[Char]] -> GlobalFlags -> IO ())
-> Command (GlobalFlags -> IO ()))
-> (flags -> [[Char]] -> GlobalFlags -> IO ())
-> Command (GlobalFlags -> IO ())
forall a b. (a -> b) -> a -> b
$ \flags
flags [[Char]]
extraArgs GlobalFlags
globalFlags -> do
let common :: CommonSetupFlags
common = flags -> CommonSetupFlags
getCommonFlags flags
flags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
mbWorkDir :: Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir = Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
setupWorkingDir CommonSetupFlags
common
load <- IO SavedConfig -> IO (Either SomeException SavedConfig)
forall e a. Exception e => IO a -> IO (Either e a)
try (Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags)
let config = (SomeException -> SavedConfig)
-> (SavedConfig -> SavedConfig)
-> Either SomeException SavedConfig
-> SavedConfig
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(SomeException e
_) -> SavedConfig
forall a. Monoid a => a
mempty) SavedConfig -> SavedConfig
forall a. a -> a
id Either SomeException SavedConfig
load
distPref <- findSavedDistPref config (setupDistPref common)
let setupScriptOptions =
SetupScriptOptions
defaultSetupScriptOptions
{ useDistPref = distPref
, useWorkingDir = mbWorkDir
}
setupWrapper
verbosity
setupScriptOptions
Nothing
command
getCommonFlags
(const (return flags))
(const extraArgs)
configureAction
:: (ConfigFlags, ConfigExFlags)
-> [String]
-> Action
configureAction :: (ConfigFlags, ConfigExFlags) -> [[Char]] -> GlobalFlags -> IO ()
configureAction (ConfigFlags
configFlags, ConfigExFlags
configExFlags) [[Char]]
extraArgs GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = ConfigFlags -> CommonSetupFlags
configCommonFlags ConfigFlags
configFlags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
config <-
Flag Bool -> SavedConfig -> SavedConfig
updateInstallDirs (ConfigFlags -> Flag Bool
configUserInstall ConfigFlags
configFlags)
(SavedConfig -> SavedConfig) -> IO SavedConfig -> IO SavedConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- getSymbolicPath <$> findSavedDistPref config (setupDistPref common)
nixInstantiate verbosity distPref True globalFlags config
nixShell verbosity distPref globalFlags config $ do
let configFlags' = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config ConfigFlags -> ConfigFlags -> ConfigFlags
forall a. Monoid a => a -> a -> a
`mappend` ConfigFlags
configFlags
configExFlags' = SavedConfig -> ConfigExFlags
savedConfigureExFlags SavedConfig
config ConfigExFlags -> ConfigExFlags -> ConfigExFlags
forall a. Monoid a => a -> a -> a
`mappend` ConfigExFlags
configExFlags
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, platform, progdb) <- configCompilerAuxEx configFlags'
writeConfigFlags verbosity distPref (configFlags', configExFlags')
let packageDBs :: PackageDBStack
packageDBs =
Bool
-> [Maybe (PackageDBX (SymbolicPath Pkg ('Dir PkgDB)))]
-> PackageDBStack
forall fp. Bool -> [Maybe (PackageDBX fp)] -> PackageDBStackX fp
interpretPackageDbFlags
(Flag Bool -> Bool
forall a. WithCallStack (Flag a -> a)
fromFlag (ConfigFlags -> Flag Bool
configUserInstall ConfigFlags
configFlags'))
(ConfigFlags -> [Maybe (PackageDBX (SymbolicPath Pkg ('Dir PkgDB)))]
configPackageDBs ConfigFlags
configFlags')
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> Platform
-> ProgramDb
-> ConfigFlags
-> ConfigExFlags
-> [[Char]]
-> IO ()
configure
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing PackageDBStack
packageDBs)
RepoContext
repoContext
Compiler
comp
Platform
platform
ProgramDb
progdb
ConfigFlags
configFlags'
ConfigExFlags
configExFlags'
[[Char]]
extraArgs
reconfigureAction
:: (ConfigFlags, ConfigExFlags)
-> [String]
-> Action
reconfigureAction :: (ConfigFlags, ConfigExFlags) -> [[Char]] -> GlobalFlags -> IO ()
reconfigureAction flags :: (ConfigFlags, ConfigExFlags)
flags@(ConfigFlags
configFlags, ConfigExFlags
_) [[Char]]
_ GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = ConfigFlags -> CommonSetupFlags
configCommonFlags ConfigFlags
configFlags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common)
config <-
Flag Bool -> SavedConfig -> SavedConfig
updateInstallDirs (ConfigFlags -> Flag Bool
configUserInstall ConfigFlags
configFlags)
(SavedConfig -> SavedConfig) -> IO SavedConfig -> IO SavedConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config (setupDistPref common)
let checkFlags = (Any
-> (ConfigFlags, ConfigExFlags)
-> IO (Any, (ConfigFlags, ConfigExFlags)))
-> Check (ConfigFlags, ConfigExFlags)
forall a. (Any -> a -> IO (Any, a)) -> Check a
Check ((Any
-> (ConfigFlags, ConfigExFlags)
-> IO (Any, (ConfigFlags, ConfigExFlags)))
-> Check (ConfigFlags, ConfigExFlags))
-> (Any
-> (ConfigFlags, ConfigExFlags)
-> IO (Any, (ConfigFlags, ConfigExFlags)))
-> Check (ConfigFlags, ConfigExFlags)
forall a b. (a -> b) -> a -> b
$ \Any
_ (ConfigFlags, ConfigExFlags)
saved -> do
let flags' :: (ConfigFlags, ConfigExFlags)
flags' = (ConfigFlags, ConfigExFlags)
saved (ConfigFlags, ConfigExFlags)
-> (ConfigFlags, ConfigExFlags) -> (ConfigFlags, ConfigExFlags)
forall a. Semigroup a => a -> a -> a
<> (ConfigFlags, ConfigExFlags)
flags
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((ConfigFlags, ConfigExFlags)
saved (ConfigFlags, ConfigExFlags)
-> (ConfigFlags, ConfigExFlags) -> Bool
forall a. Eq a => a -> a -> Bool
== (ConfigFlags, ConfigExFlags)
flags') (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Verbosity -> [Char] -> IO ()
info Verbosity
verbosity [Char]
message
(Any, (ConfigFlags, ConfigExFlags))
-> IO (Any, (ConfigFlags, ConfigExFlags))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool -> Any
Any Bool
True, (ConfigFlags, ConfigExFlags)
flags')
where
message :: [Char]
message =
[Char]
"flags changed: "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
unwords (CommandUI (ConfigFlags, ConfigExFlags)
-> (ConfigFlags, ConfigExFlags) -> [[Char]]
forall flags. CommandUI flags -> flags -> [[Char]]
commandShowOptions CommandUI (ConfigFlags, ConfigExFlags)
configureExCommand (ConfigFlags, ConfigExFlags)
flags)
nixInstantiate verbosity (getSymbolicPath distPref) True globalFlags config
_ <-
reconfigure
configureAction
verbosity
distPref
NoFlag
checkFlags
[]
globalFlags
config
pure ()
buildAction :: BuildFlags -> [String] -> Action
buildAction :: BuildFlags -> [[Char]] -> GlobalFlags -> IO ()
buildAction BuildFlags
buildFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = BuildFlags -> CommonSetupFlags
buildCommonFlags BuildFlags
buildFlags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config (setupDistPref common)
config' <-
reconfigure
configureAction
verbosity
distPref
(buildNumJobs buildFlags)
mempty
[]
globalFlags
config
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
build verbosity config' distPref buildFlags extraArgs
build :: Verbosity -> SavedConfig -> SymbolicPath Pkg (Dir Dist) -> BuildFlags -> [String] -> IO ()
build :: Verbosity
-> SavedConfig
-> SymbolicPath Pkg ('Dir Dist)
-> BuildFlags
-> [[Char]]
-> IO ()
build Verbosity
verbosity SavedConfig
config SymbolicPath Pkg ('Dir Dist)
distPref BuildFlags
buildFlags [[Char]]
extraArgs =
Verbosity
-> SetupScriptOptions
-> Maybe PackageDescription
-> CommandUI BuildFlags
-> (BuildFlags -> CommonSetupFlags)
-> (Version -> IO BuildFlags)
-> (Version -> [[Char]])
-> IO ()
forall flags.
Verbosity
-> SetupScriptOptions
-> Maybe PackageDescription
-> CommandUI flags
-> (flags -> CommonSetupFlags)
-> (Version -> IO flags)
-> (Version -> [[Char]])
-> IO ()
setupWrapper
Verbosity
verbosity
SetupScriptOptions
setupOptions
Maybe PackageDescription
forall a. Maybe a
Nothing
(ProgramDb -> CommandUI BuildFlags
Cabal.buildCommand ProgramDb
progDb)
BuildFlags -> CommonSetupFlags
buildCommonFlags
(BuildFlags -> IO BuildFlags
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (BuildFlags -> IO BuildFlags)
-> (Version -> BuildFlags) -> Version -> IO BuildFlags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> BuildFlags
mkBuildFlags)
([[Char]] -> Version -> [[Char]]
forall a b. a -> b -> a
const [[Char]]
extraArgs)
where
progDb :: ProgramDb
progDb = ProgramDb
defaultProgramDb
setupOptions :: SetupScriptOptions
setupOptions = SetupScriptOptions
defaultSetupScriptOptions{useDistPref = distPref}
mkBuildFlags :: Version -> BuildFlags
mkBuildFlags Version
version = Version -> SavedConfig -> BuildFlags -> BuildFlags
filterBuildFlags Version
version SavedConfig
config BuildFlags
buildFlags'
commonFlags :: CommonSetupFlags
commonFlags = BuildFlags -> CommonSetupFlags
buildCommonFlags BuildFlags
buildFlags
buildFlags' :: BuildFlags
buildFlags' =
BuildFlags
buildFlags
{ buildCommonFlags =
commonFlags
{ setupVerbosity = toFlag verbosity
, setupDistPref = toFlag distPref
}
}
filterBuildFlags :: Version -> SavedConfig -> BuildFlags -> BuildFlags
filterBuildFlags :: Version -> SavedConfig -> BuildFlags -> BuildFlags
filterBuildFlags Version
version SavedConfig
config BuildFlags
buildFlags =
let flags' :: BuildFlags
flags' = Version -> SavedConfig -> BuildFlags -> BuildFlags
filterBuildFlags' Version
version SavedConfig
config BuildFlags
buildFlags
in BuildFlags
flags'
{ buildCommonFlags =
filterCommonFlags (buildCommonFlags flags') version
}
filterBuildFlags' :: Version -> SavedConfig -> BuildFlags -> BuildFlags
filterBuildFlags' :: Version -> SavedConfig -> BuildFlags -> BuildFlags
filterBuildFlags' Version
version SavedConfig
config BuildFlags
buildFlags
| Version
version Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int] -> Version
mkVersion [Int
1, Int
19, Int
1] = BuildFlags
buildFlags_latest
| Bool
otherwise = BuildFlags
buildFlags_pre_1_19_1
where
buildFlags_pre_1_19_1 :: BuildFlags
buildFlags_pre_1_19_1 =
BuildFlags
buildFlags
{ buildNumJobs = NoFlag
}
buildFlags_latest :: BuildFlags
buildFlags_latest =
BuildFlags
buildFlags
{
buildNumJobs =
Flag . Just . determineNumJobs $
(numJobsConfigFlag `mappend` numJobsCmdLineFlag)
}
numJobsConfigFlag :: Flag (Maybe Int)
numJobsConfigFlag = InstallFlags -> Flag (Maybe Int)
installNumJobs (InstallFlags -> Flag (Maybe Int))
-> (SavedConfig -> InstallFlags) -> SavedConfig -> Flag (Maybe Int)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SavedConfig -> InstallFlags
savedInstallFlags (SavedConfig -> Flag (Maybe Int))
-> SavedConfig -> Flag (Maybe Int)
forall a b. (a -> b) -> a -> b
$ SavedConfig
config
numJobsCmdLineFlag :: Flag (Maybe Int)
numJobsCmdLineFlag = BuildFlags -> Flag (Maybe Int)
buildNumJobs BuildFlags
buildFlags
replAction :: ReplFlags -> [String] -> Action
replAction :: ReplFlags -> [[Char]] -> GlobalFlags -> IO ()
replAction ReplFlags
replFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = ReplFlags -> CommonSetupFlags
replCommonFlags ReplFlags
replFlags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config (setupDistPref common)
pkgDesc <- findPackageDesc Nothing
let
onPkgDesc = do
_ <-
((ConfigFlags, ConfigExFlags) -> [[Char]] -> GlobalFlags -> IO ())
-> Verbosity
-> SymbolicPath Pkg ('Dir Dist)
-> Flag (Maybe Int)
-> Check (ConfigFlags, ConfigExFlags)
-> [[Char]]
-> GlobalFlags
-> SavedConfig
-> IO SavedConfig
reconfigure
(ConfigFlags, ConfigExFlags) -> [[Char]] -> GlobalFlags -> IO ()
configureAction
Verbosity
verbosity
SymbolicPath Pkg ('Dir Dist)
distPref
Flag (Maybe Int)
forall a. Last a
NoFlag
Check (ConfigFlags, ConfigExFlags)
forall a. Monoid a => a
mempty
[]
GlobalFlags
globalFlags
SavedConfig
config
let progDb = ProgramDb
defaultProgramDb
setupOptions =
SetupScriptOptions
defaultSetupScriptOptions
{ useCabalVersion = orLaterVersion $ mkVersion [1, 18, 0]
, useDistPref = distPref
}
commonFlags = ReplFlags -> CommonSetupFlags
replCommonFlags ReplFlags
replFlags
replFlags' =
ReplFlags
replFlags
{ replCommonFlags =
commonFlags
{ setupVerbosity = toFlag verbosity
, setupDistPref = toFlag distPref
}
}
nixShell verbosity (getSymbolicPath distPref) globalFlags config $
setupWrapper
verbosity
setupOptions
Nothing
(Cabal.replCommand progDb)
Cabal.replCommonFlags
(const (return replFlags'))
(const extraArgs)
onNoPkgDesc = do
let configFlags :: ConfigFlags
configFlags = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
(comp, platform, programDb) <- ConfigFlags -> IO (Compiler, Platform, ProgramDb)
configCompilerAux' ConfigFlags
configFlags
programDb' <-
reconfigurePrograms
verbosity
(replProgramPaths replFlags)
(replProgramArgs replFlags)
programDb
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
startInterpreter
verbosity
programDb'
comp
platform
(configPackageDB' configFlags)
either (const onNoPkgDesc) (const onPkgDesc) pkgDesc
installAction
:: ( ConfigFlags
, ConfigExFlags
, InstallFlags
, HaddockFlags
, TestFlags
, BenchmarkFlags
)
-> [String]
-> Action
installAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags,
BenchmarkFlags)
-> [[Char]] -> GlobalFlags -> IO ()
installAction (ConfigFlags
configFlags, ConfigExFlags
_, InstallFlags
installFlags, HaddockFlags
_, TestFlags
_, BenchmarkFlags
_) [[Char]]
_ GlobalFlags
globalFlags
| Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (InstallFlags -> Flag Bool
installOnly InstallFlags
installFlags) = do
let common :: CommonSetupFlags
common = ConfigFlags -> CommonSetupFlags
configCommonFlags ConfigFlags
configFlags
verb :: Verbosity
verb = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common)
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verb GlobalFlags
globalFlags
dist <- findSavedDistPref config (setupDistPref common)
let setupOpts = SetupScriptOptions
defaultSetupScriptOptions{useDistPref = dist}
setupWrapper
verb
setupOpts
Nothing
installCommand
(const common)
(const (return (mempty, mempty, mempty, mempty, mempty, mempty)))
(const [])
installAction
( ConfigFlags
configFlags
, ConfigExFlags
configExFlags
, InstallFlags
installFlags
, HaddockFlags
haddockFlags
, TestFlags
testFlags
, BenchmarkFlags
benchmarkFlags
)
[[Char]]
extraArgs
GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = ConfigFlags -> CommonSetupFlags
configCommonFlags ConfigFlags
configFlags
verb :: Verbosity
verb = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
config <-
Flag Bool -> SavedConfig -> SavedConfig
updateInstallDirs (ConfigFlags -> Flag Bool
configUserInstall ConfigFlags
configFlags)
(SavedConfig -> SavedConfig) -> IO SavedConfig -> IO SavedConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verb GlobalFlags
globalFlags
dist <- findSavedDistPref config $ setupDistPref common
do
targets <- readUserTargets verb extraArgs
let configFlags' =
InstallFlags -> ConfigFlags -> ConfigFlags
maybeForceTests InstallFlags
installFlags' (ConfigFlags -> ConfigFlags) -> ConfigFlags -> ConfigFlags
forall a b. (a -> b) -> a -> b
$
SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
ConfigFlags -> ConfigFlags -> ConfigFlags
forall a. Monoid a => a -> a -> a
`mappend` ConfigFlags
configFlags
{ configCommonFlags =
(configCommonFlags configFlags)
{ setupDistPref = toFlag dist
}
}
configExFlags' =
ConfigExFlags
defaultConfigExFlags
ConfigExFlags -> ConfigExFlags -> ConfigExFlags
forall a. Monoid a => a -> a -> a
`mappend` SavedConfig -> ConfigExFlags
savedConfigureExFlags SavedConfig
config
ConfigExFlags -> ConfigExFlags -> ConfigExFlags
forall a. Monoid a => a -> a -> a
`mappend` ConfigExFlags
configExFlags
installFlags' =
InstallFlags
defaultInstallFlags
InstallFlags -> InstallFlags -> InstallFlags
forall a. Monoid a => a -> a -> a
`mappend` SavedConfig -> InstallFlags
savedInstallFlags SavedConfig
config
InstallFlags -> InstallFlags -> InstallFlags
forall a. Monoid a => a -> a -> a
`mappend` InstallFlags
installFlags
haddockFlags' =
HaddockFlags
defaultHaddockFlags
HaddockFlags -> HaddockFlags -> HaddockFlags
forall a. Monoid a => a -> a -> a
`mappend` SavedConfig -> HaddockFlags
savedHaddockFlags SavedConfig
config
HaddockFlags -> HaddockFlags -> HaddockFlags
forall a. Monoid a => a -> a -> a
`mappend` HaddockFlags
haddockFlags
{ haddockCommonFlags =
(haddockCommonFlags haddockFlags)
{ setupDistPref = toFlag dist
}
}
testFlags' =
TestFlags
Cabal.defaultTestFlags
TestFlags -> TestFlags -> TestFlags
forall a. Monoid a => a -> a -> a
`mappend` SavedConfig -> TestFlags
savedTestFlags SavedConfig
config
TestFlags -> TestFlags -> TestFlags
forall a. Monoid a => a -> a -> a
`mappend` TestFlags
testFlags
{ testCommonFlags =
(testCommonFlags testFlags)
{ setupDistPref = toFlag dist
}
}
benchmarkFlags' =
BenchmarkFlags
Cabal.defaultBenchmarkFlags
BenchmarkFlags -> BenchmarkFlags -> BenchmarkFlags
forall a. Monoid a => a -> a -> a
`mappend` SavedConfig -> BenchmarkFlags
savedBenchmarkFlags SavedConfig
config
BenchmarkFlags -> BenchmarkFlags -> BenchmarkFlags
forall a. Monoid a => a -> a -> a
`mappend` BenchmarkFlags
benchmarkFlags
{ benchmarkCommonFlags =
(benchmarkCommonFlags benchmarkFlags)
{ setupDistPref = toFlag dist
}
}
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, platform, progdb) <- configCompilerAux' configFlags'
progdb' <- configureAllKnownPrograms verb progdb
withRepoContext verb globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> Platform
-> ProgramDb
-> GlobalFlags
-> ConfigFlags
-> ConfigExFlags
-> InstallFlags
-> HaddockFlags
-> TestFlags
-> BenchmarkFlags
-> [UserTarget]
-> IO ()
install
Verbosity
verb
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
configFlags'))
RepoContext
repoContext
Compiler
comp
Platform
platform
ProgramDb
progdb'
GlobalFlags
globalFlags'
ConfigFlags
configFlags'
ConfigExFlags
configExFlags'
InstallFlags
installFlags'
HaddockFlags
haddockFlags'
TestFlags
testFlags'
BenchmarkFlags
benchmarkFlags'
[UserTarget]
targets
where
maybeForceTests :: InstallFlags -> ConfigFlags -> ConfigFlags
maybeForceTests InstallFlags
installFlags' ConfigFlags
configFlags' =
if Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (InstallFlags -> Flag Bool
installRunTests InstallFlags
installFlags')
then ConfigFlags
configFlags'{configTests = toFlag True}
else ConfigFlags
configFlags'
testAction
:: (BuildFlags, TestFlags)
-> [String]
-> GlobalFlags
-> IO ()
testAction :: (BuildFlags, TestFlags) -> [[Char]] -> GlobalFlags -> IO ()
testAction (BuildFlags
buildFlags, TestFlags
testFlags) [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (CommonSetupFlags -> Flag Verbosity
setupVerbosity (CommonSetupFlags -> Flag Verbosity)
-> CommonSetupFlags -> Flag Verbosity
forall a b. (a -> b) -> a -> b
$ BuildFlags -> CommonSetupFlags
buildCommonFlags BuildFlags
buildFlags)
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config (setupDistPref $ testCommonFlags testFlags)
let buildFlags' =
BuildFlags
buildFlags
{ buildCommonFlags =
(buildCommonFlags buildFlags)
{ setupVerbosity = setupVerbosity $ testCommonFlags testFlags
}
}
checkFlags = (Any -> (ConfigFlags, b) -> IO (Any, (ConfigFlags, b)))
-> Check (ConfigFlags, b)
forall a. (Any -> a -> IO (Any, a)) -> Check a
Check ((Any -> (ConfigFlags, b) -> IO (Any, (ConfigFlags, b)))
-> Check (ConfigFlags, b))
-> (Any -> (ConfigFlags, b) -> IO (Any, (ConfigFlags, b)))
-> Check (ConfigFlags, b)
forall a b. (a -> b) -> a -> b
$ \Any
_ flags :: (ConfigFlags, b)
flags@(ConfigFlags
configFlags, b
configExFlags) ->
if Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (ConfigFlags -> Flag Bool
configTests ConfigFlags
configFlags)
then (Any, (ConfigFlags, b)) -> IO (Any, (ConfigFlags, b))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Any
forall a. Monoid a => a
mempty, (ConfigFlags, b)
flags)
else do
Verbosity -> [Char] -> IO ()
info Verbosity
verbosity [Char]
"reconfiguring to enable tests"
let flags' :: (ConfigFlags, b)
flags' =
( ConfigFlags
configFlags{configTests = toFlag True}
, b
configExFlags
)
(Any, (ConfigFlags, b)) -> IO (Any, (ConfigFlags, b))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool -> Any
Any Bool
True, (ConfigFlags, b)
flags')
_ <-
reconfigure
configureAction
verbosity
distPref
(buildNumJobs buildFlags')
checkFlags
[]
globalFlags
config
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
let setupOptions = SetupScriptOptions
defaultSetupScriptOptions{useDistPref = distPref}
testFlags' =
TestFlags
testFlags
{ testCommonFlags =
(testCommonFlags testFlags){setupDistPref = toFlag distPref}
}
mbWorkDir = Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ TestFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
testWorkingDir TestFlags
testFlags
names <-
componentNamesFromLBI
verbosity
mbWorkDir
distPref
"test suites"
(\Component
c -> case Component
c of LBI.CTest{} -> Bool
True; Component
_ -> Bool
False)
let extraArgs'
| [[Char]] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
extraArgs = case ComponentNames
names of
ComponentNames
ComponentNamesUnknown -> []
ComponentNames [ComponentName]
names' ->
[ UnqualComponentName -> [Char]
Make.unUnqualComponentName UnqualComponentName
name
| LBI.CTestName UnqualComponentName
name <- [ComponentName]
names'
]
| Bool
otherwise = [[Char]]
extraArgs
build verbosity config distPref buildFlags' extraArgs'
setupWrapper
verbosity
setupOptions
Nothing
Cabal.testCommand
Cabal.testCommonFlags
(const (return testFlags'))
(const extraArgs')
data ComponentNames
= ComponentNamesUnknown
| ComponentNames [LBI.ComponentName]
componentNamesFromLBI
:: Verbosity
-> Maybe (SymbolicPath CWD (Dir Pkg))
-> SymbolicPath Pkg (Dir Dist)
-> String
-> (LBI.Component -> Bool)
-> IO ComponentNames
componentNamesFromLBI :: Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> SymbolicPath Pkg ('Dir Dist)
-> [Char]
-> (Component -> Bool)
-> IO ComponentNames
componentNamesFromLBI Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir SymbolicPath Pkg ('Dir Dist)
distPref [Char]
targetsDescr Component -> Bool
compPred = do
eLBI <- Maybe (SymbolicPath CWD ('Dir Pkg))
-> SymbolicPath Pkg ('Dir Dist)
-> IO (Either ConfigStateFileError LocalBuildInfo)
tryGetPersistBuildConfig Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir SymbolicPath Pkg ('Dir Dist)
distPref
case eLBI of
Left ConfigStateFileError
err -> case ConfigStateFileError
err of
ConfigStateFileBadVersion PackageIdentifier
_ PackageIdentifier
_ Either ConfigStateFileError LocalBuildInfo
_ -> ComponentNames -> IO ComponentNames
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ComponentNames
ComponentNamesUnknown
ConfigStateFileError
_ -> Verbosity -> CabalInstallException -> IO ComponentNames
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalInstallException -> IO ComponentNames)
-> CabalInstallException -> IO ComponentNames
forall a b. (a -> b) -> a -> b
$ [Char] -> CabalInstallException
ConfigStateFileException (ConfigStateFileError -> [Char]
forall a. Show a => a -> [Char]
show ConfigStateFileError
err)
Right LocalBuildInfo
lbi -> do
let pkgDescr :: PackageDescription
pkgDescr = LocalBuildInfo -> PackageDescription
LBI.localPkgDescr LocalBuildInfo
lbi
names :: [ComponentName]
names =
(Component -> ComponentName) -> [Component] -> [ComponentName]
forall a b. (a -> b) -> [a] -> [b]
map Component -> ComponentName
LBI.componentName
([Component] -> [ComponentName])
-> ([Component] -> [Component]) -> [Component] -> [ComponentName]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Component -> Bool) -> [Component] -> [Component]
forall a. (a -> Bool) -> [a] -> [a]
filter (BuildInfo -> Bool
buildable (BuildInfo -> Bool)
-> (Component -> BuildInfo) -> Component -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Component -> BuildInfo
LBI.componentBuildInfo)
([Component] -> [Component])
-> ([Component] -> [Component]) -> [Component] -> [Component]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Component -> Bool) -> [Component] -> [Component]
forall a. (a -> Bool) -> [a] -> [a]
filter Component -> Bool
compPred
([Component] -> [ComponentName]) -> [Component] -> [ComponentName]
forall a b. (a -> b) -> a -> b
$ PackageDescription -> [Component]
LBI.pkgComponents PackageDescription
pkgDescr
if [ComponentName] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ComponentName]
names
then do
Verbosity -> [Char] -> IO ()
notice Verbosity
verbosity ([Char] -> IO ()) -> [Char] -> IO ()
forall a b. (a -> b) -> a -> b
$
[Char]
"Package has no buildable "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
targetsDescr
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"."
IO ComponentNames
forall a. IO a
exitSuccess
else ComponentNames -> IO ComponentNames
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (ComponentNames -> IO ComponentNames)
-> ComponentNames -> IO ComponentNames
forall a b. (a -> b) -> a -> b
$! ([ComponentName] -> ComponentNames
ComponentNames [ComponentName]
names)
benchmarkAction
:: (BuildFlags, BenchmarkFlags)
-> [String]
-> GlobalFlags
-> IO ()
benchmarkAction :: (BuildFlags, BenchmarkFlags) -> [[Char]] -> GlobalFlags -> IO ()
benchmarkAction
(BuildFlags
buildFlags, BenchmarkFlags
benchmarkFlags)
[[Char]]
extraArgs
GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity =
Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault
Verbosity
normal
(CommonSetupFlags -> Flag Verbosity
setupVerbosity (CommonSetupFlags -> Flag Verbosity)
-> CommonSetupFlags -> Flag Verbosity
forall a b. (a -> b) -> a -> b
$ BuildFlags -> CommonSetupFlags
buildCommonFlags BuildFlags
buildFlags)
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config (setupDistPref $ benchmarkCommonFlags benchmarkFlags)
let buildFlags' =
BuildFlags
buildFlags
{ buildCommonFlags =
(buildCommonFlags buildFlags)
{ setupVerbosity = setupVerbosity $ benchmarkCommonFlags benchmarkFlags
}
}
let checkFlags = (Any -> (ConfigFlags, b) -> IO (Any, (ConfigFlags, b)))
-> Check (ConfigFlags, b)
forall a. (Any -> a -> IO (Any, a)) -> Check a
Check ((Any -> (ConfigFlags, b) -> IO (Any, (ConfigFlags, b)))
-> Check (ConfigFlags, b))
-> (Any -> (ConfigFlags, b) -> IO (Any, (ConfigFlags, b)))
-> Check (ConfigFlags, b)
forall a b. (a -> b) -> a -> b
$ \Any
_ flags :: (ConfigFlags, b)
flags@(ConfigFlags
configFlags, b
configExFlags) ->
if Bool -> Flag Bool -> Bool
forall a. a -> Flag a -> a
fromFlagOrDefault Bool
False (ConfigFlags -> Flag Bool
configBenchmarks ConfigFlags
configFlags)
then (Any, (ConfigFlags, b)) -> IO (Any, (ConfigFlags, b))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Any
forall a. Monoid a => a
mempty, (ConfigFlags, b)
flags)
else do
Verbosity -> [Char] -> IO ()
info Verbosity
verbosity [Char]
"reconfiguring to enable benchmarks"
let flags' :: (ConfigFlags, b)
flags' =
( ConfigFlags
configFlags{configBenchmarks = toFlag True}
, b
configExFlags
)
(Any, (ConfigFlags, b)) -> IO (Any, (ConfigFlags, b))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool -> Any
Any Bool
True, (ConfigFlags, b)
flags')
config' <-
reconfigure
configureAction
verbosity
distPref
(buildNumJobs buildFlags')
checkFlags
[]
globalFlags
config
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
let setupOptions = SetupScriptOptions
defaultSetupScriptOptions{useDistPref = distPref}
benchmarkFlags' =
BenchmarkFlags
benchmarkFlags
{ benchmarkCommonFlags =
(benchmarkCommonFlags benchmarkFlags)
{ setupDistPref = toFlag distPref
}
}
mbWorkDir = Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ BenchmarkFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
benchmarkWorkingDir BenchmarkFlags
benchmarkFlags
names <-
componentNamesFromLBI
verbosity
mbWorkDir
distPref
"benchmarks"
(\Component
c -> case Component
c of LBI.CBench{} -> Bool
True; Component
_ -> Bool
False)
let extraArgs'
| [[Char]] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
extraArgs = case ComponentNames
names of
ComponentNames
ComponentNamesUnknown -> []
ComponentNames [ComponentName]
names' ->
[ UnqualComponentName -> [Char]
Make.unUnqualComponentName UnqualComponentName
name
| LBI.CBenchName UnqualComponentName
name <- [ComponentName]
names'
]
| Bool
otherwise = [[Char]]
extraArgs
build verbosity config' distPref buildFlags' extraArgs'
setupWrapper
verbosity
setupOptions
Nothing
Cabal.benchmarkCommand
Cabal.benchmarkCommonFlags
(const (return benchmarkFlags'))
(const extraArgs')
haddockAction :: HaddockFlags -> [String] -> Action
haddockAction :: HaddockFlags -> [[Char]] -> GlobalFlags -> IO ()
haddockAction HaddockFlags
haddockFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = HaddockFlags -> CommonSetupFlags
haddockCommonFlags HaddockFlags
haddockFlags
verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config (setupDistPref common)
config' <-
reconfigure
configureAction
verbosity
distPref
NoFlag
mempty
[]
globalFlags
config
let mbWorkDir = Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
setupWorkingDir CommonSetupFlags
common
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
let haddockFlags' =
HaddockFlags
defaultHaddockFlags
HaddockFlags -> HaddockFlags -> HaddockFlags
forall a. Monoid a => a -> a -> a
`mappend` SavedConfig -> HaddockFlags
savedHaddockFlags SavedConfig
config'
HaddockFlags -> HaddockFlags -> HaddockFlags
forall a. Monoid a => a -> a -> a
`mappend` HaddockFlags
haddockFlags
{ haddockCommonFlags =
(haddockCommonFlags haddockFlags)
{ setupDistPref = toFlag distPref
}
}
setupScriptOptions =
SetupScriptOptions
defaultSetupScriptOptions
{ useDistPref = distPref
}
setupWrapper
verbosity
setupScriptOptions
Nothing
haddockCommand
haddockCommonFlags
(const (return haddockFlags'))
(const extraArgs)
when (haddockForHackage haddockFlags == Flag ForHackage) $ do
pkg <- fmap LBI.localPkgDescr (getPersistBuildConfig mbWorkDir distPref)
let dest = SymbolicPath Pkg ('Dir Dist) -> [Char]
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> [Char]
getSymbolicPath SymbolicPath Pkg ('Dir Dist)
distPref [Char] -> [Char] -> [Char]
</> [Char]
name [Char] -> [Char] -> [Char]
<.> [Char]
"tar.gz"
name = PackageIdentifier -> [Char]
forall a. Pretty a => a -> [Char]
display (PackageDescription -> PackageIdentifier
forall pkg. Package pkg => pkg -> PackageIdentifier
packageId PackageDescription
pkg) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"-docs"
docDir = SymbolicPath Pkg ('Dir Dist) -> [Char]
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> [Char]
getSymbolicPath SymbolicPath Pkg ('Dir Dist)
distPref [Char] -> [Char] -> [Char]
</> [Char]
"doc" [Char] -> [Char] -> [Char]
</> [Char]
"html"
createTarGzFile dest docDir name
notice verbosity $ "Documentation tarball created: " ++ dest
cleanAction :: CleanFlags -> [String] -> Action
cleanAction :: CleanFlags -> [[Char]] -> GlobalFlags -> IO ()
cleanAction CleanFlags
cleanFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = CleanFlags -> CommonSetupFlags
cleanCommonFlags CleanFlags
cleanFlags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
load <- IO SavedConfig -> IO (Either SomeException SavedConfig)
forall e a. Exception e => IO a -> IO (Either e a)
try (Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags)
let config = (SomeException -> SavedConfig)
-> (SavedConfig -> SavedConfig)
-> Either SomeException SavedConfig
-> SavedConfig
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(SomeException e
_) -> SavedConfig
forall a. Monoid a => a
mempty) SavedConfig -> SavedConfig
forall a. a -> a
id Either SomeException SavedConfig
load
distPref <- findSavedDistPref config $ setupDistPref common
let setupScriptOptions =
SetupScriptOptions
defaultSetupScriptOptions
{ useDistPref = distPref
, useWin32CleanHack = True
}
cleanFlags' =
CleanFlags
cleanFlags
{ cleanCommonFlags =
(cleanCommonFlags cleanFlags)
{ setupDistPref = toFlag distPref
}
}
setupWrapper
verbosity
setupScriptOptions
Nothing
cleanCommand
cleanCommonFlags
(const (return cleanFlags'))
(const extraArgs)
listAction :: ListFlags -> [String] -> Action
listAction :: ListFlags -> [[Char]] -> GlobalFlags -> IO ()
listAction ListFlags
listFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (ListFlags -> Flag Verbosity
listVerbosity ListFlags
listFlags)
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
let configFlags' = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
configFlags =
ConfigFlags
configFlags'
{ configPackageDBs =
configPackageDBs configFlags'
`mappend` listPackageDBs listFlags
, configHcPath = listHcPath listFlags
}
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
compProgdb <-
if listNeedsCompiler listFlags
then do
(comp, _, progdb) <- configCompilerAux' configFlags
return (Just (comp, progdb))
else return Nothing
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Maybe (Compiler, ProgramDb)
-> ListFlags
-> [[Char]]
-> IO ()
List.list
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
configFlags))
RepoContext
repoContext
Maybe (Compiler, ProgramDb)
compProgdb
ListFlags
listFlags
[[Char]]
extraArgs
infoAction :: InfoFlags -> [String] -> Action
infoAction :: InfoFlags -> [[Char]] -> GlobalFlags -> IO ()
infoAction InfoFlags
infoFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (InfoFlags -> Flag Verbosity
infoVerbosity InfoFlags
infoFlags)
targets <- Verbosity -> [[Char]] -> IO [UserTarget]
readUserTargets Verbosity
verbosity [[Char]]
extraArgs
config <- loadConfigOrSandboxConfig verbosity globalFlags
let configFlags' = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
configFlags =
ConfigFlags
configFlags'
{ configPackageDBs =
configPackageDBs configFlags'
`mappend` infoPackageDBs infoFlags
}
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, _, progdb) <- configCompilerAuxEx configFlags
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> ProgramDb
-> GlobalFlags
-> InfoFlags
-> [UserTarget]
-> IO ()
List.info
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
configFlags))
RepoContext
repoContext
Compiler
comp
ProgramDb
progdb
GlobalFlags
globalFlags'
InfoFlags
infoFlags
[UserTarget]
targets
fetchAction :: FetchFlags -> [String] -> Action
fetchAction :: FetchFlags -> [[Char]] -> GlobalFlags -> IO ()
fetchAction FetchFlags
fetchFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (FetchFlags -> Flag Verbosity
fetchVerbosity FetchFlags
fetchFlags)
targets <- Verbosity -> [[Char]] -> IO [UserTarget]
readUserTargets Verbosity
verbosity [[Char]]
extraArgs
config <- loadConfig verbosity (globalConfigFile globalFlags)
let configFlags = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, platform, progdb) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> Platform
-> ProgramDb
-> GlobalFlags
-> FetchFlags
-> [UserTarget]
-> IO ()
fetch
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
configFlags))
RepoContext
repoContext
Compiler
comp
Platform
platform
ProgramDb
progdb
GlobalFlags
globalFlags'
FetchFlags
fetchFlags
[UserTarget]
targets
freezeAction :: FreezeFlags -> [String] -> Action
freezeAction :: FreezeFlags -> [[Char]] -> GlobalFlags -> IO ()
freezeAction FreezeFlags
freezeFlags [[Char]]
_extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (FreezeFlags -> Flag Verbosity
freezeVerbosity FreezeFlags
freezeFlags)
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config NoFlag
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
let configFlags = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, platform, progdb) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> Platform
-> ProgramDb
-> GlobalFlags
-> FreezeFlags
-> IO ()
freeze
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
configFlags))
RepoContext
repoContext
Compiler
comp
Platform
platform
ProgramDb
progdb
GlobalFlags
globalFlags'
FreezeFlags
freezeFlags
genBoundsAction :: FreezeFlags -> [String] -> GlobalFlags -> IO ()
genBoundsAction :: FreezeFlags -> [[Char]] -> GlobalFlags -> IO ()
genBoundsAction FreezeFlags
freezeFlags [[Char]]
_extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (FreezeFlags -> Flag Verbosity
freezeVerbosity FreezeFlags
freezeFlags)
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config NoFlag
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
let configFlags = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, platform, progdb) <- configCompilerAux' configFlags
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> Platform
-> ProgramDb
-> GlobalFlags
-> FreezeFlags
-> IO ()
genBounds
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
configFlags))
RepoContext
repoContext
Compiler
comp
Platform
platform
ProgramDb
progdb
GlobalFlags
globalFlags'
FreezeFlags
freezeFlags
uploadAction :: UploadFlags -> [String] -> Action
uploadAction :: UploadFlags -> [[Char]] -> GlobalFlags -> IO ()
uploadAction UploadFlags
uploadFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
config <- Verbosity -> Flag [Char] -> IO SavedConfig
loadConfig Verbosity
verbosity (GlobalFlags -> Flag [Char]
globalConfigFile GlobalFlags
globalFlags)
let uploadFlags' = SavedConfig -> UploadFlags
savedUploadFlags SavedConfig
config UploadFlags -> UploadFlags -> UploadFlags
forall a. Monoid a => a -> a -> a
`mappend` UploadFlags
uploadFlags
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
tarfiles = [[Char]]
extraArgs
when (null tarfiles && not (fromFlag (uploadDoc uploadFlags'))) $
dieWithException verbosity UploadAction
checkTarFiles extraArgs
maybe_password <-
case uploadPasswordCmd uploadFlags' of
Flag ([Char]
xs : [[Char]]
xss) ->
Password -> Maybe Password
forall a. a -> Maybe a
Just (Password -> Maybe Password)
-> ([Char] -> Password) -> [Char] -> Maybe Password
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Password
Password
([Char] -> Maybe Password) -> IO [Char] -> IO (Maybe Password)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Verbosity -> ProgramInvocation -> IO [Char]
getProgramInvocationOutput
Verbosity
verbosity
([Char] -> [[Char]] -> ProgramInvocation
simpleProgramInvocation [Char]
xs [[Char]]
xss)
Flag [[Char]]
_ -> Maybe Password -> IO (Maybe Password)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe Password -> IO (Maybe Password))
-> Maybe Password -> IO (Maybe Password)
forall a b. (a -> b) -> a -> b
$ Flag Password -> Maybe Password
forall a. Flag a -> Maybe a
flagToMaybe (Flag Password -> Maybe Password)
-> Flag Password -> Maybe Password
forall a b. (a -> b) -> a -> b
$ UploadFlags -> Flag Password
uploadPassword UploadFlags
uploadFlags'
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext -> do
if Flag Bool -> Bool
forall a. WithCallStack (Flag a -> a)
fromFlag (UploadFlags -> Flag Bool
uploadDoc UploadFlags
uploadFlags')
then do
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([[Char]] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [[Char]]
tarfiles Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity CabalInstallException
UploadActionDocumentation
tarfile <- IO [Char] -> ([Char] -> IO [Char]) -> Maybe [Char] -> IO [Char]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (SavedConfig -> IO [Char]
generateDocTarball SavedConfig
config) [Char] -> IO [Char]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe [Char] -> IO [Char]) -> Maybe [Char] -> IO [Char]
forall a b. (a -> b) -> a -> b
$ [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
listToMaybe [[Char]]
tarfiles
Upload.uploadDoc
verbosity
repoContext
(flagToMaybe $ uploadToken uploadFlags')
(flagToMaybe $ uploadUsername uploadFlags')
maybe_password
(fromFlag (uploadCandidate uploadFlags'))
tarfile
else do
Verbosity
-> RepoContext
-> Maybe Token
-> Maybe Username
-> Maybe Password
-> IsCandidate
-> [[Char]]
-> IO ()
Upload.upload
Verbosity
verbosity
RepoContext
repoContext
(Flag Token -> Maybe Token
forall a. Flag a -> Maybe a
flagToMaybe (Flag Token -> Maybe Token) -> Flag Token -> Maybe Token
forall a b. (a -> b) -> a -> b
$ UploadFlags -> Flag Token
uploadToken UploadFlags
uploadFlags')
(Flag Username -> Maybe Username
forall a. Flag a -> Maybe a
flagToMaybe (Flag Username -> Maybe Username)
-> Flag Username -> Maybe Username
forall a b. (a -> b) -> a -> b
$ UploadFlags -> Flag Username
uploadUsername UploadFlags
uploadFlags')
Maybe Password
maybe_password
(Flag IsCandidate -> IsCandidate
forall a. WithCallStack (Flag a -> a)
fromFlag (UploadFlags -> Flag IsCandidate
uploadCandidate UploadFlags
uploadFlags'))
[[Char]]
tarfiles
where
verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (UploadFlags -> Flag Verbosity
uploadVerbosity UploadFlags
uploadFlags)
checkTarFiles :: [[Char]] -> IO ()
checkTarFiles [[Char]]
tarfiles
| Bool -> Bool
not ([[Char]] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
otherFiles) =
Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalInstallException -> IO ()) -> CabalInstallException -> IO ()
forall a b. (a -> b) -> a -> b
$ [[Char]] -> CabalInstallException
UploadActionOnlyArchives [[Char]]
otherFiles
| Bool
otherwise =
[IO ()] -> IO ()
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
[ do
exists <- [Char] -> IO Bool
doesFileExist [Char]
tarfile
unless exists $ dieWithException verbosity $ FileNotFound tarfile
| [Char]
tarfile <- [[Char]]
tarfiles
]
where
otherFiles :: [[Char]]
otherFiles = ([Char] -> Bool) -> [[Char]] -> [[Char]]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ([Char] -> Bool) -> [Char] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Bool
isTarGzFile) [[Char]]
tarfiles
isTarGzFile :: [Char] -> Bool
isTarGzFile [Char]
file = case [Char] -> ([Char], [Char])
splitExtension [Char]
file of
([Char]
file', [Char]
".gz") -> [Char] -> [Char]
takeExtension [Char]
file' [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
".tar"
([Char], [Char])
_ -> Bool
False
generateDocTarball :: SavedConfig -> IO [Char]
generateDocTarball SavedConfig
config = do
Verbosity -> [Char] -> IO ()
notice Verbosity
verbosity ([Char] -> IO ()) -> [Char] -> IO ()
forall a b. (a -> b) -> a -> b
$
[Char]
"No documentation tarball specified. "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"Building a documentation tarball with default settings...\n"
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"If you need to customise Haddock options, "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"run 'haddock --for-hackage' first "
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"to generate a documentation tarball."
HaddockFlags -> [[Char]] -> GlobalFlags -> IO ()
haddockAction
(HaddockFlags
defaultHaddockFlags{haddockForHackage = Flag ForHackage})
[]
GlobalFlags
globalFlags
distPref <- SavedConfig
-> Flag (SymbolicPath Pkg ('Dir Dist))
-> IO (SymbolicPath Pkg ('Dir Dist))
findSavedDistPref SavedConfig
config Flag (SymbolicPath Pkg ('Dir Dist))
forall a. Last a
NoFlag
let mbWorkDir = Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ ConfigFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
configWorkingDir (ConfigFlags -> Flag (SymbolicPath CWD ('Dir Pkg)))
-> ConfigFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
config
pkg <- fmap LBI.localPkgDescr (getPersistBuildConfig mbWorkDir distPref)
return $ getSymbolicPath distPref </> display (packageId pkg) ++ "-docs" <.> "tar.gz"
checkAction :: CheckFlags -> [String] -> Action
checkAction :: CheckFlags -> [[Char]] -> GlobalFlags -> IO ()
checkAction CheckFlags
checkFlags [[Char]]
extraArgs GlobalFlags
_globalFlags = do
let verbosityFlag :: Flag Verbosity
verbosityFlag = CheckFlags -> Flag Verbosity
checkVerbosity CheckFlags
checkFlags
verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag Flag Verbosity
verbosityFlag
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([[Char]] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
extraArgs) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalInstallException -> IO ()) -> CabalInstallException -> IO ()
forall a b. (a -> b) -> a -> b
$
[[Char]] -> CabalInstallException
CheckAction [[Char]]
extraArgs
allOk <- Verbosity -> [[Char]] -> IO Bool
Check.check (Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag Flag Verbosity
verbosityFlag) (CheckFlags -> [[Char]]
checkIgnore CheckFlags
checkFlags)
unless allOk exitFailure
formatAction :: Flag Verbosity -> [String] -> Action
formatAction :: Flag Verbosity -> [[Char]] -> GlobalFlags -> IO ()
formatAction Flag Verbosity
verbosityFlag [[Char]]
extraArgs GlobalFlags
_globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag Flag Verbosity
verbosityFlag
Verbosity -> [Char] -> IO ()
warn Verbosity
verbosity [Char]
"This command is not a full formatter yet"
path <- case [[Char]]
extraArgs of
[] -> RelativePath Pkg 'File -> SymbolicPathX 'AllowAbsolute Pkg 'File
forall from (to :: FileOrDir).
RelativePath from to -> SymbolicPath from to
relativeSymbolicPath (RelativePath Pkg 'File -> SymbolicPathX 'AllowAbsolute Pkg 'File)
-> IO (RelativePath Pkg 'File)
-> IO (SymbolicPathX 'AllowAbsolute Pkg 'File)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> IO (RelativePath Pkg 'File)
tryFindPackageDesc Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing
([Char]
p : [[Char]]
_) -> SymbolicPathX 'AllowAbsolute Pkg 'File
-> IO (SymbolicPathX 'AllowAbsolute Pkg 'File)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (SymbolicPathX 'AllowAbsolute Pkg 'File
-> IO (SymbolicPathX 'AllowAbsolute Pkg 'File))
-> SymbolicPathX 'AllowAbsolute Pkg 'File
-> IO (SymbolicPathX 'AllowAbsolute Pkg 'File)
forall a b. (a -> b) -> a -> b
$ [Char] -> SymbolicPathX 'AllowAbsolute Pkg 'File
forall from (to :: FileOrDir). [Char] -> SymbolicPath from to
makeSymbolicPath [Char]
p
pkgDesc <- readGenericPackageDescription verbosity Nothing path
writeGenericPackageDescription (getSymbolicPath path) pkgDesc
reportAction :: ReportFlags -> [String] -> Action
reportAction :: ReportFlags -> [[Char]] -> GlobalFlags -> IO ()
reportAction ReportFlags
reportFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (ReportFlags -> Flag Verbosity
reportVerbosity ReportFlags
reportFlags)
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([[Char]] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
extraArgs) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalInstallException -> IO ()) -> CabalInstallException -> IO ()
forall a b. (a -> b) -> a -> b
$
[[Char]] -> CabalInstallException
ReportAction [[Char]]
extraArgs
config <- Verbosity -> Flag [Char] -> IO SavedConfig
loadConfig Verbosity
verbosity (GlobalFlags -> Flag [Char]
globalConfigFile GlobalFlags
globalFlags)
let globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
reportFlags' = SavedConfig -> ReportFlags
savedReportFlags SavedConfig
config ReportFlags -> ReportFlags -> ReportFlags
forall a. Monoid a => a -> a -> a
`mappend` ReportFlags
reportFlags
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> RepoContext
-> Maybe Token
-> Maybe Username
-> Maybe Password
-> IO ()
Upload.report
Verbosity
verbosity
RepoContext
repoContext
(Flag Token -> Maybe Token
forall a. Flag a -> Maybe a
flagToMaybe (Flag Token -> Maybe Token) -> Flag Token -> Maybe Token
forall a b. (a -> b) -> a -> b
$ ReportFlags -> Flag Token
reportToken ReportFlags
reportFlags')
(Flag Username -> Maybe Username
forall a. Flag a -> Maybe a
flagToMaybe (Flag Username -> Maybe Username)
-> Flag Username -> Maybe Username
forall a b. (a -> b) -> a -> b
$ ReportFlags -> Flag Username
reportUsername ReportFlags
reportFlags')
(Flag Password -> Maybe Password
forall a. Flag a -> Maybe a
flagToMaybe (Flag Password -> Maybe Password)
-> Flag Password -> Maybe Password
forall a b. (a -> b) -> a -> b
$ ReportFlags -> Flag Password
reportPassword ReportFlags
reportFlags')
runAction :: BuildFlags -> [String] -> Action
runAction :: BuildFlags -> [[Char]] -> GlobalFlags -> IO ()
runAction BuildFlags
buildFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let common :: CommonSetupFlags
common = BuildFlags -> CommonSetupFlags
buildCommonFlags BuildFlags
buildFlags
verbosity :: Verbosity
verbosity = Verbosity -> Flag Verbosity -> Verbosity
forall a. a -> Flag a -> a
fromFlagOrDefault Verbosity
normal (Flag Verbosity -> Verbosity) -> Flag Verbosity -> Verbosity
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag Verbosity
setupVerbosity CommonSetupFlags
common
config <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
distPref <- findSavedDistPref config $ setupDistPref common
config' <-
reconfigure
configureAction
verbosity
distPref
(buildNumJobs buildFlags)
mempty
[]
globalFlags
config
let mbWorkDir = Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a b. (a -> b) -> a -> b
$ CommonSetupFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
setupWorkingDir CommonSetupFlags
common
nixShell verbosity (getSymbolicPath distPref) globalFlags config $ do
lbi <- getPersistBuildConfig mbWorkDir distPref
(exe, exeArgs) <- splitRunArgs verbosity lbi extraArgs
build verbosity config' distPref buildFlags ["exe:" ++ display (exeName exe)]
run verbosity lbi exe exeArgs
getAction :: GetFlags -> [String] -> Action
getAction :: GetFlags -> [[Char]] -> GlobalFlags -> IO ()
getAction GetFlags
getFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (GetFlags -> Flag Verbosity
getVerbosity GetFlags
getFlags)
targets <- Verbosity -> [[Char]] -> IO [UserTarget]
readUserTargets Verbosity
verbosity [[Char]]
extraArgs
config <- loadConfigOrSandboxConfig verbosity globalFlags
let globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
config GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
withRepoContext verbosity (savedGlobalFlags config) $ \RepoContext
repoContext ->
Verbosity
-> RepoContext -> GlobalFlags -> GetFlags -> [UserTarget] -> IO ()
get
Verbosity
verbosity
RepoContext
repoContext
GlobalFlags
globalFlags'
GetFlags
getFlags
[UserTarget]
targets
unpackAction :: GetFlags -> [String] -> Action
unpackAction :: GetFlags -> [[Char]] -> GlobalFlags -> IO ()
unpackAction GetFlags
getFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
GetFlags -> [[Char]] -> GlobalFlags -> IO ()
getAction GetFlags
getFlags [[Char]]
extraArgs GlobalFlags
globalFlags
initAction :: InitFlags -> [String] -> Action
initAction :: InitFlags -> [[Char]] -> GlobalFlags -> IO ()
initAction InitFlags
initFlags [[Char]]
extraArgs GlobalFlags
globalFlags = do
case [[Char]]
extraArgs of
[] -> IO ()
initAction'
[[Char]
projectDir] -> do
Verbosity -> Bool -> [Char] -> IO ()
createDirectoryIfMissingVerbose Verbosity
verbosity Bool
True [Char]
projectDir
[Char] -> IO () -> IO ()
forall a. [Char] -> IO a -> IO a
withCurrentDirectory [Char]
projectDir IO ()
initAction'
[[Char]]
_ -> Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity CabalInstallException
InitAction
where
initAction' :: IO ()
initAction' = do
confFlags <- Verbosity -> GlobalFlags -> IO SavedConfig
loadConfigOrSandboxConfig Verbosity
verbosity GlobalFlags
globalFlags
let confFlags' = SavedConfig -> ConfigFlags
savedConfigureFlags SavedConfig
confFlags ConfigFlags -> ConfigFlags -> ConfigFlags
forall a. Monoid a => a -> a -> a
`mappend` ConfigFlags
compFlags
initFlags' = SavedConfig -> InitFlags
savedInitFlags SavedConfig
confFlags InitFlags -> InitFlags -> InitFlags
forall a. Monoid a => a -> a -> a
`mappend` InitFlags
initFlags
globalFlags' = SavedConfig -> GlobalFlags
savedGlobalFlags SavedConfig
confFlags GlobalFlags -> GlobalFlags -> GlobalFlags
forall a. Monoid a => a -> a -> a
`mappend` GlobalFlags
globalFlags
(comp, _, progdb) <- configCompilerAux' confFlags'
withRepoContext verbosity globalFlags' $ \RepoContext
repoContext ->
Verbosity
-> PackageDBStackCWD
-> RepoContext
-> Compiler
-> ProgramDb
-> InitFlags
-> IO ()
initCmd
Verbosity
verbosity
(Maybe (SymbolicPath CWD ('Dir Pkg))
-> PackageDBStack -> PackageDBStackCWD
interpretPackageDBStack Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Maybe a
Nothing (ConfigFlags -> PackageDBStack
configPackageDB' ConfigFlags
confFlags'))
RepoContext
repoContext
Compiler
comp
ProgramDb
progdb
InitFlags
initFlags'
verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (InitFlags -> Flag Verbosity
initVerbosity InitFlags
initFlags)
compFlags :: ConfigFlags
compFlags = ConfigFlags
forall a. Monoid a => a
mempty{configHcPath = initHcPath initFlags}
userConfigAction :: UserConfigFlags -> [String] -> Action
userConfigAction :: UserConfigFlags -> [[Char]] -> GlobalFlags -> IO ()
userConfigAction UserConfigFlags
ucflags [[Char]]
extraArgs GlobalFlags
globalFlags = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (UserConfigFlags -> Flag Verbosity
userConfigVerbosity UserConfigFlags
ucflags)
frc :: Bool
frc = Flag Bool -> Bool
forall a. WithCallStack (Flag a -> a)
fromFlag (UserConfigFlags -> Flag Bool
userConfigForce UserConfigFlags
ucflags)
extraLines :: [[Char]]
extraLines = Flag [[Char]] -> [[Char]]
forall a. WithCallStack (Flag a -> a)
fromFlag (UserConfigFlags -> Flag [[Char]]
userConfigAppendLines UserConfigFlags
ucflags)
case [[Char]]
extraArgs of
([Char]
"init" : [[Char]]
_) -> do
path <- IO [Char]
configFile
fileExists <- doesFileExist path
if (not fileExists || (fileExists && frc))
then void $ createDefaultConfigFile verbosity extraLines path
else dieWithException verbosity $ UserConfigAction path
([Char]
"diff" : [[Char]]
_) -> ([Char] -> IO ()) -> [[Char]] -> IO ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ [Char] -> IO ()
putStrLn ([[Char]] -> IO ()) -> IO [[Char]] -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Verbosity -> GlobalFlags -> [[Char]] -> IO [[Char]]
userConfigDiff Verbosity
verbosity GlobalFlags
globalFlags [[Char]]
extraLines
([Char]
"update" : [[Char]]
_) -> Verbosity -> GlobalFlags -> [[Char]] -> IO ()
userConfigUpdate Verbosity
verbosity GlobalFlags
globalFlags [[Char]]
extraLines
[] -> Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity CabalInstallException
SpecifySubcommand
[[Char]]
_ -> Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalInstallException -> IO ()) -> CabalInstallException -> IO ()
forall a b. (a -> b) -> a -> b
$ [[Char]] -> CabalInstallException
UnknownUserConfigSubcommand [[Char]]
extraArgs
where
configFile :: IO [Char]
configFile = Flag [Char] -> IO [Char]
getConfigFilePath (GlobalFlags -> Flag [Char]
globalConfigFile GlobalFlags
globalFlags)
actAsSetupAction :: ActAsSetupFlags -> [String] -> Action
actAsSetupAction :: ActAsSetupFlags -> [[Char]] -> GlobalFlags -> IO ()
actAsSetupAction ActAsSetupFlags
actAsSetupFlags [[Char]]
args GlobalFlags
_globalFlags =
let bt :: BuildType
bt = Flag BuildType -> BuildType
forall a. WithCallStack (Flag a -> a)
fromFlag (ActAsSetupFlags -> Flag BuildType
actAsSetupBuildType ActAsSetupFlags
actAsSetupFlags)
in case BuildType
bt of
BuildType
Simple -> [[Char]] -> IO ()
Simple.defaultMainArgs [[Char]]
args
BuildType
Configure ->
SetupHooks -> [[Char]] -> IO ()
Simple.defaultMainWithSetupHooksArgs
SetupHooks
Simple.autoconfSetupHooks
[[Char]]
args
BuildType
Make -> [[Char]] -> IO ()
Make.defaultMainArgs [[Char]]
args
BuildType
Hooks -> [Char] -> IO ()
forall a. HasCallStack => [Char] -> a
error [Char]
"actAsSetupAction Hooks"
BuildType
Custom -> [Char] -> IO ()
forall a. HasCallStack => [Char] -> a
error [Char]
"actAsSetupAction Custom"
manpageAction :: [CommandSpec action] -> ManpageFlags -> [String] -> Action
manpageAction :: forall action.
[CommandSpec action]
-> ManpageFlags -> [[Char]] -> GlobalFlags -> IO ()
manpageAction [CommandSpec action]
commands ManpageFlags
flags [[Char]]
extraArgs GlobalFlags
_ = do
let verbosity :: Verbosity
verbosity = Flag Verbosity -> Verbosity
forall a. WithCallStack (Flag a -> a)
fromFlag (ManpageFlags -> Flag Verbosity
manpageVerbosity ManpageFlags
flags)
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([[Char]] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
extraArgs) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
Verbosity -> CabalInstallException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalInstallException -> IO ()) -> CabalInstallException -> IO ()
forall a b. (a -> b) -> a -> b
$
[[Char]] -> CabalInstallException
ManpageAction [[Char]]
extraArgs
pname <- IO [Char]
getProgName
let cabalCmd =
if [Char] -> [Char]
takeExtension [Char]
pname [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
".exe"
then [Char] -> [Char]
dropExtension [Char]
pname
else [Char]
pname
manpageCmd cabalCmd commands flags