56 lines
2.0 KiB
Ruby
56 lines
2.0 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.5.14.tar.gz"
|
|
sha256 "72e98ad09b6454abb739871443b01dbbf0225e85ec5fc6f2d988c81f2763e721"
|
|
license "GPL-2.0"
|
|
head "https://github.com/melsman/mlkit.git"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 monterey: "48eaafe4367a976dbda3624e2ef41fcc3c7684fa99eb63857b4bacdbd163db24"
|
|
sha256 big_sur: "b7f4d508ec1a015edbc44c559d6ad3105a9435c06845fe1aace0df238100ec60"
|
|
sha256 catalina: "b610ab16230e6d59b9ef761af1e6c5c1e1026d480f4239136c4111a437e62892"
|
|
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
|