Occurrrence analysis improvements for NOINLINE functions
[ghc.git] / hadrian / src / Settings / Builders / Haddock.hs
1 module Settings.Builders.Haddock (haddockBuilderArgs) where
2
3 import Hadrian.Utilities
4 import Hadrian.Haskell.Cabal
5
6 import Rules.Documentation
7 import Settings.Builders.Common
8 import Settings.Builders.Ghc
9
10 -- | Given a version string such as "2.16.2" produce an integer equivalent.
11 versionToInt :: String -> Int
12 versionToInt s = case map read . words $ replaceEq '.' ' ' s of
13 [major, minor, patch] -> major * 1000 + minor * 10 + patch
14 _ -> error "versionToInt: cannot parse version."
15
16 haddockBuilderArgs :: Args
17 haddockBuilderArgs = withHsPackage $ \cabalFile -> mconcat
18 [ builder (Haddock BuildIndex) ? do
19 output <- getOutput
20 inputs <- getInputs
21 mconcat
22 [ arg "--gen-index"
23 , arg "--gen-contents"
24 , arg "-o", arg $ takeDirectory output
25 , arg "-t", arg "Haskell Hierarchical Libraries"
26 , arg "-p", arg "libraries/prologue.txt"
27 , pure [ "--read-interface="
28 ++ (takeFileName . takeDirectory) haddock
29 ++ "," ++ haddock | haddock <- inputs ] ]
30
31 , builder (Haddock BuildPackage) ? do
32 output <- getOutput
33 pkg <- getPackage
34 path <- getBuildPath
35 version <- expr $ pkgVersion cabalFile
36 synopsis <- expr $ pkgSynopsis cabalFile
37 deps <- getPkgDataList DepNames
38 haddocks <- expr . haddockDependencies =<< getContext
39 hVersion <- expr $ pkgVersion (unsafePkgCabalFile haddock) -- TODO: improve
40 ghcOpts <- haddockGhcArgs
41 mconcat
42 [ arg $ "--odir=" ++ takeDirectory output
43 , arg "--verbosity=0"
44 , arg "--no-tmp-comp-dir"
45 , arg $ "--dump-interface=" ++ output
46 , arg "--html"
47 , arg "--hyperlinked-source"
48 , arg "--hoogle"
49 , arg $ "--title=" ++ pkgName pkg ++ "-" ++ version
50 ++ ": " ++ synopsis
51 , arg $ "--prologue=" ++ path -/- "haddock-prologue.txt"
52 , arg $ "--optghc=-D__HADDOCK_VERSION__="
53 ++ show (versionToInt hVersion)
54 , map ("--hide=" ++) <$> getPkgDataList HiddenModules
55 , pure [ "--read-interface=../" ++ dep
56 ++ ",../" ++ dep ++ "/src/%{MODULE}.html#%{NAME},"
57 ++ haddock | (dep, haddock) <- zip deps haddocks ]
58 , pure [ "--optghc=" ++ opt | opt <- ghcOpts ]
59 , getInputs
60 , arg "+RTS"
61 , arg $ "-t" ++ path -/- "haddock.t"
62 , arg "--machine-readable"
63 , arg "-RTS" ] ]