git.iko.soy/typeable/pandoc
on master help sign in
Simplified Setup.hs.

It no longer builds and installs man pages. All it does is hook the hsb preprocessor. This should make the build process more robust over Cabal API changes. We'll add a Makefile to generate man pages.

commitfa71a08ed3cae4ed26d2cb84b1f7a29be94e3ddb authorJohn MacFarlane <jgm@berkeley.edu> dateWed 13 Aug 2014, 10:18 (12 years ago) parent1d6e1cf
1 file changed+3−51
Setup.hs+3−51
Setup.hs+3−51
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-
32Copyright (C) 2006-2014 John MacFarlane <jgm@berkeley.edu>
43
@@ -19,60 +18,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1918
2019import Distribution.Simple
2120import Distribution.Simple.PreProcess
22−import Distribution.Simple.Setup
23− (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..),
24− TestFlags(..))
25−import Distribution.PackageDescription (PackageDescription(..), Executable(..))
26−import Distribution.Simple.LocalBuildInfo
27− (LocalBuildInfo(..), absoluteInstallDirs)
28−import Distribution.Verbosity ( Verbosity, silent )
29−import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest), toPathTemplate)
30−import Distribution.Simple.Utils (installOrdinaryFiles, info)
31−import Distribution.Simple.Test (test)
3221import System.Process ( rawSystem )
3322import System.FilePath ( (</>) )
3423import System.Directory ( findExecutable )
35−import System.Exit
24+import Distribution.Simple.Utils (info)
3625
3726main :: IO ()
38−main = do
39− defaultMainWithHooks $ simpleUserHooks {
40− postBuild = makeManPages
41− , postCopy = \ _ flags pkg lbi ->
42− installManpages pkg lbi (fromFlag $ copyVerbosity flags)
43− (fromFlag $ copyDest flags)
44− , postInst = \ _ flags pkg lbi ->
45− installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest
46− , copyHook = \pkgdescr ->
47− (copyHook simpleUserHooks) pkgdescr{ executables =
48− [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
49− , instHook = \pkgdescr ->
50− (instHook simpleUserHooks) pkgdescr{ executables =
51− [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
52− , hookedPreProcessors = [ppBlobSuffixHandler]
53− }
54− exitWith ExitSuccess
55−
56−-- | Build man pages from markdown sources in man/
57−makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
58−makeManPages _ flags _ lbi = do
59− let verbosity = fromFlag $ buildVerbosity flags
60− let args = ["--verbose" | verbosity /= silent]
61− rawSystem (buildDir lbi </> "make-pandoc-man-pages" </> "make-pandoc-man-pages")
62− args >>= exitWith
63−
64−manpages :: [FilePath]
65−manpages = ["man1" </> "pandoc.1"
66− ,"man5" </> "pandoc_markdown.5"]
67−
68−manDir :: FilePath
69−manDir = "man"
70−
71−installManpages :: PackageDescription -> LocalBuildInfo
72− -> Verbosity -> CopyDest -> IO ()
73−installManpages pkg lbi verbosity copy =
74− installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
75− (zip (repeat manDir) manpages)
27+main = defaultMainWithHooks $ simpleUserHooks {
28+ hookedPreProcessors = [ppBlobSuffixHandler] }
7629
7730ppBlobSuffixHandler :: PPSuffixHandler
7831ppBlobSuffixHandler = ("hsb", \_ _ ->
@@ -85,5 +38,4 @@ ppBlobSuffixHandler = ("hsb", \_ _ ->
8538 Just p -> rawSystem p [infile, infile, outfile]
8639 Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
8740 return ()
88−
8941 })