git.iko.soy/typeable/pandoc
on master help sign in
Setup: Making man pages now works with cabal-dev.
8bf890dJohn MacFarlane
Setup.hs+24−8
@@ -6,6 +6,7 @@ import Distribution.PackageDescription
6import Distribution.Simple.LocalBuildInfo
6import Distribution.Simple.LocalBuildInfo
7 (LocalBuildInfo(..), absoluteInstallDirs)
7 (LocalBuildInfo(..), absoluteInstallDirs)
8import Distribution.Verbosity ( Verbosity, silent )
8import Distribution.Verbosity ( Verbosity, silent )
9+import Distribution.Simple.GHC (ghcPackageDbOptions)
9import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest))
10import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest))
10import Distribution.Simple.Utils (copyFiles)
11import Distribution.Simple.Utils (copyFiles)
11import Control.Exception ( bracket_ )
12import Control.Exception ( bracket_ )
@@ -49,21 +50,36 @@ runTestSuite args _ pkg lbi = do
49
50
50-- | Build man pages from markdown sources in man/
51-- | Build man pages from markdown sources in man/
51makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
52makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
52−makeManPages _ flags _ _ = do
53+makeManPages _ flags _ lbi = do
53− let verbosity = fromFlag $ buildVerbosity flags
54 ds1 <- modifiedDependencies (manDir </> "man1" </> "pandoc.1")
54 ds1 <- modifiedDependencies (manDir </> "man1" </> "pandoc.1")
55 ["README", manDir </> "man1" </> "pandoc.1.template"]
55 ["README", manDir </> "man1" </> "pandoc.1.template"]
56 ds2 <- modifiedDependencies (manDir </> "man1" </> "markdown2pdf.1")
56 ds2 <- modifiedDependencies (manDir </> "man1" </> "markdown2pdf.1")
57 [manDir </> "man1" </> "markdown2pdf.1.md"]
57 [manDir </> "man1" </> "markdown2pdf.1.md"]
58 ds3 <- modifiedDependencies (manDir </> "man5" </> "pandoc_markdown.5")
58 ds3 <- modifiedDependencies (manDir </> "man5" </> "pandoc_markdown.5")
59 ["README", manDir </> "man5" </> "pandoc_markdown.5.template"]
59 ["README", manDir </> "man5" </> "pandoc_markdown.5.template"]
60− let cmd = "runghc -package-conf=dist/package.conf.inplace MakeManPage.hs"
60+
61+ let distPref = fromFlag (buildDistPref flags)
62+ packageDB =
63+ withPackageDB lbi
64+ ++ [SpecificPackageDB $ distPref </> "package.conf.inplace"]
65+
66+ verbosity = fromFlag $ buildVerbosity flags
67+
68+ args = makeGhcArgs (ghcPackageDbOptions packageDB)
69+ ++ ["MakeManPage.hs"]
61− let cmd' = if verbosity == silent
70+ args' = if verbosity == silent
62− then cmd
71+ then args
63− else cmd ++ " --verbose"
72+ else args ++ ["--verbose"]
64 -- Don't run MakeManPage.hs unless we have to
73 -- Don't run MakeManPage.hs unless we have to
65− unless (null ds1 && null ds2 && null ds3) $
74+ unless (null ds1 && null ds2 && null ds3) $ do
66− runCommand cmd' >>= waitForProcess >>= exitWith
75+ rawSystem "runghc" args' >>= exitWith
76+
77+-- format arguments to runghc that we wish to pass to ghc
78+-- normally runghc gets it right, unless the argument does
79+-- not begin with a '-' charecter, so we need to give clear
80+-- directions.
81+makeGhcArgs :: [String] -> [String]
82+makeGhcArgs = map ("--ghc-arg="++)
67
83
68manpages :: [FilePath]
84manpages :: [FilePath]
69manpages = ["man1" </> "pandoc.1"
85manpages = ["man1" </> "pandoc.1"