48 lines
1.4 KiB
Ruby
48 lines
1.4 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.5/swig-3.0.5.tar.gz"
|
|
sha1 "271813b317e4836853d2249fc8ce2df34c2a062a"
|
|
|
|
bottle do
|
|
sha1 "2f6a236c9c1d2bb97107c5d7f49584b0ed0f3a3a" => :yosemite
|
|
sha1 "c13fa26b8eab283489571d2be8ed6e2974e3b359" => :mavericks
|
|
sha1 "de9eaea18c94fffba837d14b9254af46621b4960" => :mountain_lion
|
|
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", "-flat_namespace", "-undefined", "suppress", "test.o", "test_wrap.o", "-o", "test.bundle"
|
|
assert_equal "2", shell_output("ruby run.rb").strip
|
|
end
|
|
end
|