homebrew-core/Formula/mlkit.rb
2019-07-04 15:14:24 +08:00

49 lines
1.9 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/mlkit-4.4.3.tar.gz"
sha256 "51ee5ced1dc639f2c58556dca0dec5c3243dba4705e1cdb91247fa9644b16625"
head "https://github.com/melsman/mlkit.git"
bottle do
sha256 "52ac5d00915774111535053f287c05a63976c83ed7a5a900bbc263f030ea6900" => :mojave
sha256 "79694e15c915cb2c08b680b2b4404cfbbb6fff56e8f6b5f0196fcc485466d41b" => :high_sierra
sha256 "5df6b95fad69e10b31352824433251d3306a42c55c5e7164b0c47b986ea1009d" => :sierra
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