Commit 5e1d004c authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Minor revision

parent a432cffc
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Hadrian.Oracles.ArgsHash ( module Hadrian.Oracles.ArgsHash (
TrackArgument, trackAllArguments, checkArgsHash, argsHashOracle TrackArgument, trackAllArguments, trackArgsHash, argsHashOracle
) where ) where
import Control.Monad import Control.Monad
...@@ -34,13 +34,14 @@ newtype ArgsHashKey c b = ArgsHashKey (Target c b) ...@@ -34,13 +34,14 @@ newtype ArgsHashKey c b = ArgsHashKey (Target c b)
-- in the Shake database. This optimisation is normally harmless, because -- in the Shake database. This optimisation is normally harmless, because
-- argument list constructors are assumed not to examine target sources, but -- argument list constructors are assumed not to examine target sources, but
-- only append them to argument lists where appropriate. -- only append them to argument lists where appropriate.
checkArgsHash :: (ShakeValue c, ShakeValue b) => Target c b -> Action () trackArgsHash :: (ShakeValue c, ShakeValue b) => Target c b -> Action ()
checkArgsHash t = do trackArgsHash t = do
let hashedInputs = [ show $ hash (inputs t) ] let hashedInputs = [ show $ hash (inputs t) ]
hashedTarget = target (context t) (builder t) hashedInputs (outputs t) hashedTarget = target (context t) (builder t) hashedInputs (outputs t)
void (askOracle $ ArgsHashKey hashedTarget :: Action Int) void (askOracle $ ArgsHashKey hashedTarget :: Action Int)
-- | Oracle for storing per-target argument list hashes. -- | This oracle stores per-target argument list hashes in the Shake database,
-- allowing the user to track them between builds using 'trackArgsHash' queries.
argsHashOracle :: (ShakeValue c, ShakeValue b) => TrackArgument c b -> Args c b -> Rules () argsHashOracle :: (ShakeValue c, ShakeValue b) => TrackArgument c b -> Args c b -> Rules ()
argsHashOracle trackArgument args = void $ argsHashOracle trackArgument args = void $
addOracle $ \(ArgsHashKey target) -> do addOracle $ \(ArgsHashKey target) -> do
......
...@@ -51,7 +51,7 @@ customBuild rs opts target = do ...@@ -51,7 +51,7 @@ customBuild rs opts target = do
argList <- interpret target getArgs argList <- interpret target getArgs
verbose <- interpret target verboseCommands verbose <- interpret target verboseCommands
let quietlyUnlessVerbose = if verbose then withVerbosity Loud else quietly let quietlyUnlessVerbose = if verbose then withVerbosity Loud else quietly
checkArgsHash target -- Rerun the rule if the hash of argList has changed. trackArgsHash target -- Rerun the rule if the hash of argList has changed.
withResources rs $ do withResources rs $ do
putInfo target putInfo target
quietlyUnlessVerbose $ case targetBuilder of quietlyUnlessVerbose $ case targetBuilder of
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment