summaryrefslogtreecommitdiff
path: root/hadrian/src/Rules/Documentation.hs
diff options
context:
space:
mode:
authorAndrey Mokhov <andrey.mokhov@gmail.com>2019-02-14 14:29:50 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-02-20 09:59:16 -0500
commit1dad4fc27ea128a11ba0077f459494c2a1ca0d5c (patch)
treec5b569c56435e699c03fca5ad08cf03cb8b21b80 /hadrian/src/Rules/Documentation.hs
parent908b4b8659713f0b7a1704ce33c7fa30e3e0ffc3 (diff)
downloadhaskell-1dad4fc27ea128a11ba0077f459494c2a1ca0d5c.tar.gz
Hadrian: Fix untracked dependencies
This is a preparation for #16295: https://ghc.haskell.org/trac/ghc/ticket/16295 This commit mostly focuses on getting rid of untracked dependencies, which prevent Shake's new `--shared` feature from appropriately caching build rules. There are three different solutions to untracked dependencies: * Track them! This is the obvious and the best approach, but in some situations we cannot use it, for example, because a build rule creates files whose names are not known statically and hence cannot be specified as the rule's outputs. * Use Shake's `produces` to record outputs dynamically, within the rule. * Use Shake's `historyDisable` to disable caching for a particular build rule. We currently use this approach only for `ghc-pkg` which mutates the package database and the file `package.cache`. These two tickets are fixed as the result: Ticket #16271: ​https://ghc.haskell.org/trac/ghc/ticket/16271 Ticket #16272: ​https://ghc.haskell.org/trac/ghc/ticket/16272 (this one is fixed only partially: we correctly record the dependency, but we still copy files into the RTS build tree).
Diffstat (limited to 'hadrian/src/Rules/Documentation.hs')
-rw-r--r--hadrian/src/Rules/Documentation.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 2d7a4b1ef7..c9de3038ed 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -141,7 +141,7 @@ buildPackageDocumentation = do
-- Per-package haddocks
root -/- htmlRoot -/- "libraries/*/haddock-prologue.txt" %> \file -> do
- ctx <- getPkgDocTarget root file >>= pkgDocContext
+ ctx <- pkgDocContext <$> getPkgDocTarget root file
-- This is how @ghc-cabal@ used to produces "haddock-prologue.txt" files.
syn <- pkgSynopsis (Context.package ctx)
desc <- pkgDescription (Context.package ctx)
@@ -149,7 +149,7 @@ buildPackageDocumentation = do
liftIO $ writeFile file prologue
root -/- htmlRoot -/- "libraries/*/*.haddock" %> \file -> do
- context <- getPkgDocTarget root file >>= pkgDocContext
+ context <- pkgDocContext <$> getPkgDocTarget root file
need [ takeDirectory file -/- "haddock-prologue.txt"]
haddocks <- haddockDependencies context
@@ -172,14 +172,11 @@ buildPackageDocumentation = do
data PkgDocTarget = DotHaddock PackageName | HaddockPrologue PackageName
deriving (Eq, Show)
-pkgDocContext :: PkgDocTarget -> Action Context
-pkgDocContext target = case findPackageByName pkgname of
- Nothing -> error $ "pkgDocContext: couldn't find package " ++ pkgname
- Just p -> return (Context Stage1 p vanilla)
-
- where pkgname = case target of
- DotHaddock n -> n
- HaddockPrologue n -> n
+pkgDocContext :: PkgDocTarget -> Context
+pkgDocContext target = Context Stage1 (unsafeFindPackageByName name) vanilla
+ where
+ name = case target of DotHaddock n -> n
+ HaddockPrologue n -> n
parsePkgDocTarget :: FilePath -> Parsec.Parsec String () PkgDocTarget
parsePkgDocTarget root = do