3import Distribution.Simple
4import Distribution.Simple.PreProcess
5import Distribution.Simple.Setup
6 (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..))
7import Distribution.PackageDescription (PackageDescription(..), Executable(..))
8import Distribution.Simple.LocalBuildInfo
9 (LocalBuildInfo(..), absoluteInstallDirs)
10import Distribution.Verbosity ( Verbosity, silent )
11import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest))
12import Distribution.Simple.Utils (installOrdinaryFiles, info)
13import Prelude hiding (catch)
14import System.Process ( rawSystem )
15import System.FilePath ( (</>) )
16import System.Directory ( findExecutable )
21 defaultMainWithHooks $ simpleUserHooks {
22 postBuild = makeManPages
23 , postCopy = \ _ flags pkg lbi ->
24 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
25 (fromFlag $ copyDest flags)
26 , postInst = \ _ flags pkg lbi ->
27 installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest
28 , copyHook = \pkgdescr ->
29 (copyHook simpleUserHooks) pkgdescr{ executables =
30 [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
31 , instHook = \pkgdescr ->
32 (instHook simpleUserHooks) pkgdescr{ executables =
33 [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
34 , hookedPreProcessors = [ppBlobSuffixHandler]
38-- | Build man pages from markdown sources in man/
39makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
40makeManPages _ flags _ lbi = do
41 let verbosity = fromFlag $ buildVerbosity flags
42 let args = ["--verbose" | verbosity /= silent]
43 rawSystem (buildDir lbi </> "make-pandoc-man-pages" </> "make-pandoc-man-pages")
47manpages = ["man1" </> "pandoc.1"
48 ,"man5" </> "pandoc_markdown.5"]
53installManpages :: PackageDescription -> LocalBuildInfo
54 -> Verbosity -> CopyDest -> IO ()
55installManpages pkg lbi verbosity copy =
56 installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
57 (zip (repeat manDir) manpages)
59ppBlobSuffixHandler :: PPSuffixHandler
60ppBlobSuffixHandler = ("hsb", \_ _ ->
62 platformIndependent = True,
63 runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
64 do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
65 hsb2hsPath <- findExecutable "hsb2hs"
67 Just p -> rawSystem p [infile, infile, outfile]
68 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