Commit ff619555 authored by Alec Theriault's avatar Alec Theriault Committed by Ben Gamari

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
parent 699e5072
......@@ -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@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
......
module Rules.Generate (
isGeneratedCmmFile, generatePackageCode, generateRules, copyRules,
includesDependencies, generatedDependencies
includesDependencies, generatedDependencies, ghcPrimDependencies
) where
import Base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment