This is an automated email from the ASF dual-hosted git repository.

wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 937783ba Fix macos ci failed with protobuf version (#2287)
937783ba is described below

commit 937783ba9ae025c52bbb1817ff77c49ea34f73a1
Author: Weibing Wang <[email protected]>
AuthorDate: Sun Jun 25 17:06:31 2023 +0800

    Fix macos ci failed with protobuf version (#2287)
---
 .github/workflows/ci-macos.yml |   6 ++-
 homebrew-formula/protobuf.rb   | 100 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml
index c620fe7d..4e98aa31 100644
--- a/.github/workflows/ci-macos.yml
+++ b/.github/workflows/ci-macos.yml
@@ -22,7 +22,8 @@ jobs:
     
     - name: install dependences
       run: |
-           brew install openssl gnu-getopt coreutils gflags protobuf leveldb
+           brew install ./homebrew-formula/protobuf.rb 
+           brew install openssl gnu-getopt coreutils gflags leveldb
 
     - name: config_brpc
       run: |
@@ -42,7 +43,8 @@ jobs:
     
     - name: install dependences
       run: |
-           brew install openssl gnu-getopt coreutils gflags protobuf leveldb
+           brew install ./homebrew-formula/protobuf.rb 
+           brew install openssl gnu-getopt coreutils gflags leveldb
 
     - name: cmake
       run: |
diff --git a/homebrew-formula/protobuf.rb b/homebrew-formula/protobuf.rb
new file mode 100644
index 00000000..15521adb
--- /dev/null
+++ b/homebrew-formula/protobuf.rb
@@ -0,0 +1,100 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class Protobuf < Formula
+  desc "Protocol buffers (Google's data interchange format)"
+  homepage "https://github.com/protocolbuffers/protobuf/";
+  url 
"https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protobuf-all-3.19.4.tar.gz";
+  sha256 "ba0650be1b169d24908eeddbe6107f011d8df0da5b1a5a4449a913b10e578faf"
+  license "BSD-3-Clause"
+
+  livecheck do
+    url :stable
+    strategy :github_latest
+  end
+
+  bottle do
+    sha256 cellar: :any,                 arm64_monterey: 
"a467da7231471d7913ed291e83852e1ca950db86d142b2a67e0839743dc132b7"
+    sha256 cellar: :any,                 arm64_big_sur:  
"188863a706dd31a59ce0f4bdcf7d77d46e681ed8e72a8ab9ba28e771b52b58fd"
+    sha256 cellar: :any,                 monterey:       
"ca9840b58a314543c0f45490e6a543eb330eb772f0db385ef005d82b6b169047"
+    sha256 cellar: :any,                 big_sur:        
"a6e39ca1c9418561aa2e576a62c86fe11674b81c922a8f610c75aa9211646863"
+    sha256 cellar: :any,                 catalina:       
"5cc145bfca99db8fbe89d8b24394297bde7075aaa3d564cd24478c5762563ef6"
+    sha256 cellar: :any_skip_relocation, x86_64_linux:   
"7c3e53cb5448c38183693262da84e5e100a11c3d08de6b5088ed2d1a7f00e106"
+  end
+
+  head do
+    url "https://github.com/protocolbuffers/protobuf.git";
+
+    depends_on "autoconf" => :build
+    depends_on "automake" => :build
+    depends_on "libtool" => :build
+  end
+
+  depends_on "[email protected]" => [:build, :test]
+  # The Python3.9 bindings can be removed when Python3.9 is made keg-only.
+  depends_on "[email protected]" => [:build, :test]
+
+  uses_from_macos "zlib"
+
+  def install
+    # Don't build in debug mode. See:
+    # https://github.com/Homebrew/homebrew/issues/9279
+    # 
https://github.com/protocolbuffers/protobuf/blob/5c24564811c08772d090305be36fae82d8f12bbe/configure.ac#L61
+    ENV.prepend "CXXFLAGS", "-DNDEBUG"
+    ENV.cxx11
+
+    system "./autogen.sh" if build.head?
+    system "./configure", "--disable-debug", "--disable-dependency-tracking",
+                          "--prefix=#{prefix}", "--with-zlib"
+    system "make"
+    system "make", "check"
+    system "make", "install"
+
+    # Install editor support and examples
+    pkgshare.install "editors/proto.vim", "examples"
+    elisp.install "editors/protobuf-mode.el"
+
+    ENV.append_to_cflags "-I#{include}"
+    ENV.append_to_cflags "-L#{lib}"
+
+    cd "python" do
+      ["3.9", "3.10"].each do |xy|
+        site_packages = prefix/Language::Python.site_packages("python#{xy}")
+        system "python#{xy}", *Language::Python.setup_install_args(prefix),
+                              "--install-lib=#{site_packages}",
+                              "--cpp_implementation"
+      end
+    end
+  end
+
+  test do
+    testdata = <<~EOS
+      syntax = "proto3";
+      package test;
+      message TestCase {
+        string name = 4;
+      }
+      message Test {
+        repeated TestCase case = 1;
+      }
+    EOS
+    (testpath/"test.proto").write testdata
+    system bin/"protoc", "test.proto", "--cpp_out=."
+    system Formula["[email protected]"].opt_bin/"python3", "-c", "import 
google.protobuf"
+    system Formula["[email protected]"].opt_bin/"python3", "-c", "import 
google.protobuf"
+  end
+end


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to