class ProtobufAT25 < Formula desc "Protocol buffers (Google's data interchange format)" homepage "https://github.com/google/protobuf" url "https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2" sha256 "13bfc5ae543cf3aa180ac2485c0bc89495e3ae711fc6fab4f8ffe90dfb4bb677" bottle do cellar :any sha256 "57b751631332e48464f3547d6608b24422001d7e98f50eb67bc8594f3dfc6284" => :high_sierra sha256 "2666bcf184708bdd23c1df2c209f3bf6fcdfe4769e02db878632be3b2267a106" => :sierra sha256 "738a1b9437b4fa18d607d9b385e83c5065c683da3aee3d88b7b30c06a85b7960" => :el_capitan sha256 "18c6d55b58fa0e9b8d36738f937a86cb2583b7eeb66412905ffe4870f7e5b60b" => :yosemite end keg_only :versioned_formula # this will double the build time approximately if enabled option "with-test", "Run build-time check" option :cxx11 depends_on "python" => :optional deprecated_option "with-check" => "with-test" def install # Don't build in debug mode. See: # https://github.com/Homebrew/homebrew/issues/9279 ENV.prepend "CXXFLAGS", "-DNDEBUG" ENV.cxx11 if build.cxx11? system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--with-zlib" system "make" system "make", "check" if build.with?("test") || build.bottle? system "make", "install" # Install editor support and examples doc.install "editors", "examples" if build.with? "python" chdir "python" do ENV["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "cpp" ENV.append_to_cflags "-I#{include}" ENV.append_to_cflags "-L#{lib}" args = Language::Python.setup_install_args libexec system "python", *args end site_packages = "lib/python2.7/site-packages" pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n" (prefix/site_packages/"homebrew-protobuf.pth").write pth_contents end end def caveats; <<~EOS Editor support and examples have been installed to: #{doc} EOS end test do (testpath/"test.proto").write <<~EOS package test; message TestCase { required string name = 4; } message Test { repeated TestCase case = 1; } EOS system bin/"protoc", "test.proto", "--cpp_out=." if build.with? "python" protobuf_pth = lib/"python2.7/site-packages/homebrew-protobuf.pth" (testpath.realpath/"Library/Python/2.7/lib/python/site-packages").install_symlink protobuf_pth system "python", "-c", "import google.protobuf" end end end