72 lines
2.2 KiB
Ruby
72 lines
2.2 KiB
Ruby
|
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"
|
||
|
|
||
|
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.undent
|
||
|
Editor support and examples have been installed to:
|
||
|
#{doc}
|
||
|
EOS
|
||
|
end
|
||
|
|
||
|
test do
|
||
|
(testpath/"test.proto").write <<-EOS.undent
|
||
|
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
|