-
Notifications
You must be signed in to change notification settings - Fork 0
/
cliffi.rb
26 lines (23 loc) · 823 Bytes
/
cliffi.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
class Cliffi < Formula
desc "Tool for calling shared library functions directly from your shell"
homepage "https://github.com/YSaxon/cliffi"
url "https://github.com/YSaxon/cliffi/archive/refs/tags/0.6.2-e7fad00.tar.gz"
sha256 "24518e4da132395891d96df39f18d7360c7ef06dd03e11a4d8d5025aff1132c4"
license "MIT"
depends_on "cmake" => [:build, :test]
uses_from_macos "libffi"
def install
system "cmake", "-S", ".", "-B", "build", *std_cmake_args
system "make", "-C", "build"
bin.install "build/cliffi"
end
test do
(testpath/"test.c").write <<~EOS
int add(int a, int b) {
return a + b;
}
EOS
system ENV.cc, "test.c", "-shared", "-o", "libtest.dylib"
assert_equal "Function returned: 5", shell_output("#{bin}/cliffi ./libtest.dylib i add 2 3").strip
end
end