55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
class Swig < Formula
|
|
desc "Generate scripting interfaces to C/C++ code"
|
|
homepage "http://www.swig.org/"
|
|
url "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz"
|
|
sha256 "7a00b4d0d53ad97a14316135e2d702091cd5f193bb58bcfcd8bc59d41e7887a9"
|
|
|
|
bottle do
|
|
sha256 "d44eb5e2ae81970d131618c4ddd508d3d798e9465979a125454db75c3b9125e1" => :catalina
|
|
sha256 "3bc985b393a1f9979185a2b18341c6d1114532baf5447000d94247a01c224ed6" => :mojave
|
|
sha256 "f1df176e92ad7c3a7da641eb67dda3b4e65ed9ec8de76e3b51e366e40cc9662b" => :high_sierra
|
|
sha256 "26a33bc67766b89d55731ab3102b3c5808192b0d66f2d805d209cc933789d238" => :sierra
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/swig/swig.git"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
end
|
|
|
|
depends_on "pcre"
|
|
|
|
def install
|
|
system "./autogen.sh" if build.head?
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--prefix=#{prefix}"
|
|
system "make"
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
int add(int x, int y)
|
|
{
|
|
return x + y;
|
|
}
|
|
EOS
|
|
(testpath/"test.i").write <<~EOS
|
|
%module test
|
|
%inline %{
|
|
extern int add(int x, int y);
|
|
%}
|
|
EOS
|
|
(testpath/"run.rb").write <<~EOS
|
|
require "./test"
|
|
puts Test.add(1, 1)
|
|
EOS
|
|
system "#{bin}/swig", "-ruby", "test.i"
|
|
system ENV.cc, "-c", "test.c"
|
|
system ENV.cc, "-c", "test_wrap.c", "-I#{MacOS.sdk_path}/System/Library/Frameworks/Ruby.framework/Headers/"
|
|
system ENV.cc, "-bundle", "-undefined", "dynamic_lookup", "test.o", "test_wrap.o", "-o", "test.bundle"
|
|
assert_equal "2", shell_output("/usr/bin/ruby run.rb").strip
|
|
end
|
|
end
|