-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
mlkit.rb
57 lines (51 loc) 路 2.18 KB
/
mlkit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class Mlkit < Formula
desc "Compiler for the Standard ML programming language"
homepage "https://melsman.github.io/mlkit"
url "https://github.com/melsman/mlkit/archive/refs/tags/v4.7.9.tar.gz"
sha256 "9886a7e18c474588a573e4786d0ed951bfd0c61d87690aee283c6bfcfac8db22"
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 sonoma: "acac8b822a94932815fac507151554a7d0c6be378b51a1d3911e837de142138a"
sha256 ventura: "a04578933968b94132e149505203cfba2f978e74d0b21f9bd011b0e9c8649d55"
sha256 monterey: "046c60a758960f9cd5d6864e4da3a76ec496e13da734577f6ac405185bdecc37"
sha256 x86_64_linux: "e09dcf348415255b807f09e617bd2ee7b21c8c3dfdeb7ada585b980060eeae74"
end
depends_on "autoconf" => :build
depends_on "mlton" => :build
depends_on arch: :x86_64 # https://github.com/melsman/mlkit/issues/115
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