Skip to content

Commit 6f725a4

Browse files
authored
Merge pull request #204243 from Homebrew/bnfc-ghc912
bnfc: workaround to build with GHC 9.12
2 parents 5182bf4 + 4913a18 commit 6f725a4

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

Formula/b/bnfc.rb

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class Bnfc < Formula
22
desc "BNF Converter"
33
homepage "https://bnfc.digitalgrammars.com/"
4+
# TODO: Check if `aeson` allow-newer workaround can be removed
45
url "https://github.com/BNFC/bnfc/archive/refs/tags/v2.9.5.tar.gz"
56
sha256 "32a6293b95e10cf1192f348ec79f3c125b52a56350caa4f67087feb3642eef77"
67
license "BSD-3-Clause"
@@ -29,12 +30,16 @@ class Bnfc < Formula
2930
depends_on "openjdk" => :test
3031

3132
def install
32-
cd "source" do
33-
system "cabal", "v2-update"
34-
system "cabal", "v2-install", *std_cabal_v2_args
35-
doc.install "CHANGELOG.md"
36-
doc.install "src/BNFC.cf" => "BNFC.cf"
37-
end
33+
# Workaround to build with GHC 9.12, remove after https://github.com/haskell/aeson/pull/1126
34+
# is merged and available on Hackage or if `aeson` is willing to provide a metadata revision
35+
args = ["--allow-newer=aeson:ghc-prim,aeson:template-haskell"]
36+
37+
system "cabal", "v2-update"
38+
system "cabal", "v2-install", buildpath/"source", *args, *std_cabal_v2_args
39+
40+
doc.install "source/CHANGELOG.md"
41+
doc.install "source/src/BNFC.cf" => "BNFC.cf"
42+
3843
cd "docs" do
3944
system "make", "text", "man", "SPHINXBUILD=#{Formula["sphinx-doc"].bin/"sphinx-build"}"
4045
cd "_build" do
@@ -109,7 +114,7 @@ def install
109114
14 * (3 + 2 / 5 - 8)
110115
EOS
111116

112-
mktemp "c-test" do
117+
mkdir "c-test" do
113118
system bin/"bnfc", "-m", "-o.", "--c", testpath/"calc.cf"
114119
system "make", "CC=#{ENV.cc}", "CCFLAGS=#{ENV.cflags}",
115120
"FLEX=#{Formula["flex"].bin/"flex"}",
@@ -118,7 +123,7 @@ def install
118123
assert_equal check_out_c, test_out
119124
end
120125

121-
mktemp "cxx-test" do
126+
mkdir "cxx-test" do
122127
system bin/"bnfc", "-m", "-o.", "--cpp", testpath/"calc.cf"
123128
system "make", "CC=#{ENV.cxx}", "CCFLAGS=#{ENV.cxxflags}",
124129
"FLEX=#{Formula["flex"].bin/"flex"}",
@@ -127,7 +132,7 @@ def install
127132
assert_equal check_out_c, test_out
128133
end
129134

130-
mktemp "agda-test" do
135+
mkdir "agda-test" do
131136
system bin/"bnfc", "-m", "-o.", "--haskell", "--text-token",
132137
"--generic", "--functor", "--agda", "-d", testpath/"calc.cf"
133138
system "make"
@@ -138,10 +143,10 @@ def install
138143
end
139144

140145
ENV.deparallelize do # only the Java test needs this
141-
mktemp "java-test" do
146+
mkdir "java-test" do
142147
jdk_dir = Formula["openjdk"].bin
143148
antlr_bin = Formula["antlr"].bin/"antlr"
144-
antlr_jar = Dir[Formula["antlr"].prefix/"antlr-*-complete.jar"][0]
149+
antlr_jar = Formula["antlr"].prefix.glob("antlr-*-complete.jar").first
145150
ENV["CLASSPATH"] = ".:#{antlr_jar}"
146151
system bin/"bnfc", "-m", "-o.", "--java", "--antlr4", testpath/"calc.cf"
147152
system "make", "JAVAC=#{jdk_dir/"javac"}", "JAVA=#{jdk_dir/"java"}",

0 commit comments

Comments
 (0)