Cabal-2.2.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 Source #

Constructors

NoAbiTag 
AbiTag String 
Instances
Eq AbiTag Source # 
Instance details

Methods

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

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

Read AbiTag Source # 
Instance details
Show AbiTag Source # 
Instance details
Generic AbiTag Source # 
Instance details

Associated Types

type Rep AbiTag :: * -> * #

Methods

from :: AbiTag -> Rep AbiTag x #

to :: Rep AbiTag x -> AbiTag #

Binary AbiTag Source # 
Instance details

Methods

put :: AbiTag -> Put #

get :: Get AbiTag #

putList :: [AbiTag] -> Put #

Text AbiTag Source # 
Instance details
type Rep AbiTag Source # 
Instance details
type Rep AbiTag = D1 (MetaData "AbiTag" "Distribution.Compiler" "Cabal-2.2.0.0-inplace" False) (C1 (MetaCons "NoAbiTag" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "AbiTag" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))

data CompilerInfo Source #

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 Source # 
Instance details
Show CompilerInfo Source # 
Instance details
Generic CompilerInfo Source # 
Instance details

Associated Types

type Rep CompilerInfo :: * -> * #

Binary CompilerInfo Source # 
Instance details
type Rep CompilerInfo Source # 
Instance details
type Rep CompilerInfo = D1 (MetaData "CompilerInfo" "Distribution.Compiler" "Cabal-2.2.0.0-inplace" 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 Source #

Instances
Eq CompilerId Source # 
Instance details
Ord CompilerId Source # 
Instance details
Read CompilerId Source # 
Instance details
Show CompilerId Source # 
Instance details
Generic CompilerId Source # 
Instance details

Associated Types

type Rep CompilerId :: * -> * #

Binary CompilerId Source # 
Instance details
NFData CompilerId Source # 
Instance details

Methods

rnf :: CompilerId -> () #

Text CompilerId Source # 
Instance details
type Rep CompilerId Source # 
Instance details

data CompilerFlavor Source #

Instances
Eq CompilerFlavor Source # 
Instance details
Data CompilerFlavor Source # 
Instance details

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 Source # 
Instance details
Read CompilerFlavor Source # 
Instance details
Show CompilerFlavor Source # 
Instance details
Generic CompilerFlavor Source # 
Instance details

Associated Types

type Rep CompilerFlavor :: * -> * #

Binary CompilerFlavor Source # 
Instance details
NFData CompilerFlavor Source # 
Instance details

Methods

rnf :: CompilerFlavor -> () #

Pretty CompilerFlavor Source # 
Instance details
Parsec CompilerFlavor Source # 
Instance details
Text CompilerFlavor Source # 
Instance details
Newtype TestedWith (CompilerFlavor, VersionRange) Source # 
Instance details
type Rep CompilerFlavor Source # 
Instance details
type Rep CompilerFlavor = D1 (MetaData "CompilerFlavor" "Distribution.Compiler" "Cabal-2.2.0.0-inplace" 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 "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 Source #

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 Source #

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 Source #

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 Source #

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 Source # 
Instance details
Read ProfDetailLevel Source # 
Instance details
Show ProfDetailLevel Source # 
Instance details
Generic ProfDetailLevel Source # 
Instance details

Associated Types

type Rep ProfDetailLevel :: * -> * #

Binary ProfDetailLevel Source # 
Instance details
type Rep ProfDetailLevel Source # 
Instance details
type Rep ProfDetailLevel = D1 (MetaData "ProfDetailLevel" "Distribution.Simple.Compiler" "Cabal-2.2.0.0-inplace" 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 Source #

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 Source # 
Instance details
Enum DebugInfoLevel Source # 
Instance details
Eq DebugInfoLevel Source # 
Instance details
Read DebugInfoLevel Source # 
Instance details
Show DebugInfoLevel Source # 
Instance details
Generic DebugInfoLevel Source # 
Instance details

Associated Types

type Rep DebugInfoLevel :: * -> * #

Binary DebugInfoLevel Source # 
Instance details
type Rep DebugInfoLevel Source # 
Instance details
type Rep DebugInfoLevel = D1 (MetaData "DebugInfoLevel" "Distribution.Simple.Compiler" "Cabal-2.2.0.0-inplace" 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 Source #

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 Source # 
Instance details
Enum OptimisationLevel Source # 
Instance details
Eq OptimisationLevel Source # 
Instance details
Read OptimisationLevel Source # 
Instance details
Show OptimisationLevel Source # 
Instance details
Generic OptimisationLevel Source # 
Instance details

Associated Types

type Rep OptimisationLevel :: * -> * #

Binary OptimisationLevel Source # 
Instance details
type Rep OptimisationLevel Source # 
Instance details
type Rep OptimisationLevel = D1 (MetaData "OptimisationLevel" "Distribution.Simple.Compiler" "Cabal-2.2.0.0-inplace" False) (C1 (MetaCons "NoOptimisation" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "NormalOptimisation" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "MaximumOptimisation" PrefixI False) (U1 :: * -> *)))

type PackageDBStack = [PackageDB] Source #

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 Source #

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 Source # 
Instance details
Ord PackageDB Source # 
Instance details
Read PackageDB Source # 
Instance details
Show PackageDB Source # 
Instance details
Generic PackageDB Source # 
Instance details

Associated Types

type Rep PackageDB :: * -> * #

Binary PackageDB Source # 
Instance details
type Rep PackageDB Source # 
Instance details
type Rep PackageDB = D1 (MetaData "PackageDB" "Distribution.Simple.Compiler" "Cabal-2.2.0.0-inplace" 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 Source #

Constructors

Compiler 

Fields

Instances
Eq Compiler Source # 
Instance details
Read Compiler Source # 
Instance details
Show Compiler Source # 
Instance details
Generic Compiler Source # 
Instance details

Associated Types

type Rep Compiler :: * -> * #

Methods

from :: Compiler -> Rep Compiler x #

to :: Rep Compiler x -> Compiler #

Binary Compiler Source # 
Instance details

Methods

put :: Compiler -> Put #

get :: Get Compiler #

putList :: [Compiler] -> Put #

type Rep Compiler Source # 
Instance details

compilerCompatFlavor :: CompilerFlavor -> Compiler -> Bool Source #

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 Source #

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 Source #

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

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

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

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

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

parmakeSupported :: Compiler -> Bool Source #

Does this compiler support parallel --make mode?

reexportedModulesSupported :: Compiler -> Bool Source #

Does this compiler support reexported-modules?

renamingPackageFlagsSupported :: Compiler -> Bool Source #

Does this compiler support thinning/renaming on package flags?

unifiedIPIDRequired :: Compiler -> Bool Source #

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

packageKeySupported :: Compiler -> Bool Source #

Does this compiler support package keys?

unitIdSupported :: Compiler -> Bool Source #

Does this compiler support unit IDs?

backpackSupported :: Compiler -> Bool Source #

Does this compiler support Backpack?

libraryDynDirSupported :: Compiler -> Bool Source #

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

arResponseFilesSupported :: Compiler -> Bool Source #

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

coverageSupported :: Compiler -> Bool Source #

Does this compiler support Haskell program coverage?

profilingSupported :: Compiler -> Bool Source #

Does this compiler support profiling?

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

type Args = [String] Source #

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.

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

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

Since: 2.2.0.0

Standard sets of hooks

simpleUserHooks :: UserHooks Source #

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

defaultUserHooks :: UserHooks Source #

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 Source #

Empty UserHooks which do nothing.

Utils

defaultHookedPackageDesc :: IO (Maybe FilePath) Source #

Deprecated: Use findHookedPackageDesc with the proper base directory instead

Optional auxiliary package information file (pkgname.buildinfo)