104 lines
3.9 KiB
Ruby
104 lines
3.9 KiB
Ruby
class EtcdCppApiv3 < Formula
|
|
desc "C++ implementation for etcd's v3 client API, i.e., ETCDCTL_API=3"
|
|
homepage "https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3"
|
|
url "https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3/archive/refs/tags/v0.2.8.tar.gz"
|
|
sha256 "8fa03d54debb79e242c617fc2871dde9f841359e34f7d87d59abecc72cfe5e2f"
|
|
license "BSD-3-Clause"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "8ff53f0f293d99c8fd178e96fa0dfd7b75cd59e917e174839b351136c16d3956"
|
|
sha256 cellar: :any, arm64_big_sur: "487f06118ca02c2d590e22d5cdf8c8b11d471717b0df527907674834d7e9b3be"
|
|
sha256 cellar: :any, monterey: "3811244523002f5c875ae187a39537b74a6fbafbc1f749ccf8b1f431bc93ec56"
|
|
sha256 cellar: :any, big_sur: "9fe5ae7827a59e0f39dfb2f2f2d30cfdf4fe07dafb4e6dffdc79a1bcf1a7286a"
|
|
sha256 cellar: :any, catalina: "42d20193de797f8f9d57e911a6698ff5f81f74646efd93bcc50d9fdb89e88c36"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "fb5e526422cf4aa26568a9b0d44615a9bce0a1f0fdac0b2dabb5dbe1e22fbe81"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "etcd" => :test
|
|
|
|
depends_on "boost"
|
|
depends_on "cpprestsdk"
|
|
depends_on "grpc"
|
|
depends_on "openssl@1.1"
|
|
depends_on "protobuf"
|
|
|
|
fails_with gcc: "5"
|
|
|
|
def install
|
|
system "cmake", "-S", ".", "-B", "build",
|
|
"-DCMAKE_CXX_STANDARD=17",
|
|
"-DCMAKE_CXX_STANDARD_REQUIRED=TRUE",
|
|
"-DBUILD_ETCD_TESTS=OFF",
|
|
"-DOPENSSL_ROOT_DIR=#{Formula["openssl@1.1"].opt_prefix}",
|
|
*std_cmake_args
|
|
system "cmake", "--build", "build"
|
|
system "cmake", "--install", "build"
|
|
end
|
|
|
|
test do
|
|
port = free_port
|
|
|
|
(testpath/"test.cc").write <<~EOS
|
|
#include <iostream>
|
|
#include <etcd/Client.hpp>
|
|
|
|
int main() {
|
|
etcd::Client etcd("http://127.0.0.1:#{port}");
|
|
etcd.set("foo", "bar").wait();
|
|
auto response = etcd.get("foo").get();
|
|
std::cout << response.value().as_string() << std::endl;
|
|
}
|
|
EOS
|
|
|
|
system ENV.cxx, "test.cc", "-std=c++17",
|
|
"-I#{Formula["boost"].include}",
|
|
"-I#{Formula["cpprestsdk"].include}",
|
|
"-I#{Formula["grpc"].include}",
|
|
"-I#{Formula["openssl@1.1"].include}",
|
|
"-I#{Formula["protobuf"].include}",
|
|
"-I#{include}",
|
|
"-L#{Formula["boost"].lib}",
|
|
"-L#{Formula["cpprestsdk"].lib}",
|
|
"-L#{Formula["grpc"].lib}",
|
|
"-L#{Formula["openssl@1.1"].lib}",
|
|
"-L#{Formula["protobuf"].lib}",
|
|
"-L#{lib}",
|
|
"-lboost_random-mt",
|
|
"-lboost_chrono-mt",
|
|
"-lboost_thread-mt",
|
|
"-lboost_system-mt",
|
|
"-lboost_filesystem-mt",
|
|
"-lcpprest",
|
|
"-letcd-cpp-api",
|
|
"-lgpr", "-lgrpc", "-lgrpc++",
|
|
"-lssl", "-lcrypto",
|
|
"-lprotobuf",
|
|
"-o", "test_etcd_cpp_apiv3"
|
|
|
|
# prepare etcd
|
|
etcd_pid = fork do
|
|
if OS.mac? && Hardware::CPU.arm?
|
|
# etcd isn't officially supported on arm64
|
|
# https://github.com/etcd-io/etcd/issues/10318
|
|
# https://github.com/etcd-io/etcd/issues/10677
|
|
ENV["ETCD_UNSUPPORTED_ARCH"]="arm64"
|
|
end
|
|
|
|
exec "#{Formula["etcd"].opt_prefix}/bin/etcd",
|
|
"--force-new-cluster",
|
|
"--data-dir=#{testpath}",
|
|
"--listen-client-urls=http://127.0.0.1:#{port}",
|
|
"--advertise-client-urls=http://127.0.0.1:#{port}"
|
|
end
|
|
|
|
# sleep to let etcd get its wits about it
|
|
sleep 10
|
|
|
|
assert_equal("bar\n", shell_output("./test_etcd_cpp_apiv3"))
|
|
ensure
|
|
# clean up the etcd process before we leave
|
|
Process.kill("HUP", etcd_pid)
|
|
end
|
|
end
|