Cabal-1.16.0: A framework for packaging Haskell software

Portability | portable
Maintainer | cabal-devel@haskell.org
Safe Haskell | None

Distribution.Simple.LocalBuildInfo

Contents

- Buildable package components
- Installation directories

Description

Once a package has been configured we have resolved conditionals and dependencies, configured the compiler and other needed external programs. The `LocalBuildInfo` is used to hold all this information. It holds the install dirs, the compiler, the exact package dependencies, the configured programs, the package database to use and a bunch of miscellaneous configure flags. It gets saved and reloaded from a file (`dist/setup-config`). It gets passed in to very many subsequent build actions.

Synopsis

- data LocalBuildInfo = LocalBuildInfo {
  - configFlags :: ConfigFlags
  - extraConfigArgs :: [String]
  - installDirTemplates :: InstallDirTemplates
  - compiler :: Compiler
  - buildDir :: FilePath
  - scratchDir :: FilePath
  - libraryConfig :: Maybe ComponentLocalBuildInfo
  - executableConfigs :: [(String, ComponentLocalBuildInfo)]
  - compBuildOrder :: [ComponentName]
  - testSuiteConfigs :: [(String, ComponentLocalBuildInfo)]
  - benchmarkConfigs :: [(String, ComponentLocalBuildInfo)]
  - installedPkgs :: PackageIndex
  - pkgDescrFile :: Maybe FilePath
  - localPkgDescr :: PackageDescription
  - withPrograms :: ProgramConfiguration
  - withPackageDB :: PackageDBStack
  - withVanillaLib :: Bool
  - withProfLib :: Bool
  - withSharedLib :: Bool
  - withDynExe :: Bool
  - withProfExe :: Bool
  - withOptimization :: OptimisationLevel
  - withGHCiLib :: Bool
  - splitObjs :: Bool
  - stripExes :: Bool
  - progPrefix :: PathTemplate
  - progSuffix :: PathTemplate
  }
- externalPackageDeps :: LocalBuildInfo -> [(InstalledPackageId, PackageId)]
- inplacePackageId :: PackageId -> InstalledPackageId
- data Component
  - = CLib Library
  - | CExe Executable
  - | CTest TestSuite
  - | CBench Benchmark
- foldComponent :: (Library -> a) -> (Executable -> a) -> (TestSuite -> a) -> (Benchmark -> a) -> Component -> a
- componentBuildInfo :: Component -> BuildInfo
- allComponentsBy :: PackageDescription -> (Component -> a) -> [a]
- data ComponentName
  - = CLibName
  - | CExeName String
  - | CTestName String
  - | CBenchName String
- data ComponentLocalBuildInfo = ComponentLocalBuildInfo {
  - componentPackageDeps :: [(InstalledPackageId, PackageId)]
  }
- withComponentsLBI :: PackageDescription -> LocalBuildInfo -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withLibLBI :: PackageDescription -> LocalBuildInfo -> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withExeLBI :: PackageDescription -> LocalBuildInfo -> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withTestLBI :: PackageDescription -> LocalBuildInfo -> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- module Distribution.Simple.InstallDirs
- absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest -> InstallDirs FilePath
- prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo -> InstallDirs (Maybe FilePath)
- substPathTemplate :: PackageId -> LocalBuildInfo -> PathTemplate -> FilePath

# Documentation

data LocalBuildInfo

Data cached after configuration step. See also `ConfigFlags`.

Constructors

LocalBuildInfo |

Fields

configFlags :: ConfigFlags

  Options passed to the configuration step. Needed to re-run configuration when .cabal is out of date

extraConfigArgs :: [String]

  Extra args on the command line for the configuration step. Needed to re-run configuration when .cabal is out of date

installDirTemplates :: InstallDirTemplates

  The installation directories for the various differnt kinds of files TODO: inplaceDirTemplates :: InstallDirs FilePath

compiler :: Compiler

  The compiler we're building with

buildDir :: FilePath

  Where to build the package. TODO: eliminate hugs's scratchDir, use builddir

scratchDir :: FilePath

  Where to put the result of the Hugs build.

libraryConfig :: Maybe ComponentLocalBuildInfo
executableConfigs :: [(String, ComponentLocalBuildInfo)]
compBuildOrder :: [ComponentName]

  All the components to build, ordered by topological sort over the intrapackage dependency graph

testSuiteConfigs :: [(String, ComponentLocalBuildInfo)]
benchmarkConfigs :: [(String, ComponentLocalBuildInfo)]
installedPkgs :: PackageIndex

  All the info about the installed packages that the current package depends on (directly or indirectly).

pkgDescrFile :: Maybe FilePath

  the filename containing the .cabal file, if available

localPkgDescr :: PackageDescription

  The resolved package description, that does not contain any conditionals.

withPrograms :: ProgramConfiguration

  Location and args for all programs

withPackageDB :: PackageDBStack

  What package database to use, global/user

withVanillaLib :: Bool

  Whether to build normal libs.

withProfLib :: Bool

  Whether to build profiling versions of libs.

withSharedLib :: Bool

  Whether to build shared versions of libs.

withDynExe :: Bool

  Whether to link executables dynamically

withProfExe :: Bool

  Whether to build executables for profiling.

withOptimization :: OptimisationLevel

  Whether to build with optimization (if available).

withGHCiLib :: Bool

  Whether to build libs suitable for use with GHCi.

splitObjs :: Bool

  Use -split-objs with GHC, if available

stripExes :: Bool

  Whether to strip executables during install

progPrefix :: PathTemplate

  Prefix to be prepended to installed executables

progSuffix :: PathTemplate

  Suffix to be appended to installed executables

Instances

Read LocalBuildInfo |
Show LocalBuildInfo |

externalPackageDeps :: LocalBuildInfo -> [(InstalledPackageId, PackageId)]

External package dependencies for the package as a whole. This is the union of the individual `componentPackageDeps`, less any internal deps.

inplacePackageId :: PackageId -> InstalledPackageId

The installed package Id we use for local packages registered in the local package db. This is what is used for intra-package deps between components.

# Buildable package components

data Component

Constructors

CLib Library |
CExe Executable |
CTest TestSuite |
CBench Benchmark |

Instances

Eq Component |
Read Component |
Show Component |

foldComponent :: (Library -> a) -> (Executable -> a) -> (TestSuite -> a) -> (Benchmark -> a) -> Component -> a

componentBuildInfo :: Component -> BuildInfo

allComponentsBy :: PackageDescription -> (Component -> a) -> [a]

Obtains all components (libs, exes, or test suites), transformed by the given function. Useful for gathering dependencies with component context.

data ComponentName

Constructors

CLibName |
CExeName String |
CTestName String |
CBenchName String |

Instances

Eq ComponentName |
Read ComponentName |
Show ComponentName |

data ComponentLocalBuildInfo

Constructors

ComponentLocalBuildInfo |

Fields

componentPackageDeps :: [(InstalledPackageId, PackageId)]

  Resolved internal and external package dependencies for this component. The `BuildInfo` specifies a set of build dependencies that must be satisfied in terms of version ranges. This field fixes those dependencies to the specific versions available on this machine for this compiler.

Instances

Read ComponentLocalBuildInfo |
Show ComponentLocalBuildInfo |

withComponentsLBI :: PackageDescription -> LocalBuildInfo -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO ()

Perform the action on each buildable `Library` or `Executable` (Component) in the PackageDescription, subject to the build order specified by the `compBuildOrder` field of the given `LocalBuildInfo`

withLibLBI :: PackageDescription -> LocalBuildInfo -> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO ()

If the package description has a library section, call the given function with the library build info as argument. Extended version of `withLib` that also gives corresponding build info.

withExeLBI :: PackageDescription -> LocalBuildInfo -> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO ()

Perform the action on each buildable `Executable` in the package description. Extended version of `withExe` that also gives corresponding build info.

withTestLBI :: PackageDescription -> LocalBuildInfo -> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO ()

# Installation directories

module Distribution.Simple.InstallDirs

absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest -> InstallDirs FilePath

See `absoluteInstallDirs`

prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo -> InstallDirs (Maybe FilePath)

See `prefixRelativeInstallDirs`

substPathTemplate :: PackageId -> LocalBuildInfo -> PathTemplate -> FilePath