Skip to content

Commit

Permalink
protoc-gen-grpc-java 1.68.2 (new formula)
Browse files Browse the repository at this point in the history
  • Loading branch information
cho-m committed Nov 30, 2024
1 parent d886aab commit caf3fb0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Formula/p/protoc-gen-grpc-java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class ProtocGenGrpcJava < Formula
desc "Protoc plugin for gRPC Java"
homepage "https://grpc.io/docs/languages/java/"
url "https://github.com/grpc/grpc-java/archive/refs/tags/v1.68.2.tar.gz"
sha256 "dc1ad2272c1442075c59116ec468a7227d0612350c44401237facd35aab15732"
license "Apache-2.0"

depends_on "openjdk@21" => :build # due to Gradle 8.5
depends_on "pkgconf" => :build
depends_on "abseil"
depends_on "protobuf"

def install
# Workaround for newer Protobuf
# Ref: https://github.com/grpc/grpc-java/issues/11475
ENV.append "CXXFLAGS", "-std=c++17"
ENV.append "CXXFLAGS", Utils.safe_popen_read("pkgconf", "--cflags", "protobuf").chomp
ENV.append "LDFLAGS", Utils.safe_popen_read("pkgconf", "--libs", "protobuf").chomp

inreplace "compiler/build.gradle" do |s|
# Avoid build errors on ARM macOS from old minimum macOS deployment
s.gsub! '"-mmacosx-version-min=10.7",', ""
# Avoid static linkage
s.gsub! '"-Wl,-Bstatic", "-lprotoc", "-lprotobuf", "-static-libgcc",' + "\n", ""
end

# Fails with brew `gradle` due to animalsniffer 1.7.1
# Ref: https://github.com/xvik/gradle-animalsniffer-plugin/issues/100
system "./gradlew", "--no-daemon", "--project-dir=compiler", "-PskipAndroid=true", "java_pluginExecutable"
bin.install "compiler/build/exe/java_plugin/protoc-gen-grpc-java"

pkgshare.install "examples/src/main/proto/helloworld.proto"
end

test do
system Formula["protobuf"].bin/"protoc", "--grpc-java_out=.", "--proto_path=#{pkgshare}", "helloworld.proto"
output_file = testpath/"io/grpc/examples/helloworld/GreeterGrpc.java"
assert_path_exists output_file
assert_match "public io.grpc.examples.helloworld.HelloReply sayHello(", output_file.read
end
end

0 comments on commit caf3fb0

Please sign in to comment.