summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2019-01-10 03:45:06 -0800
committerBen Gamari <ben@smart-cactus.org>2019-01-16 14:17:47 -0500
commit2e05912086bbb8eab213d44af300ecc396d912aa (patch)
treeb8b17a3e299f57ffb5bf7eb33049608f00eb19f5
parent46d46ede77ef327966e9364800c7da52c208d8ae (diff)
downloadhaskell-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.
-rw-r--r--hadrian/src/Builder.hs11
-rw-r--r--hadrian/src/Rules/Documentation.hs32
-rw-r--r--hadrian/src/Settings/Builders/Haddock.hs4
3 files changed, 29 insertions, 18 deletions
diff --git a/hadrian/src/Builder.hs b/hadrian/src/Builder.hs
index a3a3f547fd..55dcb3c148 100644
--- a/hadrian/src/Builder.hs
+++ b/hadrian/src/Builder.hs
@@ -23,6 +23,7 @@ import Hadrian.Builder.Sphinx
import Hadrian.Builder.Tar
import Hadrian.Oracles.Path
import Hadrian.Oracles.TextFile
+import Hadrian.Oracles.DirectoryContents
import Hadrian.Utilities
import Base
@@ -187,6 +188,16 @@ instance H.Builder Builder where
Hsc2Hs stage -> (\p -> [p]) <$> templateHscPath stage
Make dir -> return [dir -/- "Makefile"]
+
+ Haddock _ -> do
+ let resdir = "utils/haddock/haddock-api/resources"
+ latexResources <- directoryContents matchAll (resdir -/- "latex")
+ htmlResources <- directoryContents matchAll (resdir -/- "html")
+
+ haddockLib <- stageLibPath Stage1 -- Haddock is built in stage1
+ return $ [ haddockLib -/- makeRelative resdir f
+ | f <- latexResources ++ htmlResources ]
+
_ -> return []
-- query the builder for some information.
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
diff --git a/hadrian/src/Settings/Builders/Haddock.hs b/hadrian/src/Settings/Builders/Haddock.hs
index 2830c209e7..92ac714560 100644
--- a/hadrian/src/Settings/Builders/Haddock.hs
+++ b/hadrian/src/Settings/Builders/Haddock.hs
@@ -21,7 +21,7 @@ haddockBuilderArgs = mconcat
root <- getBuildRoot
mconcat
[ arg $ "-B" ++ root -/- "stage1" -/- "lib"
- , arg $ "--lib=" ++ root -/- "docs"
+ , arg $ "--lib=" ++ root -/- "stage1" -/- "lib"
, arg "--gen-index"
, arg "--gen-contents"
, arg "-o", arg $ takeDirectory output
@@ -46,7 +46,7 @@ haddockBuilderArgs = mconcat
mconcat
[ arg "--verbosity=0"
, arg $ "-B" ++ root -/- "stage1" -/- "lib"
- , arg $ "--lib=" ++ root -/- "docs"
+ , arg $ "--lib=" ++ root -/- "stage1" -/- "lib"
, arg $ "--odir=" ++ takeDirectory output
, arg "--no-tmp-comp-dir"
, arg $ "--dump-interface=" ++ output