Cabal-2.4.0.0: A framework for packaging Haskell software

CopyrightIsaac Jones 2003-2005
LicenseBSD3
Maintainercabal-devel@haskell.org
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

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

data AbiTag #

Constructors

NoAbiTag 
AbiTag String 
Instances
Eq AbiTag # 
Instance details

Defined in Distribution.Compiler

Methods

(==) :: AbiTag -> AbiTag -> Bool #

(/=) :: AbiTag -> AbiTag -> Bool #

Read AbiTag # 
Instance details

Defined in Distribution.Compiler

Show AbiTag # 
Instance details

Defined in Distribution.Compiler

Generic AbiTag # 
Instance details

Defined in Distribution.Compiler

Associated Types

type Rep AbiTag :: * -> * #

Methods

from :: AbiTag -> Rep AbiTag x #

to :: Rep AbiTag x -> AbiTag #

Binary AbiTag # 
Instance details

Defined in Distribution.Compiler

Methods

put :: AbiTag -> Put #

get :: Get AbiTag #

putList :: [AbiTag] -> Put #

Text AbiTag # 
Instance details

Defined in Distribution.Compiler

Methods

disp :: AbiTag -> Doc #

parse :: ReadP r AbiTag #

type Rep AbiTag # 
Instance details

Defined in Distribution.Compiler

type Rep AbiTag = D1 (MetaData "AbiTag" "Distribution.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) (C1 (MetaCons "NoAbiTag" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "AbiTag" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))

data CompilerInfo #

Compiler information used for resolving configurations. Some fields can be set to Nothing to indicate that the information is unknown.

Constructors

CompilerInfo 

Fields

Instances
Read CompilerInfo # 
Instance details

Defined in Distribution.Compiler

Show CompilerInfo # 
Instance details

Defined in Distribution.Compiler

Generic CompilerInfo # 
Instance details

Defined in Distribution.Compiler

Associated Types

type Rep CompilerInfo :: * -> * #

Binary CompilerInfo # 
Instance details

Defined in Distribution.Compiler

type Rep CompilerInfo # 
Instance details

Defined in Distribution.Compiler

type Rep CompilerInfo = D1 (MetaData "CompilerInfo" "Distribution.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) (C1 (MetaCons "CompilerInfo" PrefixI True) ((S1 (MetaSel (Just "compilerInfoId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CompilerId) :*: S1 (MetaSel (Just "compilerInfoAbiTag") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 AbiTag)) :*: (S1 (MetaSel (Just "compilerInfoCompat") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [CompilerId])) :*: (S1 (MetaSel (Just "compilerInfoLanguages") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Language])) :*: S1 (MetaSel (Just "compilerInfoExtensions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Extension]))))))

data CompilerId #

Instances
Eq CompilerId # 
Instance details

Defined in Distribution.Compiler

Ord CompilerId # 
Instance details

Defined in Distribution.Compiler

Read CompilerId # 
Instance details

Defined in Distribution.Compiler

Show CompilerId # 
Instance details

Defined in Distribution.Compiler

Generic CompilerId # 
Instance details

Defined in Distribution.Compiler

Associated Types

type Rep CompilerId :: * -> * #

Binary CompilerId # 
Instance details

Defined in Distribution.Compiler

NFData CompilerId # 
Instance details

Defined in Distribution.Compiler

Methods

rnf :: CompilerId -> () #

Text CompilerId # 
Instance details

Defined in Distribution.Compiler

type Rep CompilerId # 
Instance details

Defined in Distribution.Compiler

data CompilerFlavor #

Instances
Eq CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Data CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CompilerFlavor -> c CompilerFlavor #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CompilerFlavor #

toConstr :: CompilerFlavor -> Constr #

dataTypeOf :: CompilerFlavor -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CompilerFlavor) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompilerFlavor) #

gmapT :: (forall b. Data b => b -> b) -> CompilerFlavor -> CompilerFlavor #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CompilerFlavor -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CompilerFlavor -> r #

gmapQ :: (forall d. Data d => d -> u) -> CompilerFlavor -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CompilerFlavor -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CompilerFlavor -> m CompilerFlavor #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CompilerFlavor -> m CompilerFlavor #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CompilerFlavor -> m CompilerFlavor #

Ord CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Read CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Show CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Generic CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Associated Types

type Rep CompilerFlavor :: * -> * #

Binary CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

NFData CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Methods

rnf :: CompilerFlavor -> () #

Pretty CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Methods

pretty :: CompilerFlavor -> Doc #

Parsec CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Text CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Newtype TestedWith (CompilerFlavor, VersionRange) # 
Instance details

Defined in Distribution.Parsec.Newtypes

type Rep CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

type Rep CompilerFlavor = D1 (MetaData "CompilerFlavor" "Distribution.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) (((C1 (MetaCons "GHC" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "GHCJS" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "NHC" PrefixI False) (U1 :: * -> *))) :+: (C1 (MetaCons "YHC" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "Hugs" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "HBC" PrefixI False) (U1 :: * -> *)))) :+: ((C1 (MetaCons "Helium" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "JHC" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "LHC" PrefixI False) (U1 :: * -> *))) :+: ((C1 (MetaCons "UHC" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "Eta" PrefixI False) (U1 :: * -> *)) :+: (C1 (MetaCons "HaskellSuite" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: C1 (MetaCons "OtherCompiler" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))))

parseCompilerFlavorCompat :: ReadP r CompilerFlavor #

Like classifyCompilerFlavor but compatible with the old ReadS parser.

It is compatible in the sense that it accepts only the same strings, eg GHC but not "ghc". However other strings get mapped to OtherCompiler. The point of this is that we do not allow extra valid values that would upset older Cabal versions that had a stricter parser however we cope with new values more gracefully so that we'll be able to introduce new value in future without breaking things so much.

defaultCompilerFlavor :: Maybe CompilerFlavor #

The default compiler flavour to pick when compiling stuff. This defaults to the compiler used to build the Cabal lib.

However if it's not a recognised compiler then it's Nothing and the user will have to specify which compiler they want.

unknownCompilerInfo :: CompilerId -> AbiTag -> CompilerInfo #

Make a CompilerInfo of which only the known information is its CompilerId, its AbiTag and that it does not claim to be compatible with other compiler id's.

data ProfDetailLevel #

Some compilers (notably GHC) support profiling and can instrument programs so the system can account costs to different functions. There are different levels of detail that can be used for this accounting. For compilers that do not support this notion or the particular detail levels, this is either ignored or just capped to some similar level they do support.

Instances
Eq ProfDetailLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Read ProfDetailLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Show ProfDetailLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Generic ProfDetailLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Associated Types

type Rep ProfDetailLevel :: * -> * #

Binary ProfDetailLevel # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep ProfDetailLevel # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep ProfDetailLevel = D1 (MetaData "ProfDetailLevel" "Distribution.Simple.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) ((C1 (MetaCons "ProfDetailNone" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "ProfDetailDefault" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "ProfDetailExportedFunctions" PrefixI False) (U1 :: * -> *))) :+: (C1 (MetaCons "ProfDetailToplevelFunctions" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "ProfDetailAllFunctions" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "ProfDetailOther" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))))

data DebugInfoLevel #

Some compilers support emitting debug info. Some have different levels. For compilers that do not the level is just capped to the level they do support.

Instances
Bounded DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Enum DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Eq DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Read DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Show DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Generic DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Associated Types

type Rep DebugInfoLevel :: * -> * #

Binary DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep DebugInfoLevel # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep DebugInfoLevel = D1 (MetaData "DebugInfoLevel" "Distribution.Simple.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) ((C1 (MetaCons "NoDebugInfo" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "MinimalDebugInfo" PrefixI False) (U1 :: * -> *)) :+: (C1 (MetaCons "NormalDebugInfo" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "MaximalDebugInfo" PrefixI False) (U1 :: * -> *)))

data OptimisationLevel #

Some compilers support optimising. Some have different levels. For compilers that do not the level is just capped to the level they do support.

Instances
Bounded OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Enum OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Eq OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Read OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Show OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Generic OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

Associated Types

type Rep OptimisationLevel :: * -> * #

Binary OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep OptimisationLevel # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep OptimisationLevel = D1 (MetaData "OptimisationLevel" "Distribution.Simple.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) (C1 (MetaCons "NoOptimisation" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "NormalOptimisation" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "MaximumOptimisation" PrefixI False) (U1 :: * -> *)))

type PackageDBStack = [PackageDB] #

We typically get packages from several databases, and stack them together. This type lets us be explicit about that stacking. For example typical stacks include:

[GlobalPackageDB]
[GlobalPackageDB, UserPackageDB]
[GlobalPackageDB, SpecificPackageDB "package.conf.inplace"]

Note that the GlobalPackageDB is invariably at the bottom since it contains the rts, base and other special compiler-specific packages.

We are not restricted to using just the above combinations. In particular we can use several custom package dbs and the user package db together.

When it comes to writing, the top most (last) package is used.

data PackageDB #

Some compilers have a notion of a database of available packages. For some there is just one global db of packages, other compilers support a per-user or an arbitrary db specified at some location in the file system. This can be used to build isloated environments of packages, for example to build a collection of related packages without installing them globally.

Instances
Eq PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

Ord PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

Read PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

Show PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

Generic PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

Associated Types

type Rep PackageDB :: * -> * #

Binary PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep PackageDB # 
Instance details

Defined in Distribution.Simple.Compiler

type Rep PackageDB = D1 (MetaData "PackageDB" "Distribution.Simple.Compiler" "Cabal-2.4.0.0-8En9aDn0HOVDVTKXJjqCyH" False) (C1 (MetaCons "GlobalPackageDB" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "UserPackageDB" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "SpecificPackageDB" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath))))

data Compiler #

Constructors

Compiler 

Fields

Instances
Eq Compiler # 
Instance details

Defined in Distribution.Simple.Compiler

Read Compiler # 
Instance details

Defined in Distribution.Simple.Compiler

Show Compiler # 
Instance details

Defined in Distribution.Simple.Compiler

Generic Compiler # 
Instance details

Defined in Distribution.Simple.Compiler

Associated Types

type Rep Compiler :: * -> * #

Methods

from :: Compiler -> Rep Compiler x #

to :: Rep Compiler x -> Compiler #

Binary Compiler # 
Instance details

Defined in Distribution.Simple.Compiler

Methods

put :: Compiler -> Put #

get :: Get Compiler #

putList :: [Compiler] -> Put #

type Rep Compiler # 
Instance details

Defined in Distribution.Simple.Compiler

compilerCompatFlavor :: CompilerFlavor -> Compiler -> Bool #

Is this compiler compatible with the compiler flavour we're interested in?

For example this checks if the compiler is actually GHC or is another compiler that claims to be compatible with some version of GHC, e.g. GHCJS.

if compilerCompatFlavor GHC compiler then ... else ...

compilerCompatVersion :: CompilerFlavor -> Compiler -> Maybe Version #

Is this compiler compatible with the compiler flavour we're interested in, and if so what version does it claim to be compatible with.

For example this checks if the compiler is actually GHC-7.x or is another compiler that claims to be compatible with some GHC-7.x version.

case compilerCompatVersion GHC compiler of
  Just (Version (7:_)) -> ...
  _                    -> ...

registrationPackageDB :: PackageDBStack -> PackageDB #

Return the package that we should register into. This is the package db at the top of the stack.

unsupportedExtensions :: Compiler -> [Extension] -> [Extension] #

For the given compiler, return the extensions it does not support.

extensionsToFlags :: Compiler -> [Extension] -> [Flag] #

For the given compiler, return the flags for the supported extensions.

parmakeSupported :: Compiler -> Bool #

Does this compiler support parallel --make mode?

reexportedModulesSupported :: Compiler -> Bool #

Does this compiler support reexported-modules?

renamingPackageFlagsSupported :: Compiler -> Bool #

Does this compiler support thinning/renaming on package flags?

unifiedIPIDRequired :: Compiler -> Bool #

Does this compiler have unified IPIDs (so no package keys)

packageKeySupported :: Compiler -> Bool #

Does this compiler support package keys?

unitIdSupported :: Compiler -> Bool #

Does this compiler support unit IDs?

backpackSupported :: Compiler -> Bool #

Does this compiler support Backpack?

libraryDynDirSupported :: Compiler -> Bool #

Does this compiler support a package database entry with: "dynamic-library-dirs"?

arResponseFilesSupported :: Compiler -> Bool #

Does this compiler's "ar" command supports response file arguments (i.e. @file-style arguments).

coverageSupported :: Compiler -> Bool #

Does this compiler support Haskell program coverage?

profilingSupported :: Compiler -> Bool #

Does this compiler support profiling?

Simple interface

defaultMain :: IO () #

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 () #

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

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

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

Customization

data UserHooks #

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

type Args = [String] #

defaultMainWithHooks :: UserHooks -> IO () #

A customizable version of defaultMain.

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

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

defaultMainWithHooksNoReadArgs :: UserHooks -> GenericPackageDescription -> [String] -> IO () #

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

Since: 2.2.0.0

Standard sets of hooks

simpleUserHooks :: UserHooks #

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

defaultUserHooks :: UserHooks #

Deprecated: Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2 compatibility in which case you must stick with defaultUserHooks

Basic autoconf UserHooks:

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

emptyUserHooks :: UserHooks #

Empty UserHooks which do nothing.

Utils

defaultHookedPackageDesc :: IO (Maybe FilePath) #

Deprecated: Use findHookedPackageDesc with the proper base directory instead

Optional auxiliary package information file (pkgname.buildinfo)