Skip to content

Commit

Permalink
fix happy bounds (digital-asset#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
shayne-fletcher authored Oct 28, 2024
1 parent e470e18 commit 2ca3e31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ghc-lib-gen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ executable ghc-lib-gen

executable ghc-lib-build-tool
import: base
build-tool-depends: alex:alex, happy:happy < 2.0
if impl (ghc > 9.12.0)
build-tool-depends: alex:alex, happy:happy == 1.20.* || >= 2.0.2 && < 2.1
else
build-tool-depends: alex:alex, happy:happy < 2.0
build-depends:
directory, filepath, time, extra, optparse-applicative
if flag(semaphore-compat)
Expand Down
11 changes: 9 additions & 2 deletions ghc-lib-gen/src/Ghclibgen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,13 @@ libBinParserLibModules ghcFlavor = do
filterGhcInternalModules mods =
[f | f <- mods, not ("GHC.Internal" `isPrefixOf` f) || (f `elem` keptGhcInternalModules)]

happyBounds :: GhcFlavor -> String
happyBounds ghcFlavor
| series < GHC_9_8 = "== 1.20.*"
| otherwise = "== 1.20.* || >= 2.0.2 && < 2.1" -- c.f. m4/fptools_happy.m4
where
series = ghcSeries ghcFlavor

-- Produces a ghc-lib Cabal file.
generateGhcLibCabal :: GhcFlavor -> [String] -> IO ()
generateGhcLibCabal ghcFlavor customCppOpts = do
Expand Down Expand Up @@ -1369,7 +1376,7 @@ generateGhcLibCabal ghcFlavor customCppOpts = do
" build-depends:"
],
indent2 (Data.List.NonEmpty.toList (withCommas (ghcLibBuildDepends ghcFlavor))),
[" build-tool-depends: alex:alex >= 3.1, " ++ "happy:happy > " ++ if ghcSeries ghcFlavor < GHC_8_10 then "1.19" else "1.20" ++ " && < 2.0"],
[" build-tool-depends: alex:alex >= 3.1, " ++ "happy:happy " ++ happyBounds ghcFlavor],
[" other-extensions:"],
indent2 (askField lib "other-extensions:"),
[" default-extensions:"],
Expand Down Expand Up @@ -1480,7 +1487,7 @@ generateGhcLibParserCabal ghcFlavor customCppOpts = do
[ " if impl(ghc >= 9.10)",
" build-depends: ghc-internal"
],
[" build-tool-depends: alex:alex >= 3.1, " ++ "happy:happy > " ++ if ghcSeries ghcFlavor < GHC_8_10 then "1.19" else "1.20" ++ " && < 2.0"],
[" build-tool-depends: alex:alex >= 3.1, " ++ "happy:happy " ++ happyBounds ghcFlavor],
[" other-extensions:"],
indent2 (askField lib "other-extensions:"),
[" default-extensions:"],
Expand Down

0 comments on commit 2ca3e31

Please sign in to comment.