summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2019-01-10 04:37:36 -0800
committerBen Gamari <ben@smart-cactus.org>2019-01-16 14:17:47 -0500
commit8765c1e6e6aca590a2fc252c64846890bf87f387 (patch)
tree3486cd9d5eca722a6b19f1f3f038ad72dbbe6958
parent2e05912086bbb8eab213d44af300ecc396d912aa (diff)
downloadhaskell-8765c1e6e6aca590a2fc252c64846890bf87f387.tar.gz
Make sure 'haddock' package also copies resources
...and does so in the lib folder of the right stage
-rw-r--r--hadrian/src/Base.hs15
-rw-r--r--hadrian/src/Builder.hs12
-rw-r--r--hadrian/src/Rules/Documentation.hs13
-rw-r--r--hadrian/src/Rules/Generate.hs14
-rw-r--r--hadrian/src/Rules/Program.hs3
-rw-r--r--hadrian/src/Settings/Builders/Haddock.hs8
6 files changed, 31 insertions, 34 deletions
diff --git a/hadrian/src/Base.hs b/hadrian/src/Base.hs
index cb0dba06ea..277d6148ab 100644
--- a/hadrian/src/Base.hs
+++ b/hadrian/src/Base.hs
@@ -24,7 +24,8 @@ module Base (
-- * Paths
hadrianPath, configPath, configFile, sourcePath, shakeFilesDir,
generatedDir, generatedPath, stageBinPath, stageLibPath, templateHscPath,
- ghcDeps, relativePackageDbPath, packageDbPath, packageDbStamp, ghcSplitPath
+ ghcDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp,
+ ghcSplitPath
) where
import Control.Applicative
@@ -37,6 +38,7 @@ import Development.Shake hiding (parallel, unit, (*>), Normal)
import Development.Shake.Classes
import Development.Shake.FilePath
import Development.Shake.Util
+import Hadrian.Oracles.DirectoryContents
import Hadrian.Utilities
import Hadrian.Package
@@ -114,6 +116,17 @@ ghcDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f))
, "platformConstants"
, "settings" ]
+-- | Files the `haddock` binary depends on
+haddockDeps :: Stage -> Action [FilePath]
+haddockDeps stage = do
+ let resdir = "utils/haddock/haddock-api/resources"
+ latexResources <- directoryContents matchAll (resdir -/- "latex")
+ htmlResources <- directoryContents matchAll (resdir -/- "html")
+
+ haddockLib <- stageLibPath stage
+ return $ [ haddockLib -/- makeRelative resdir f
+ | f <- latexResources ++ htmlResources ]
+
-- ref: utils/hsc2hs/ghc.mk
-- | Path to 'hsc2hs' template.
templateHscPath :: Stage -> Action FilePath
diff --git a/hadrian/src/Builder.hs b/hadrian/src/Builder.hs
index 55dcb3c148..d09af9942e 100644
--- a/hadrian/src/Builder.hs
+++ b/hadrian/src/Builder.hs
@@ -23,7 +23,6 @@ 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
@@ -188,16 +187,7 @@ 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 ]
-
+ Haddock _ -> haddockDeps Stage1 -- Haddock currently runs in Stage1
_ -> return []
-- query the builder for some information.
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 2aa663f2aa..954264aa28 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -64,8 +64,6 @@ pathPath _ = ""
-- | Build all documentation
documentationRules :: Rules ()
documentationRules = do
- haddockResources
-
buildDocumentationArchives
buildHtmlDocumentation
buildManPage
@@ -109,17 +107,6 @@ buildSphinxHtml path = do
------------------------------------ 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
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index e03575347b..9db5b198e4 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -161,6 +161,12 @@ copyRules = do
root <- buildRootRules
forM_ [Stage0 ..] $ \stage -> do
let prefix = root -/- stageString stage -/- "lib"
+
+ infixl 1 <~
+ pattern <~ mdir = pattern %> \file -> do
+ dir <- mdir
+ copyFile (dir -/- makeRelative prefix file) file
+
prefix -/- "ghc-usage.txt" <~ return "driver"
prefix -/- "ghci-usage.txt" <~ return "driver"
prefix -/- "llvm-targets" <~ return "."
@@ -168,11 +174,9 @@ copyRules = do
prefix -/- "platformConstants" <~ (buildRoot <&> (-/- generatedDir))
prefix -/- "settings" <~ return "."
prefix -/- "template-hsc.h" <~ return (pkgPath hsc2hs)
- where
- infixl 1 <~
- pattern <~ mdir = pattern %> \file -> do
- dir <- mdir
- copyFile (dir -/- takeFileName file) file
+
+ prefix -/- "html//*" <~ return "utils/haddock/haddock-api/resources"
+ prefix -/- "latex//*" <~ return "utils/haddock/haddock-api/resources"
generateRules :: Rules ()
generateRules = do
diff --git a/hadrian/src/Rules/Program.hs b/hadrian/src/Rules/Program.hs
index 9d8b6d0a0c..c9df6f5e2d 100644
--- a/hadrian/src/Rules/Program.hs
+++ b/hadrian/src/Rules/Program.hs
@@ -71,6 +71,9 @@ buildProgram bin ctx@(Context{..}) rs = do
-- @llvm-targets@, @ghc-usage.txt@, @ghci-usage.txt@,
-- @llvm-passes@.
need =<< ghcDeps stage
+ when (package == haddock) $ do
+ -- Haddock has a resource folder
+ need =<< haddockDeps stage
cross <- flag CrossCompiling
-- For cross compiler, copy @stage0/bin/<pgm>@ to @stage1/bin/@.
diff --git a/hadrian/src/Settings/Builders/Haddock.hs b/hadrian/src/Settings/Builders/Haddock.hs
index 92ac714560..65c703160c 100644
--- a/hadrian/src/Settings/Builders/Haddock.hs
+++ b/hadrian/src/Settings/Builders/Haddock.hs
@@ -20,8 +20,8 @@ haddockBuilderArgs = mconcat
inputs <- getInputs
root <- getBuildRoot
mconcat
- [ arg $ "-B" ++ root -/- "stage1" -/- "lib"
- , arg $ "--lib=" ++ root -/- "stage1" -/- "lib"
+ [ arg $ "-B" ++ root -/- stageString Stage1 -/- "lib"
+ , arg $ "--lib=" ++ root -/- stageString Stage1 -/- "lib"
, arg "--gen-index"
, arg "--gen-contents"
, arg "-o", arg $ takeDirectory output
@@ -45,8 +45,8 @@ haddockBuilderArgs = mconcat
ghcOpts <- haddockGhcArgs
mconcat
[ arg "--verbosity=0"
- , arg $ "-B" ++ root -/- "stage1" -/- "lib"
- , arg $ "--lib=" ++ root -/- "stage1" -/- "lib"
+ , arg $ "-B" ++ root -/- stageString Stage1 -/- "lib"
+ , arg $ "--lib=" ++ root -/- stageString Stage1 -/- "lib"
, arg $ "--odir=" ++ takeDirectory output
, arg "--no-tmp-comp-dir"
, arg $ "--dump-interface=" ++ output