Skip to content

Commit

Permalink
brpc: add 1.3.0 bottle.
Browse files Browse the repository at this point in the history
  • Loading branch information
gromgit committed Jan 27, 2023
1 parent 8f7c5be commit 1277933
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Formula/brpc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class Brpc < Formula
desc "Better RPC framework"
homepage "https://brpc.apache.org/"
url "https://dlcdn.apache.org/brpc/1.3.0/apache-brpc-1.3.0-incubating-src.tar.gz"
sha256 "582287922f5c8fe7649f820a39f64e1c61c3fdda827c7b393ad3ec2df5b4f9d7"
license "Apache-2.0"
head "https://github.com/apache/incubator-brpc.git", branch: "master"

bottle do
root_url "https://github.com/gromgit/homebrew-core-mojave/releases/download/brpc"
sha256 cellar: :any, mojave: "0ae55b16d8f0454be8a0ade0c4a8faedb1e3ce9876fb3913d50b37e0bd4b8a29"
end

depends_on "cmake" => :build
depends_on "gflags"
depends_on "leveldb"
depends_on "openssl@3"
depends_on "protobuf"

def install
args = %w[
-DBUILD_SHARED_LIBS=ON
-DBUILD_UNIT_TESTS=OFF
-DDOWNLOAD_GTEST=OFF
-DWITH_DEBUG_SYMBOLS=OFF
]
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <brpc/channel.h>
#include <brpc/controller.h>
#include <butil/logging.h>
int main() {
brpc::Channel channel;
brpc::ChannelOptions options;
options.protocol = "http";
options.timeout_ms = 1000;
if (channel.Init("https://brew.sh/", &options) != 0) {
LOG(ERROR) << "Failed to initialize channel";
return 1;
}
brpc::Controller cntl;
cntl.http_request().uri() = "https://brew.sh/";
channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
if (cntl.Failed()) {
LOG(ERROR) << cntl.ErrorText();
return 1;
}
std::cout << cntl.http_response().status_code();
return 0;
}
EOS
flags = %W[
-I#{include}
-L#{lib}
-L#{Formula["protobuf"].opt_lib}
-lbrpc
-lprotobuf
]
system ENV.cxx, "-std=c++11", testpath/"test.cpp", "-o", "test", *flags
assert_equal "200", shell_output("./test")
end
end

0 comments on commit 1277933

Please sign in to comment.