LibZip-0.0.1: Setup.lhs
#!/usr/bin/env runhaskell
> import Distribution.Simple
> import System.Cmd (system)
> import System.Exit (ExitCode(..))
> import Distribution.PackageDescription (emptyHookedBuildInfo)
>
> main = defaultMainWithHooks simpleUserHooks
> { preBuild = generateC2HSdoths
> , runTests = runUnitTests
> }
>
> generateC2HSdoths _ _ =
> system "c2hs -l" >>=
> onExit "Cannot copy C2HS.hs library module in." emptyHookedBuildInfo
>
> runUnitTests _ _ _ _ =
> system "cd tests && runhaskell -lzip Tests.hs" >>=
> onExit "Some tests did not pass." ()
>
> onExit :: String -> a -> ExitCode -> IO a
> onExit errmsg okvalue r =
> case r of
> ExitSuccess -> return okvalue
> _ -> fail errmsg