From cc119f82b279f66597407d32cc94f3589258c8b0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 10 Mar 2017 18:51:02 +0000 Subject: [PATCH] swig@2: import from homebrew/versions. --- Formula/swig@2.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Formula/swig@2.rb diff --git a/Formula/swig@2.rb b/Formula/swig@2.rb new file mode 100644 index 0000000000..297422048a --- /dev/null +++ b/Formula/swig@2.rb @@ -0,0 +1,41 @@ +class SwigAT2 < Formula + desc "Generate scripting interfaces to C/C++ code" + homepage "http://www.swig.org/" + url "https://downloads.sourceforge.net/project/swig/swig/swig-2.0.12/swig-2.0.12.tar.gz" + sha256 "65e13f22a60cecd7279c59882ff8ebe1ffe34078e85c602821a541817a4317f7" + + keg_only :versioned_formula + + depends_on "pcre" + + def install + system "./configure", "--disable-debug", "--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", "-flat_namespace", "-undefined", "suppress", "test.o", "test_wrap.o", "-o", "test.bundle" + assert_equal "2", shell_output("ruby run.rb").strip + end +end