Commit 486a3e58 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Optimise ArgsHash oracle improving zero build time.

parent 810b1e22
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Oracles.ArgsHash ( module Oracles.ArgsHash (
askArgsHash, argsHashOracle checkArgsHash, argsHashOracle
) where ) where
import Base import Base
import Target
import Expression import Expression
import Settings.Args import Settings.Args
import Control.Applicative import Control.Applicative
newtype ArgsHashKey = ArgsHashKey FullTarget newtype ArgsHashKey = ArgsHashKey Target
deriving (Show, Typeable, Eq, Hashable, Binary, NFData) deriving (Show, Eq, Typeable, Binary, Hashable, NFData)
-- This is an action that given a full target determines the corresponding -- This is an action that given a full target determines the corresponding
-- argument list and computes its hash. The resulting value is tracked in a -- argument list and computes its hash. The resulting value is tracked in a
-- Shake oracle, hence initiating rebuilts when the hash is changed (a hash -- Shake oracle, hence initiating rebuilts when the hash is changed (a hash
-- change indicates changes in the build system). -- change indicates changes in the build system).
askArgsHash :: FullTarget -> Action Int checkArgsHash :: FullTarget -> Action ()
askArgsHash = askOracle . ArgsHashKey checkArgsHash target = do
tmp <- askOracle . ArgsHashKey $ target { sources = ["src"] } :: Action Int
return ()
-- Oracle for storing per-target argument list hashes -- Oracle for storing per-target argument list hashes
argsHashOracle :: Rules () argsHashOracle :: Rules ()
......
...@@ -19,13 +19,11 @@ import Settings.Builders.Ar ...@@ -19,13 +19,11 @@ import Settings.Builders.Ar
buildWithResources :: [(Resource, Int)] -> FullTarget -> Action () buildWithResources :: [(Resource, Int)] -> FullTarget -> Action ()
buildWithResources rs target = do buildWithResources rs target = do
let builder = Target.builder target let builder = Target.builder target
deps = Target.dependencies target
needBuilder builder needBuilder builder
-- need deps -- TODO: think if needs could be done here
path <- builderPath builder path <- builderPath builder
argList <- interpret target getArgs argList <- interpret target getArgs
-- The line below forces the rule to be rerun if the args hash has changed -- The line below forces the rule to be rerun if the args hash has changed
argsHash <- askArgsHash target checkArgsHash target
withResources rs $ do withResources rs $ do
putBuild $ "/--------\n" ++ "| Running " putBuild $ "/--------\n" ++ "| Running "
++ show builder ++ " with arguments:" ++ show builder ++ " with arguments:"
......
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