From 653c75130773cbbb092a35a021a1bf25d4ccaf68 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Wed, 25 Jan 2023 16:20:07 -0500 Subject: hadrian: Substitute LIBRARY_*_VERSION variables This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables in `libraries/prologue.txt`, fixing #22714. Fixes #22714. (cherry picked from commit 93f0e3c49cea484bd6e838892ff8702ec51f34c3) --- hadrian/src/Rules/Documentation.hs | 10 ++++++++-- hadrian/src/Rules/Generate.hs | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'hadrian/src') diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs index 85408a1104..9beef97c79 100644 --- a/hadrian/src/Rules/Documentation.hs +++ b/hadrian/src/Rules/Documentation.hs @@ -76,6 +76,8 @@ needDocDeps = do , ghci , libiserv , compiler + , ghcHeap + , templateHaskell ] need templatedCabalFiles @@ -100,8 +102,6 @@ documentationRules = do "docs" ~> do root <- buildRoot - needDocDeps - doctargets <- ghcDocs =<< flavour let html = htmlRoot -/- "index.html" -- also implies "docs-haddock" archives = map pathArchive docPaths @@ -201,6 +201,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] @@ -312,6 +315,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 c576019ebb..b04bfb15da 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 @@ -302,6 +304,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 @@ -327,6 +336,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 -- cgit v1.2.1