Skip to content

Commit 3e5f475

Browse files
committed
Use file monitoring for preprocessor re-run (#11411)
This replaces the previous preprocessor re-run logic ("if the preprocessor output exists and is newer than the input, don't re-run the preprocessor") with a file monitor, which takes both the input file and the preprocessor itself into account, solving #11411. To make this possible, each preprocessor is now tagged with a hash that uniquely identifies the specific preprocessor version. The process of finding the actual preprocessor (`runPreProcessor`) to run has been split off from the actual running; this was necessary so that we can get a unique hash of the preprocessor (including version) without having to actually run it, while also avoiding duplicate work and a potential mismatch between the hash and the actual preprocessor. Hence, we now have `configurePreProcessor`, which returns a pair of the former `runPreProcessor` action and the preprocessor hash.
1 parent 77bc27e commit 3e5f475

6 files changed

Lines changed: 234 additions & 124 deletions

File tree

Cabal/src/Distribution/Simple/HashValue.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module Distribution.Simple.HashValue
44
( HashValue
55
, hashValue
6+
, hashEncode
67
, rawHashValue
78
, truncateHash
89
, showHashValue
@@ -12,6 +13,7 @@ module Distribution.Simple.HashValue
1213
import Distribution.Compat.Prelude
1314
import Prelude ()
1415

16+
import qualified Data.Binary as Binary
1517
import qualified Crypto.Hash.SHA256 as SHA256
1618
import qualified Data.ByteString.Base16 as Base16
1719
import qualified Data.ByteString.Char8 as BS
@@ -48,6 +50,10 @@ instance Structured HashValue
4850
hashValue :: LBS.ByteString -> HashValue
4951
hashValue = HashValue . SHA256.hashlazy
5052

53+
-- | Hash a value's 'Binary' representation.
54+
hashEncode :: Binary a => a -> HashValue
55+
hashEncode = hashValue . Binary.encode
56+
5157
-- | Convert a raw hash value, given as a bytestring, into a 'HashValue'. No
5258
-- well-formedness guarantees are provided; the caller is responsible for
5359
-- ensuring that the provided hash is valid.

0 commit comments

Comments
 (0)