Distribution.Client.ProjectPlanning.SetupPolicy

cabal-install-3.12.1.0: The command-line interface for Cabal and Hackage.

Safe Haskell | None
Language | Haskell2010

Distribution.Client.ProjectPlanning.SetupPolicy

Description

Setup.hs script policy

Handling for Setup.hs scripts is a bit tricky, part of it lives in the solver phase, and part in the elaboration phase. We keep the helper functions for both phases together here so at least you can see all of it in one place.

There are four major cases for Setup.hs handling:

1. `build-type` Custom with a `custom-setup` section
2. `build-type` Custom without a `custom-setup` section
3. `build-type` not Custom with `cabal-version > $our-cabal-version`
4. `build-type` not Custom with `cabal-version <= $our-cabal-version`

It's also worth noting that packages specifying `cabal-version: >= 1.23` or later that have `build-type` Custom will always have a `custom-setup` section. Therefore in case 2, the specified `cabal-version` will always be less than 1.23.

In cases 1 and 2 we obviously have to build an external Setup.hs script, while in case 4 we can use the internal library API.

Since: 3.12.0.0

Synopsis

- mkDefaultSetupDeps :: Compiler -> Platform -> PackageDescription -> Maybe [Dependency]
- packageSetupScriptStyle :: PackageDescription -> SetupScriptStyle
- packageSetupScriptSpecVersion :: SetupScriptStyle -> PackageDescription -> Graph NonSetupLibDepSolverPlanPackage -> ComponentDeps [SolverId] -> Version
- newtype NonSetupLibDepSolverPlanPackage = NonSetupLibDepSolverPlanPackage {
  - unNonSetupLibDepSolverPlanPackage :: SolverPlanPackage
  }

# Documentation

mkDefaultSetupDeps :: Compiler -> Platform -> PackageDescription -> Maybe [Dependency] #

Part of our Setup.hs handling policy is implemented by getting the solver to work out setup dependencies for packages. The solver already handles packages that explicitly specify setup dependencies, but we can also tell the solver to treat other packages as if they had setup dependencies. That's what this function does, it gets called by `planPackages` for all packages that don't already have setup dependencies.

The dependencies we want to add is different for each `SetupScriptStyle`.

Note in addition to adding setup dependencies, we also use `addSetupCabalMinVersionConstraint` (in `planPackages`) to require `Cabal >= 1.20` for Setup scripts.

Since: 3.12.0.0

packageSetupScriptStyle :: PackageDescription -> SetupScriptStyle #

Work out the `SetupScriptStyle` given the package description.

Since: 3.12.0.0

packageSetupScriptSpecVersion :: SetupScriptStyle -> PackageDescription -> Graph NonSetupLibDepSolverPlanPackage -> ComponentDeps [SolverId] -> Version #

Work out which version of the Cabal we will be using to talk to the Setup.hs interface for this package.

This depends somewhat on the `SetupScriptStyle` but most cases are a result of what the solver picked for us, based on the explicit setup deps or the ones added implicitly by `mkDefaultSetupDeps`.

Since: 3.12.0.0

newtype NonSetupLibDepSolverPlanPackage #

A newtype for `SolverPlanPackage` for which the dependency graph considers only dependencies on libraries which are NOT from setup dependencies. Used to compute the set of packages needed for profiling and dynamic libraries.

Since: 3.12.0.0

Constructors

NonSetupLibDepSolverPlanPackage |
Fields unNonSetupLibDepSolverPlanPackage :: SolverPlanPackage

#### Instances

Instances details

IsNode NonSetupLibDepSolverPlanPackage # |
Instance details Defined in Distribution.Client.ProjectPlanning.SetupPolicy Associated Types
type Key NonSetupLibDepSolverPlanPackage |
Instance details Defined in Distribution.Client.ProjectPlanning.SetupPolicy type Key NonSetupLibDepSolverPlanPackage = SolverId
Methods nodeKey :: NonSetupLibDepSolverPlanPackage -> Key NonSetupLibDepSolverPlanPackage # nodeNeighbors :: NonSetupLibDepSolverPlanPackage -> [Key NonSetupLibDepSolverPlanPackage] #
Package NonSetupLibDepSolverPlanPackage # |
Instance details Defined in Distribution.Client.ProjectPlanning.SetupPolicy Methods packageId :: NonSetupLibDepSolverPlanPackage -> PackageIdentifier #
type Key NonSetupLibDepSolverPlanPackage # |
Instance details Defined in Distribution.Client.ProjectPlanning.SetupPolicy type Key NonSetupLibDepSolverPlanPackage = SolverId