diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2019-01-10 03:45:06 -0800 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-01-16 14:17:47 -0500 |
commit | 2e05912086bbb8eab213d44af300ecc396d912aa (patch) | |
tree | b8b17a3e299f57ffb5bf7eb33049608f00eb19f5 /hadrian/src/Rules/Documentation.hs | |
parent | 46d46ede77ef327966e9364800c7da52c208d8ae (diff) | |
download | haskell-2e05912086bbb8eab213d44af300ecc396d912aa.tar.gz |
Hadrian: handle Haddock's resource directory
Fixes #16105
* Require Haddock's resource as runtime dependencies of the Haddock
builder. This means we no longer have to `need` particular resources
in every other documentation rule.
* Do a _tracked_ copy of both the 'html' and 'latex' folder resource
folders.
* Move resources into `stage1/lib` (NB: the `haddock` binary goes in
`stage1/bin`). Besides now actually matching the Haddock script
wrapper generated by BinaryDist, this also prepares for Haddock
in relocatable build folder detecting its own resources.
Diffstat (limited to 'hadrian/src/Rules/Documentation.hs')
-rw-r--r-- | hadrian/src/Rules/Documentation.hs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs index f1a7454fbb..2aa663f2aa 100644 --- a/hadrian/src/Rules/Documentation.hs +++ b/hadrian/src/Rules/Documentation.hs @@ -36,9 +36,6 @@ pdfRoot = docRoot -/- "pdfs" archiveRoot :: FilePath archiveRoot = docRoot -/- "archives" -haddockHtmlLib :: FilePath -haddockHtmlLib = htmlRoot -/- "haddock-bundle.min.js" - manPageBuildPath :: FilePath manPageBuildPath = "docs/users_guide/build-man/ghc.1" @@ -67,6 +64,8 @@ pathPath _ = "" -- | Build all documentation documentationRules :: Rules () documentationRules = do + haddockResources + buildDocumentationArchives buildHtmlDocumentation buildManPage @@ -97,7 +96,6 @@ buildHtmlDocumentation = do root <- buildRootRules root -/- htmlRoot -/- "index.html" %> \file -> do - need [root -/- haddockHtmlLib] need $ map ((root -/-) . pathIndex) docPaths copyFileUntracked "docs/index.html" file @@ -106,25 +104,30 @@ buildSphinxHtml :: FilePath -> Rules () buildSphinxHtml path = do root <- buildRootRules root -/- htmlRoot -/- path -/- "index.html" %> \file -> do - need [root -/- haddockHtmlLib] let dest = takeDirectory file build $ target docContext (Sphinx Html) [pathPath path] [dest] ------------------------------------ Haddock ----------------------------------- +-- | Copy resources into the @lib@ directory +haddockResources :: Rules () +haddockResources = do + root <- buildRootRules + let resdir = "utils/haddock/haddock-api/resources" + haddockLib = root -/- "stage1/lib" -- Haddock is built in stage1 + + [ haddockLib -/- "html//*", haddockLib -/- "latex//*" ] |%> \target -> do + let source = resdir -/- makeRelative haddockLib target + copyFile source target + -- | Build the haddocks for GHC's libraries. buildLibraryDocumentation :: Rules () buildLibraryDocumentation = do root <- buildRootRules - -- Js and Css files for haddock output - root -/- haddockHtmlLib %> \_ -> - copyDirectory "utils/haddock/haddock-api/resources/html" (root -/- docRoot) - -- Building the "Haskell Hierarchical Libraries" index root -/- htmlRoot -/- "libraries/index.html" %> \file -> do - need [ root -/- haddockHtmlLib - , "libraries/prologue.txt" ] + need [ "libraries/prologue.txt" ] -- We want Haddocks for everything except `rts` to be built, but we -- don't want the index to be polluted by stuff from `ghc`-the-library @@ -152,7 +155,6 @@ buildPackageDocumentation = do -- Per-package haddocks root -/- htmlRoot -/- "libraries/*/haddock-prologue.txt" %> \file -> do ctx <- getPkgDocTarget root file >>= pkgDocContext - need [root -/- haddockHtmlLib] -- This is how @ghc-cabal@ used to produces "haddock-prologue.txt" files. syn <- pkgSynopsis (Context.package ctx) desc <- pkgDescription (Context.package ctx) @@ -172,7 +174,7 @@ buildPackageDocumentation = do vanillaSrcs <- hsSources context let srcs = vanillaSrcs `union` generatedSrcs - need $ srcs ++ haddocks ++ [root -/- haddockHtmlLib] + need $ srcs ++ haddocks -- Build Haddock documentation -- TODO: Pass the correct way from Rules via Context. @@ -220,7 +222,6 @@ buildSphinxPdf :: FilePath -> Rules () buildSphinxPdf path = do root <- buildRootRules root -/- pdfRoot -/- path <.> "pdf" %> \file -> do - need [root -/- haddockHtmlLib] withTempDir $ \dir -> do build $ target docContext (Sphinx Latex) [pathPath path] [dir] build $ target docContext Xelatex [path <.> "tex"] [dir] @@ -236,7 +237,6 @@ buildArchive :: FilePath -> Rules () buildArchive path = do root <- buildRootRules root -/- pathArchive path %> \file -> do - need [root -/- haddockHtmlLib] root <- buildRoot let src = root -/- pathIndex path need [src] @@ -247,7 +247,7 @@ buildManPage :: Rules () buildManPage = do root <- buildRootRules root -/- manPageBuildPath %> \file -> do - need [root -/- haddockHtmlLib, "docs/users_guide/ghc.rst"] + need ["docs/users_guide/ghc.rst"] withTempDir $ \dir -> do build $ target docContext (Sphinx Man) ["docs/users_guide"] [dir] copyFileUntracked (dir -/- "ghc.1") file |