Cabal-1.10.2.0: A framework for packaging Haskell software

Portabilityportable
Maintainercabal-devel@haskell.org

Distribution.Simple

Contents

Description

This is the command line front end to the Simple build system. When given the parsed command-line args and package information, is able to perform basic commands like configure, build, install, register, etc.

This module exports the main functions that Setup.hs scripts use. It re-exports the UserHooks type, the standard entry points like defaultMain and defaultMainWithHooks and the predefined sets of UserHooks that custom Setup.hs scripts can extend to add their own behaviour.

This module isn't called "Simple" because it's simple. Far from it. It's called "Simple" because it does complicated things to simple software.

The original idea was that there could be different build systems that all presented the same compatible command line interfaces. There is still a Distribution.Make system but in practice no packages use it.

Synopsis

Documentation

Simple interface

defaultMain :: IO ()Source

A simple implementation of main for a Cabal setup script. It reads the package description file using IO, and performs the action specified on the command line.

defaultMainNoRead :: GenericPackageDescription -> IO ()Source

Like defaultMain, but accepts the package description as input rather than using IO to read it.

defaultMainArgs :: [String] -> IO ()Source

A version of defaultMain that is passed the command line arguments, rather than getting them from the environment.

Customization

data UserHooks Source

Hooks allow authors to add specific functionality before and after a command is run, and also to specify additional preprocessors.

  • WARNING: The hooks interface is under rather constant flux as we try to understand users needs. Setup files that depend on this interface may break in future releases.

Constructors

UserHooks 

Fields

runTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()

Used for ./setup test

readDesc :: IO (Maybe GenericPackageDescription)

Read the description file

hookedPreProcessors :: [PPSuffixHandler]

Custom preprocessors in addition to and overriding knownSuffixHandlers.

hookedPrograms :: [Program]

These programs are detected at configure time. Arguments for them are added to the configure command.

preConf :: Args -> ConfigFlags -> IO HookedBuildInfo

Hook to run before configure command

confHook :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo

Over-ride this hook to get different behavior during configure.

postConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after configure command

preBuild :: Args -> BuildFlags -> IO HookedBuildInfo

Hook to run before build command. Second arg indicates verbosity level.

buildHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()

Over-ride this hook to gbet different behavior during build.

postBuild :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after build command. Second arg indicates verbosity level.

preClean :: Args -> CleanFlags -> IO HookedBuildInfo

Hook to run before clean command. Second arg indicates verbosity level.

cleanHook :: PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()

Over-ride this hook to get different behavior during clean.

postClean :: Args -> CleanFlags -> PackageDescription -> () -> IO ()

Hook to run after clean command. Second arg indicates verbosity level.

preCopy :: Args -> CopyFlags -> IO HookedBuildInfo

Hook to run before copy command

copyHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()

Over-ride this hook to get different behavior during copy.

postCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after copy command

preInst :: Args -> InstallFlags -> IO HookedBuildInfo

Hook to run before install command

instHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()

Over-ride this hook to get different behavior during install.

postInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after install command. postInst should be run on the target, not on the build machine.

preSDist :: Args -> SDistFlags -> IO HookedBuildInfo

Hook to run before sdist command. Second arg indicates verbosity level.

sDistHook :: PackageDescription -> Maybe LocalBuildInfo -> UserHooks -> SDistFlags -> IO ()

Over-ride this hook to get different behavior during sdist.

postSDist :: Args -> SDistFlags -> PackageDescription -> Maybe LocalBuildInfo -> IO ()

Hook to run after sdist command. Second arg indicates verbosity level.

preReg :: Args -> RegisterFlags -> IO HookedBuildInfo

Hook to run before register command

regHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()

Over-ride this hook to get different behavior during registration.

postReg :: Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after register command

preUnreg :: Args -> RegisterFlags -> IO HookedBuildInfo

Hook to run before unregister command

unregHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()

Over-ride this hook to get different behavior during registration.

postUnreg :: Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after unregister command

preHscolour :: Args -> HscolourFlags -> IO HookedBuildInfo

Hook to run before hscolour command. Second arg indicates verbosity level.

hscolourHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()

Over-ride this hook to get different behavior during hscolour.

postHscolour :: Args -> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after hscolour command. Second arg indicates verbosity level.

preHaddock :: Args -> HaddockFlags -> IO HookedBuildInfo

Hook to run before haddock command. Second arg indicates verbosity level.

haddockHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()

Over-ride this hook to get different behavior during haddock.

postHaddock :: Args -> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after haddock command. Second arg indicates verbosity level.

preTest :: Args -> TestFlags -> IO HookedBuildInfo

Hook to run before test command.

testHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()

Over-ride this hook to get different behavior during test.

postTest :: Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()

Hook to run after test command.

defaultMainWithHooks :: UserHooks -> IO ()Source

A customizable version of defaultMain.

defaultMainWithHooksArgs :: UserHooks -> [String] -> IO ()Source

A customizable version of defaultMain that also takes the command line arguments.

Standard sets of hooks

simpleUserHooks :: UserHooksSource

Hooks that correspond to a plain instantiation of the "simple" build system

defaultUserHooks :: UserHooksSource

Basic autoconf UserHooks:

Thus configure can use local system information to generate package.buildinfo and possibly other files.

emptyUserHooks :: UserHooksSource

Empty UserHooks which do nothing.

Utils

defaultHookedPackageDesc :: IO (Maybe FilePath)Source

Optional auxiliary package information file (pkgname.buildinfo)