Skip to content

Commit

Permalink
Merge pull request #204243 from Homebrew/bnfc-ghc912
Browse files Browse the repository at this point in the history
bnfc: workaround to build with GHC 9.12
  • Loading branch information
BrewTestBot authored Jan 14, 2025
2 parents 5182bf4 + 4913a18 commit 6f725a4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions Formula/b/bnfc.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Bnfc < Formula
desc "BNF Converter"
homepage "https://bnfc.digitalgrammars.com/"
# TODO: Check if `aeson` allow-newer workaround can be removed
url "https://github.com/BNFC/bnfc/archive/refs/tags/v2.9.5.tar.gz"
sha256 "32a6293b95e10cf1192f348ec79f3c125b52a56350caa4f67087feb3642eef77"
license "BSD-3-Clause"
Expand Down Expand Up @@ -29,12 +30,16 @@ class Bnfc < Formula
depends_on "openjdk" => :test

def install
cd "source" do
system "cabal", "v2-update"
system "cabal", "v2-install", *std_cabal_v2_args
doc.install "CHANGELOG.md"
doc.install "src/BNFC.cf" => "BNFC.cf"
end
# Workaround to build with GHC 9.12, remove after https://github.com/haskell/aeson/pull/1126
# is merged and available on Hackage or if `aeson` is willing to provide a metadata revision
args = ["--allow-newer=aeson:ghc-prim,aeson:template-haskell"]

system "cabal", "v2-update"
system "cabal", "v2-install", buildpath/"source", *args, *std_cabal_v2_args

doc.install "source/CHANGELOG.md"
doc.install "source/src/BNFC.cf" => "BNFC.cf"

cd "docs" do
system "make", "text", "man", "SPHINXBUILD=#{Formula["sphinx-doc"].bin/"sphinx-build"}"
cd "_build" do
Expand Down Expand Up @@ -109,7 +114,7 @@ def install
14 * (3 + 2 / 5 - 8)
EOS

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

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

mktemp "agda-test" do
mkdir "agda-test" do
system bin/"bnfc", "-m", "-o.", "--haskell", "--text-token",
"--generic", "--functor", "--agda", "-d", testpath/"calc.cf"
system "make"
Expand All @@ -138,10 +143,10 @@ def install
end

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

0 comments on commit 6f725a4

Please sign in to comment.