From 182f4fb8dc8d8b104ed537af324d76cc0079e882 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 14 Apr 2013 15:49:19 -0400 Subject: avoid updating a file if the old splice is the same as the new --- Build/EvilSplicer.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Build') diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs index 3927fcc5a..2a1984ed6 100644 --- a/Build/EvilSplicer.hs +++ b/Build/EvilSplicer.hs @@ -35,6 +35,7 @@ import Data.Char import System.Environment import System.FilePath import System.Directory +import Control.Monad import Utility.Monad import Utility.Misc @@ -179,7 +180,10 @@ applySplices destdir imports l@(first:_) = do putStrLn $ "splicing " ++ f lls <- map (++ "\n") . lines <$> readFileStrict f createDirectoryIfMissing True (parentDir dest) - writeFile dest $ concat $ addimports $ expand lls l + let newcontent = concat $ addimports $ expand lls l + oldcontent <- catchMaybeIO $ readFile dest + when (oldcontent /= Just newcontent) $ + writeFile dest newcontent where expand lls [] = lls expand lls (s:rest) = expand (expandSplice s lls) rest -- cgit v1.2.3