-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protoc-gen-grpc-java 1.68.2 (new formula)
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |