Copyright | Isaac Jones 2003-2004 |
---|---|
License | BSD3 |
Maintainer | cabal-devel@haskell.org |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
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
- flagAssignment :: FlagAssignment
- componentEnabledSpec :: ComponentRequestedSpec
- extraConfigArgs :: [String]
- installDirTemplates :: InstallDirTemplates
- compiler :: Compiler
- hostPlatform :: Platform
- buildDir :: FilePath
- cabalFilePath :: Maybe FilePath
- componentGraph :: Graph ComponentLocalBuildInfo
- componentNameMap :: Map ComponentName [ComponentLocalBuildInfo]
- installedPkgs :: InstalledPackageIndex
- pkgDescrFile :: Maybe FilePath
- localPkgDescr :: PackageDescription
- withPrograms :: ProgramDb
- withPackageDB :: PackageDBStack
- withVanillaLib :: Bool
- withProfLib :: Bool
- withSharedLib :: Bool
- withStaticLib :: Bool
- withDynExe :: Bool
- withProfExe :: Bool
- withProfLibDetail :: ProfDetailLevel
- withProfExeDetail :: ProfDetailLevel
- withOptimization :: OptimisationLevel
- withDebugInfo :: DebugInfoLevel
- withGHCiLib :: Bool
- splitSections :: Bool
- splitObjs :: Bool
- stripExes :: Bool
- stripLibs :: Bool
- exeCoverage :: Bool
- libCoverage :: Bool
- progPrefix :: PathTemplate
- progSuffix :: PathTemplate
- relocatable :: Bool
- externalPackageDeps :: LocalBuildInfo -> [(UnitId, MungedPackageId)]
- localComponentId :: LocalBuildInfo -> ComponentId
- localUnitId :: LocalBuildInfo -> UnitId
- localCompatPackageKey :: LocalBuildInfo -> String
- data Component
- data ComponentName
- defaultLibName :: ComponentName
- showComponentName :: ComponentName -> String
- componentNameString :: ComponentName -> Maybe UnqualComponentName
- data ComponentLocalBuildInfo
- = LibComponentLocalBuildInfo {
- componentLocalName :: ComponentName
- componentComponentId :: ComponentId
- componentUnitId :: UnitId
- componentIsIndefinite_ :: Bool
- componentInstantiatedWith :: [(ModuleName, OpenModule)]
- componentPackageDeps :: [(UnitId, MungedPackageId)]
- componentIncludes :: [(OpenUnitId, ModuleRenaming)]
- componentExeDeps :: [UnitId]
- componentInternalDeps :: [UnitId]
- componentCompatPackageKey :: String
- componentCompatPackageName :: MungedPackageName
- componentExposedModules :: [ExposedModule]
- componentIsPublic :: Bool
- | FLibComponentLocalBuildInfo { }
- | ExeComponentLocalBuildInfo { }
- | TestComponentLocalBuildInfo { }
- | BenchComponentLocalBuildInfo { }
- = LibComponentLocalBuildInfo {
- componentBuildDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
- foldComponent :: (Library -> a) -> (ForeignLib -> a) -> (Executable -> a) -> (TestSuite -> a) -> (Benchmark -> a) -> Component -> a
- componentName :: Component -> ComponentName
- componentBuildInfo :: Component -> BuildInfo
- componentBuildable :: Component -> Bool
- pkgComponents :: PackageDescription -> [Component]
- pkgBuildableComponents :: PackageDescription -> [Component]
- lookupComponent :: PackageDescription -> ComponentName -> Maybe Component
- getComponent :: PackageDescription -> ComponentName -> Component
- getComponentLocalBuildInfo :: LocalBuildInfo -> ComponentName -> ComponentLocalBuildInfo
- allComponentsInBuildOrder :: LocalBuildInfo -> [ComponentLocalBuildInfo]
- componentsInBuildOrder :: LocalBuildInfo -> [ComponentName] -> [ComponentLocalBuildInfo]
- depLibraryPaths :: Bool -> Bool -> LocalBuildInfo -> ComponentLocalBuildInfo -> NoCallStackIO [FilePath]
- allLibModules :: Library -> ComponentLocalBuildInfo -> [ModuleName]
- withAllComponentsInBuildOrder :: PackageDescription -> LocalBuildInfo -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withComponentsInBuildOrder :: PackageDescription -> LocalBuildInfo -> [ComponentName] -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withComponentsLBI :: PackageDescription -> LocalBuildInfo -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withLibLBI :: PackageDescription -> LocalBuildInfo -> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withExeLBI :: PackageDescription -> LocalBuildInfo -> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withBenchLBI :: PackageDescription -> LocalBuildInfo -> (Benchmark -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- withTestLBI :: PackageDescription -> LocalBuildInfo -> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO ()
- enabledTestLBIs :: PackageDescription -> LocalBuildInfo -> [(TestSuite, ComponentLocalBuildInfo)]
- enabledBenchLBIs :: PackageDescription -> LocalBuildInfo -> [(Benchmark, ComponentLocalBuildInfo)]
- type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)]
- data PathTemplateVariable
- data PathTemplate
- data CopyDest
- type InstallDirTemplates = InstallDirs PathTemplate
- data InstallDirs dir = InstallDirs {
- prefix :: dir
- bindir :: dir
- libdir :: dir
- libsubdir :: dir
- dynlibdir :: dir
- flibdir :: dir
- libexecdir :: dir
- libexecsubdir :: dir
- includedir :: dir
- datadir :: dir
- datasubdir :: dir
- docdir :: dir
- mandir :: dir
- htmldir :: dir
- haddockdir :: dir
- sysconfdir :: dir
- combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c
- defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
- defaultInstallDirs' :: Bool -> CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
- substituteInstallDirTemplates :: PathTemplateEnv -> InstallDirTemplates -> InstallDirTemplates
- toPathTemplate :: FilePath -> PathTemplate
- fromPathTemplate :: PathTemplate -> FilePath
- combinePathTemplate :: PathTemplate -> PathTemplate -> PathTemplate
- initialPathTemplateEnv :: PackageIdentifier -> UnitId -> CompilerInfo -> Platform -> PathTemplateEnv
- packageTemplateEnv :: PackageIdentifier -> UnitId -> PathTemplateEnv
- compilerTemplateEnv :: CompilerInfo -> PathTemplateEnv
- platformTemplateEnv :: Platform -> PathTemplateEnv
- abiTemplateEnv :: CompilerInfo -> Platform -> PathTemplateEnv
- installDirsTemplateEnv :: InstallDirs PathTemplate -> PathTemplateEnv
- absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest -> InstallDirs FilePath
- prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo -> InstallDirs (Maybe FilePath)
- absoluteComponentInstallDirs :: PackageDescription -> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
- prefixRelativeComponentInstallDirs :: PackageId -> LocalBuildInfo -> UnitId -> InstallDirs (Maybe FilePath)
- substPathTemplate :: PackageId -> LocalBuildInfo -> UnitId -> PathTemplate -> FilePath
Documentation
data LocalBuildInfo #
Data cached after configuration step. See also
ConfigFlags
.
LocalBuildInfo | |
|
Instances
externalPackageDeps :: LocalBuildInfo -> [(UnitId, MungedPackageId)] #
Deprecated: You almost certainly don't want this function, which agglomerates the dependencies of ALL enabled components. If you're using this to write out information on your dependencies, read off the dependencies directly from the actual component in question. To be removed in Cabal 3.0
External package dependencies for the package as a whole. This is the
union of the individual componentPackageDeps
, less any internal deps.
localComponentId :: LocalBuildInfo -> ComponentId #
Extract the ComponentId
from the public library component of a
LocalBuildInfo
if it exists, or make a fake component ID based
on the package ID.
localUnitId :: LocalBuildInfo -> UnitId #
Extract the UnitId
from the library component of a
LocalBuildInfo
if it exists, or make a fake unit ID based on
the package ID.
localCompatPackageKey :: LocalBuildInfo -> String #
Extract the compatibility package key from the public library component of a
LocalBuildInfo
if it exists, or make a fake package key based
on the package ID.
Buildable package components
Instances
data ComponentName #
CLibName | |
CSubLibName UnqualComponentName | |
CFLibName UnqualComponentName | |
CExeName UnqualComponentName | |
CTestName UnqualComponentName | |
CBenchName UnqualComponentName |
Instances
componentNameString :: ComponentName -> Maybe UnqualComponentName #
This gets the underlying unqualified component name. In fact, it is
guaranteed to uniquely identify a component, returning
Nothing
if the ComponentName
was for the public
library.
data ComponentLocalBuildInfo #
The first five fields are common across all algebraic variants.
LibComponentLocalBuildInfo | |
| |
FLibComponentLocalBuildInfo | |
| |
ExeComponentLocalBuildInfo | |
| |
TestComponentLocalBuildInfo | |
| |
BenchComponentLocalBuildInfo | |
|
Instances
foldComponent :: (Library -> a) -> (ForeignLib -> a) -> (Executable -> a) -> (TestSuite -> a) -> (Benchmark -> a) -> Component -> a #
componentName :: Component -> ComponentName #
componentBuildable :: Component -> Bool #
Is a component buildable (i.e., not marked with buildable: False
)?
See also this note in
Distribution.Types.ComponentRequestedSpec.
Since: 2.0.0.2
pkgComponents :: PackageDescription -> [Component] #
All the components in the package.
pkgBuildableComponents :: PackageDescription -> [Component] #
A list of all components in the package that are buildable,
i.e., were not marked with buildable: False
. This does NOT
indicate if we are actually going to build the component,
see enabledComponents
instead.
Since: 2.0.0.2
getComponentLocalBuildInfo :: LocalBuildInfo -> ComponentName -> ComponentLocalBuildInfo #
Deprecated: This function is not well-defined, because a ComponentName
does not uniquely identify a ComponentLocalBuildInfo
. If you have a TargetInfo
, you should use targetCLBI
to get the ComponentLocalBuildInfo
. Otherwise, use componentNameTargets
to get all possible ComponentLocalBuildInfo
s. This will be removed in Cabal 2.2.
componentsInBuildOrder :: LocalBuildInfo -> [ComponentName] -> [ComponentLocalBuildInfo] #
Deprecated: You've got TargetInfo
right? Use neededTargetsInBuildOrder
on the UnitId
s you can nodeKey
out.
:: Bool | Building for inplace? |
-> Bool | Generate prefix-relative library paths |
-> LocalBuildInfo | |
-> ComponentLocalBuildInfo | Component that is being built |
-> NoCallStackIO [FilePath] |
Determine the directories containing the dynamic libraries of the transitive dependencies of the component we are building.
When wanted, and possible, returns paths relative to the installDirs prefix
allLibModules :: Library -> ComponentLocalBuildInfo -> [ModuleName] #
Get all module names that needed to be built by GHC; i.e., all
of these ModuleName
s have interface files associated with them
that need to be installed.
withAllComponentsInBuildOrder :: 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
withComponentsInBuildOrder :: PackageDescription -> LocalBuildInfo -> [ComponentName] -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO () #
Deprecated: You have got a TargetInfo
right? Use withNeededTargetsInBuildOrder
on the UnitId
s you can nodeKey
out.
withComponentsLBI :: PackageDescription -> LocalBuildInfo -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO () #
Deprecated: Use withAllComponentsInBuildOrder
withLibLBI :: PackageDescription -> LocalBuildInfo -> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO () #
Perform the action on each enabled library
in the package
description with the ComponentLocalBuildInfo
.
withExeLBI :: PackageDescription -> LocalBuildInfo -> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO () #
Perform the action on each enabled Executable
in the package
description. Extended version of withExe
that also gives corresponding
build info.
withBenchLBI :: PackageDescription -> LocalBuildInfo -> (Benchmark -> ComponentLocalBuildInfo -> IO ()) -> IO () #
Perform the action on each enabled Benchmark
in the package
description.
withTestLBI :: PackageDescription -> LocalBuildInfo -> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO () #
enabledBenchLBIs :: PackageDescription -> LocalBuildInfo -> [(Benchmark, ComponentLocalBuildInfo)] #
Installation directories
type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)] #
data PathTemplateVariable #
PrefixVar | The |
BindirVar | The |
LibdirVar | The |
LibsubdirVar | The |
DynlibdirVar | The |
DatadirVar | The |
DatasubdirVar | The |
DocdirVar | The |
HtmldirVar | The |
PkgNameVar | The |
PkgVerVar | The |
PkgIdVar | The |
LibNameVar | The |
CompilerVar | The compiler name and version, eg |
OSVar | The operating system name, eg |
ArchVar | The CPU architecture name, eg |
AbiVar | The Compiler's ABI identifier, $arch-$os-$compiler-$abitag |
AbiTagVar | The optional ABI tag for the compiler |
ExecutableNameVar | The executable name; used in shell wrappers |
TestSuiteNameVar | The name of the test suite being run |
TestSuiteResultVar | The result of the test suite being run, eg
|
BenchmarkNameVar | The name of the benchmark being run |
Instances
data PathTemplate #
An abstract path, possibly containing variables that need to be
substituted for to get a real FilePath
.
Instances
The location prefix for the copy command.
NoCopyDest | |
CopyTo FilePath | |
CopyToDb FilePath | when using the ${pkgroot} as prefix. The CopyToDb will adjust the paths to be relative to the provided package database when copying / installing. |
Instances
Eq CopyDest # | |
Show CopyDest # | |
Generic CopyDest # | |
Binary CopyDest # | |
type Rep CopyDest # | |
Defined in Distribution.Simple.InstallDirs type Rep CopyDest = D1 (MetaData "CopyDest" "Distribution.Simple.InstallDirs" "Cabal-2.4.1.0-ALhzvdqe44A7vLWPOxSupv" False) (C1 (MetaCons "NoCopyDest" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "CopyTo" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)) :+: C1 (MetaCons "CopyToDb" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)))) |
type InstallDirTemplates = InstallDirs PathTemplate #
The installation directories in terms of PathTemplate
s that contain
variables.
The defaults for most of the directories are relative to each other, in
particular they are all relative to a single prefix. This makes it
convenient for the user to override the default installation directory
by only having to specify --prefix=... rather than overriding each
individually. This is done by allowing $-style variables in the dirs.
These are expanded by textual substitution (see substPathTemplate
).
A few of these installation directories are split into two components, the
dir and subdir. The full installation path is formed by combining the two
together with /
. The reason for this is compatibility with other Unix
build systems which also support --libdir
and --datadir
. We would like
users to be able to configure --libdir=/usr/lib64
for example but
because by default we want to support installing multiple versions of
packages and building the same package for multiple compilers we append the
libsubdir to get: /usr/lib64/$libname/$compiler
.
An additional complication is the need to support relocatable packages on systems which support such things, like Windows.
data InstallDirs dir #
The directories where we will install files for packages.
We have several different directories for different types of files since many systems have conventions whereby different types of files in a package are installed in different directories. This is particularly the case on Unix style systems.
InstallDirs | |
|
Instances
combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c #
defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates #
defaultInstallDirs' :: Bool -> CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates #
substituteInstallDirTemplates :: PathTemplateEnv -> InstallDirTemplates -> InstallDirTemplates #
Substitute the install dir templates into each other.
To prevent cyclic substitutions, only some variables are allowed in particular dir templates. If out of scope vars are present, they are not substituted for. Checking for any remaining unsubstituted vars can be done as a subsequent operation.
The reason it is done this way is so that in prefixRelativeInstallDirs
we
can replace prefix
with the PrefixVar
and get resulting
PathTemplate
s that still have the PrefixVar
in them. Doing this makes it
each to check which paths are relative to the $prefix.
toPathTemplate :: FilePath -> PathTemplate #
Convert a FilePath
to a PathTemplate
including any template vars.
fromPathTemplate :: PathTemplate -> FilePath #
Convert back to a path, any remaining vars are included
initialPathTemplateEnv :: PackageIdentifier -> UnitId -> CompilerInfo -> Platform -> PathTemplateEnv #
The initial environment has all the static stuff but no paths
abiTemplateEnv :: CompilerInfo -> Platform -> PathTemplateEnv #
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest -> InstallDirs FilePath #
Backwards compatibility function which computes the InstallDirs
assuming that $libname
points to the public library (or some fake
package identifier if there is no public library.) IF AT ALL
POSSIBLE, please use absoluteComponentInstallDirs
instead.
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo -> InstallDirs (Maybe FilePath) #
Backwards compatibility function which computes the InstallDirs
assuming that $libname
points to the public library (or some fake
package identifier if there is no public library.) IF AT ALL
POSSIBLE, please use prefixRelativeComponentInstallDirs
instead.
absoluteComponentInstallDirs :: PackageDescription -> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath #
See absoluteInstallDirs
.
prefixRelativeComponentInstallDirs :: PackageId -> LocalBuildInfo -> UnitId -> InstallDirs (Maybe FilePath) #
substPathTemplate :: PackageId -> LocalBuildInfo -> UnitId -> PathTemplate -> FilePath #