Skip to content

Commit

Permalink
use -D__HADDOCK__ only when preprocessing for haddock < 2
Browse files Browse the repository at this point in the history
haddock-2.x doesn't define any additional macros.
  • Loading branch information
Saizan committed Mar 2, 2009
1 parent 0164dc6 commit afc1603
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Distribution/Simple/Haddock.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ haddock pkg_descr lbi suffixes flags = do
withLib pkg_descr () $ \lib -> do withLib pkg_descr () $ \lib -> do
let bi = libBuildInfo lib let bi = libBuildInfo lib
libArgs <- fromLibrary lbi lib libArgs <- fromLibrary lbi lib
prepareSources verbosity lbi bi (args `mappend` libArgs) $ prepareSources verbosity lbi isVersion2 bi (args `mappend` libArgs) $
runHaddock verbosity confHaddock runHaddock verbosity confHaddock


when (flag haddockExecutables) $ when (flag haddockExecutables) $
withExe pkg_descr $ \exe -> do withExe pkg_descr $ \exe -> do
let bi = buildInfo exe let bi = buildInfo exe
exeArgs <- fromExecutable lbi exe exeArgs <- fromExecutable lbi exe
prepareSources verbosity lbi bi (args `mappend` exeArgs) $ prepareSources verbosity lbi isVersion2 bi (args `mappend` exeArgs) $
runHaddock verbosity confHaddock runHaddock verbosity confHaddock


where where
Expand All @@ -210,11 +210,12 @@ haddock pkg_descr lbi suffixes flags = do
-- | argTargets, which must have an .hs or .lhs extension. -- | argTargets, which must have an .hs or .lhs extension.
prepareSources :: Verbosity prepareSources :: Verbosity
-> LocalBuildInfo -> LocalBuildInfo
-> Bool -- haddock == 2.*
-> BuildInfo -> BuildInfo
-> HaddockArgs -> HaddockArgs
-> (HaddockArgs -> IO a) -> (HaddockArgs -> IO a)
-> IO a -> IO a
prepareSources verbosity lbi bi args@HaddockArgs{argTargets=files} k = prepareSources verbosity lbi isVersion2 bi args@HaddockArgs{argTargets=files} k =
withTempDirectory verbosity (buildDir lbi) "tmp" $ \tmp -> withTempDirectory verbosity (buildDir lbi) "tmp" $ \tmp ->
mapM (mockPP tmp) files >>= \targets -> k args {argTargets=targets} mapM (mockPP tmp) files >>= \targets -> k args {argTargets=targets}
where where
Expand All @@ -231,7 +232,7 @@ prepareSources verbosity lbi bi args@HaddockArgs{argTargets=files} k =


if needsCpp if needsCpp
then do then do
runSimplePreProcessor (ppCpp' ["-D__HADDOCK__"] bi lbi) runSimplePreProcessor (ppCpp' defines bi lbi)
file targetFile verbosity file targetFile verbosity
else else
copyFileVerbose verbosity file targetFile copyFileVerbose verbosity file targetFile
Expand All @@ -242,6 +243,8 @@ prepareSources verbosity lbi bi args@HaddockArgs{argTargets=files} k =


return hsFile return hsFile
needsCpp = CPP `elem` extensions bi needsCpp = CPP `elem` extensions bi
defines | isVersion2 = []
| otherwise = ["-D__HADDOCK__"]


-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
-- constributions to HaddockArgs -- constributions to HaddockArgs
Expand Down

0 comments on commit afc1603

Please sign in to comment.