Guard quickcheck.1 regeneration

Without this guard it will be regenerate on each run,
and cabal new-build considers whole package dirty.
This commit is contained in:
Oleg Grenrus 2018-09-10 19:41:52 +03:00
parent 5516596b26
commit d510a3ef6c
2 changed files with 16 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import Distribution.Simple (
import Distribution.Simple.Setup ( SDistFlags ) import Distribution.Simple.Setup ( SDistFlags )
import System.Process ( system ) import System.Process ( system )
import System.Directory ( doesFileExist, getModificationTime )
#ifndef MIN_VERSION_cabal_doctest #ifndef MIN_VERSION_cabal_doctest
#define MIN_VERSION_cabal_doctest(x,y,z) 0 #define MIN_VERSION_cabal_doctest(x,y,z) 0
@ -61,10 +62,20 @@ main = defaultMainWithHooks myHooks
-- --
myPreSDist :: Args -> SDistFlags -> IO HookedBuildInfo myPreSDist :: Args -> SDistFlags -> IO HookedBuildInfo
myPreSDist _ _ = do myPreSDist _ _ = do
putStrLn "Building the man page (shellcheck.1) with pandoc..." exists <- doesFileExist "shellcheck.1"
putStrLn pandoc_cmd if exists
result <- system pandoc_cmd then do
putStrLn $ "pandoc exited with " ++ show result 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 return emptyHookedBuildInfo
where 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" pandoc_cmd = "pandoc -s -t man shellcheck.1.md -o shellcheck.1"

View File

@ -32,6 +32,7 @@ Extra-Source-Files:
custom-setup custom-setup
setup-depends: setup-depends:
base >= 4 && <5, base >= 4 && <5,
directory >= 1.2 && <1.4,
process >= 1.0 && <1.7, process >= 1.0 && <1.7,
cabal-doctest >= 1.0.6 && <1.1, cabal-doctest >= 1.0.6 && <1.1,
Cabal >= 1.10 && <2.5 Cabal >= 1.10 && <2.5