avoid rewriting SysConfig.hs with identical contents
This avoids some compliation when when reconfiguring.
This commit is contained in:
parent
ff62bc5151
commit
981e1ab43d
1 changed files with 8 additions and 1 deletions
|
@ -5,6 +5,7 @@ module Build.TestConfig where
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Cmd
|
import System.Cmd
|
||||||
import System.Exit
|
import System.Exit
|
||||||
|
import System.Directory
|
||||||
|
|
||||||
type ConfigKey = String
|
type ConfigKey = String
|
||||||
data ConfigValue =
|
data ConfigValue =
|
||||||
|
@ -36,8 +37,14 @@ instance Show Config where
|
||||||
valuetype (MaybeBoolConfig _) = "Maybe Bool"
|
valuetype (MaybeBoolConfig _) = "Maybe Bool"
|
||||||
|
|
||||||
writeSysConfig :: [Config] -> IO ()
|
writeSysConfig :: [Config] -> IO ()
|
||||||
writeSysConfig config = writeFile "Build/SysConfig.hs" body
|
writeSysConfig config = do
|
||||||
|
e <- doesFileExist dest
|
||||||
|
old <- if e then readFile dest else return []
|
||||||
|
if (old /= body)
|
||||||
|
then writeFile dest body
|
||||||
|
else return ()
|
||||||
where
|
where
|
||||||
|
dest = "Build/SysConfig.hs"
|
||||||
body = unlines $ header ++ map show config ++ footer
|
body = unlines $ header ++ map show config ++ footer
|
||||||
header = [
|
header = [
|
||||||
"{- Automatically generated. -}"
|
"{- Automatically generated. -}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue