Copyright | Isaac Jones 2003-2005 |
---|---|
License | BSD3 |
Maintainer | cabal-devel@haskell.org |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This deals with the configure phase. It provides the configure
action
which is given the package description and configure flags. It then tries
to: configure the compiler; resolves any conditionals in the package
description; resolve the package dependencies; check if all the extensions
used by this package are supported by the compiler; check that all the build
tools are available (including version checks if appropriate); checks for
any required pkg-config
packages (updating the BuildInfo
with the
results)
Then based on all this it saves the info in the LocalBuildInfo
and writes
it out to the dist/setup-config
file. It also displays various details to
the user, the amount of information displayed depending on the verbosity
level.
Synopsis
- configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
- configure_setupHooks :: ConfigureHooks -> (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
- writePersistBuildConfig :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) -> LocalBuildInfo -> IO ()
- getConfigStateFile :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg File -> IO LocalBuildInfo
- getPersistBuildConfig :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) -> IO LocalBuildInfo
- checkPersistBuildConfigOutdated :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) -> SymbolicPath Pkg File -> IO Bool
- tryGetPersistBuildConfig :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) -> IO (Either ConfigStateFileError LocalBuildInfo)
- maybeGetPersistBuildConfig :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) -> IO (Maybe LocalBuildInfo)
- findDistPref :: SymbolicPath Pkg (Dir Dist) -> Flag (SymbolicPath Pkg (Dir Dist)) -> IO (SymbolicPath Pkg (Dir Dist))
- findDistPrefOrDefault :: Flag (SymbolicPath Pkg (Dir Dist)) -> IO (SymbolicPath Pkg (Dir Dist))
- getInternalLibraries :: GenericPackageDescription -> Set LibraryName
- computeComponentId :: Bool -> Flag String -> Flag ComponentId -> PackageIdentifier -> ComponentName -> Maybe ([ComponentId], FlagAssignment) -> ComponentId
- computeCompatPackageKey :: Compiler -> MungedPackageName -> Version -> UnitId -> String
- localBuildInfoFile :: SymbolicPath Pkg (Dir Dist) -> SymbolicPath Pkg File
- getInstalledPackages :: Verbosity -> Compiler -> Maybe (SymbolicPath CWD (Dir from)) -> PackageDBStackX (SymbolicPath from (Dir PkgDB)) -> ProgramDb -> IO InstalledPackageIndex
- getInstalledPackagesMonitorFiles :: Verbosity -> Compiler -> Maybe (SymbolicPath CWD ('Dir from)) -> PackageDBStackS from -> ProgramDb -> Platform -> IO [FilePath]
- getInstalledPackagesById :: (Exception (VerboseException exception), Show exception, Typeable exception) => Verbosity -> LocalBuildInfo -> (UnitId -> exception) -> [UnitId] -> IO [InstalledPackageInfo]
- getPackageDBContents :: Verbosity -> Compiler -> Maybe (SymbolicPath CWD (Dir Pkg)) -> PackageDB -> ProgramDb -> IO InstalledPackageIndex
- configCompilerEx :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath -> ProgramDb -> Verbosity -> IO (Compiler, Platform, ProgramDb)
- configCompilerAuxEx :: ConfigFlags -> IO (Compiler, Platform, ProgramDb)
- computeEffectiveProfiling :: ConfigFlags -> (Bool, Bool, Bool)
- ccLdOptionsBuildInfo :: [String] -> [String] -> [String] -> BuildInfo
- checkForeignDeps :: PackageDescription -> LocalBuildInfo -> Verbosity -> IO ()
- interpretPackageDbFlags :: Bool -> [Maybe (PackageDBX fp)] -> PackageDBStackX fp
- data ConfigStateFileError
- = ConfigStateFileNoHeader
- | ConfigStateFileBadHeader
- | ConfigStateFileNoParse
- | ConfigStateFileMissing {
- cfgStateFileErrorCwd :: Maybe (SymbolicPath CWD (Dir Pkg))
- cfgStateFileErrorFile :: SymbolicPath Pkg File
- | ConfigStateFileBadVersion PackageIdentifier PackageIdentifier (Either ConfigStateFileError LocalBuildInfo)
- tryGetConfigStateFile :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg File -> IO (Either ConfigStateFileError LocalBuildInfo)
- platformDefines :: LocalBuildInfo -> [String]
Documentation
configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo Source #
Perform the "./setup configure
" action.
Returns the .setup-config
file.
configure_setupHooks :: ConfigureHooks -> (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo Source #
writePersistBuildConfig Source #
:: Maybe (SymbolicPath CWD (Dir Pkg)) | Working directory |
-> SymbolicPath Pkg (Dir Dist) | The |
-> LocalBuildInfo | The |
-> IO () |
After running configure, output the LocalBuildInfo
to the
localBuildInfoFile
.
:: Maybe (SymbolicPath CWD (Dir Pkg)) | |
-> SymbolicPath Pkg File | The file path of the |
-> IO LocalBuildInfo |
Read the localBuildInfoFile
. Throw an exception if the file is
missing, if the file cannot be read, or if the file was created by an older
version of Cabal.
getPersistBuildConfig Source #
:: Maybe (SymbolicPath CWD (Dir Pkg)) | Working directory. |
-> SymbolicPath Pkg (Dir Dist) | The |
-> IO LocalBuildInfo |
Read the localBuildInfoFile
. Throw an exception if the file is
missing, if the file cannot be read, or if the file was created by an older
version of Cabal.
checkPersistBuildConfigOutdated :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) -> SymbolicPath Pkg File -> IO Bool Source #
Check that localBuildInfoFile is up-to-date with respect to the .cabal file.
tryGetPersistBuildConfig Source #
:: Maybe (SymbolicPath CWD (Dir Pkg)) | Working directory. |
-> SymbolicPath Pkg (Dir Dist) | The |
-> IO (Either ConfigStateFileError LocalBuildInfo) |
Try to read the localBuildInfoFile
.
maybeGetPersistBuildConfig Source #
:: Maybe (SymbolicPath CWD (Dir Pkg)) | Working directory. |
-> SymbolicPath Pkg (Dir Dist) | The |
-> IO (Maybe LocalBuildInfo) |
Try to read the localBuildInfoFile
.
:: SymbolicPath Pkg (Dir Dist) | default "dist" prefix |
-> Flag (SymbolicPath Pkg (Dir Dist)) | override "dist" prefix |
-> IO (SymbolicPath Pkg (Dir Dist)) |
Return the "dist/" prefix, or the default prefix. The prefix is taken from (in order of highest to lowest preference) the override prefix, the "CABAL_BUILDDIR" environment variable, or the default prefix.
findDistPrefOrDefault Source #
Return the "dist/" prefix, or the default prefix. The prefix is taken
from (in order of highest to lowest preference) the override prefix, the
"CABAL_BUILDDIR" environment variable, or defaultDistPref
is used. Call
this function to resolve a *DistPref
flag whenever it is not known to be
set. (The *DistPref
flags are always set to a definite value before
invoking UserHooks
.)
getInternalLibraries :: GenericPackageDescription -> Set LibraryName Source #
Create a PackageIndex that makes *any libraries that might be* defined internally to this package look like installed packages, in case an executable should refer to any of them as dependencies.
It must be *any libraries that might be* defined rather than the actual definitions, because these depend on conditionals in the .cabal file, and we haven't resolved them yet. finalizePD does the resolution of conditionals, and it takes internalPackageSet as part of its input.
computeComponentId :: Bool -> Flag String -> Flag ComponentId -> PackageIdentifier -> ComponentName -> Maybe ([ComponentId], FlagAssignment) -> ComponentId Source #
This method computes a default, "good enough" ComponentId
for a package. The intent is that cabal-install (or the user) will
specify a more detailed IPID via the --ipid
flag if necessary.
computeCompatPackageKey :: Compiler -> MungedPackageName -> Version -> UnitId -> String Source #
In GHC 8.0, the string we pass to GHC to use for symbol names for a package can be an arbitrary, IPID-compatible string. However, prior to GHC 8.0 there are some restrictions on what format this string can be (due to how ghc-pkg parsed the key):
- In GHC 7.10, the string had either be of the form foo_ABCD, where foo is a non-semantic alphanumeric/hyphenated prefix and ABCD is two base-64 encoded 64-bit integers, or a GHC 7.8 style identifier.
- In GHC 7.8, the string had to be a valid package identifier like foo-0.1.
So, the problem is that Cabal, in general, has a general IPID, but needs to figure out a package key / package ID that the old ghc-pkg will actually accept. But there's an EVERY WORSE problem: if ghc-pkg decides to parse an identifier foo-0.1-xxx as if it were a package identifier, which means it will SILENTLY DROP the "xxx" (because it's a tag, and Cabal does not allow tags.) So we must CONNIVE to ensure that we don't pick something that looks like this.
So this function attempts to define a mapping into the old formats.
The mapping for GHC 7.8 and before:
- We use the *compatibility* package name and version. For
public libraries this is just the package identifier; for
internal libraries, it's something like "z-pkgname-z-libname-0.1".
See
computeCompatPackageName
for more details.
The mapping for GHC 7.10:
For CLibName: If the IPID is of the form foo-0.1-ABCDEF where foo_ABCDEF would validly parse as a package key, we pass ABCDEF. (NB: not all hashes parse this way, because GHC 7.10 mandated that these hashes be two base-62 encoded 64 bit integers), but hashes that Cabal generated using
computeComponentId
are guaranteed to have this form.If it is not of this form, we rehash the IPID into the correct form and pass that.
- For sub-components, we rehash the IPID into the correct format and pass that.
:: SymbolicPath Pkg (Dir Dist) | The |
-> SymbolicPath Pkg File |
Get the path of dist/setup-config
.
:: Verbosity | |
-> Compiler | |
-> Maybe (SymbolicPath CWD (Dir from)) | |
-> PackageDBStackX (SymbolicPath from (Dir PkgDB)) | The stack of package databases. |
-> ProgramDb | |
-> IO InstalledPackageIndex |
List all installed packages in the given package databases. Non-existent package databases do not cause errors, they just get skipped with a warning and treated as empty ones, since technically they do not contain any package.
getInstalledPackagesMonitorFiles :: Verbosity -> Compiler -> Maybe (SymbolicPath CWD ('Dir from)) -> PackageDBStackS from -> ProgramDb -> Platform -> IO [FilePath] Source #
A set of files (or directories) that can be monitored to detect when there might have been a change in the installed packages.
getInstalledPackagesById Source #
:: (Exception (VerboseException exception), Show exception, Typeable exception) | |
=> Verbosity | |
-> LocalBuildInfo | |
-> (UnitId -> exception) | Construct an exception that is thrown if a unit-id is not found in the installed packages, from the unit-id that is missing. |
-> [UnitId] | The unit ids to lookup in the installed packages |
-> IO [InstalledPackageInfo] |
Looks up the InstalledPackageInfo
of the given UnitId
s from the
PackageDBStack
in the LocalBuildInfo
.
getPackageDBContents :: Verbosity -> Compiler -> Maybe (SymbolicPath CWD (Dir Pkg)) -> PackageDB -> ProgramDb -> IO InstalledPackageIndex Source #
Like getInstalledPackages
, but for a single package DB.
NB: Why isn't this always a fall through to getInstalledPackages
?
That is because getInstalledPackages
performs some sanity checks
on the package database stack in question. However, when sandboxes
are involved these sanity checks are not desirable.
configCompilerEx :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath -> ProgramDb -> Verbosity -> IO (Compiler, Platform, ProgramDb) Source #
configCompilerAuxEx :: ConfigFlags -> IO (Compiler, Platform, ProgramDb) Source #
computeEffectiveProfiling :: ConfigFlags -> (Bool, Bool, Bool) Source #
Compute the effective value of the profiling flags
--enable-library-profiling
and --enable-executable-profiling
from the specified ConfigFlags
. This may be useful for
external Cabal tools which need to interact with Setup in
a backwards-compatible way: the most predictable mechanism
for enabling profiling across many legacy versions is to
NOT use --enable-profiling
and use those two flags instead.
Note that --enable-executable-profiling
also affects profiling
of benchmarks and (non-detailed) test suites.
ccLdOptionsBuildInfo :: [String] -> [String] -> [String] -> BuildInfo Source #
Makes a BuildInfo
from C compiler and linker flags.
This can be used with the output from configuration programs like pkg-config and similar package-specific programs like mysql-config, freealut-config etc. For example:
ccflags <- getDbProgramOutput verbosity prog progdb ["--cflags"] ldflags <- getDbProgramOutput verbosity prog progdb ["--libs"] ldflags_static <- getDbProgramOutput verbosity prog progdb ["--libs", "--static"] return (ccldOptionsBuildInfo (words ccflags) (words ldflags) (words ldflags_static))
checkForeignDeps :: PackageDescription -> LocalBuildInfo -> Verbosity -> IO () Source #
interpretPackageDbFlags :: Bool -> [Maybe (PackageDBX fp)] -> PackageDBStackX fp Source #
The user interface specifies the package dbs to use with a combination of
--global
, --user
and --package-db=global|user|clear|$file
.
This function combines the global/user flag and interprets the package-db
flag into a single package db stack.
data ConfigStateFileError Source #
The errors that can be thrown when reading the setup-config
file.
ConfigStateFileNoHeader | No header found. |
ConfigStateFileBadHeader | Incorrect header. |
ConfigStateFileNoParse | Cannot parse file contents. |
ConfigStateFileMissing | No file! |
| |
ConfigStateFileBadVersion PackageIdentifier PackageIdentifier (Either ConfigStateFileError LocalBuildInfo) | Mismatched version. |
Instances
Exception ConfigStateFileError Source # | |
Show ConfigStateFileError Source # | |
Defined in Distribution.Simple.Configure showsPrec :: Int -> ConfigStateFileError -> ShowS # show :: ConfigStateFileError -> String # showList :: [ConfigStateFileError] -> ShowS # |
tryGetConfigStateFile Source #
:: Maybe (SymbolicPath CWD (Dir Pkg)) | Working directory. |
-> SymbolicPath Pkg File | The file path of the |
-> IO (Either ConfigStateFileError LocalBuildInfo) |
Read the localBuildInfoFile
, returning either an error or the local build
info.
platformDefines :: LocalBuildInfo -> [String] Source #