summaryrefslogtreecommitdiff
path: root/hadrian/src/Hadrian/Target.hs
blob: 88489776c08e1d89b7e8bf37379caf5f4003618a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Hadrian.Target (Target, target, context, builder, inputs, outputs) where

import Development.Shake.Classes
import GHC.Generics

-- | Each invocation of a builder is fully described by a 'Target', which
-- comprises a build context (type variable @c@), a builder (type variable @b@),
-- a list of input files and a list of output files. For example:
--
-- @
-- preludeTarget = Target (GHC.Context) (GHC.Builder)
--     { context = Context Stage1 base profiling
--     , builder = Ghc Stage1
--     , inputs = ["libraries/base/Prelude.hs"]
--     , outputs = ["build/stage1/libraries/base/Prelude.p_o"] }
-- @
data Target c b = Target
    { context :: c          -- ^ Current build context
    , builder :: b          -- ^ Builder to be invoked
    , inputs  :: [FilePath] -- ^ Input files for the builder
    , outputs :: [FilePath] -- ^ Files to be produced
    } deriving (Eq, Generic, Show)

target :: c -> b -> [FilePath] -> [FilePath] -> Target c b
target = Target

instance (Binary   c, Binary   b) => Binary   (Target c b)
instance (Hashable c, Hashable b) => Hashable (Target c b)
instance (NFData   c, NFData   b) => NFData   (Target c b)