homebrew-core/Formula/mongo-c-driver.rb
2017-01-11 10:46:49 +01: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.2/mongo-c-driver-1.5.2.tar.gz"
sha256 "33e1e39c0eca8e43f6ea366cfad76fa22cbbb09cfba7ff15474299906bb30721"
bottle do
cellar :any
sha256 "533190e8e3b1dcda658640490e79fed85ca73cabd16f930cb0e2cb6c970d5f4b" => :sierra
sha256 "5b46c75de954ecbefb9a5f7f0d80d448ca5cbb390b1d5c3317c5b72b37763c02" => :el_capitan
sha256 "3f7ffcdcdfa1f35e626a89484166138b83a76ac66a631ef5dcb66d16d985e4ab" => :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