Skip to content

Commit

Permalink
protobuf: switch to cmake
Browse files Browse the repository at this point in the history
Closes #122277.

Signed-off-by: Rui Chen <[email protected]>
Signed-off-by: BrewTestBot <[email protected]>
  • Loading branch information
PaperChalice authored and BrewTestBot committed Feb 4, 2023
1 parent 47e087f commit ba96a35
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions Formula/protobuf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Protobuf < Formula
desc "Protocol buffers (Google's data interchange format)"
homepage "https://github.com/protocolbuffers/protobuf/"
license "BSD-3-Clause"
head "https://github.com/protocolbuffers/protobuf.git", branch: "main"

stable do
url "https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protobuf-all-21.12.tar.gz"
Expand Down Expand Up @@ -29,14 +30,7 @@ class Protobuf < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "13a477c4b847bdb0a0f7fe06b65ba816c083152b946a55744bb41bb2921aef31"
end

head do
url "https://github.com/protocolbuffers/protobuf.git", branch: "main"

depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end

depends_on "cmake" => :build
depends_on "[email protected]" => [:build, :test]
depends_on "[email protected]" => [:build, :test]

Expand All @@ -49,24 +43,23 @@ def pythons
end

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", *std_configure_args, "--with-zlib", "--with-pic"
system "make"
system "make", "check"
system "make", "install"

# Install editor support and examples
pkgshare.install "editors/proto.vim", "examples"
cmake_args = %w[
-Dprotobuf_BUILD_LIBPROTOC=ON
-Dprotobuf_BUILD_SHARED_LIBS=ON
-Dprotobuf_INSTALL_EXAMPLES=ON
-Dprotobuf_BUILD_TESTS=OFF
] + std_cmake_args

system "cmake", "-S", ".", "-B", "build", *cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"

pkgshare.install "editors/proto.vim"
elisp.install "editors/protobuf-mode.el"

ENV.append_to_cflags "-I#{include}"
ENV.append_to_cflags "-L#{lib}"
ENV["PROTOC"] = bin/"protoc"

cd "python" do
pythons.each do |python|
Expand Down

0 comments on commit ba96a35

Please sign in to comment.