summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-01-25 16:20:07 -0500
committerBen Gamari <ben@smart-cactus.org>2023-01-29 11:11:34 -0500
commit1bff1f03ad790447b293652993459249a854a588 (patch)
treef5c98d7c55cf0f1873ad78c23aca9b2eb9016ac7
parent7c0b4dddc0a30e09750be560cd7899c50f8f14c9 (diff)
downloadhaskell-wip/T22714.tar.gz
hadrian: Substitute LIBRARY_*_VERSION variableswip/T22714
This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables in `libraries/prologue.txt`, fixing #22714. Fixes #22714.
-rw-r--r--hadrian/src/Rules/Documentation.hs10
-rw-r--r--hadrian/src/Rules/Generate.hs10
2 files changed, 18 insertions, 2 deletions
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 3c31823889..27aece61d2 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -78,6 +78,8 @@ needDocDeps = do
, ghci
, libiserv
, compiler
+ , ghcHeap
+ , templateHaskell
]
need templatedCabalFiles
@@ -102,8 +104,6 @@ documentationRules = do
"docs" ~> do
root <- buildRoot
- needDocDeps
-
doctargets <- ghcDocs =<< flavour
let html = htmlRoot -/- "index.html" -- also implies "docs-haddock"
archives = map pathArchive docPaths
@@ -203,6 +203,9 @@ buildSphinxHtml path = do
root -/- htmlRoot -/- path -/- "index.html" %> \file -> do
let dest = takeDirectory file
rstFilesDir = pathPath path
+
+ needDocDeps
+
rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"]
need (map (rstFilesDir -/-) rstFiles)
build $ target docContext (Sphinx HtmlMode) [pathPath path] [dest]
@@ -314,6 +317,9 @@ buildSphinxPdf :: FilePath -> Rules ()
buildSphinxPdf path = do
root <- buildRootRules
root -/- pdfRoot -/- path <.> "pdf" %> \file -> do
+
+ needDocDeps
+
withTempDir $ \dir -> do
let rstFilesDir = pathPath path
rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"]
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index f17ff0eb21..a37d69d7d1 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -13,6 +13,8 @@ import Hadrian.Oracles.TextFile (lookupSystemConfig)
import Oracles.Flag
import Oracles.ModuleFiles
import Oracles.Setting
+import Hadrian.Haskell.Cabal.Type (PackageData(version))
+import Hadrian.Oracles.Cabal (readPackageData)
import Packages
import Rules.Libffi
import Settings
@@ -303,6 +305,13 @@ rtsCabalFlags = mconcat
where
flag = interpolateCabalFlag
+packageVersions :: Interpolations
+packageVersions = foldMap f [ base, ghcPrim, ghc, cabal, templateHaskell, ghcCompact, array ]
+ where
+ f :: Package -> Interpolations
+ f pkg = interpolateVar var $ show . version <$> readPackageData pkg
+ where var = "LIBRARY_" <> pkgName pkg <> "_VERSION"
+
templateRule :: FilePath -> Interpolations -> Rules ()
templateRule outPath interps = do
outPath %> \_ -> do
@@ -328,6 +337,7 @@ templateRules = do
templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion
templateRule "libraries/libiserv/libiserv.cabal" $ projectVersion
templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion
+ templateRule "libraries/prologue.txt" $ packageVersions
-- Generators