47 lines
1.5 KiB
Ruby
47 lines
1.5 KiB
Ruby
class SwigAT3 < Formula
|
|
desc "Generate scripting interfaces to C/C++ code"
|
|
homepage "http://www.swig.org/"
|
|
url "https://downloads.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz"
|
|
sha256 "7cf9f447ae7ed1c51722efc45e7f14418d15d7a1e143ac9f09a668999f4fc94d"
|
|
|
|
bottle do
|
|
sha256 "28e5c0a5e8aac0c0d5f58e4dd69c590f57d3a450d92aa35b18aee037ab7d8b60" => :mojave
|
|
sha256 "730bd728981cc1534664ef35d08d0b285e79756c286913d868af6afa43f60f4d" => :high_sierra
|
|
sha256 "23275971784bb9272a734f44c9689dafecd5e6c4be917cd3d621064858cd76db" => :sierra
|
|
end
|
|
|
|
keg_only :versioned_formula
|
|
|
|
depends_on "pcre"
|
|
|
|
def install
|
|
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
|