Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf: switch to cmake #122277

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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