{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.Simple.Program
(
Program (..)
, ProgramSearchPath
, ProgramSearchPathEntry (..)
, simpleProgram
, findProgramOnSearchPath
, defaultProgramSearchPath
, findProgramVersion
, ConfiguredProgram (..)
, programPath
, ProgArg
, ProgramLocation (..)
, runProgram
, runProgramCwd
, getProgramOutput
, suppressOverrideArgs
, ProgramInvocation (..)
, emptyProgramInvocation
, simpleProgramInvocation
, programInvocation
, runProgramInvocation
, getProgramInvocationOutput
, getProgramInvocationLBS
, builtinPrograms
, ProgramDb
, defaultProgramDb
, emptyProgramDb
, restoreProgramDb
, addKnownProgram
, addKnownPrograms
, lookupKnownProgram
, knownPrograms
, getProgramSearchPath
, setProgramSearchPath
, userSpecifyPath
, userSpecifyPaths
, userMaybeSpecifyPath
, userSpecifyArgs
, userSpecifyArgss
, userSpecifiedArgs
, lookupProgram
, lookupProgramVersion
, updateProgram
, configureProgram
, configureAllKnownPrograms
, reconfigurePrograms
, requireProgram
, requireProgramVersion
, needProgram
, runDbProgram
, runDbProgramCwd
, getDbProgramOutput
, getDbProgramOutputCwd
, ghcProgram
, ghcPkgProgram
, ghcjsProgram
, ghcjsPkgProgram
, hmakeProgram
, jhcProgram
, uhcProgram
, gccProgram
, arProgram
, stripProgram
, happyProgram
, alexProgram
, hsc2hsProgram
, c2hsProgram
, cpphsProgram
, hscolourProgram
, doctestProgram
, haddockProgram
, greencardProgram
, ldProgram
, tarProgram
, cppProgram
, pkgConfigProgram
, hpcProgram
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Simple.Errors
import Distribution.Simple.Program.Builtin
import Distribution.Simple.Program.Db
import Distribution.Simple.Program.Find
import Distribution.Simple.Program.Run
import Distribution.Simple.Program.Types
import Distribution.Simple.Utils
import Distribution.Utils.Path
import Distribution.Verbosity
runProgram
:: Verbosity
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
runProgram Verbosity
verbosity ConfiguredProgram
prog [ProgArg]
args =
Verbosity -> ProgramInvocation -> IO ()
runProgramInvocation Verbosity
verbosity (ConfiguredProgram -> [ProgArg] -> ProgramInvocation
programInvocation ConfiguredProgram
prog [ProgArg]
args)
runProgramCwd
:: Verbosity
-> Maybe (SymbolicPath CWD (Dir to))
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
runProgramCwd :: forall to.
Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
runProgramCwd Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir to))
mbWorkDir ConfiguredProgram
prog [ProgArg]
args =
Verbosity -> ProgramInvocation -> IO ()
runProgramInvocation Verbosity
verbosity (Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram -> [ProgArg] -> ProgramInvocation
forall to.
Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram -> [ProgArg] -> ProgramInvocation
programInvocationCwd Maybe (SymbolicPath CWD ('Dir to))
mbWorkDir ConfiguredProgram
prog [ProgArg]
args)
getProgramOutput
:: Verbosity
-> ConfiguredProgram
-> [ProgArg]
-> IO String
getProgramOutput :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ProgArg
getProgramOutput Verbosity
verbosity ConfiguredProgram
prog [ProgArg]
args =
Verbosity -> ProgramInvocation -> IO ProgArg
getProgramInvocationOutput Verbosity
verbosity (ConfiguredProgram -> [ProgArg] -> ProgramInvocation
programInvocation ConfiguredProgram
prog [ProgArg]
args)
runDbProgram
:: Verbosity
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ()
runDbProgram :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()
runDbProgram Verbosity
verbosity Program
prog ProgramDb
progDb [ProgArg]
args =
Verbosity
-> Maybe (SymbolicPath CWD ('Dir (ZonkAny 1)))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ()
forall to.
Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ()
runDbProgramCwd Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir (ZonkAny 1)))
forall a. Maybe a
Nothing Program
prog ProgramDb
progDb [ProgArg]
args
runDbProgramCwd
:: Verbosity
-> Maybe (SymbolicPath CWD (Dir to))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ()
runDbProgramCwd :: forall to.
Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ()
runDbProgramCwd Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir to))
mbWorkDir Program
prog ProgramDb
programDb [ProgArg]
args =
case Program -> ProgramDb -> Maybe ConfiguredProgram
lookupProgram Program
prog ProgramDb
programDb of
Maybe ConfiguredProgram
Nothing ->
Verbosity -> CabalException -> IO ()
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalException -> IO ()) -> CabalException -> IO ()
forall a b. (a -> b) -> a -> b
$ ProgArg -> CabalException
ProgramNotFound (Program -> ProgArg
programName Program
prog)
Just ConfiguredProgram
configuredProg -> Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
forall to.
Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
runProgramCwd Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir to))
mbWorkDir ConfiguredProgram
configuredProg [ProgArg]
args
getDbProgramOutput
:: Verbosity
-> Program
-> ProgramDb
-> [ProgArg]
-> IO String
getDbProgramOutput :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ProgArg
getDbProgramOutput Verbosity
verb Program
prog ProgramDb
progDb [ProgArg]
args =
Verbosity
-> Maybe (SymbolicPath CWD ('Dir (ZonkAny 0)))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ProgArg
forall to.
Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ProgArg
getDbProgramOutputCwd Verbosity
verb Maybe (SymbolicPath CWD ('Dir (ZonkAny 0)))
forall a. Maybe a
Nothing Program
prog ProgramDb
progDb [ProgArg]
args
getDbProgramOutputCwd
:: Verbosity
-> Maybe (SymbolicPath CWD (Dir to))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO String
getDbProgramOutputCwd :: forall to.
Verbosity
-> Maybe (SymbolicPath CWD ('Dir to))
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ProgArg
getDbProgramOutputCwd Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir to))
mbWorkDir Program
prog ProgramDb
programDb [ProgArg]
args =
case Program -> ProgramDb -> Maybe ConfiguredProgram
lookupProgram Program
prog ProgramDb
programDb of
Maybe ConfiguredProgram
Nothing -> Verbosity -> CabalException -> IO ProgArg
forall a1 a.
(HasCallStack, Show a1, Typeable a1,
Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalException -> IO ProgArg) -> CabalException -> IO ProgArg
forall a b. (a -> b) -> a -> b
$ ProgArg -> CabalException
ProgramNotFound (Program -> ProgArg
programName Program
prog)
Just ConfiguredProgram
configuredProg ->
Verbosity -> ProgramInvocation -> IO ProgArg
getProgramInvocationOutput Verbosity
verbosity (ProgramInvocation -> IO ProgArg)
-> ProgramInvocation -> IO ProgArg
forall a b. (a -> b) -> a -> b
$
Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram -> [ProgArg] -> ProgramInvocation
forall to.
Maybe (SymbolicPath CWD ('Dir to))
-> ConfiguredProgram -> [ProgArg] -> ProgramInvocation
programInvocationCwd Maybe (SymbolicPath CWD ('Dir to))
mbWorkDir ConfiguredProgram
configuredProg [ProgArg]
args