{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.Simple.Program (
Program(..)
, ProgramSearchPath
, ProgramSearchPathEntry(..)
, simpleProgram
, findProgramOnSearchPath
, defaultProgramSearchPath
, findProgramVersion
, ConfiguredProgram(..)
, programPath
, ProgArg
, ProgramLocation(..)
, runProgram
, getProgramOutput
, suppressOverrideArgs
, ProgramInvocation(..)
, emptyProgramInvocation
, simpleProgramInvocation
, programInvocation
, runProgramInvocation
, getProgramInvocationOutput
, 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
, runDbProgram
, getDbProgramOutput
, ghcProgram
, ghcPkgProgram
, ghcjsProgram
, ghcjsPkgProgram
, hmakeProgram
, jhcProgram
, uhcProgram
, gccProgram
, arProgram
, stripProgram
, happyProgram
, alexProgram
, hsc2hsProgram
, c2hsProgram
, cpphsProgram
, hscolourProgram
, doctestProgram
, haddockProgram
, greencardProgram
, ldProgram
, tarProgram
, cppProgram
, pkgConfigProgram
, hpcProgram
, ProgramConfiguration
, emptyProgramConfiguration
, defaultProgramConfiguration
, restoreProgramConfiguration
, rawSystemProgram
, rawSystemProgramStdout
, rawSystemProgramConf
, rawSystemProgramStdoutConf
, findProgramOnPath
, findProgramLocation
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Simple.Program.Types
import Distribution.Simple.Program.Run
import Distribution.Simple.Program.Db
import Distribution.Simple.Program.Builtin
import Distribution.Simple.Program.Find
import Distribution.Simple.Utils
import Distribution.Verbosity
runProgram :: Verbosity
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
runProgram verbosity :: Verbosity
verbosity prog :: ConfiguredProgram
prog args :: [ProgArg]
args =
Verbosity -> ProgramInvocation -> IO ()
runProgramInvocation Verbosity
verbosity (ConfiguredProgram -> [ProgArg] -> ProgramInvocation
programInvocation ConfiguredProgram
prog [ProgArg]
args)
getProgramOutput :: Verbosity
-> ConfiguredProgram
-> [ProgArg]
-> IO String
getProgramOutput :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ProgArg
getProgramOutput verbosity :: Verbosity
verbosity prog :: ConfiguredProgram
prog args :: [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
verbosity prog :: Program
prog programDb :: ProgramDb
programDb args :: [ProgArg]
args =
case Program -> ProgramDb -> Maybe ConfiguredProgram
lookupProgram Program
prog ProgramDb
programDb of
Nothing -> Verbosity -> ProgArg -> IO ()
forall a. Verbosity -> ProgArg -> IO a
die' Verbosity
verbosity ProgArg
notFound
Just configuredProg :: ConfiguredProgram
configuredProg -> Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
runProgram Verbosity
verbosity ConfiguredProgram
configuredProg [ProgArg]
args
where
notFound :: ProgArg
notFound = "The program '" ProgArg -> ProgArg -> ProgArg
forall a. [a] -> [a] -> [a]
++ Program -> ProgArg
programName Program
prog
ProgArg -> ProgArg -> ProgArg
forall a. [a] -> [a] -> [a]
++ "' is required but it could not be found"
getDbProgramOutput :: Verbosity
-> Program
-> ProgramDb
-> [ProgArg]
-> IO String
getDbProgramOutput :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ProgArg
getDbProgramOutput verbosity :: Verbosity
verbosity prog :: Program
prog programDb :: ProgramDb
programDb args :: [ProgArg]
args =
case Program -> ProgramDb -> Maybe ConfiguredProgram
lookupProgram Program
prog ProgramDb
programDb of
Nothing -> Verbosity -> ProgArg -> IO ProgArg
forall a. Verbosity -> ProgArg -> IO a
die' Verbosity
verbosity ProgArg
notFound
Just configuredProg :: ConfiguredProgram
configuredProg -> Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ProgArg
getProgramOutput Verbosity
verbosity ConfiguredProgram
configuredProg [ProgArg]
args
where
notFound :: ProgArg
notFound = "The program '" ProgArg -> ProgArg -> ProgArg
forall a. [a] -> [a] -> [a]
++ Program -> ProgArg
programName Program
prog
ProgArg -> ProgArg -> ProgArg
forall a. [a] -> [a] -> [a]
++ "' is required but it could not be found"
{-# DEPRECATED rawSystemProgram "use runProgram instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
rawSystemProgram :: Verbosity -> ConfiguredProgram
-> [ProgArg] -> IO ()
rawSystemProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
rawSystemProgram = Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
runProgram
{-# DEPRECATED rawSystemProgramStdout "use getProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
rawSystemProgramStdout :: Verbosity -> ConfiguredProgram
-> [ProgArg] -> IO String
rawSystemProgramStdout :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ProgArg
rawSystemProgramStdout = Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ProgArg
Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ProgArg
getProgramOutput
{-# DEPRECATED rawSystemProgramConf "use runDbProgram instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration
-> [ProgArg] -> IO ()
rawSystemProgramConf :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()
rawSystemProgramConf = Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()
Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()
runDbProgram
{-# DEPRECATED rawSystemProgramStdoutConf "use getDbProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration
-> [ProgArg] -> IO String
rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ProgArg
rawSystemProgramStdoutConf = Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ProgArg
Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ProgArg
getDbProgramOutput
{-# DEPRECATED ProgramConfiguration "use ProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
type ProgramConfiguration = ProgramDb
{-# DEPRECATED emptyProgramConfiguration "use emptyProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
{-# DEPRECATED defaultProgramConfiguration "use defaultProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
emptyProgramConfiguration, defaultProgramConfiguration :: ProgramConfiguration
emptyProgramConfiguration :: ProgramDb
emptyProgramConfiguration = ProgramDb
emptyProgramDb
defaultProgramConfiguration :: ProgramDb
defaultProgramConfiguration = ProgramDb
defaultProgramDb
{-# DEPRECATED restoreProgramConfiguration "use restoreProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
restoreProgramConfiguration :: [Program] -> ProgramConfiguration
-> ProgramConfiguration
restoreProgramConfiguration :: [Program] -> ProgramDb -> ProgramDb
restoreProgramConfiguration = [Program] -> ProgramDb -> ProgramDb
restoreProgramDb
{-# DEPRECATED findProgramOnPath "use findProgramOnSearchPath instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-}
findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath)
findProgramOnPath :: ProgArg -> Verbosity -> IO (Maybe ProgArg)
findProgramOnPath name :: ProgArg
name verbosity :: Verbosity
verbosity =
(Maybe (ProgArg, [ProgArg]) -> Maybe ProgArg)
-> IO (Maybe (ProgArg, [ProgArg])) -> IO (Maybe ProgArg)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((ProgArg, [ProgArg]) -> ProgArg)
-> Maybe (ProgArg, [ProgArg]) -> Maybe ProgArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ProgArg, [ProgArg]) -> ProgArg
forall a b. (a, b) -> a
fst) (IO (Maybe (ProgArg, [ProgArg])) -> IO (Maybe ProgArg))
-> IO (Maybe (ProgArg, [ProgArg])) -> IO (Maybe ProgArg)
forall a b. (a -> b) -> a -> b
$
Verbosity
-> ProgramSearchPath -> ProgArg -> IO (Maybe (ProgArg, [ProgArg]))
findProgramOnSearchPath Verbosity
verbosity ProgramSearchPath
defaultProgramSearchPath ProgArg
name