Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
1b013b08
Commit
1b013b08
authored
Jan 06, 2016
by
quchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Haddocks to Target.hs
parent
bee9ceed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
33 deletions
+46
-33
src/Expression.hs
src/Expression.hs
+2
-2
src/Target.hs
src/Target.hs
+44
-31
No files found.
src/Expression.hs
View file @
1b013b08
...
...
@@ -12,7 +12,7 @@ module Expression (
-- ** Common expressions
Args
,
Ways
,
Packages
,
-- ** Targets
Target
,
PartialTarget
(
..
),
f
romPartial
,
fullTarget
,
fullTargetWithWay
,
Target
,
PartialTarget
(
..
),
unsafeF
romPartial
,
fullTarget
,
fullTargetWithWay
,
-- * Convenient accessors
getStage
,
getPackage
,
getBuilder
,
getOutputs
,
getInputs
,
getWay
,
...
...
@@ -150,7 +150,7 @@ interpret :: Target -> Expr a -> Action a
interpret
=
flip
runReaderT
interpretPartial
::
PartialTarget
->
Expr
a
->
Action
a
interpretPartial
=
interpret
.
f
romPartial
interpretPartial
=
interpret
.
unsafeF
romPartial
interpretWithStage
::
Stage
->
Expr
a
->
Action
a
interpretWithStage
s
=
interpretPartial
$
...
...
src/Target.hs
View file @
1b013b08
{-# LANGUAGE DeriveGeneric, FlexibleInstances #-}
module
Target
(
Target
(
..
),
PartialTarget
(
..
),
fromPartial
,
fullTarget
,
fullTargetWithWay
)
where
Target
(
..
)
,
PartialTarget
(
..
)
,
unsafeFromPartial
,
fullTarget
,
fullTargetWithWay
)
where
import
Control.Monad.Trans.Reader
...
...
@@ -12,50 +16,53 @@ import Package
import
Stage
import
Way
-- Target captures all parameters relevant to the current build target:
-- * Stage and Package being built,
-- * Builder to be invoked,
-- * Way to be built (set to vanilla for most targets),
-- * source file(s) to be passed to Builder,
-- * file(s) to be produced.
-- | Parameters relevant to the current build target.
data
Target
=
Target
{
stage
::
Stage
,
package
::
Package
,
builder
::
Builder
,
way
::
Way
,
inputs
::
[
FilePath
],
outputs
::
[
FilePath
]
stage
::
Stage
,
-- ^ Stage being built
package
::
Package
,
-- ^ Package being built
builder
::
Builder
,
-- ^ Builder to be invoked
way
::
Way
,
-- ^ Way to build (set to vanilla for most targets)
inputs
::
[
FilePath
],
-- ^ Source files passed to the builder
outputs
::
[
FilePath
]
-- ^ Files to be produced
}
deriving
(
Show
,
Eq
,
Generic
)
-- If values of type 'a' form a Monoid then we can also derive a Monoid instance
-- for values of type 'ReaderT Target Action a':
-- * the empty computation returns the identity element of the underlying type
-- | If values of type @a@ form a 'Monoid' then we can also derive a 'Monoid'
-- instance for values of type @'ReaderT' 'Target' 'Action' a@:
--
-- * the empty computation is the identity element of the underlying type
-- * two computations can be combined by combining their results
instance
Monoid
a
=>
Monoid
(
ReaderT
Target
Action
a
)
where
mempty
=
return
mempty
mappend
=
liftM2
mappend
--
PartialTarget is a
partially constructed Target with fields Stage and
--
Package only.
PartialTarget's are used for generating build rules.
--
A
partially constructed Target with fields
'
Stage
'
and
'Package' only.
--
'
PartialTarget's are used for generating build rules.
data
PartialTarget
=
PartialTarget
Stage
Package
deriving
(
Eq
,
Show
)
-- Convert PartialTarget to Target assuming that unknown fields won't be used.
fromPartial
::
PartialTarget
->
Target
fromPartial
(
PartialTarget
s
p
)
=
Target
-- | Convert 'PartialTarget' to a 'Target' assuming that unknown fields won't
-- be used.
unsafeFromPartial
::
PartialTarget
->
Target
unsafeFromPartial
(
PartialTarget
s
p
)
=
Target
{
stage
=
s
,
package
=
p
,
builder
=
error
"
f
romPartial: builder not set"
,
way
=
error
"
f
romPartial: way not set"
,
inputs
=
error
"
f
romPartial: inputs not set"
,
outputs
=
error
"
f
romPartial: outputs not set"
builder
=
error
"
unsafeF
romPartial: builder not set"
,
way
=
error
"
unsafeF
romPartial: way not set"
,
inputs
=
error
"
unsafeF
romPartial: inputs not set"
,
outputs
=
error
"
unsafeF
romPartial: outputs not set"
}
-- Construct a full target by augmenting a PartialTarget with missing fields.
-- Most targets are built only one way, vanilla, hence we set it by default.
fullTarget
::
PartialTarget
->
Builder
->
[
FilePath
]
->
[
FilePath
]
->
Target
-- | Construct a full 'Target' by augmenting a 'PartialTarget' with missing
-- fields. Most targets are built only one way, 'vanilla', hence it is set by
-- default. Use 'fullTargetWithWay' otherwise.
fullTarget
::
PartialTarget
->
Builder
->
[
FilePath
]
-- ^ Source files
->
[
FilePath
]
-- ^ Produced files
->
Target
fullTarget
(
PartialTarget
s
p
)
b
srcs
fs
=
Target
{
stage
=
s
,
...
...
@@ -66,8 +73,14 @@ fullTarget (PartialTarget s p) b srcs fs = Target
outputs
=
map
unifyPath
fs
}
-- Use this function to be explicit about the build way.
fullTargetWithWay
::
PartialTarget
->
Builder
->
Way
->
[
FilePath
]
->
[
FilePath
]
->
Target
-- | Like 'fullTarget', but allows an explicit 'Way' parameter.
fullTargetWithWay
::
PartialTarget
->
Builder
->
Way
->
[
FilePath
]
-- ^ Source files
->
[
FilePath
]
-- ^ Produced files
->
Target
fullTargetWithWay
pt
b
w
srcs
fs
=
(
fullTarget
pt
b
srcs
fs
)
{
way
=
w
}
-- Instances for storing in the Shake database
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment