Distribution.Simple.SetupHooks.Internal

Cabal-3.16.0.0: A framework for packaging Haskell software

Safe Haskell | None
Language | Haskell2010

Distribution.Simple.SetupHooks.Internal

Contents

- The setup hooks datatype
- Configure hooks
  - Per-package configure hooks
  - Per-component configure hooks
- Build hooks
  - Pre-build rules
  - Post-build hook
- Install hooks
- Internals
  - Per-component hook utilities
  - Executing build rules
  - HookedBuildInfo compatibility code

Description

Internal implementation module. Users of `build-type: Hooks` should import Distribution.Simple.SetupHooks instead.

Synopsis

- data SetupHooks = SetupHooks {
  - configureHooks :: ConfigureHooks
  - buildHooks :: BuildHooks
  - installHooks :: InstallHooks
  }
- noSetupHooks :: SetupHooks
- data ConfigureHooks = ConfigureHooks {
  - preConfPackageHook :: Maybe PreConfPackageHook
  - postConfPackageHook :: Maybe PostConfPackageHook
  - preConfComponentHook :: Maybe PreConfComponentHook
  }
- noConfigureHooks :: ConfigureHooks
- data PreConfPackageInputs = PreConfPackageInputs {
  - configFlags :: ConfigFlags
  - localBuildConfig :: LocalBuildConfig
  - compiler :: Compiler
  - platform :: Platform
  }
- data PreConfPackageOutputs = PreConfPackageOutputs {
  - buildOptions :: BuildOptions
  - extraConfiguredProgs :: ConfiguredProgs
  }
- noPreConfPackageOutputs :: PreConfPackageInputs -> PreConfPackageOutputs
- type PreConfPackageHook = PreConfPackageInputs -> IO PreConfPackageOutputs
- data PostConfPackageInputs = PostConfPackageInputs {
  - localBuildConfig :: LocalBuildConfig
  - packageBuildDescr :: PackageBuildDescr
  }
- type PostConfPackageHook = PostConfPackageInputs -> IO ()
- data PreConfComponentInputs = PreConfComponentInputs {
  - localBuildConfig :: LocalBuildConfig
  - packageBuildDescr :: PackageBuildDescr
  - component :: Component
  }
- data PreConfComponentOutputs = PreConfComponentOutputs {
  - componentDiff :: ComponentDiff
  }
- noPreConfComponentOutputs :: PreConfComponentInputs -> PreConfComponentOutputs
- type PreConfComponentHook = PreConfComponentInputs -> IO PreConfComponentOutputs
- newtype ComponentDiff = ComponentDiff {
  - componentDiff :: Component
  }
- emptyComponentDiff :: ComponentName -> ComponentDiff
- buildInfoComponentDiff :: ComponentName -> BuildInfo -> ComponentDiff
- type LibraryDiff = Library
- type ForeignLibDiff = ForeignLib
- type ExecutableDiff = Executable
- type TestSuiteDiff = TestSuite
- type BenchmarkDiff = Benchmark
- type BuildInfoDiff = BuildInfo
- data BuildHooks = BuildHooks {
  - preBuildComponentRules :: Maybe PreBuildComponentRules
  - postBuildComponentHook :: Maybe PostBuildComponentHook
  }
- noBuildHooks :: BuildHooks
- data BuildingWhat
  - = BuildNormal BuildFlags
  - | BuildRepl ReplFlags
  - | BuildHaddock HaddockFlags
  - | BuildHscolour HscolourFlags
- buildingWhatVerbosity :: BuildingWhat -> Verbosity
- buildingWhatWorkingDir :: BuildingWhat -> Maybe (SymbolicPath CWD ('Dir Pkg))
- buildingWhatDistPref :: BuildingWhat -> SymbolicPath Pkg ('Dir Dist)
- data PreBuildComponentInputs = PreBuildComponentInputs {
  - buildingWhat :: BuildingWhat
  - localBuildInfo :: LocalBuildInfo
  - targetInfo :: TargetInfo
  }
- type PreBuildComponentRules = Rules PreBuildComponentInputs
- data PostBuildComponentInputs = PostBuildComponentInputs {
  - buildFlags :: BuildFlags
  - localBuildInfo :: LocalBuildInfo
  - targetInfo :: TargetInfo
  }
- type PostBuildComponentHook = PostBuildComponentInputs -> IO ()
- data InstallHooks = InstallHooks {
  - installComponentHook :: Maybe InstallComponentHook
  }
- noInstallHooks :: InstallHooks
- data InstallComponentInputs = InstallComponentInputs {
  - copyFlags :: CopyFlags
  - localBuildInfo :: LocalBuildInfo
  - targetInfo :: TargetInfo
  }
- type InstallComponentHook = InstallComponentInputs -> IO ()
- applyComponentDiffs :: Verbosity -> (Component -> IO (Maybe ComponentDiff)) -> PackageDescription -> IO PackageDescription
- forComponents_ :: PackageDescription -> (Component -> IO ()) -> IO ()
- executeRules :: Verbosity -> LocalBuildInfo -> TargetInfo -> Map RuleId Rule -> IO ()
- hookedBuildInfoComponents :: HookedBuildInfo -> Set ComponentName
- hookedBuildInfoComponentDiff_maybe :: HookedBuildInfo -> ComponentName -> Maybe (IO ComponentDiff)

# The setup hooks datatype

data SetupHooks Source #

Hooks into the `cabal` build phases.

Usage:

- In your `.cabal` file, declare `build-type: Hooks` (with a `cabal-version` greater than or equal to `3.14`),
- In your `.cabal` file, include a `custom-setup` stanza which declares the dependencies of your `SetupHooks` module; this will usually contain a dependency on the `Cabal-hooks` package.
- Provide a `SetupHooks.hs` module next to your `.cabal` file; it must export `setupHooks :: SetupHooks`.

Constructors

SetupHooks |
Fields configureHooks :: ConfigureHooks Hooks into the configure phase. buildHooks :: BuildHooks Hooks into the build phase. These hooks are relevant to any build-like phase, such as repl or haddock. installHooks :: InstallHooks Hooks into the copy/install phase.

#### Instances

Instances details

Monoid SetupHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods mempty :: SetupHooks # mappend :: SetupHooks -> SetupHooks -> SetupHooks # mconcat :: [SetupHooks] -> SetupHooks #
Semigroup SetupHooks Source # | `SetupHooks` can be combined monoidally. This is useful to combine setup hooks defined by another package with your own package-specific hooks. Warning: this `Semigroup` instance is not commutative.
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods (<>) :: SetupHooks -> SetupHooks -> SetupHooks # sconcat :: NonEmpty SetupHooks -> SetupHooks # stimes :: Integral b => b -> SetupHooks -> SetupHooks #

noSetupHooks :: SetupHooks Source #

Empty hooks.

# Configure hooks

data ConfigureHooks Source #

Configure-time hooks.

Order of execution:

- `preConfPackageHook`,
- configure the package,
- `postConfPackageHook`,
- `preConfComponentHook`,
- configure the components.

Constructors

ConfigureHooks |
Fields preConfPackageHook :: Maybe PreConfPackageHook Package-wide pre-configure hook. See `PreConfPackageHook`. postConfPackageHook :: Maybe PostConfPackageHook Package-wide post-configure hook. See `PostConfPackageHook`. preConfComponentHook :: Maybe PreConfComponentHook Per-component pre-configure hook. See `PreConfComponentHook`.

#### Instances

Instances details

Monoid ConfigureHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods mempty :: ConfigureHooks # mappend :: ConfigureHooks -> ConfigureHooks -> ConfigureHooks # mconcat :: [ConfigureHooks] -> ConfigureHooks #
Semigroup ConfigureHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods (<>) :: ConfigureHooks -> ConfigureHooks -> ConfigureHooks # sconcat :: NonEmpty ConfigureHooks -> ConfigureHooks # stimes :: Integral b => b -> ConfigureHooks -> ConfigureHooks #

noConfigureHooks :: ConfigureHooks Source #

Empty configure phase hooks.

## Per-package configure hooks

data PreConfPackageInputs Source #

Inputs to the package-wide pre-configure step.

Constructors

PreConfPackageInputs |
Fields configFlags :: ConfigFlags localBuildConfig :: LocalBuildConfig Warning: the `ProgramDb` in the `withPrograms` field will not contain any unconfigured programs. compiler :: Compiler platform :: Platform

#### Instances

Instances details

Structured PreConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PreConfPackageInputs -> Structure Source # structureHash' :: Tagged PreConfPackageInputs MD5
Binary PreConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PreConfPackageInputs -> Put # get :: Get PreConfPackageInputs # putList :: [PreConfPackageInputs] -> Put #
Generic PreConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PreConfPackageInputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfPackageInputs = D1 ('MetaData "PreConfPackageInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfPackageInputs" 'PrefixI 'True) ((S1 ('MetaSel ('Just "configFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfigFlags) :*: S1 ('MetaSel ('Just "localBuildConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildConfig)) :*: (S1 ('MetaSel ('Just "compiler") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Compiler) :*: S1 ('MetaSel ('Just "platform") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Platform))))
Methods from :: PreConfPackageInputs -> Rep PreConfPackageInputs x # to :: Rep PreConfPackageInputs x -> PreConfPackageInputs #
Show PreConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PreConfPackageInputs -> ShowS # show :: PreConfPackageInputs -> String # showList :: [PreConfPackageInputs] -> ShowS #
type Rep PreConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfPackageInputs = D1 ('MetaData "PreConfPackageInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfPackageInputs" 'PrefixI 'True) ((S1 ('MetaSel ('Just "configFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfigFlags) :*: S1 ('MetaSel ('Just "localBuildConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildConfig)) :*: (S1 ('MetaSel ('Just "compiler") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Compiler) :*: S1 ('MetaSel ('Just "platform") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Platform))))

data PreConfPackageOutputs Source #

Outputs of the package-wide pre-configure step.

Prefer using `noPreConfPackageOutputs` and overriding the fields you care about, to avoid depending on implementation details of this datatype.

Constructors

PreConfPackageOutputs |
Fields buildOptions :: BuildOptions extraConfiguredProgs :: ConfiguredProgs

#### Instances

Instances details

Structured PreConfPackageOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PreConfPackageOutputs -> Structure Source # structureHash' :: Tagged PreConfPackageOutputs MD5
Binary PreConfPackageOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PreConfPackageOutputs -> Put # get :: Get PreConfPackageOutputs # putList :: [PreConfPackageOutputs] -> Put #
Generic PreConfPackageOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PreConfPackageOutputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfPackageOutputs = D1 ('MetaData "PreConfPackageOutputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfPackageOutputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "buildOptions") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildOptions) :*: S1 ('MetaSel ('Just "extraConfiguredProgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfiguredProgs)))
Methods from :: PreConfPackageOutputs -> Rep PreConfPackageOutputs x # to :: Rep PreConfPackageOutputs x -> PreConfPackageOutputs #
Show PreConfPackageOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PreConfPackageOutputs -> ShowS # show :: PreConfPackageOutputs -> String # showList :: [PreConfPackageOutputs] -> ShowS #
type Rep PreConfPackageOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfPackageOutputs = D1 ('MetaData "PreConfPackageOutputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfPackageOutputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "buildOptions") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildOptions) :*: S1 ('MetaSel ('Just "extraConfiguredProgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConfiguredProgs)))

noPreConfPackageOutputs :: PreConfPackageInputs -> PreConfPackageOutputs Source #

Use this smart constructor to declare an empty set of changes by the package-wide pre-configure hook, and override the fields you care about.

Use this rather than `PreConfPackageOutputs` to avoid relying on internal implementation details of the latter.

type PreConfPackageHook = PreConfPackageInputs -> IO PreConfPackageOutputs Source #

data PostConfPackageInputs Source #

Inputs to the package-wide post-configure step.

Constructors

PostConfPackageInputs |
Fields localBuildConfig :: LocalBuildConfig packageBuildDescr :: PackageBuildDescr

#### Instances

Instances details

Structured PostConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PostConfPackageInputs -> Structure Source # structureHash' :: Tagged PostConfPackageInputs MD5
Binary PostConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PostConfPackageInputs -> Put # get :: Get PostConfPackageInputs # putList :: [PostConfPackageInputs] -> Put #
Generic PostConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PostConfPackageInputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PostConfPackageInputs = D1 ('MetaData "PostConfPackageInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PostConfPackageInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "localBuildConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildConfig) :*: S1 ('MetaSel ('Just "packageBuildDescr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageBuildDescr)))
Methods from :: PostConfPackageInputs -> Rep PostConfPackageInputs x # to :: Rep PostConfPackageInputs x -> PostConfPackageInputs #
Show PostConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PostConfPackageInputs -> ShowS # show :: PostConfPackageInputs -> String # showList :: [PostConfPackageInputs] -> ShowS #
type Rep PostConfPackageInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PostConfPackageInputs = D1 ('MetaData "PostConfPackageInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PostConfPackageInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "localBuildConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildConfig) :*: S1 ('MetaSel ('Just "packageBuildDescr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageBuildDescr)))

type PostConfPackageHook = PostConfPackageInputs -> IO () Source #

Package-wide post-configure step.

Perform side effects. Last opportunity for any package-wide logic; any subsequent hooks work per-component.

## Per-component configure hooks

data PreConfComponentInputs Source #

Inputs to the per-component pre-configure step.

Constructors

PreConfComponentInputs |
Fields localBuildConfig :: LocalBuildConfig packageBuildDescr :: PackageBuildDescr component :: Component

#### Instances

Instances details

Structured PreConfComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PreConfComponentInputs -> Structure Source # structureHash' :: Tagged PreConfComponentInputs MD5
Binary PreConfComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PreConfComponentInputs -> Put # get :: Get PreConfComponentInputs # putList :: [PreConfComponentInputs] -> Put #
Generic PreConfComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PreConfComponentInputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfComponentInputs = D1 ('MetaData "PreConfComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "localBuildConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildConfig) :*: (S1 ('MetaSel ('Just "packageBuildDescr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageBuildDescr) :*: S1 ('MetaSel ('Just "component") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Component))))
Methods from :: PreConfComponentInputs -> Rep PreConfComponentInputs x # to :: Rep PreConfComponentInputs x -> PreConfComponentInputs #
Show PreConfComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PreConfComponentInputs -> ShowS # show :: PreConfComponentInputs -> String # showList :: [PreConfComponentInputs] -> ShowS #
type Rep PreConfComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfComponentInputs = D1 ('MetaData "PreConfComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "localBuildConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildConfig) :*: (S1 ('MetaSel ('Just "packageBuildDescr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageBuildDescr) :*: S1 ('MetaSel ('Just "component") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Component))))

data PreConfComponentOutputs Source #

Outputs of the per-component pre-configure step.

Prefer using `noPreComponentOutputs` and overriding the fields you care about, to avoid depending on implementation details of this datatype.

Constructors

PreConfComponentOutputs |
Fields componentDiff :: ComponentDiff

#### Instances

Instances details

Structured PreConfComponentOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PreConfComponentOutputs -> Structure Source # structureHash' :: Tagged PreConfComponentOutputs MD5
Binary PreConfComponentOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PreConfComponentOutputs -> Put # get :: Get PreConfComponentOutputs # putList :: [PreConfComponentOutputs] -> Put #
Generic PreConfComponentOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PreConfComponentOutputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfComponentOutputs = D1 ('MetaData "PreConfComponentOutputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfComponentOutputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "componentDiff") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ComponentDiff)))
Methods from :: PreConfComponentOutputs -> Rep PreConfComponentOutputs x # to :: Rep PreConfComponentOutputs x -> PreConfComponentOutputs #
Show PreConfComponentOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PreConfComponentOutputs -> ShowS # show :: PreConfComponentOutputs -> String # showList :: [PreConfComponentOutputs] -> ShowS #
type Rep PreConfComponentOutputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreConfComponentOutputs = D1 ('MetaData "PreConfComponentOutputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreConfComponentOutputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "componentDiff") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ComponentDiff)))

noPreConfComponentOutputs :: PreConfComponentInputs -> PreConfComponentOutputs Source #

Use this smart constructor to declare an empty set of changes by a per-component pre-configure hook, and override the fields you care about.

Use this rather than `PreConfComponentOutputs` to avoid relying on internal implementation details of the latter.

type PreConfComponentHook = PreConfComponentInputs -> IO PreConfComponentOutputs Source #

Per-component pre-configure step.

For each component of the package, this hook can perform side effects, and return a diff to the passed in component, e.g. to declare additional autogenerated modules.

newtype ComponentDiff Source #

A diff to a Cabal `Component`, that gets combined monoidally into an existing `Component`.

Constructors

ComponentDiff |
Fields componentDiff :: Component

#### Instances

Instances details

Structured ComponentDiff Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy ComponentDiff -> Structure Source # structureHash' :: Tagged ComponentDiff MD5
Binary ComponentDiff Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: ComponentDiff -> Put # get :: Get ComponentDiff # putList :: [ComponentDiff] -> Put #
Semigroup ComponentDiff Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods (<>) :: ComponentDiff -> ComponentDiff -> ComponentDiff # sconcat :: NonEmpty ComponentDiff -> ComponentDiff # stimes :: Integral b => b -> ComponentDiff -> ComponentDiff #
Show ComponentDiff Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> ComponentDiff -> ShowS # show :: ComponentDiff -> String # showList :: [ComponentDiff] -> ShowS #

emptyComponentDiff :: ComponentName -> ComponentDiff Source #

buildInfoComponentDiff :: ComponentName -> BuildInfo -> ComponentDiff Source #

type LibraryDiff = Library Source #

type ForeignLibDiff = ForeignLib Source #

type ExecutableDiff = Executable Source #

type TestSuiteDiff = TestSuite Source #

type BenchmarkDiff = Benchmark Source #

type BuildInfoDiff = BuildInfo Source #

# Build hooks

data BuildHooks Source #

Build-time hooks.

Constructors

BuildHooks |
Fields preBuildComponentRules :: Maybe PreBuildComponentRules Per-component fine-grained pre-build rules. postBuildComponentHook :: Maybe PostBuildComponentHook Per-component post-build hook.

#### Instances

Instances details

Monoid BuildHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods mempty :: BuildHooks # mappend :: BuildHooks -> BuildHooks -> BuildHooks # mconcat :: [BuildHooks] -> BuildHooks #
Semigroup BuildHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods (<>) :: BuildHooks -> BuildHooks -> BuildHooks # sconcat :: NonEmpty BuildHooks -> BuildHooks # stimes :: Integral b => b -> BuildHooks -> BuildHooks #

noBuildHooks :: BuildHooks Source #

Empty build hooks.

data BuildingWhat Source #

What kind of build phase are we doing/hooking into?

Is this a normal build, or is it perhaps for running an interactive session or Haddock?

Constructors

BuildNormal BuildFlags | A normal build.
BuildRepl ReplFlags | Build steps for an interactive session.
BuildHaddock HaddockFlags | Build steps for generating documentation.
BuildHscolour HscolourFlags | Build steps for Hscolour.

#### Instances

Instances details

Structured BuildingWhat Source # |
Instance details Defined in Distribution.Simple.Setup Methods structure :: Proxy BuildingWhat -> Structure Source # structureHash' :: Tagged BuildingWhat MD5
Binary BuildingWhat Source # |
Instance details Defined in Distribution.Simple.Setup Methods put :: BuildingWhat -> Put # get :: Get BuildingWhat # putList :: [BuildingWhat] -> Put #
Generic BuildingWhat Source # |
Instance details Defined in Distribution.Simple.Setup Associated Types
type Rep BuildingWhat |
Instance details Defined in Distribution.Simple.Setup type Rep BuildingWhat = D1 ('MetaData "BuildingWhat" "Distribution.Simple.Setup" "Cabal-3.16.0.0-558c" 'False) ((C1 ('MetaCons "BuildNormal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildFlags)) :+: C1 ('MetaCons "BuildRepl" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReplFlags))) :+: (C1 ('MetaCons "BuildHaddock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HaddockFlags)) :+: C1 ('MetaCons "BuildHscolour" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HscolourFlags))))
Methods from :: BuildingWhat -> Rep BuildingWhat x # to :: Rep BuildingWhat x -> BuildingWhat #
Show BuildingWhat Source # |
Instance details Defined in Distribution.Simple.Setup Methods showsPrec :: Int -> BuildingWhat -> ShowS # show :: BuildingWhat -> String # showList :: [BuildingWhat] -> ShowS #
type Rep BuildingWhat Source # |
Instance details Defined in Distribution.Simple.Setup type Rep BuildingWhat = D1 ('MetaData "BuildingWhat" "Distribution.Simple.Setup" "Cabal-3.16.0.0-558c" 'False) ((C1 ('MetaCons "BuildNormal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildFlags)) :+: C1 ('MetaCons "BuildRepl" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReplFlags))) :+: (C1 ('MetaCons "BuildHaddock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HaddockFlags)) :+: C1 ('MetaCons "BuildHscolour" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HscolourFlags))))

buildingWhatVerbosity :: BuildingWhat -> Verbosity Source #

buildingWhatWorkingDir :: BuildingWhat -> Maybe (SymbolicPath CWD ('Dir Pkg)) Source #

buildingWhatDistPref :: BuildingWhat -> SymbolicPath Pkg ('Dir Dist) Source #

## Pre-build rules

data PreBuildComponentInputs Source #

Constructors

PreBuildComponentInputs |
Fields buildingWhat :: BuildingWhat what kind of build phase are we hooking into? localBuildInfo :: LocalBuildInfo information about the package targetInfo :: TargetInfo information about an individual component

#### Instances

Instances details

Structured PreBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PreBuildComponentInputs -> Structure Source # structureHash' :: Tagged PreBuildComponentInputs MD5
Binary PreBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PreBuildComponentInputs -> Put # get :: Get PreBuildComponentInputs # putList :: [PreBuildComponentInputs] -> Put #
Generic PreBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PreBuildComponentInputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreBuildComponentInputs = D1 ('MetaData "PreBuildComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreBuildComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "buildingWhat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildingWhat) :*: (S1 ('MetaSel ('Just "localBuildInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildInfo) :*: S1 ('MetaSel ('Just "targetInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetInfo))))
Methods from :: PreBuildComponentInputs -> Rep PreBuildComponentInputs x # to :: Rep PreBuildComponentInputs x -> PreBuildComponentInputs #
Show PreBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PreBuildComponentInputs -> ShowS # show :: PreBuildComponentInputs -> String # showList :: [PreBuildComponentInputs] -> ShowS #
type Rep PreBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PreBuildComponentInputs = D1 ('MetaData "PreBuildComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PreBuildComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "buildingWhat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildingWhat) :*: (S1 ('MetaSel ('Just "localBuildInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildInfo) :*: S1 ('MetaSel ('Just "targetInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetInfo))))

type PreBuildComponentRules = Rules PreBuildComponentInputs Source #

## Post-build hook

data PostBuildComponentInputs Source #

Constructors

PostBuildComponentInputs |
Fields buildFlags :: BuildFlags localBuildInfo :: LocalBuildInfo targetInfo :: TargetInfo

#### Instances

Instances details

Structured PostBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy PostBuildComponentInputs -> Structure Source # structureHash' :: Tagged PostBuildComponentInputs MD5
Binary PostBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: PostBuildComponentInputs -> Put # get :: Get PostBuildComponentInputs # putList :: [PostBuildComponentInputs] -> Put #
Generic PostBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep PostBuildComponentInputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PostBuildComponentInputs = D1 ('MetaData "PostBuildComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PostBuildComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "buildFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildFlags) :*: (S1 ('MetaSel ('Just "localBuildInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildInfo) :*: S1 ('MetaSel ('Just "targetInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetInfo))))
Methods from :: PostBuildComponentInputs -> Rep PostBuildComponentInputs x # to :: Rep PostBuildComponentInputs x -> PostBuildComponentInputs #
Show PostBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> PostBuildComponentInputs -> ShowS # show :: PostBuildComponentInputs -> String # showList :: [PostBuildComponentInputs] -> ShowS #
type Rep PostBuildComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep PostBuildComponentInputs = D1 ('MetaData "PostBuildComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "PostBuildComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "buildFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuildFlags) :*: (S1 ('MetaSel ('Just "localBuildInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildInfo) :*: S1 ('MetaSel ('Just "targetInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetInfo))))

type PostBuildComponentHook = PostBuildComponentInputs -> IO () Source #

# Install hooks

data InstallHooks Source #

Copy/install hooks.

Constructors

InstallHooks |
Fields installComponentHook :: Maybe InstallComponentHook Per-component install hook.

#### Instances

Instances details

Monoid InstallHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods mempty :: InstallHooks # mappend :: InstallHooks -> InstallHooks -> InstallHooks # mconcat :: [InstallHooks] -> InstallHooks #
Semigroup InstallHooks Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods (<>) :: InstallHooks -> InstallHooks -> InstallHooks # sconcat :: NonEmpty InstallHooks -> InstallHooks # stimes :: Integral b => b -> InstallHooks -> InstallHooks #

noInstallHooks :: InstallHooks Source #

Empty copy/install hooks.

data InstallComponentInputs Source #

Constructors

InstallComponentInputs |
Fields copyFlags :: CopyFlags localBuildInfo :: LocalBuildInfo targetInfo :: TargetInfo

#### Instances

Instances details

Structured InstallComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods structure :: Proxy InstallComponentInputs -> Structure Source # structureHash' :: Tagged InstallComponentInputs MD5
Binary InstallComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods put :: InstallComponentInputs -> Put # get :: Get InstallComponentInputs # putList :: [InstallComponentInputs] -> Put #
Generic InstallComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Associated Types
type Rep InstallComponentInputs |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep InstallComponentInputs = D1 ('MetaData "InstallComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "InstallComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "copyFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CopyFlags) :*: (S1 ('MetaSel ('Just "localBuildInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildInfo) :*: S1 ('MetaSel ('Just "targetInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetInfo))))
Methods from :: InstallComponentInputs -> Rep InstallComponentInputs x # to :: Rep InstallComponentInputs x -> InstallComponentInputs #
Show InstallComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal Methods showsPrec :: Int -> InstallComponentInputs -> ShowS # show :: InstallComponentInputs -> String # showList :: [InstallComponentInputs] -> ShowS #
type Rep InstallComponentInputs Source # |
Instance details Defined in Distribution.Simple.SetupHooks.Internal type Rep InstallComponentInputs = D1 ('MetaData "InstallComponentInputs" "Distribution.Simple.SetupHooks.Internal" "Cabal-3.16.0.0-558c" 'False) (C1 ('MetaCons "InstallComponentInputs" 'PrefixI 'True) (S1 ('MetaSel ('Just "copyFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CopyFlags) :*: (S1 ('MetaSel ('Just "localBuildInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalBuildInfo) :*: S1 ('MetaSel ('Just "targetInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetInfo))))

type InstallComponentHook = InstallComponentInputs -> IO () Source #

A per-component install hook, which can only perform side effects (e.g. copying files).

# Internals

## Per-component hook utilities

applyComponentDiffs :: Verbosity -> (Component -> IO (Maybe ComponentDiff)) -> PackageDescription -> IO PackageDescription Source #

forComponents_ :: PackageDescription -> (Component -> IO ()) -> IO () Source #

## Executing build rules

executeRules :: Verbosity -> LocalBuildInfo -> TargetInfo -> Map RuleId Rule -> IO () Source #

Run all pre-build rules.

This function should only be called internally within `Cabal`, as it is used to implement the (legacy) Setup.hs interface. The build tool (e.g. `cabal-install` or `hls`) should instead go through the separate hooks executable, which allows us to only rerun the out-of-date rules (instead of running all of these rules at once).

## HookedBuildInfo compatibility code

hookedBuildInfoComponents :: HookedBuildInfo -> Set ComponentName Source #

hookedBuildInfoComponentDiff_maybe :: HookedBuildInfo -> ComponentName -> Maybe (IO ComponentDiff) Source #