-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05379d5
commit 24307ca
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Formula/swig.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |