Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module is used for defining new types of rules for Shake build systems. Most users will find the built-in set of rules sufficient.
- addBuiltinRule :: (RuleResult key ~ value, ShakeValue key, ShakeValue value) => BuiltinLint key value -> BuiltinRun key value -> Rules ()
- type BuiltinLint key value = key -> value -> IO (Maybe String)
- noLint :: BuiltinLint key value
- type BuiltinRun key value = key -> Maybe ByteString -> Bool -> Action (RunResult value)
- data RunChanged
- data RunResult value = RunResult {
- runChanged :: RunChanged
- runStore :: ByteString
- runValue :: value
- apply :: (RuleResult key ~ value, ShakeValue key, ShakeValue value) => [key] -> Action [value]
- apply1 :: (RuleResult key ~ value, ShakeValue key, ShakeValue value) => key -> Action value
- data UserRule a
- addUserRule :: Typeable a => a -> Rules ()
- getUserRules :: Typeable a => Action (UserRule a)
- userRuleMatch :: UserRule a -> (a -> Maybe b) -> [b]
- trackUse :: ShakeValue key => key -> Action ()
- trackChange :: ShakeValue key => key -> Action ()
- trackAllow :: ShakeValue key => (key -> Bool) -> Action ()
Defining builtin rules
addBuiltinRule :: (RuleResult key ~ value, ShakeValue key, ShakeValue value) => BuiltinLint key value -> BuiltinRun key value -> Rules () Source #
Add a builtin rule, comprising of a lint rule and an action. Each builtin rule must be identified by a unique key.
type BuiltinLint key value = key -> value -> IO (Maybe String) Source #
The action performed by --lint
for a given key
/value
pair.
At the end of the build the lint action will be called for each key
that was built this run,
passing the value
it produced. Return Nothing
to indicate the value has not changed and
is acceptable, or Just
an error message to indicate failure.
For builtin rules where the value is expected to change use noLint
.
noLint :: BuiltinLint key value Source #
A suitable BuiltinLint
that always succeeds.
type BuiltinRun key value = key -> Maybe ByteString -> Bool -> Action (RunResult value) Source #
Define a rule between key
and value
. A rule for a class of artifacts (e.g. files) provides:
- How to identify individual artifacts, given by the
key
type, e.g. with file names. - How to describe the state of an artifact, given by the
value
type, e.g. the file modification time. - How to persist the state of an artifact, using the
ByteString
values, e.g. seralisedvalue
.
The arguments comprise the key
, the value of the previous serialisation or Nothing
if the rule
has not been run previously, and True
to indicate the dependencies have changed or False
that
they have not.
data RunChanged Source #
How has a rule changed.
ChangedNothing | Nothing has changed. |
ChangedStore | The persisted value has changed, but in a way that should be considered identical. |
ChangedRecomputeSame | I recomputed the value and it was the same. |
ChangedRecomputeDiff | I recomputed the value and it was different. |
The result of BuiltinRun
.
RunResult | |
|
Calling builtin rules
apply :: (RuleResult key ~ value, ShakeValue key, ShakeValue value) => [key] -> Action [value] Source #
Execute a rule, returning the associated values. If possible, the rules will be run in parallel.
This function requires that appropriate rules have been added with addUserRule
.
All key
values passed to apply
become dependencies of the Action
.
apply1 :: (RuleResult key ~ value, ShakeValue key, ShakeValue value) => key -> Action value Source #
User rules
A UserRule
data type, representing user-defined rules associated with a particular type.
As an example ?>
and %>
will add entries to the UserRule
data type.
getUserRules :: Typeable a => Action (UserRule a) Source #
Get the UserRule
value at a given type. This UserRule
will capture
all rules added, along with things such as priority
and alternatives
.
userRuleMatch :: UserRule a -> (a -> Maybe b) -> [b] Source #
Give a UserRule
, and a function that tests a given rule, return the most important values
that match. In most cases the caller will raise an error if the rule matching returns anything
other than a singleton.
Lint integration
trackUse :: ShakeValue key => key -> Action () Source #
Track that a key has been used by the action preceeding it.
trackChange :: ShakeValue key => key -> Action () Source #
Track that a key has been changed by the action preceding it.
trackAllow :: ShakeValue key => (key -> Bool) -> Action () Source #
Allow any matching key to violate the tracking rules.