[Git][ghc/ghc][wip/hadddock-libraries] haddock: Build haddock-api and haddock-library using hadrian

Zubin (@wz1000) gitlab at gitlab.haskell.org
Wed May 29 08:37:07 UTC 2024



Zubin pushed to branch wip/hadddock-libraries at Glasgow Haskell Compiler / GHC


Commits:
6de0f992 by Zubin Duggal at 2024-05-29T14:06:56+05:30
haddock: Build haddock-api and haddock-library using hadrian

We build these two packages as regular boot library dependencies rather
than using the `in-ghc-tree` flag to include the source files into the haddock
executable.

The `in-ghc-tree` flag is moved into haddock-api to ensure that haddock built
from hackage can still find the location of the GHC bindist using `ghc-paths`.

Addresses #24834

- - - - -


9 changed files:

- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Packages.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Packages.hs
- hadrian/src/Settings/Warnings.hs
- utils/haddock/haddock-api/haddock-api.cabal
- utils/haddock/haddock-api/src/Haddock/Version.hs
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock.cabal


Changes:

=====================================
hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
=====================================
@@ -78,8 +78,10 @@ import Packages
 -- "Hadrian.Oracles.TextFile.readPackageData" oracle.
 parsePackageData :: Package -> Action PackageData
 parsePackageData pkg = do
-    gpd <- traced "cabal-read" $
+    gpd' <- traced "cabal-read" $
         C.readGenericPackageDescription C.verbose (pkgCabalFile pkg)
+    -- We need to make the data dir relative to the package path so that cabal can actually find it
+    let gpd = gpd' { C.packageDescription = (C.packageDescription gpd') { C.dataDir = pkgPath pkg </> C.dataDir (C.packageDescription gpd') } }
     let pd      = C.packageDescription gpd
         pkgId   = C.package pd
         name    = C.unPackageName (C.pkgName pkgId)


=====================================
hadrian/src/Packages.hs
=====================================
@@ -6,7 +6,7 @@ module Packages (
     compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls,
     exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcBootThNext, ghcPlatform,
     ghcCompact, ghcConfig, ghcExperimental, ghcHeap, ghcInternal, ghci, ghciWrapper, ghcPkg, ghcPrim,
-    ghcToolchain, ghcToolchainBin, haddock, haskeline,
+    ghcToolchain, ghcToolchainBin, haddockApi, haddockLibrary, haddock, haskeline,
     hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy,
     libffi, mtl, osString, parsec, pretty, primitive, process, remoteIserv, rts,
     runGhc, semaphoreCompat, stm, templateHaskell, templateHaskellNext, terminfo, text, time, timeout,
@@ -39,7 +39,7 @@ ghcPackages =
     , compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls
     , exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcBootThNext, ghcPlatform
     , ghcCompact, ghcConfig, ghcExperimental, ghcHeap, ghcInternal, ghci, ghciWrapper, ghcPkg, ghcPrim
-    , ghcToolchain, ghcToolchainBin, haddock, haskeline, hsc2hs
+    , ghcToolchain, ghcToolchainBin, haddockApi, haddockLibrary, haddock, haskeline, hsc2hs
     , hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, mtl, osString
     , parsec, pretty, process, rts, runGhc, stm, semaphoreCompat, templateHaskell, templateHaskellNext
     , terminfo, text, time, transformers, unlit, unix, win32, xhtml
@@ -56,7 +56,7 @@ array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, count
   compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls,
   exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcBootThNext, ghcPlatform,
   ghcCompact, ghcConfig, ghcExperimental, ghcHeap, ghci, ghcInternal, ghciWrapper, ghcPkg, ghcPrim,
-  ghcToolchain, ghcToolchainBin, haddock, haskeline, hsc2hs,
+  ghcToolchain, ghcToolchainBin, haddockLibrary, haddockApi, haddock, haskeline, hsc2hs,
   hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, remoteIserv, libffi, mtl,
   osString, parsec, pretty, primitive, process, rts, runGhc, semaphoreCompat, stm, templateHaskell,
   terminfo, text, time, transformers, unlit, unix, win32, xhtml,
@@ -101,6 +101,8 @@ ghcPkg              = util "ghc-pkg"
 ghcPrim             = lib  "ghc-prim"
 ghcToolchain        = lib  "ghc-toolchain"     `setPath` "utils/ghc-toolchain"
 ghcToolchainBin     = prg  "ghc-toolchain-bin" `setPath` "utils/ghc-toolchain/exe" -- workaround for #23690
+haddockLibrary      = lib "haddock-library" `setPath` "utils/haddock/haddock-library"
+haddockApi          = lib "haddock-api" `setPath` "utils/haddock/haddock-api"
 haddock             = util "haddock"
 haskeline           = lib  "haskeline"
 hsc2hs              = util "hsc2hs"


=====================================
hadrian/src/Settings/Default.hs
=====================================
@@ -93,6 +93,8 @@ stage0Packages = do
              , ghcPlatform
              , ghcToolchain
              , ghci
+             , haddockApi
+             , haddockLibrary
              , haddock
              , hp2ps
              , hpc


=====================================
hadrian/src/Settings/Packages.hs
=====================================
@@ -183,7 +183,7 @@ packageArgs = do
           [ builder (Ghc LinkHs) ? arg "-optl-Wl,--export-dynamic" ]
 
         -------------------------------- haddock -------------------------------
-        , package haddock ?
+        , package haddockApi ?
           builder (Cabal Flags) ? arg "in-ghc-tree"
 
         ---------------------------- template-haskell --------------------------


=====================================
hadrian/src/Settings/Warnings.hs
=====================================
@@ -44,9 +44,10 @@ ghcWarningsArgs = do
                                       , "-Wincomplete-record-updates"
                                       ]
         , package ghcPrim      ? pure [ "-Wno-trustworthy-safe" ]
-        , package haddock      ? pure [ "-Wno-unused-imports"
-                                      , "-Wno-deprecations"
-                                      , "-Wno-x-partial" ]
+        , package haddockLibrary ? pure [ "-Wno-unused-imports" ]
+        , package haddockApi     ? pure [ "-Wno-unused-imports"
+                                        , "-Wno-deprecations"
+                                        , "-Wno-x-partial" ]
         , package haskeline    ? pure [ "-Wno-deprecations"
                                       , "-Wno-x-partial"
                                       , "-Wno-unused-imports"


=====================================
utils/haddock/haddock-api/haddock-api.cabal
=====================================
@@ -39,13 +39,22 @@ data-files:
   html/Linuwial.std-theme/synopsis.png
   latex/haddock.sty
 
+flag in-ghc-tree
+  description: Are we in a GHC tree?
+  default: False
+  manual: True
+
 library
   default-language: Haskell2010
 
+  if flag(in-ghc-tree)
+    cpp-options: -DIN_GHC_TREE
+  else
+    build-depends: ghc-paths       ^>= 0.1.0.12
+
   -- this package typically supports only single major versions
   build-depends: base             >= 4.16 && < 4.21
                , ghc             ^>= 9.11
-               , ghc-paths       ^>= 0.1.0.12
                , haddock-library ^>= 1.11
                , xhtml           ^>= 3000.2.2
                , parsec          ^>= 3.1.13.0


=====================================
utils/haddock/haddock-api/src/Haddock/Version.hs
=====================================
@@ -18,11 +18,7 @@ module Haddock.Version
   , projectUrl
   ) where
 
-#ifdef IN_GHC_TREE
-import Paths_haddock ( version )
-#else
 import Paths_haddock_api ( version )
-#endif
 import Data.Version (showVersion)
 
 projectName :: String


=====================================
utils/haddock/haddock-library/haddock-library.cabal
=====================================
@@ -35,7 +35,7 @@ common lib-defaults
   default-language: Haskell2010
 
   build-depends:
-    , base         >= 4.10     && < 4.20
+    , base         >= 4.10     && < 4.21
     , containers   ^>= 0.4.2.1 || ^>= 0.5.0.0 || ^>= 0.6.0.1 || ^>= 0.7
     , text         ^>= 1.2.3.0 || ^>= 2.0 || ^>= 2.1
     , parsec       ^>= 3.1.13.0


=====================================
utils/haddock/haddock.cabal
=====================================
@@ -55,11 +55,6 @@ extra-source-files:
   hoogle-test/src/**/*.hs
   hoogle-test/ref/**/*.txt
 
-flag in-ghc-tree
-  description: Are we in a GHC tree?
-  default: False
-  manual: True
-
 flag threaded
   description: Build haddock with the threaded RTS
   default: True
@@ -75,87 +70,8 @@ executable haddock
 
   -- haddock typically only supports a single GHC major version
   build-depends:
-    base ^>= 4.13.0.0 || ^>= 4.14.0.0 || ^>= 4.15.0.0 || ^>= 4.16.0.0 || ^>= 4.17.0.0 || ^>= 4.18.0.0 || ^>= 4.19.0.0 || ^>= 4.20.0.0
-
-  if flag(in-ghc-tree)
-    hs-source-dirs: haddock-api/src,  haddock-library/src
-    cpp-options: -DIN_GHC_TREE
-    build-depends:
-      filepath,
-      directory,
-      containers,
-      deepseq,
-      exceptions,
-      array,
-      xhtml >= 3000.2 && < 3000.3,
-      ghc-boot,
-      ghc-boot-th,
-      ghc == 9.11.*,
-      bytestring,
-      parsec,
-      text,
-      transformers,
-      mtl
-
-    other-modules:
-      Documentation.Haddock.Parser
-      Documentation.Haddock.Parser.Monad
-      Documentation.Haddock.Parser.Identifier
-      Documentation.Haddock.Types
-      Documentation.Haddock.Doc
-      Documentation.Haddock.Parser.Util
-      Documentation.Haddock.Markup
-
-      Documentation.Haddock
-      Haddock
-      Haddock.Interface
-      Haddock.Interface.Json
-      Haddock.Interface.Rename
-      Haddock.Interface.Create
-      Haddock.Interface.AttachInstances
-      Haddock.Interface.LexParseRn
-      Haddock.Interface.ParseModuleHeader
-      Haddock.Interface.RenameType
-      Haddock.Parser
-      Haddock.Utils
-      Haddock.Utils.Json
-      Haddock.Utils.Json.Parser
-      Haddock.Utils.Json.Types
-      Haddock.Backends.Xhtml
-      Haddock.Backends.Xhtml.Decl
-      Haddock.Backends.Xhtml.DocMarkup
-      Haddock.Backends.Xhtml.Layout
-      Haddock.Backends.Xhtml.Meta
-      Haddock.Backends.Xhtml.Names
-      Haddock.Backends.Xhtml.Themes
-      Haddock.Backends.Xhtml.Types
-      Haddock.Backends.Xhtml.Utils
-      Haddock.Backends.LaTeX
-      Haddock.Backends.HaddockDB
-      Haddock.Backends.Hoogle
-      Haddock.Backends.Hyperlinker
-      Haddock.Backends.Hyperlinker.Parser
-      Haddock.Backends.Hyperlinker.Renderer
-      Haddock.Backends.Hyperlinker.Types
-      Haddock.Backends.Hyperlinker.Utils
-      Haddock.ModuleTree
-      Haddock.Types
-      Haddock.Doc
-      Haddock.Version
-      Haddock.InterfaceFile
-      Haddock.Options
-      Haddock.GhcUtils
-      Haddock.Convert
-
-      Paths_haddock
-
-    autogen-modules:
-      Paths_haddock
-
-  else
-    -- in order for haddock's advertised version number to have proper meaning,
-    -- we pin down to a single haddock-api version.
-    build-depends:  haddock-api == 2.30.0
+      base ^>= 4.13.0.0 || ^>= 4.14.0.0 || ^>= 4.15.0.0 || ^>= 4.16.0.0 || ^>= 4.17.0.0 || ^>= 4.18.0.0 || ^>= 4.19.0.0 || ^>= 4.20.0.0
+    , haddock-api == 2.30.0
 
 test-suite html-test
   type:             exitcode-stdio-1.0



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6de0f992cb4e55fcaba1fad64bcae446f6c6015f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6de0f992cb4e55fcaba1fad64bcae446f6c6015f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240529/0bad4cb4/attachment-0001.html>


More information about the ghc-commits mailing list