homebrew-core/Formula/swig.rb

49 lines
1.5 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-3.0.11/swig-3.0.11.tar.gz"
sha256 "d9031d531d7418829a54d0d51c4ed9007016b213657ec70be44031951810566e"
bottle do
sha256 "2e2906a9606fa06638ab536daf72de73cca26fd3632dc440867f19581edc2e85" => :sierra
sha256 "629ab98025d468cdb5cf344d11c1589053b892398249206dc935f6e282d31625" => :el_capitan
sha256 "cf75192b973e09e4495e7bc64a8093309fcb394a7638c4da6106ce4812b091f9" => :yosemite
end
option :universal
depends_on "pcre"
def install
ENV.universal_binary if build.universal?
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
(testpath/"test.c").write <<-EOS.undent
int add(int x, int y)
{
return x + y;
}
EOS
(testpath/"test.i").write <<-EOS.undent
%module test
%inline %{
extern int add(int x, int y);
%}
EOS
(testpath/"run.rb").write <<-EOS.undent
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/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("ruby run.rb").strip
end
end