protobuf: add an option to do build-time checks.
add an option to do build-time checks and double the build time approximately if enabled, add a simple test protobuf is moved to github, see more https://groups.google.com/d/msg/protobuf/3qvNnYo8-SM/GSMYGGBNXfoJ provide better format Closes Homebrew/homebrew#34364. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
36a147e2dc
commit
06cb7b08a1
1 changed files with 28 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
require 'formula'
|
||||
require "formula"
|
||||
|
||||
class OldOrNoDateutilUnlessGoogleApputils < Requirement
|
||||
# https://github.com/Homebrew/homebrew/issues/32571
|
||||
|
@ -35,7 +35,7 @@ class OldOrNoDateutilUnlessGoogleApputils < Requirement
|
|||
end
|
||||
|
||||
class Protobuf < Formula
|
||||
homepage 'http://code.google.com/p/protobuf/'
|
||||
homepage "https://github.com/google/protobuf/"
|
||||
url 'https://github.com/google/protobuf/releases/download/2.6.1/protobuf-2.6.1.tar.bz2'
|
||||
sha1 '6421ee86d8fb4e39f21f56991daa892a3e8d314b'
|
||||
|
||||
|
@ -46,6 +46,9 @@ class Protobuf < Formula
|
|||
sha1 "4acb8d1239cd352b4b90691114b4abe8a0ef4d65" => :mountain_lion
|
||||
end
|
||||
|
||||
# this will double the build time approximately if enabled
|
||||
option "with-check", "Run build-time check"
|
||||
|
||||
option :universal
|
||||
option :cxx11
|
||||
|
||||
|
@ -60,7 +63,7 @@ class Protobuf < Formula
|
|||
# Don't build in debug mode. See:
|
||||
# https://github.com/Homebrew/homebrew/issues/9279
|
||||
# http://code.google.com/p/protobuf/source/browse/trunk/configure.ac#61
|
||||
ENV.prepend 'CXXFLAGS', '-DNDEBUG'
|
||||
ENV.prepend "CXXFLAGS", "-DNDEBUG"
|
||||
ENV.universal_binary if build.universal?
|
||||
ENV.cxx11 if build.cxx11?
|
||||
|
||||
|
@ -68,22 +71,38 @@ class Protobuf < Formula
|
|||
"--prefix=#{prefix}",
|
||||
"--with-zlib"
|
||||
system "make"
|
||||
system "make install"
|
||||
system "make", "check" if build.with? "check"
|
||||
system "make", "install"
|
||||
|
||||
# Install editor support and examples
|
||||
doc.install %w( editors examples )
|
||||
|
||||
if build.with? 'python'
|
||||
chdir 'python' do
|
||||
if build.with? "python"
|
||||
chdir "python" do
|
||||
ENV.append_to_cflags "-I#{include}"
|
||||
ENV.append_to_cflags "-L#{lib}"
|
||||
system 'python', 'setup.py', 'build'
|
||||
system 'python', 'setup.py', 'install', '--cpp_implementation', "--prefix=#{prefix}",
|
||||
'--single-version-externally-managed', '--record=installed.txt'
|
||||
system "python", "setup.py", "build"
|
||||
system "python", "setup.py", "install", "--cpp_implementation", "--prefix=#{prefix}",
|
||||
"--single-version-externally-managed", "--record=installed.txt"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
def testdata; <<-EOS.undent
|
||||
package test;
|
||||
message TestCase {
|
||||
required string name = 4;
|
||||
}
|
||||
message Test {
|
||||
repeated TestCase case = 1;
|
||||
}
|
||||
EOS
|
||||
end
|
||||
(testpath/"test.proto").write(testdata)
|
||||
system "protoc", "test.proto", "--cpp_out=."
|
||||
end
|
||||
|
||||
def caveats; <<-EOS.undent
|
||||
Editor support and examples have been installed to:
|
||||
#{doc}
|
||||
|
|
Loading…
Reference in a new issue