module Distribution.Simple.Program (
Program(..)
, simpleProgram
, findProgramLocation
, findProgramVersion
, ConfiguredProgram(..)
, programPath
, ProgArg
, ProgramLocation(..)
, runProgram
, getProgramOutput
, ProgramInvocation(..)
, emptyProgramInvocation
, simpleProgramInvocation
, programInvocation
, runProgramInvocation
, getProgramInvocationOutput
, builtinPrograms
, ProgramConfiguration
, emptyProgramConfiguration
, defaultProgramConfiguration
, restoreProgramConfiguration
, addKnownProgram
, addKnownPrograms
, lookupKnownProgram
, knownPrograms
, userSpecifyPath
, userSpecifyPaths
, userMaybeSpecifyPath
, userSpecifyArgs
, userSpecifyArgss
, userSpecifiedArgs
, lookupProgram
, updateProgram
, configureProgram
, configureAllKnownPrograms
, reconfigurePrograms
, requireProgram
, requireProgramVersion
, runDbProgram
, getDbProgramOutput
, ghcProgram
, ghcPkgProgram
, lhcProgram
, lhcPkgProgram
, nhcProgram
, hmakeProgram
, jhcProgram
, hugsProgram
, ffihugsProgram
, uhcProgram
, gccProgram
, ranlibProgram
, arProgram
, stripProgram
, happyProgram
, alexProgram
, hsc2hsProgram
, c2hsProgram
, cpphsProgram
, hscolourProgram
, haddockProgram
, greencardProgram
, ldProgram
, tarProgram
, cppProgram
, pkgConfigProgram
, rawSystemProgram
, rawSystemProgramStdout
, rawSystemProgramConf
, rawSystemProgramStdoutConf
, findProgramOnPath
) where
import Distribution.Simple.Program.Types
import Distribution.Simple.Program.Run
import Distribution.Simple.Program.Db
import Distribution.Simple.Program.Builtin
import Distribution.Simple.Utils
( die, findProgramLocation, findProgramVersion )
import Distribution.Verbosity
( Verbosity )
runProgram :: Verbosity
-> ConfiguredProgram
-> [ProgArg]
-> IO ()
runProgram verbosity prog args =
runProgramInvocation :: Verbosity -> ProgramInvocation -> IO ()runProgramInvocation verbosity :: Verbosityverbosity (programInvocation ::
ConfiguredProgram -> [String] -> ProgramInvocationprogramInvocation prog :: Programprog args :: [ProgArg]args)
getProgramOutput :: Verbosity
-> ConfiguredProgram
-> [ProgArg]
-> IO String
getProgramOutput verbosity prog args =
getProgramInvocationOutput ::
Verbosity -> ProgramInvocation -> IO StringgetProgramInvocationOutput verbosity :: Verbosityverbosity (programInvocation ::
ConfiguredProgram -> [String] -> ProgramInvocationprogramInvocation prog :: Programprog args :: [ProgArg]args)
runDbProgram :: Verbosity
-> Program
-> ProgramDb
-> [ProgArg]
-> IO ()
runDbProgram verbosity prog programDb args =
case lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgramlookupProgram prog :: Programprog programDb :: ProgramDbprogramDb of
Nothing -> die :: String -> IO adie notFound :: [Char]notFound
Just configuredProg -> runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()runProgram verbosity :: Verbosityverbosity configuredProg :: ConfiguredProgramconfiguredProg args :: [ProgArg]args
where
notFound = "The program " (++) :: [a] -> [a] -> [a]++ programName :: Program -> StringprogramName prog :: Programprog
(++) :: [a] -> [a] -> [a]++ " is required but it could not be found"
getDbProgramOutput :: Verbosity
-> Program
-> ProgramDb
-> [ProgArg]
-> IO String
getDbProgramOutput verbosity prog programDb args =
case lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgramlookupProgram prog :: Programprog programDb :: ProgramDbprogramDb of
Nothing -> die :: String -> IO adie notFound :: [Char]notFound
Just configuredProg -> getProgramOutput ::
Verbosity -> ConfiguredProgram -> [ProgArg] -> IO StringgetProgramOutput verbosity :: Verbosityverbosity configuredProg :: ConfiguredProgramconfiguredProg args :: [ProgArg]args
where
notFound = "The program " (++) :: [a] -> [a] -> [a]++ programName :: Program -> StringprogramName prog :: Programprog
(++) :: [a] -> [a] -> [a]++ " is required but it could not be found"
rawSystemProgram :: Verbosity -> ConfiguredProgram
-> [ProgArg] -> IO ()
rawSystemProgram = runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()runProgram
rawSystemProgramStdout :: Verbosity -> ConfiguredProgram
-> [ProgArg] -> IO String
rawSystemProgramStdout = getProgramOutput ::
Verbosity -> ConfiguredProgram -> [ProgArg] -> IO StringgetProgramOutput
rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration
-> [ProgArg] -> IO ()
rawSystemProgramConf = runDbProgram ::
Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()runDbProgram
rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration
-> [ProgArg] -> IO String
rawSystemProgramStdoutConf = getDbProgramOutput ::
Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO StringgetDbProgramOutput
type ProgramConfiguration = ProgramDb
emptyProgramConfiguration, defaultProgramConfiguration :: ProgramConfiguration
emptyProgramConfiguration = emptyProgramDb :: ProgramDbemptyProgramDb
defaultProgramConfiguration = defaultProgramDb :: ProgramDbdefaultProgramDb
restoreProgramConfiguration :: [Program] -> ProgramConfiguration
-> ProgramConfiguration
restoreProgramConfiguration = restoreProgramDb :: [Program] -> ProgramDb -> ProgramDbrestoreProgramDb
findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath)
findProgramOnPath = flip :: (a -> b -> c) -> b -> a -> cflip findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath)findProgramLocation