From d510a3ef6c68692f83db09ed17f5be18463e054b Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Mon, 10 Sep 2018 19:41:52 +0300 Subject: [PATCH] Guard quickcheck.1 regeneration Without this guard it will be regenerate on each run, and cabal new-build considers whole package dirty. --- Setup.hs | 19 +++++++++++++++---- ShellCheck.cabal | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Setup.hs b/Setup.hs index 276d8a5..229e8a6 100644 --- a/Setup.hs +++ b/Setup.hs @@ -14,6 +14,7 @@ import Distribution.Simple ( import Distribution.Simple.Setup ( SDistFlags ) import System.Process ( system ) +import System.Directory ( doesFileExist, getModificationTime ) #ifndef MIN_VERSION_cabal_doctest #define MIN_VERSION_cabal_doctest(x,y,z) 0 @@ -61,10 +62,20 @@ main = defaultMainWithHooks myHooks -- myPreSDist :: Args -> SDistFlags -> IO HookedBuildInfo myPreSDist _ _ = do - putStrLn "Building the man page (shellcheck.1) with pandoc..." - putStrLn pandoc_cmd - result <- system pandoc_cmd - putStrLn $ "pandoc exited with " ++ show result + exists <- doesFileExist "shellcheck.1" + if exists + then do + source <- getModificationTime "shellcheck.1.md" + target <- getModificationTime "shellcheck.1" + if target < source + then makeManPage + else putStrLn "shellcheck.1 is more recent than shellcheck.1.md" + else makeManPage return emptyHookedBuildInfo where + makeManPage = do + putStrLn "Building the man page (shellcheck.1) with pandoc..." + putStrLn pandoc_cmd + result <- system pandoc_cmd + putStrLn $ "pandoc exited with " ++ show result pandoc_cmd = "pandoc -s -t man shellcheck.1.md -o shellcheck.1" diff --git a/ShellCheck.cabal b/ShellCheck.cabal index c409704..c28a11e 100644 --- a/ShellCheck.cabal +++ b/ShellCheck.cabal @@ -32,6 +32,7 @@ Extra-Source-Files: custom-setup setup-depends: base >= 4 && <5, + directory >= 1.2 && <1.4, process >= 1.0 && <1.7, cabal-doctest >= 1.0.6 && <1.1, Cabal >= 1.10 && <2.5