Skip to content

Commit

Permalink
Merge pull request #199494 from Homebrew/apache-pulsar-arm-macos
Browse files Browse the repository at this point in the history
protoc-gen-grpc-java 1.68.2 (new formula)
  • Loading branch information
BrewTestBot authored Dec 2, 2024
2 parents 4a0fdcd + 41a90a0 commit 95d1de0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Formula/a/apache-pulsar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ class ApachePulsar < Formula
head "https://github.com/apache/pulsar.git", branch: "master"

bottle do
sha256 cellar: :any_skip_relocation, sonoma: "3cbd5ddae480d01655634e38431c8e11aa3b7e244b494b8361aa192cfcbb8a07"
sha256 cellar: :any_skip_relocation, ventura: "3d2b2c2b5753c72152a76c6aab6ab28dc9947ef9038590ff72fe70e2f476e2e8"
sha256 cellar: :any_skip_relocation, x86_64_linux: "c0847ca767f80ff5405fa975a3cedec0001f4476ee6be3903f55537cd26d1d3f"
rebuild 1
sha256 cellar: :any_skip_relocation, arm64_sequoia: "24087d099b3a27f15fd36c09819324c0aea461f8b62974243ccff6c57efdf4b8"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "fae3916aeb26d157911c426c4788d146bd186478b7303f75f9b29201a98232f6"
sha256 cellar: :any_skip_relocation, arm64_ventura: "69543f45f1f046c14bf922faf625a714848b5f972b75dbef5648413a016b387b"
sha256 cellar: :any_skip_relocation, sonoma: "729047245e954df7b6d41eb30574c6402e9d74e336e228b2ebc641e3ab8cd379"
sha256 cellar: :any_skip_relocation, ventura: "7a6565081a8924b667354a9685f17a3833ba8cdf08f653355cff2b13d92ebbf7"
sha256 cellar: :any_skip_relocation, x86_64_linux: "3ee90bb08b934ee8397089852a2b9ea696590bcf2b2676f6fabfc0d0b66cf3d2"
end

depends_on "maven" => :build
depends_on arch: :x86_64 # https://github.com/grpc/grpc-java/issues/7690
depends_on "protoc-gen-grpc-java" => :build
depends_on "openjdk@21"

def install
# Avoid using pre-built `protoc-gen-grpc-java`
grpc_java_files = ["pulsar-client/pom.xml", "pulsar-functions/proto/pom.xml"]
plugin_artifact = "io.grpc:protoc-gen-grpc-java:${protoc-gen-grpc-java.version}:exe:${os.detected.classifier}"
inreplace grpc_java_files, %r{<pluginArtifact>#{Regexp.escape(plugin_artifact)}\s*</pluginArtifact>}, ""

java_home_env = Language::Java.java_home_env("21")
with_env(TMPDIR: buildpath, **java_home_env) do
system "mvn", "clean", "package", "-DskipTests", "-Pcore-modules"
Expand Down Expand Up @@ -60,7 +69,8 @@ def post_install
spawn bin/"pulsar", "standalone", "--zookeeper-dir", "#{testpath}/zk", "--bookkeeper-dir", "#{testpath}/bk"
# The daemon takes some time to start; pulsar-client will retry until it gets a connection, but emit confusing
# errors until that happens, so sleep to reduce log spam.
sleep 45
sleep 30
sleep 30 if OS.mac? && Hardware::CPU.intel?

output = shell_output("#{bin}/pulsar-client produce my-topic --messages 'hello-pulsar'")
assert_match "1 messages successfully produced", output
Expand Down
51 changes: 51 additions & 0 deletions Formula/p/protoc-gen-grpc-java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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"

bottle do
sha256 cellar: :any, arm64_sequoia: "341faf5bfb58c9b66d8125f13f4ba2df0c04f5c2399182a58d4dc22580aed63b"
sha256 cellar: :any, arm64_sonoma: "3085a73cf17253d55994083f536b81d76c9a4e3a3e95078c6fb26688567f41f7"
sha256 cellar: :any, arm64_ventura: "c7901410547f1d7fed00e88c3dcb2c8cee89e2a572f19cacf8ff85ba6e3abfe7"
sha256 cellar: :any, sonoma: "3024ae1dca662042d54cfc017a7def5ee34393dbf675f78bf5a3dbf7193d4801"
sha256 cellar: :any, ventura: "51658d35fbb323d2cfacea2cc657c4325b3bab0fec35802e65ecdda8dbf21016"
sha256 cellar: :any_skip_relocation, x86_64_linux: "12b17544fb60d27a9b5bca4cbdebf6ef0df3209a7ad50a8356d16f1b82898d6d"
end

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 to link to Abseil libraries
# 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 on Linux
s.gsub! '"-Wl,-Bstatic"', "\"-L#{Formula["protobuf"].opt_lib}\""
s.gsub! ', "-static-libgcc"', ""
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 95d1de0

Please sign in to comment.