[commit: ghc] master: Hadrian: Misc. fixes in Haddock rules (ff61955)
git at git.haskell.org
git at git.haskell.org
Thu Nov 22 18:47:43 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ff619555439a8fc671fffb239910972b054a7d96/ghc
>---------------------------------------------------------------
commit ff619555439a8fc671fffb239910972b054a7d96
Author: Alec Theriault <alec.theriault at gmail.com>
Date: Thu Nov 22 11:53:10 2018 -0500
Hadrian: Misc. fixes in Haddock rules
* Pass 'GHC/Prim.hs' to Haddock when processing 'ghc-prim'. This
file is autogenerated for the sole purpose of giving Haddock
something to process, so we really should make sure it gets
through to Haddock!
* Add a "docs-haddock" build rule, which should build all Haddock docs
that the Makefile builds by default (all libs + index for libs + ghc)
* Prune some unnecessary rules (esp. `gen_contents_index`)
Reviewers: bgamari, snowleopard
Reviewed By: snowleopard
Subscribers: alpmestan, snowleopard, rwbarton, carter
Differential Revision: https://phabricator.haskell.org/D5316
>---------------------------------------------------------------
ff619555439a8fc671fffb239910972b054a7d96
hadrian/src/Rules/Documentation.hs | 51 +++++++++++++++++++++++++-------------
hadrian/src/Rules/Generate.hs | 2 +-
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 92b5ff5..963bc4c 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -9,9 +9,10 @@ module Rules.Documentation (
import Hadrian.Haskell.Cabal
import Hadrian.Haskell.Cabal.Type
+import Rules.Generate (ghcPrimDependencies)
import Base
import Context
-import Expression (getContextData, interpretInContext)
+import Expression (getContextData, interpretInContext, (?), package)
import Flavour
import Oracles.ModuleFiles
import Packages
@@ -19,6 +20,8 @@ import Settings
import Target
import Utilities
+import Data.List (union)
+
docRoot :: FilePath
docRoot = "docs"
@@ -67,15 +70,20 @@ documentationRules = do
buildManPage
buildPdfDocumentation
+ -- a phony rule that runs Haddock for "Haskell Hierarchical Libraries" and
+ -- the "GHC-API"
+ "docs-haddock" ~> do
+ root <- buildRoot
+ need [ root -/- pathIndex "libraries" ]
+
+ -- a phony rule that runs Haddock, builds the User's guide, builds
+ -- Haddock's manual, and builds man pages
"docs" ~> do
root <- buildRoot
- let html = htmlRoot -/- "index.html"
+ let html = htmlRoot -/- "index.html" -- also implies "docs-haddock"
archives = map pathArchive docPaths
pdfs = map pathPdf $ docPaths \\ ["libraries"]
- need $ map (root -/-) $ [html] ++ archives ++ pdfs
- need [ root -/- htmlRoot -/- "libraries" -/- "gen_contents_index"
- , root -/- htmlRoot -/- "libraries" -/- "prologue.txt"
- , root -/- manPageBuildPath ]
+ need $ map (root -/-) $ [html] ++ archives ++ pdfs ++ [manPageBuildPath]
------------------------------------- HTML -------------------------------------
@@ -85,11 +93,6 @@ buildHtmlDocumentation = do
mapM_ buildSphinxHtml $ docPaths \\ ["libraries"]
buildLibraryDocumentation
root <- buildRootRules
- root -/- htmlRoot -/- "libraries/gen_contents_index" %>
- copyFile "libraries/gen_contents_index"
-
- root -/- htmlRoot -/- "libraries/prologue.txt" %>
- copyFile "libraries/prologue.txt"
root -/- htmlRoot -/- "index.html" %> \file -> do
need [root -/- haddockHtmlLib]
@@ -116,13 +119,19 @@ buildLibraryDocumentation = do
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]
+ need [ root -/- haddockHtmlLib
+ , "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
+ -- (there will be a seperate top-level link to those Haddocks).
haddocks <- allHaddocks
- let libDocs = filter
- (\x -> takeFileName x `notElem` ["ghc.haddock", "rts.haddock"])
- haddocks
- need (root -/- haddockHtmlLib : libDocs)
+ let neededDocs = filter (\x -> takeFileName x /= "rts.haddock") haddocks
+ libDocs = filter (\x -> takeFileName x /= "ghc.haddock") neededDocs
+
+ need neededDocs
build $ target docContext (Haddock BuildIndex) libDocs [file]
allHaddocks :: Action [FilePath]
@@ -150,7 +159,15 @@ buildPackageDocumentation context at Context {..} = when (stage == Stage1 && packag
root -/- htmlRoot -/- "libraries" -/- pkgName package -/- pkgName package <.> "haddock" %> \file -> do
need [root -/- htmlRoot -/- "libraries" -/- pkgName package -/- "haddock-prologue.txt"]
haddocks <- haddockDependencies context
- srcs <- hsSources context
+
+ -- `ghc-prim` has a source file for 'GHC.Prim' which is generated just
+ -- for Haddock. We need to 'union' (instead of '++') to avoid passing
+ -- 'GHC.PrimopWrappers' (which unfortunately shows up in both
+ -- `generatedSrcs` and `vanillaSrcs`) to Haddock twice.
+ generatedSrcs <- interpretInContext context (Expression.package ghcPrim ? ghcPrimDependencies)
+ vanillaSrcs <- hsSources context
+ let srcs = vanillaSrcs `union` generatedSrcs
+
need $ srcs ++ haddocks ++ [root -/- haddockHtmlLib]
-- Build Haddock documentation
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index c3650c3..7c59899 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -1,6 +1,6 @@
module Rules.Generate (
isGeneratedCmmFile, generatePackageCode, generateRules, copyRules,
- includesDependencies, generatedDependencies
+ includesDependencies, generatedDependencies, ghcPrimDependencies
) where
import Base
More information about the ghc-commits
mailing list