avoid writing to Build/Version when it already contains the same version
This will hopefully avoid ghc unncessarily rebuilding everything that depends on it due to the file's timestamp changing.
This commit is contained in:
parent
c94b3a3890
commit
5d58c54a8b
1 changed files with 6 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
{- Package version determination. -}
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||
|
||||
module Build.Version where
|
||||
|
@ -54,9 +55,11 @@ getChangelogVersion = do
|
|||
middle = drop 1 . init
|
||||
|
||||
writeVersion :: Version -> IO ()
|
||||
writeVersion = writeFile "Build/Version" . body
|
||||
writeVersion ver = catchMaybeIO (readFile f) >>= \case
|
||||
Just s | s == body -> return ()
|
||||
_ -> writeFile f body
|
||||
where
|
||||
body ver = unlines $ concat
|
||||
body = unlines $ concat
|
||||
[ header
|
||||
, ["packageversion :: String"]
|
||||
, ["packageversion = \"" ++ ver ++ "\""]
|
||||
|
@ -67,3 +70,4 @@ writeVersion = writeFile "Build/Version" . body
|
|||
, ""
|
||||
]
|
||||
footer = []
|
||||
f = "Build/Version"
|
||||
|
|
Loading…
Reference in a new issue