3import Distribution.Simple
4import Distribution.Simple.PreProcess
5import Distribution.Simple.Setup
6 (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..),
8import Distribution.PackageDescription (PackageDescription(..), Executable(..))
9import Distribution.Simple.LocalBuildInfo
10 (LocalBuildInfo(..), absoluteInstallDirs)
11import Distribution.Verbosity ( Verbosity, silent )
12import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest), toPathTemplate)
13import Distribution.Simple.Utils (installOrdinaryFiles, info)
14import Distribution.Simple.Test (test)
15import Prelude hiding (catch)
16import System.Process ( rawSystem )
17import System.FilePath ( (</>) )
18import System.Directory ( findExecutable )
23 defaultMainWithHooks $ simpleUserHooks {
24 postBuild = makeManPages
25 , testHook = \pkg lbi _ flags ->
26 -- pass build directory as first argument to test program
27 test pkg lbi flags{ testOptions =
28 toPathTemplate (buildDir lbi) : testOptions flags }
29 , postCopy = \ _ flags pkg lbi ->
30 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
31 (fromFlag $ copyDest flags)
32 , postInst = \ _ flags pkg lbi ->
33 installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest
34 , copyHook = \pkgdescr ->
35 (copyHook simpleUserHooks) pkgdescr{ executables =
36 [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
37 , instHook = \pkgdescr ->
38 (instHook simpleUserHooks) pkgdescr{ executables =
39 [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
40 , hookedPreProcessors = [ppBlobSuffixHandler]
44-- | Build man pages from markdown sources in man/
45makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
46makeManPages _ flags _ lbi = do
47 let verbosity = fromFlag $ buildVerbosity flags
48 let args = ["--verbose" | verbosity /= silent]
49 rawSystem (buildDir lbi </> "make-pandoc-man-pages" </> "make-pandoc-man-pages")
53manpages = ["man1" </> "pandoc.1"
54 ,"man5" </> "pandoc_markdown.5"]
59installManpages :: PackageDescription -> LocalBuildInfo
60 -> Verbosity -> CopyDest -> IO ()
61installManpages pkg lbi verbosity copy =
62 installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
63 (zip (repeat manDir) manpages)
65ppBlobSuffixHandler :: PPSuffixHandler
66ppBlobSuffixHandler = ("hsb", \_ _ ->
68 platformIndependent = True,
69 runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
70 do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
71 hsb2hsPath <- findExecutable "hsb2hs"
73 Just p -> rawSystem p [infile, infile, outfile]
74 Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list