protobuf@3.6 3.6.1.3 (new formula)

Closes #37648.

Signed-off-by: FX Coudert <fxcoudert@gmail.com>
This commit is contained in:
Dennis Luxen 2019-03-06 11:43:58 +01:00 committed by FX Coudert
parent 4019135324
commit 3779d02c74

82
Formula/protobuf@3.6.rb Normal file
View file

@ -0,0 +1,82 @@
class ProtobufAT36 < Formula
desc "Protocol buffers (Google's data interchange format)"
homepage "https://github.com/protocolbuffers/protobuf/"
url "https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.tar.gz"
sha256 "73fdad358857e120fd0fa19e071a96e15c0f23bb25f85d3f7009abfd4f264a2a"
keg_only :versioned_formula
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "cmake" => :build
depends_on "libtool" => :build
depends_on "python"
depends_on "python@2"
resource "six" do
url "https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz"
sha256 "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
end
resource "gtest" do
url "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
sha256 "9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c"
end
def install
(buildpath/"gtest").install resource "gtest"
(buildpath/"gtest/googletest").cd do
system "cmake", "."
system "make"
end
ENV["CXXFLAGS"] = "-I../gtest/googletest/include"
# 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"
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}", "--with-zlib"
system "make"
system "make", "install"
# Install editor support and examples
doc.install "editors", "examples"
ENV.append_to_cflags "-I#{include}"
ENV.append_to_cflags "-L#{lib}"
["python2", "python3"].each do |python|
resource("six").stage do
system python, *Language::Python.setup_install_args(libexec)
end
chdir "python" do
system python, *Language::Python.setup_install_args(libexec),
"--cpp_implementation"
end
version = Language::Python.major_minor_version python
site_packages = "lib/python#{version}/site-packages"
pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n"
(prefix/site_packages/"homebrew-protobuf.pth").write pth_contents
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=."
end
end