Distribution.Simple.Program

Cabal-2.4.0.1: A framework for packaging Haskell software

Copyright | Isaac Jones 2006 Duncan Coutts 2007-2009
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.Simple.Program

Contents

- Program and functions for constructing them
- Configured program and related functions
- Program invocations
- The collection of unconfigured and configured programs
- The collection of configured programs we can run
- Programs that Cabal knows about
- deprecated

Description

This provides an abstraction which deals with configuring and running programs. A `Program` is a static notion of a known program. A `ConfiguredProgram` is a `Program` that has been found on the current machine and is ready to be run (possibly with some user-supplied default args). Configuring a program involves finding its location and if necessary finding its version. There is also a `ProgramDb` type which holds configured and not-yet configured programs. It is the parameter to lots of actions elsewhere in Cabal that need to look up and run programs. If we had a Cabal monad, the `ProgramDb` would probably be a reader or state component of it.

The module also defines all the known built-in `Program`s and the `defaultProgramDb` which contains them all.

One nice thing about using it is that any program that is registered with Cabal will get some "configure" and ".cabal" helpers like --with-foo-args --foo-path= and extra-foo-args.

There's also good default behavior for trying to find "foo" in PATH, being able to override its location, etc.

There's also a hook for adding programs in a Setup.lhs script. See hookedPrograms in `UserHooks`. This gives a hook user the ability to get the above flags and such so that they don't have to write all the PATH logic inside Setup.lhs.

Synopsis

- data Program = Program {
  - programName :: String
  - programFindLocation :: Verbosity -> ProgramSearchPath -> IO (Maybe (FilePath, [FilePath]))
  - programFindVersion :: Verbosity -> FilePath -> IO (Maybe Version)
  - programPostConf :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
  - programNormaliseArgs :: Maybe Version -> PackageDescription -> [String] -> [String]
  }
- type ProgramSearchPath = [ProgramSearchPathEntry]
- data ProgramSearchPathEntry
  - = ProgramSearchPathDir FilePath
  - | ProgramSearchPathDefault
- simpleProgram :: String -> Program
- findProgramOnSearchPath :: Verbosity -> ProgramSearchPath -> FilePath -> IO (Maybe (FilePath, [FilePath]))
- defaultProgramSearchPath :: ProgramSearchPath
- findProgramVersion :: String -> (String -> String) -> Verbosity -> FilePath -> IO (Maybe Version)
- data ConfiguredProgram = ConfiguredProgram {
  - programId :: String
  - programVersion :: Maybe Version
  - programDefaultArgs :: [String]
  - programOverrideArgs :: [String]
  - programOverrideEnv :: [(String, Maybe String)]
  - programProperties :: Map String String
  - programLocation :: ProgramLocation
  - programMonitorFiles :: [FilePath]
  }
- programPath :: ConfiguredProgram -> FilePath
- type ProgArg = String
- data ProgramLocation
  - = UserSpecified {
    - locationPath :: FilePath
    }
  - | FoundOnSystem {
    - locationPath :: FilePath
    }
- runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
- getProgramOutput :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String
- suppressOverrideArgs :: ConfiguredProgram -> ConfiguredProgram
- data ProgramInvocation = ProgramInvocation {
  - progInvokePath :: FilePath
  - progInvokeArgs :: [String]
  - progInvokeEnv :: [(String, Maybe String)]
  - progInvokePathEnv :: [FilePath]
  - progInvokeCwd :: Maybe FilePath
  - progInvokeInput :: Maybe String
  - progInvokeInputEncoding :: IOEncoding
  - progInvokeOutputEncoding :: IOEncoding
  }
- emptyProgramInvocation :: ProgramInvocation
- simpleProgramInvocation :: FilePath -> [String] -> ProgramInvocation
- programInvocation :: ConfiguredProgram -> [String] -> ProgramInvocation
- runProgramInvocation :: Verbosity -> ProgramInvocation -> IO ()
- getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String
- builtinPrograms :: [Program]
- data ProgramDb
- defaultProgramDb :: ProgramDb
- emptyProgramDb :: ProgramDb
- restoreProgramDb :: [Program] -> ProgramDb -> ProgramDb
- addKnownProgram :: Program -> ProgramDb -> ProgramDb
- addKnownPrograms :: [Program] -> ProgramDb -> ProgramDb
- lookupKnownProgram :: String -> ProgramDb -> Maybe Program
- knownPrograms :: ProgramDb -> [(Program, Maybe ConfiguredProgram)]
- getProgramSearchPath :: ProgramDb -> ProgramSearchPath
- setProgramSearchPath :: ProgramSearchPath -> ProgramDb -> ProgramDb
- userSpecifyPath :: String -> FilePath -> ProgramDb -> ProgramDb
- userSpecifyPaths :: [(String, FilePath)] -> ProgramDb -> ProgramDb
- userMaybeSpecifyPath :: String -> Maybe FilePath -> ProgramDb -> ProgramDb
- userSpecifyArgs :: String -> [ProgArg] -> ProgramDb -> ProgramDb
- userSpecifyArgss :: [(String, [ProgArg])] -> ProgramDb -> ProgramDb
- userSpecifiedArgs :: Program -> ProgramDb -> [ProgArg]
- lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgram
- lookupProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (Either String (ConfiguredProgram, Version, ProgramDb))
- updateProgram :: ConfiguredProgram -> ProgramDb -> ProgramDb
- configureProgram :: Verbosity -> Program -> ProgramDb -> IO ProgramDb
- configureAllKnownPrograms :: Verbosity -> ProgramDb -> IO ProgramDb
- reconfigurePrograms :: Verbosity -> [(String, FilePath)] -> [(String, [ProgArg])] -> ProgramDb -> IO ProgramDb
- requireProgram :: Verbosity -> Program -> ProgramDb -> IO (ConfiguredProgram, ProgramDb)
- requireProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (ConfiguredProgram, Version, ProgramDb)
- runDbProgram :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()
- getDbProgramOutput :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO String
- ghcProgram :: Program
- ghcPkgProgram :: Program
- ghcjsProgram :: Program
- ghcjsPkgProgram :: Program
- hmakeProgram :: Program
- jhcProgram :: Program
- uhcProgram :: Program
- gccProgram :: Program
- arProgram :: Program
- stripProgram :: Program
- happyProgram :: Program
- alexProgram :: Program
- hsc2hsProgram :: Program
- c2hsProgram :: Program
- cpphsProgram :: Program
- hscolourProgram :: Program
- doctestProgram :: Program
- haddockProgram :: Program
- greencardProgram :: Program
- ldProgram :: Program
- tarProgram :: Program
- cppProgram :: Program
- pkgConfigProgram :: Program
- hpcProgram :: Program
- type ProgramConfiguration = ProgramDb
- emptyProgramConfiguration :: ProgramConfiguration
- defaultProgramConfiguration :: ProgramConfiguration
- restoreProgramConfiguration :: [Program] -> ProgramConfiguration -> ProgramConfiguration
- rawSystemProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
- rawSystemProgramStdout :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String
- rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO ()
- rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO String
- findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath)
- findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath)

# Program and functions for constructing them

data Program #

Represents a program which can be configured.

Note: rather than constructing this directly, start with `simpleProgram` and override any extra fields.

Constructors

Program |
Fields programName :: String The simple name of the program, eg. ghc programFindLocation :: Verbosity -> ProgramSearchPath -> IO (Maybe (FilePath, [FilePath])) A function to search for the program if its location was not specified by the user. Usually this will just be a call to `findProgramOnSearchPath`. It is supplied with the prevailing search path which will typically just be used as-is, but can be extended or ignored as needed. For the purpose of change monitoring, in addition to the location where the program was found, it returns all the other places that were tried. programFindVersion :: Verbosity -> FilePath -> IO (Maybe Version) Try to find the version of the program. For many programs this is not possible or is not necessary so it's OK to return Nothing. programPostConf :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram A function to do any additional configuration after we have located the program (and perhaps identified its version). For example it could add args, or environment vars. programNormaliseArgs :: Maybe Version -> PackageDescription -> [String] -> [String] A function that filters any arguments that don't impact the output from a commandline. Used to limit the volatility of dependency hashes when using new-build.

Instances

Show Program # |
Instance details Defined in Distribution.Simple.Program.Types Methods showsPrec :: Int -> Program -> ShowS Source # show :: Program -> String Source # showList :: [Program] -> ShowS Source #

type ProgramSearchPath = [ProgramSearchPathEntry] #

A search path to use when locating executables. This is analogous to the unix `$PATH` or win32 `%PATH%` but with the ability to use the system default method for finding executables (`findExecutable` which on unix is simply looking on the `$PATH` but on win32 is a bit more complicated).

The default to use is `[ProgSearchPathDefault]` but you can add extra dirs either before, after or instead of the default, e.g. here we add an extra dir to search after the usual ones.

    ['ProgramSearchPathDefault', 'ProgramSearchPathDir' dir]

data ProgramSearchPathEntry #

Constructors

ProgramSearchPathDir FilePath | A specific dir
ProgramSearchPathDefault | The system default

Instances

Eq ProgramSearchPathEntry # |
Instance details Defined in Distribution.Simple.Program.Find Methods (==) :: ProgramSearchPathEntry -> ProgramSearchPathEntry -> Bool # (/=) :: ProgramSearchPathEntry -> ProgramSearchPathEntry -> Bool #
Generic ProgramSearchPathEntry # |
Instance details Defined in Distribution.Simple.Program.Find Associated Types type Rep ProgramSearchPathEntry :: Type -> Type Source # Methods from :: ProgramSearchPathEntry -> Rep ProgramSearchPathEntry x Source # to :: Rep ProgramSearchPathEntry x -> ProgramSearchPathEntry Source #
Binary ProgramSearchPathEntry # |
Instance details Defined in Distribution.Simple.Program.Find Methods put :: ProgramSearchPathEntry -> Put Source # get :: Get ProgramSearchPathEntry Source # putList :: [ProgramSearchPathEntry] -> Put Source #
type Rep ProgramSearchPathEntry # |
Instance details Defined in Distribution.Simple.Program.Find type Rep ProgramSearchPathEntry = D1 (MetaData "ProgramSearchPathEntry" "Distribution.Simple.Program.Find" "Cabal-2.4.0.1" False) (C1 (MetaCons "ProgramSearchPathDir" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)) :+: C1 (MetaCons "ProgramSearchPathDefault" PrefixI False) (U1 :: Type -> Type))

simpleProgram :: String -> Program #

Make a simple named program.

By default we'll just search for it in the path and not try to find the version name. You can override these behaviours if necessary, eg:

    (simpleProgram "foo") { programFindLocation = ... , programFindVersion ... }

findProgramOnSearchPath :: Verbosity -> ProgramSearchPath -> FilePath -> IO (Maybe (FilePath, [FilePath])) #

defaultProgramSearchPath :: ProgramSearchPath #

findProgramVersion #

Arguments

:: String | version args
-> (String -> String) | function to select version number from program output
-> Verbosity |
-> FilePath | location
-> IO (Maybe Version) |

Look for a program and try to find it's version number. It can accept either an absolute path or the name of a program binary, in which case we will look for the program on the path.

# Configured program and related functions

data ConfiguredProgram #

Represents a program which has been configured and is thus ready to be run.

These are usually made by configuring a `Program`, but if you have to construct one directly then start with `simpleConfiguredProgram` and override any extra fields.

Constructors

ConfiguredProgram |
Fields programId :: String Just the name again programVersion :: Maybe Version The version of this program, if it is known. programDefaultArgs :: [String] Default command-line args for this program. These flags will appear first on the command line, so they can be overridden by subsequent flags. programOverrideArgs :: [String] Override command-line args for this program. These flags will appear last on the command line, so they override all earlier flags. programOverrideEnv :: [(String, Maybe String)] Override environment variables for this program. These env vars will extend/override the prevailing environment of the current to form the environment for the new process. programProperties :: Map String String A key-value map listing various properties of the program, useful for feature detection. Populated during the configuration step, key names depend on the specific program. programLocation :: ProgramLocation Location of the program. eg. `/usr/bin/ghc-6.4` programMonitorFiles :: [FilePath] In addition to the `programLocation` where the program was found, these are additional locations that were looked at. The combination of ths found location and these not-found locations can be used to monitor to detect when the re-configuring the program might give a different result (e.g. found in a different location).

Instances

Eq ConfiguredProgram # |
Instance details Defined in Distribution.Simple.Program.Types Methods (==) :: ConfiguredProgram -> ConfiguredProgram -> Bool # (/=) :: ConfiguredProgram -> ConfiguredProgram -> Bool #
Read ConfiguredProgram # |
Instance details Defined in Distribution.Simple.Program.Types Methods readsPrec :: Int -> ReadS ConfiguredProgram Source # readList :: ReadS [ConfiguredProgram] Source # readPrec :: ReadPrec ConfiguredProgram Source # readListPrec :: ReadPrec [ConfiguredProgram] Source #
Show ConfiguredProgram # |
Instance details Defined in Distribution.Simple.Program.Types Methods showsPrec :: Int -> ConfiguredProgram -> ShowS Source # show :: ConfiguredProgram -> String Source # showList :: [ConfiguredProgram] -> ShowS Source #
Generic ConfiguredProgram # |
Instance details Defined in Distribution.Simple.Program.Types Associated Types type Rep ConfiguredProgram :: Type -> Type Source # Methods from :: ConfiguredProgram -> Rep ConfiguredProgram x Source # to :: Rep ConfiguredProgram x -> ConfiguredProgram Source #
Binary ConfiguredProgram # |
Instance details Defined in Distribution.Simple.Program.Types Methods put :: ConfiguredProgram -> Put Source # get :: Get ConfiguredProgram Source # putList :: [ConfiguredProgram] -> Put Source #
type Rep ConfiguredProgram # |
Instance details Defined in Distribution.Simple.Program.Types type Rep ConfiguredProgram = D1 (MetaData "ConfiguredProgram" "Distribution.Simple.Program.Types" "Cabal-2.4.0.1" False) (C1 (MetaCons "ConfiguredProgram" PrefixI True) (((S1 (MetaSel (Just "programId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String) :*: S1 (MetaSel (Just "programVersion") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Version))) :*: (S1 (MetaSel (Just "programDefaultArgs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [String]) :*: S1 (MetaSel (Just "programOverrideArgs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [String]))) :*: ((S1 (MetaSel (Just "programOverrideEnv") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(String, Maybe String)]) :*: S1 (MetaSel (Just "programProperties") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map String String))) :*: (S1 (MetaSel (Just "programLocation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ProgramLocation) :*: S1 (MetaSel (Just "programMonitorFiles") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [FilePath])))))

programPath :: ConfiguredProgram -> FilePath #

The full path of a configured program.

type ProgArg = String #

data ProgramLocation #

Where a program was found. Also tells us whether it's specified by user or not. This includes not just the path, but the program as well.

Constructors

UserSpecified | The user gave the path to this program, eg. --ghc-path=/usr/bin/ghc-6.6
Fields locationPath :: FilePath
FoundOnSystem | The program was found automatically.
Fields locationPath :: FilePath

Instances

Eq ProgramLocation # |
Instance details Defined in Distribution.Simple.Program.Types Methods (==) :: ProgramLocation -> ProgramLocation -> Bool # (/=) :: ProgramLocation -> ProgramLocation -> Bool #
Read ProgramLocation # |
Instance details Defined in Distribution.Simple.Program.Types Methods readsPrec :: Int -> ReadS ProgramLocation Source # readList :: ReadS [ProgramLocation] Source # readPrec :: ReadPrec ProgramLocation Source # readListPrec :: ReadPrec [ProgramLocation] Source #
Show ProgramLocation # |
Instance details Defined in Distribution.Simple.Program.Types Methods showsPrec :: Int -> ProgramLocation -> ShowS Source # show :: ProgramLocation -> String Source # showList :: [ProgramLocation] -> ShowS Source #
Generic ProgramLocation # |
Instance details Defined in Distribution.Simple.Program.Types Associated Types type Rep ProgramLocation :: Type -> Type Source # Methods from :: ProgramLocation -> Rep ProgramLocation x Source # to :: Rep ProgramLocation x -> ProgramLocation Source #
Binary ProgramLocation # |
Instance details Defined in Distribution.Simple.Program.Types Methods put :: ProgramLocation -> Put Source # get :: Get ProgramLocation Source # putList :: [ProgramLocation] -> Put Source #
type Rep ProgramLocation # |
Instance details Defined in Distribution.Simple.Program.Types type Rep ProgramLocation = D1 (MetaData "ProgramLocation" "Distribution.Simple.Program.Types" "Cabal-2.4.0.1" False) (C1 (MetaCons "UserSpecified" PrefixI True) (S1 (MetaSel (Just "locationPath") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)) :+: C1 (MetaCons "FoundOnSystem" PrefixI True) (S1 (MetaSel (Just "locationPath") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)))

runProgram #

Arguments

:: Verbosity | Verbosity
-> ConfiguredProgram | The program to run
-> [ProgArg] | Any extra arguments to add
-> IO () |

Runs the given configured program.

getProgramOutput #

Arguments

:: Verbosity | Verbosity
-> ConfiguredProgram | The program to run
-> [ProgArg] | Any extra arguments to add
-> IO String |

Runs the given configured program and gets the output.

suppressOverrideArgs :: ConfiguredProgram -> ConfiguredProgram #

Suppress any extra arguments added by the user.

# Program invocations

data ProgramInvocation #

Represents a specific invocation of a specific program.

This is used as an intermediate type between deciding how to call a program and actually doing it. This provides the opportunity to the caller to adjust how the program will be called. These invocations can either be run directly or turned into shell or batch scripts.

Constructors

ProgramInvocation |
Fields progInvokePath :: FilePath progInvokeArgs :: [String] progInvokeEnv :: [(String, Maybe String)] progInvokePathEnv :: [FilePath] progInvokeCwd :: Maybe FilePath progInvokeInput :: Maybe String progInvokeInputEncoding :: IOEncoding progInvokeOutputEncoding :: IOEncoding

emptyProgramInvocation :: ProgramInvocation #

simpleProgramInvocation :: FilePath -> [String] -> ProgramInvocation #

programInvocation :: ConfiguredProgram -> [String] -> ProgramInvocation #

runProgramInvocation :: Verbosity -> ProgramInvocation -> IO () #

getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String #

# The collection of unconfigured and configured programs

builtinPrograms :: [Program] #

The default list of programs. These programs are typically used internally to Cabal.

# The collection of configured programs we can run

data ProgramDb #

The configuration is a collection of information about programs. It contains information both about configured programs and also about programs that we are yet to configure.

The idea is that we start from a collection of unconfigured programs and one by one we try to configure them at which point we move them into the configured collection. For unconfigured programs we record not just the `Program` but also any user-provided arguments and location for the program.

Instances

Read ProgramDb # | Note that this instance does not preserve the known `Program`s. See `restoreProgramDb` for details.
Instance details Defined in Distribution.Simple.Program.Db Methods readsPrec :: Int -> ReadS ProgramDb Source # readList :: ReadS [ProgramDb] Source # readPrec :: ReadPrec ProgramDb Source # readListPrec :: ReadPrec [ProgramDb] Source #
Show ProgramDb # | Note that this instance does not preserve the known `Program`s. See `restoreProgramDb` for details.
Instance details Defined in Distribution.Simple.Program.Db Methods showsPrec :: Int -> ProgramDb -> ShowS Source # show :: ProgramDb -> String Source # showList :: [ProgramDb] -> ShowS Source #
Binary ProgramDb # | Note that this instance does not preserve the known `Program`s. See `restoreProgramDb` for details.
Instance details Defined in Distribution.Simple.Program.Db Methods put :: ProgramDb -> Put Source # get :: Get ProgramDb Source # putList :: [ProgramDb] -> Put Source #

defaultProgramDb :: ProgramDb #

emptyProgramDb :: ProgramDb #

restoreProgramDb :: [Program] -> ProgramDb -> ProgramDb #

The 'Read'\/'Show' and `Binary` instances do not preserve all the unconfigured `Programs` because `Program` is not in 'Read'\/'Show' because it contains functions. So to fully restore a deserialised `ProgramDb` use this function to add back all the known `Program`s.

- It does not add the default programs, but you probably want them, use `builtinPrograms` in addition to any extra you might need.

addKnownProgram :: Program -> ProgramDb -> ProgramDb #

Add a known program that we may configure later

addKnownPrograms :: [Program] -> ProgramDb -> ProgramDb #

lookupKnownProgram :: String -> ProgramDb -> Maybe Program #

knownPrograms :: ProgramDb -> [(Program, Maybe ConfiguredProgram)] #

getProgramSearchPath :: ProgramDb -> ProgramSearchPath #

Get the current `ProgramSearchPath` used by the `ProgramDb`. This is the default list of locations where programs are looked for when configuring them. This can be overridden for specific programs (with `userSpecifyPath`), and specific known programs can modify or ignore this search path in their own configuration code.

setProgramSearchPath :: ProgramSearchPath -> ProgramDb -> ProgramDb #

Change the current `ProgramSearchPath` used by the `ProgramDb`. This will affect programs that are configured from here on, so you should usually set it before configuring any programs.

userSpecifyPath #

Arguments

:: String | Program name
-> FilePath | user-specified path to the program
-> ProgramDb |
-> ProgramDb |

User-specify this path. Basically override any path information for this program in the configuration. If it's not a known program ignore it.

userSpecifyPaths :: [(String, FilePath)] -> ProgramDb -> ProgramDb #

Like `userSpecifyPath` but for a list of progs and their paths.

userMaybeSpecifyPath :: String -> Maybe FilePath -> ProgramDb -> ProgramDb #

userSpecifyArgs #

Arguments

:: String | Program name
-> [ProgArg] | user-specified args
-> ProgramDb |
-> ProgramDb |

User-specify the arguments for this program. Basically override any args information for this program in the configuration. If it's not a known program, ignore it..

userSpecifyArgss :: [(String, [ProgArg])] -> ProgramDb -> ProgramDb #

Like `userSpecifyPath` but for a list of progs and their args.

userSpecifiedArgs :: Program -> ProgramDb -> [ProgArg] #

Get any extra args that have been previously specified for a program.

lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgram #

Try to find a configured program

lookupProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (Either String (ConfiguredProgram, Version, ProgramDb)) #

Check that a program is configured and available to be run.

Additionally check that the program version number is suitable and return it. For example you could require `AnyVersion` or ``orLaterVersion` (`Version` [1,0] [])`

It returns the configured program, its version number and a possibly updated `ProgramDb`. If the program could not be configured or the version is unsuitable, it returns an error value.

updateProgram :: ConfiguredProgram -> ProgramDb -> ProgramDb #

Update a configured program in the database.

configureProgram :: Verbosity -> Program -> ProgramDb -> IO ProgramDb #

Try to configure a specific program. If the program is already included in the collection of unconfigured programs then we use any user-supplied location and arguments. If the program gets configured successfully it gets added to the configured collection.

Note that it is not a failure if the program cannot be configured. It's only a failure if the user supplied a location and the program could not be found at that location.

The reason for it not being a failure at this stage is that we don't know up front all the programs we will need, so we try to configure them all. To verify that a program was actually successfully configured use `requireProgram`.

configureAllKnownPrograms :: Verbosity -> ProgramDb -> IO ProgramDb #

Try to configure all the known programs that have not yet been configured.

reconfigurePrograms :: Verbosity -> [(String, FilePath)] -> [(String, [ProgArg])] -> ProgramDb -> IO ProgramDb #

reconfigure a bunch of programs given new user-specified args. It takes the same inputs as `userSpecifyPath` and `userSpecifyArgs` and for all progs with a new path it calls `configureProgram`.

requireProgram :: Verbosity -> Program -> ProgramDb -> IO (ConfiguredProgram, ProgramDb) #

Check that a program is configured and available to be run.

It raises an exception if the program could not be configured, otherwise it returns the configured program.

requireProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (ConfiguredProgram, Version, ProgramDb) #

Like `lookupProgramVersion`, but raises an exception in case of error instead of returning 'Left errMsg'.

runDbProgram #

Arguments

:: Verbosity | verbosity
-> Program | The program to run
-> ProgramDb | look up the program here
-> [ProgArg] | Any extra arguments to add
-> IO () |

Looks up the given program in the program database and runs it.

getDbProgramOutput #

Arguments

:: Verbosity | verbosity
-> Program | The program to run
-> ProgramDb | look up the program here
-> [ProgArg] | Any extra arguments to add
-> IO String |

Looks up the given program in the program database and runs it.

# Programs that Cabal knows about

ghcProgram :: Program #

ghcPkgProgram :: Program #

ghcjsProgram :: Program #

ghcjsPkgProgram :: Program #

hmakeProgram :: Program #

jhcProgram :: Program #

uhcProgram :: Program #

gccProgram :: Program #

arProgram :: Program #

stripProgram :: Program #

happyProgram :: Program #

alexProgram :: Program #

hsc2hsProgram :: Program #

c2hsProgram :: Program #

cpphsProgram :: Program #

hscolourProgram :: Program #

doctestProgram :: Program #

haddockProgram :: Program #

greencardProgram :: Program #

ldProgram :: Program #

tarProgram :: Program #

cppProgram :: Program #

pkgConfigProgram :: Program #

hpcProgram :: Program #

# deprecated

type ProgramConfiguration = ProgramDb #

Deprecated: use ProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

emptyProgramConfiguration :: ProgramConfiguration #

Deprecated: use emptyProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

defaultProgramConfiguration :: ProgramConfiguration #

Deprecated: use defaultProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

restoreProgramConfiguration :: [Program] -> ProgramConfiguration -> ProgramConfiguration #

Deprecated: use restoreProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

rawSystemProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO () #

Deprecated: use runProgram instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

rawSystemProgramStdout :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String #

Deprecated: use getProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO () #

Deprecated: use runDbProgram instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO String #

Deprecated: use getDbProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath) #

Deprecated: use findProgramOnSearchPath instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018).

findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath) #

Deprecated: No longer used within Cabal, try findProgramOnSearchPath

Look for a program on the path.