homebrew-core/Formula/mlkit.rb

57 lines
2.1 KiB
Ruby

class Mlkit < Formula
desc "Compiler for the Standard ML programming language"
homepage "https://melsman.github.io/mlkit"
url "https://github.com/melsman/mlkit/archive/v4.6.1.tar.gz"
sha256 "63fda6db4997bc2c422217c4868ae09967bf8bdc7ae552908ad5daa9b43a7a35"
license "GPL-2.0-or-later"
head "https://github.com/melsman/mlkit.git", branch: "master"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 monterey: "36067c952b766856650dde4ec7063715116b3b35187bccf3d993159dcb1acff4"
sha256 big_sur: "d10a1831efd17c9a803d2d7d89bac114e8ef4c1941e370aba738a3fb7d961b8e"
sha256 catalina: "c97338472a17c0a140b823973c74d68879374e5a967c0e2e586c63ad135411ee"
sha256 x86_64_linux: "58f15971bbf285b7c71aec2b302ec80ed912957bb1d8749cc137ec9e633ffe76"
end
depends_on "autoconf" => :build
depends_on "mlton" => :build
depends_on "gmp"
def install
system "sh", "./autobuild"
system "./configure", "--prefix=#{prefix}"
# The ENV.permit_arch_flags specification is needed on 64-bit
# machines because the mlkit compiler generates 32-bit machine
# code whereas the mlton compiler generates 64-bit machine
# code. Because of this difference, the ENV.m64 and ENV.m32 flags
# are not sufficient for the formula as clang is used by both
# tools in a single makefile target. For the mlton-compilation of
# sml-code, no arch flags are used for the clang assembler
# invocation. Thus, on a 32-bit machine, both the mlton-compiled
# binary (the mlkit compiler) and the 32-bit native code generated
# by the mlkit compiler will be running 32-bit code.
ENV.permit_arch_flags
system "make", "mlkit"
system "make", "mlkit_libs"
system "make", "install"
end
test do
(testpath/"test.sml").write <<~EOS
fun f(x) = x + 2
val a = [1,2,3,10]
val b = List.foldl (op +) 0 (List.map f a)
val res = if b = 24 then "OK" else "ERR"
val () = print ("Result: " ^ res ^ "\\n")
EOS
system "#{bin}/mlkit", "-o", "test", "test.sml"
assert_equal "Result: OK\n", shell_output("./test")
end
end