113 lines
4.1 KiB
Ruby
113 lines
4.1 KiB
Ruby
class Grpc < Formula
|
|
desc "Next generation open source RPC library and framework"
|
|
homepage "https://grpc.io/"
|
|
url "https://github.com/grpc/grpc.git",
|
|
tag: "v1.51.0",
|
|
revision: "fb01bb12456d015d9e4b7b8ebf2e8a7c803e96ad"
|
|
license "Apache-2.0"
|
|
head "https://github.com/grpc/grpc.git", branch: "master"
|
|
|
|
# The "latest" release on GitHub is sometimes for an older major/minor and
|
|
# there's sometimes a notable gap between when a version is tagged and
|
|
# released, so we have to check the releases page instead.
|
|
livecheck do
|
|
url "https://github.com/grpc/grpc/releases?q=prerelease%3Afalse"
|
|
regex(%r{href=["']?[^"' >]*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
|
|
strategy :page_match
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_ventura: "f632af0914f949581059445beb0d2430ee093662dd05dbde53494166bf1a1afc"
|
|
sha256 cellar: :any, arm64_monterey: "1f26d696698d0939d188a08f76fc9b83d79948eac72e8da6bc3fc36b116cebd7"
|
|
sha256 cellar: :any, arm64_big_sur: "f6778ba11f3b03e7d4b54dcd8abae47b11384cc12c8c1303bf4f0ee2ae91d1c5"
|
|
sha256 cellar: :any, ventura: "1ddd4f6efe19cc1db320a8cd99a2785d0215ba27d7f6ae9eb9237c404aa5c775"
|
|
sha256 cellar: :any, monterey: "5cbac169214bf9807b00e76c8946550686d8e82406d909b07a1afecf0b5bb7b9"
|
|
sha256 cellar: :any, big_sur: "4946d777e2de9d4cfee797044aa3d7dc5010f43e4fe77095facb0c3f26f6828a"
|
|
sha256 cellar: :any, catalina: "d691e25ef68675dcc3a2188a1eb100dd75c97662e7d79ed179ee6137c8ec2ffc"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "5e6199445a6b3a3c9c5c8562cd1c267ddacca775a004b53762fb9d8b3c3d40d6"
|
|
end
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "cmake" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "pkg-config" => :test
|
|
depends_on "abseil"
|
|
depends_on "c-ares"
|
|
depends_on "openssl@1.1"
|
|
depends_on "protobuf"
|
|
depends_on "re2"
|
|
|
|
uses_from_macos "zlib"
|
|
|
|
on_macos do
|
|
depends_on "llvm" => :build if DevelopmentTools.clang_build_version <= 1100
|
|
end
|
|
|
|
fails_with :clang do
|
|
build 1100
|
|
cause "Requires C++17 features not yet implemented"
|
|
end
|
|
|
|
fails_with gcc: "5" # C++17
|
|
|
|
def install
|
|
ENV.llvm_clang if OS.mac? && (DevelopmentTools.clang_build_version <= 1100)
|
|
mkdir "cmake/build" do
|
|
args = %W[
|
|
../..
|
|
-DCMAKE_CXX_STANDARD=17
|
|
-DCMAKE_CXX_STANDARD_REQUIRED=TRUE
|
|
-DCMAKE_INSTALL_RPATH=#{rpath}
|
|
-DBUILD_SHARED_LIBS=ON
|
|
-DgRPC_BUILD_TESTS=OFF
|
|
-DgRPC_INSTALL=ON
|
|
-DgRPC_ABSL_PROVIDER=package
|
|
-DgRPC_CARES_PROVIDER=package
|
|
-DgRPC_PROTOBUF_PROVIDER=package
|
|
-DgRPC_SSL_PROVIDER=package
|
|
-DgRPC_ZLIB_PROVIDER=package
|
|
-DgRPC_RE2_PROVIDER=package
|
|
] + std_cmake_args
|
|
|
|
system "cmake", *args
|
|
system "make", "install"
|
|
|
|
args = %W[
|
|
../..
|
|
-DCMAKE_INSTALL_RPATH=#{rpath}
|
|
-DBUILD_SHARED_LIBS=ON
|
|
-DgRPC_BUILD_TESTS=ON
|
|
] + std_cmake_args
|
|
system "cmake", *args
|
|
system "make", "grpc_cli"
|
|
bin.install "grpc_cli"
|
|
lib.install Dir[shared_library("libgrpc++_test_config", "*")]
|
|
|
|
if OS.mac?
|
|
# These are installed manually, so need to be relocated manually as well
|
|
MachO::Tools.add_rpath(bin/"grpc_cli", rpath)
|
|
MachO::Tools.add_rpath(lib/shared_library("libgrpc++_test_config"), rpath)
|
|
end
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <grpc/grpc.h>
|
|
int main() {
|
|
grpc_init();
|
|
grpc_shutdown();
|
|
return GRPC_STATUS_OK;
|
|
}
|
|
EOS
|
|
ENV.prepend_path "PKG_CONFIG_PATH", Formula["openssl@1.1"].opt_lib/"pkgconfig"
|
|
pkg_config_flags = shell_output("pkg-config --cflags --libs libcares protobuf re2 grpc++").chomp.split
|
|
system ENV.cc, "test.cpp", "-L#{Formula["abseil"].opt_lib}", *pkg_config_flags, "-o", "test"
|
|
system "./test"
|
|
|
|
output = shell_output("grpc_cli ls localhost:#{free_port} 2>&1", 1)
|
|
assert_match "Received an error when querying services endpoint.", output
|
|
end
|
|
end
|