homebrew-core/Formula/mongo-c-driver.rb

45 lines
1.7 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.17.0/mongo-c-driver-1.17.0.tar.gz"
sha256 "90aa23a3f92be0a076fe0b903b68276a7973d4e472929943069f503d5ab50cb9"
license "Apache-2.0"
head "https://github.com/mongodb/mongo-c-driver.git"
bottle do
cellar :any
sha256 "40c31d0c81eb61f7313621d9506b615b4bdfe6ab4e483f366eab071b9dbe33de" => :catalina
sha256 "acea2c45a81abdd38c1e2773962e2ab98a5e6ddcf8e0ca1acd734d4ae9e46245" => :mojave
sha256 "8fe0c67b8679c125a8c247c7490a41e2a2f9be07e1438c5512a7ebab2b7a7d68" => :high_sierra
end
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "sphinx-doc" => :build
depends_on "openssl@1.1"
uses_from_macos "zlib"
def install
cmake_args = std_cmake_args
cmake_args << "-DBUILD_VERSION=1.18.0-pre" if build.head?
inreplace "src/libmongoc/src/mongoc/mongoc-config.h.in", "@MONGOC_CC@", ENV.cc
system "cmake", ".", *cmake_args
system "make", "install"
(pkgshare/"libbson").install "src/libbson/examples"
(pkgshare/"libmongoc").install "src/libmongoc/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/"libmongoc/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