git.iko.soy/typeable/pandoc
on master help sign in
Setup.hs: Better way of handling man page building.

Previously we tried to remove make-pandoc-man-pages from the list of packages to be haddocked, installed, copied, etc. It works better to set 'Buildable: False' on make-pandoc-man-pages, then have the buildHook temporarily set Buildable to True. This allows make-pandoc-man-pages to be built (and used in generating the man pages), but not installed.

commited061b91c8e3247e1d3b1538eca24687adf0e575 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 6 Oct 2013, 18:04 (13 years ago) parentdbd4aee
2 files changed+12−9
Setup.hs+9−8 pandoc.cabal+3−1
Setup.hs+9−8
@@ -4,7 +4,7 @@ import Distribution.Simple
44import Distribution.Simple.PreProcess
55import Distribution.Simple.Setup
66 (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..))
7−import Distribution.PackageDescription (PackageDescription(..), Executable(..))
7+import Distribution.PackageDescription (PackageDescription(..), Executable(..), BuildInfo(..))
88import Distribution.Simple.LocalBuildInfo
99 (LocalBuildInfo(..), absoluteInstallDirs)
1010import Distribution.Verbosity ( Verbosity, silent )
@@ -19,18 +19,19 @@ import System.Exit
1919main :: IO ()
2020main = do
2121 defaultMainWithHooks $ simpleUserHooks {
22− postBuild = makeManPages
22+ buildHook = \pkgdescr ->
23+ (buildHook simpleUserHooks) pkgdescr{ executables =
24+ [x | x <- executables pkgdescr,
25+ exeName x /= "make-pandoc-man-pages"] ++
26+ [x{ buildInfo = (buildInfo x){ buildable = True } }
27+ | x <- executables pkgdescr,
28+ exeName x == "make-pandoc-man-pages"] }
29+ , postBuild = makeManPages
2330 , postCopy = \ _ flags pkg lbi ->
2431 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
2532 (fromFlag $ copyDest flags)
2633 , postInst = \ _ flags pkg lbi ->
2734 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"] }
3435 , hookedPreProcessors = [ppBlobSuffixHandler]
3536 }
3637 exitWith ExitSuccess
pandoc.cabal+3−1
@@ -361,10 +361,12 @@ Executable pandoc
361361 Main-Is: pandoc.hs
362362 Buildable: True
363363
364−-- NOTE: A trick in Setup.hs makes sure this won't be installed:
365364Executable make-pandoc-man-pages
366365 Main-Is: make-pandoc-man-pages.hs
367366 Hs-Source-Dirs: man
367+ Buildable: False
368+ -- Setup.hs will make this look buildable in build phase,
369+ -- but it won't be copied/installed
368370 Build-Depends: pandoc,
369371 base >= 4.2 && < 5,
370372 directory >= 1 && < 1.3,