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

52 lines
2.0 KiB
Ruby

class MongoCxxDriver < Formula
desc "C++ driver for MongoDB"
homepage "https://github.com/mongodb/mongo-cxx-driver"
url "https://github.com/mongodb/mongo-cxx-driver/archive/r3.6.2.tar.gz"
sha256 "f50a1acb98a473f0850e2766dc7e84c05415dc63b1a2f851b77b12629ac14d62"
license "Apache-2.0"
head "https://github.com/mongodb/mongo-cxx-driver.git"
bottle do
sha256 cellar: :any, big_sur: "e68f3e5c87021c8537656445b3641966eb1b03b36870d7d63795f75692b443a9"
sha256 cellar: :any, catalina: "c914c8eb18e5b84f6e1051abfd565db1824523b487463ed4c3b670014009a323"
sha256 cellar: :any, mojave: "d257deef2474d068c1b7757aa9b2e7c1bb6259e15292c8b48e96487118a1c86a"
end
depends_on "cmake" => :build
depends_on "mongo-c-driver"
def install
# We want to avoid shims referencing in examples,
# but we need to have examples/CMakeLists.txt file to make cmake happy
pkgshare.install "examples"
(buildpath / "examples/CMakeLists.txt").write ""
mongo_c_prefix = Formula["mongo-c-driver"].opt_prefix
system "cmake", ".", *std_cmake_args,
"-DBUILD_VERSION=#{version}",
"-DLIBBSON_DIR=#{mongo_c_prefix}",
"-DLIBMONGOC_DIR=#{mongo_c_prefix}"
system "make"
system "make", "install"
end
test do
mongo_c_include = Formula["mongo-c-driver"]
system ENV.cc, "-o", "test", pkgshare/"examples/bsoncxx/builder_basic.cpp",
"-I#{include}/bsoncxx/v_noabi",
"-I#{mongo_c_include}/libbson-1.0",
"-L#{lib}", "-lbsoncxx", "-std=c++11", "-lstdc++"
system "./test"
system ENV.cc, "-o", "test", pkgshare/"examples/mongocxx/connect.cpp",
"-I#{include}/mongocxx/v_noabi",
"-I#{include}/bsoncxx/v_noabi",
"-I#{mongo_c_include}/libmongoc-1.0",
"-I#{mongo_c_include}/libbson-1.0",
"-L#{lib}", "-lmongocxx", "-lbsoncxx", "-std=c++11", "-lstdc++"
assert_match "No suitable servers",
shell_output("./test mongodb://0.0.0.0 2>&1", 1)
end
end