[commit: ghc] master: Fix Haddock (#496) (8d6945d)

git at git.haskell.org git at git.haskell.org
Tue Oct 23 20:13:02 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8d6945d970926ae77ea0d05a2b6590920eabc985/ghc

>---------------------------------------------------------------

commit 8d6945d970926ae77ea0d05a2b6590920eabc985
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sat Feb 3 01:56:47 2018 +0000

    Fix Haddock (#496)
    
    See #492.


>---------------------------------------------------------------

8d6945d970926ae77ea0d05a2b6590920eabc985
 src/Rules/Documentation.hs | 13 ++++++++-----
 src/Rules/Generate.hs      |  6 ++++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/Rules/Documentation.hs b/src/Rules/Documentation.hs
index 5a5698c..3043f8b 100644
--- a/src/Rules/Documentation.hs
+++ b/src/Rules/Documentation.hs
@@ -117,8 +117,11 @@ allHaddocks = do
     sequence [ pkgHaddockFile $ vanillaContext Stage1 pkg
              | pkg <- pkgs, isLibrary pkg, isHsPackage pkg ]
 
-haddockHtmlLib :: FilePath
-haddockHtmlLib = "inplace/lib/html/haddock-util.js"
+-- TODO: This is fragile and will break if @README.md@ is removed. We need to
+-- improve the story of program runtime dependencies on directories.
+-- See: https://github.com/snowleopard/hadrian/issues/492.
+haddockHtmlResourcesStamp :: FilePath
+haddockHtmlResourcesStamp = "inplace/lib/html/README.md"
 
 -- | Find the haddock files for the dependencies of the current library
 haddockDependencies :: Context -> Action [FilePath]
@@ -135,8 +138,8 @@ buildPackageDocumentation :: Context -> Rules ()
 buildPackageDocumentation context at Context {..} = when (stage == Stage1) $ do
 
     -- Js and Css files for haddock output
-    when (package == haddock) $ haddockHtmlLib %> \_ -> do
-        let dir = takeDirectory haddockHtmlLib
+    when (package == haddock) $ haddockHtmlResourcesStamp %> \_ -> do
+        let dir = takeDirectory haddockHtmlResourcesStamp
         liftIO $ removeFiles dir ["//*"]
         copyDirectory "utils/haddock/haddock-api/resources/html" dir
 
@@ -144,7 +147,7 @@ buildPackageDocumentation context at Context {..} = when (stage == Stage1) $ do
     "//" ++ pkgName package <.> "haddock" %> \file -> do
         haddocks <- haddockDependencies context
         srcs <- hsSources context
-        need $ srcs ++ haddocks ++ [haddockHtmlLib]
+        need $ srcs ++ haddocks ++ [haddockHtmlResourcesStamp]
 
         -- Build Haddock documentation
         -- TODO: pass the correct way from Rules via Context
diff --git a/src/Rules/Generate.hs b/src/Rules/Generate.hs
index 8e2b65d..8616da0 100644
--- a/src/Rules/Generate.hs
+++ b/src/Rules/Generate.hs
@@ -141,6 +141,12 @@ generatePackageCode context@(Context stage pkg _) =
         when (pkg == rts) $ "//" ++ dir -/- "cmm/AutoApply.cmm" %> \file ->
             build $ target context GenApply [] [file]
 
+-- TODO: These rules copy runtime dependencies of some executables, such as GHC
+-- itself (file @ghc-usage.txt@) or Hsc2Hs (file @template-hsc.h@). Ideally,
+-- these rules should be moved to package-specific settings, so that they can be
+-- discovered more easily. We also need to add proper support for runtime
+-- dependencies on directories, which is the case for Haddock -- for the current
+-- workaround see "Rules.Documentation.haddockHtmlResourcesStamp".
 copyRules :: Rules ()
 copyRules = do
     (inplaceLibPath -/- "ghc-usage.txt")     <~ return "driver"



More information about the ghc-commits mailing list