Skip to content

Commit

Permalink
swig@3 3.0.12 (new formula)
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-cheng committed May 16, 2019
1 parent 4f140c1 commit 620f401
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Formula/swig@3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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"

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

0 comments on commit 620f401

Please sign in to comment.