Cabal-syntax-3.14.1.0: A library for working with .cabal files
CopyrightThomas Schilling 2007
LicenseBSD3
Maintainercabal-devel@haskell.org
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Distribution.PackageDescription.Configuration

Description

This is about the cabal configurations feature. It exports finalizePD and flattenPackageDescription which are functions for converting GenericPackageDescriptions down to PackageDescriptions. It has code for working with the tree of conditions and resolving or flattening conditions.

Synopsis

Documentation

finalizePD Source #

Arguments

:: FlagAssignment

Explicitly specified flag assignments

-> ComponentRequestedSpec 
-> (Dependency -> Bool)

Is a given dependency satisfiable from the set of available packages? If this is unknown then use True.

-> Platform

The Arch and OS

-> CompilerInfo

Compiler information

-> [PackageVersionConstraint]

Additional constraints

-> GenericPackageDescription 
-> Either [Dependency] (PackageDescription, FlagAssignment)

Either missing dependencies or the resolved package description along with the flag assignments chosen.

Create a package description with all configurations resolved.

This function takes a GenericPackageDescription and several environment parameters and tries to generate PackageDescription by finding a flag assignment that result in satisfiable dependencies.

It takes as inputs a not necessarily complete specifications of flags assignments, an optional package index as well as platform parameters. If some flags are not assigned explicitly, this function will try to pick an assignment that causes this function to succeed. The package index is optional since on some platforms we cannot determine which packages have been installed before. When no package index is supplied, every dependency is assumed to be satisfiable, therefore all not explicitly assigned flags will get their default values.

This function will fail if it cannot find a flag assignment that leads to satisfiable dependencies. (It will not try alternative assignments for explicitly specified flags.) In case of failure it will return the missing dependencies that it encountered when trying different flag assignments. On success, it will return the package description and the full flag assignment chosen.

Note that this drops any stanzas which have buildable: False. While this is arguably the right thing to do, it means we give bad error messages in some situations, see #3858.

flattenPackageDescription :: GenericPackageDescription -> PackageDescription Source #

Flatten a generic package description by ignoring all conditions and just join the field descriptors into on package description. Note, however, that this may lead to inconsistent field values, since all values are joined into one field, which may not be possible in the original package description, due to the use of exclusive choices (if ... else ...).

TODO: One particularly tricky case is defaulting. In the original package description, e.g., the source directory might either be the default or a certain, explicitly set path. Since defaults are filled in only after the package has been resolved and when no explicit value has been set, the default path will be missing from the package description returned by this function.

parseCondition :: CabalParsing m => m (Condition ConfVar) Source #

Parse a configuration condition from a string.

extractCondition :: Eq v => (a -> Bool) -> CondTree v c a -> Condition v Source #

Extract the condition matched by the given predicate from a cond tree.

We use this mainly for extracting buildable conditions (see the Note in Distribution.PackageDescription.Configuration), but the function is in fact more general.

extractConditions :: (BuildInfo -> Bool) -> GenericPackageDescription -> [Condition ConfVar] Source #

Extract conditions matched by the given predicate from all cond trees in a GenericPackageDescription.

addBuildableCondition :: (Eq v, Monoid a, Monoid c) => (a -> BuildInfo) -> CondTree v c a -> CondTree v c a Source #

Transforms a CondTree by putting the input under the "then" branch of a conditional that is True when Buildable is True. If addBuildableCondition can determine that Buildable is always True, it returns the input unchanged. If Buildable is always False, it returns the empty CondTree.

mapCondTree :: (a -> b) -> (c -> d) -> (Condition v -> Condition w) -> CondTree v c a -> CondTree w d b Source #

mapTreeData :: (a -> b) -> CondTree v c a -> CondTree v c b Source #

mapTreeConds :: (Condition v -> Condition w) -> CondTree v c a -> CondTree w c a Source #

mapTreeConstrs :: (c -> d) -> CondTree v c a -> CondTree v d a Source #

simplifyWithSysParams :: OS -> Arch -> CompilerInfo -> Condition ConfVar -> (Condition FlagName, [FlagName]) Source #

Simplify a configuration condition using the OS and arch names. Returns the names of all the flags occurring in the condition.