-
Notifications
You must be signed in to change notification settings - Fork 1
/
Setup.hs
executable file
·47 lines (34 loc) · 1.62 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /usr/bin/env runhaskell
{-# LANGUAGE NoImplicitPrelude, UnicodeSyntax #-}
module Main (main) where
-------------------------------------------------------------------------------
-- Imports
-------------------------------------------------------------------------------
-- from base
import Control.Monad ( (>>), return )
import System.IO ( IO )
-- from cabal
import Distribution.Simple ( defaultMainWithHooks
, simpleUserHooks
, UserHooks(haddockHook)
, Args
)
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )
import Distribution.Simple.Program ( userSpecifyArgs )
import Distribution.Simple.Setup ( HaddockFlags )
import Distribution.PackageDescription ( PackageDescription(..) )
-------------------------------------------------------------------------------
-- Cabal setup program with support for 'cabal test' and
-- which sets the CPP define '__HADDOCK __' when haddock is run.
-------------------------------------------------------------------------------
main ∷ IO ()
main = defaultMainWithHooks hooks
where
hooks = simpleUserHooks { haddockHook = haddockHook' }
-- Define __HADDOCK__ for CPP when running haddock.
haddockHook' ∷ PackageDescription → LocalBuildInfo → UserHooks → HaddockFlags → IO ()
haddockHook' pkg lbi =
haddockHook simpleUserHooks pkg (lbi { withPrograms = p })
where
p = userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] (withPrograms lbi)
-- The End ---------------------------------------------------------------------