homebrew-core/Formula/mongo-c-driver.rb
2016-12-18 05:03:22 -08:00

53 lines
1.8 KiB
Ruby

class MongoCDriver < Formula
desc "C driver for MongoDB"
homepage "https://github.com/mongodb/mongo-c-driver"
url "https://github.com/mongodb/mongo-c-driver/releases/download/1.5.1/mongo-c-driver-1.5.1.tar.gz"
sha256 "4c6052f4103bb98c2d6f3689975cff97a8b3aa192a9f5885348a1434e2cd56cc"
bottle do
cellar :any
sha256 "5665b650382826d69f5f76e9a692f94178f0084d5744afa1c5d7b9119d18df0a" => :sierra
sha256 "066bb31af9cf84be1b4ed42ed35094b38d3e4220b36bae7b77a5fe7126f68cca" => :el_capitan
sha256 "d1ee7e526dbf5151c8806608c320cb6fb5b74b72a8d730408b2a09ee07e1ba9b" => :yosemite
end
head do
url "https://github.com/mongodb/mongo-c-driver.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "pkg-config" => :build
def install
system "./autogen.sh" if build.head?
args = %W[
--disable-debug
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--enable-man-pages
--with-libbson=bundled
--enable-ssl=darwin
]
system "./configure", *args
system "make", "install"
(pkgshare/"libbson").install "src/libbson/examples"
(pkgshare/"mongoc").install "examples"
end
test do
system ENV.cc, "-o", "test", pkgshare/"libbson/examples/json-to-bson.c",
"-I#{include}/libbson-1.0", "-L#{lib}", "-lbson-1.0"
(testpath/"test.json").write('{"name": "test"}')
assert_match "\u0000test\u0000", shell_output("./test test.json")
system ENV.cc, "-o", "test", pkgshare/"mongoc/examples/mongoc-ping.c",
"-I#{include}/libmongoc-1.0", "-I#{include}/libbson-1.0",
"-L#{lib}", "-lmongoc-1.0", "-lbson-1.0"
assert_match "No suitable servers", shell_output("./test mongodb://0.0.0.0 2>&1", 3)
end
end