summaryrefslogtreecommitdiff
path: root/dev-libs/protobuf/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /dev-libs/protobuf/files
reinit the tree, so we can have metadata
Diffstat (limited to 'dev-libs/protobuf/files')
-rw-r--r--dev-libs/protobuf/files/70protobuf-gentoo.el3
-rw-r--r--dev-libs/protobuf/files/proto.vim1
-rw-r--r--dev-libs/protobuf/files/protobuf-2.3.0-asneeded-2.patch28
-rw-r--r--dev-libs/protobuf/files/protobuf-2.5.0-emacs-24.4.patch14
-rw-r--r--dev-libs/protobuf/files/protobuf-2.5.0-x32.patch15
-rw-r--r--dev-libs/protobuf/files/protobuf-2.6.1-protoc-cmdline.patch256
-rw-r--r--dev-libs/protobuf/files/protobuf-3.0.0_beta2-disable-local-gmock.patch89
-rw-r--r--dev-libs/protobuf/files/protobuf-3.0.2-disable-local-gmock.patch101
-rw-r--r--dev-libs/protobuf/files/protobuf-3.3.0-disable-local-gmock.patch115
-rw-r--r--dev-libs/protobuf/files/protobuf-3.4.0-disable_no-warning-test.patch19
-rw-r--r--dev-libs/protobuf/files/protobuf-3.4.0-protoc_input_output_files.patch233
-rw-r--r--dev-libs/protobuf/files/protobuf-3.4.0-system_libraries.patch117
12 files changed, 991 insertions, 0 deletions
diff --git a/dev-libs/protobuf/files/70protobuf-gentoo.el b/dev-libs/protobuf/files/70protobuf-gentoo.el
new file mode 100644
index 000000000000..51370527f6f2
--- /dev/null
+++ b/dev-libs/protobuf/files/70protobuf-gentoo.el
@@ -0,0 +1,3 @@
+(add-to-list 'load-path "@SITELISP@")
+(add-to-list 'auto-mode-alist '("\\.proto\\'" . protobuf-mode))
+(autoload 'protobuf-mode "protobuf-mode" "Google protobuf mode." t)
diff --git a/dev-libs/protobuf/files/proto.vim b/dev-libs/protobuf/files/proto.vim
new file mode 100644
index 000000000000..6d26809efee6
--- /dev/null
+++ b/dev-libs/protobuf/files/proto.vim
@@ -0,0 +1 @@
+au BufRead,BufNewFile *.proto set filetype=proto
diff --git a/dev-libs/protobuf/files/protobuf-2.3.0-asneeded-2.patch b/dev-libs/protobuf/files/protobuf-2.3.0-asneeded-2.patch
new file mode 100644
index 000000000000..418622e547f4
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-2.3.0-asneeded-2.patch
@@ -0,0 +1,28 @@
+Fixing as-needed issue
+
+http://bugs.gentoo.org/show_bug.cgi?id=271509
+
+--- m4/acx_pthread.m4
++++ m4/acx_pthread.m4
+@@ -278,7 +278,8 @@
+ fi
+ fi
+
+- if test x"$done" = xno; then
++ if test x"$done" = xyes; then
++ done="no"
+ AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+--- gtest/m4/acx_pthread.m4
++++ gtest/m4/acx_pthread.m4
+@@ -278,7 +278,8 @@
+ fi
+ fi
+
+- if test x"$done" = xno; then
++ if test x"$done" = xyes; then
++ done="no"
+ AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
diff --git a/dev-libs/protobuf/files/protobuf-2.5.0-emacs-24.4.patch b/dev-libs/protobuf/files/protobuf-2.5.0-emacs-24.4.patch
new file mode 100644
index 000000000000..77d624938243
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-2.5.0-emacs-24.4.patch
@@ -0,0 +1,14 @@
+Fix build with emacs-24.4.
+
+http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18845
+
+--- protobuf-2.5.0/editors/protobuf-mode.el
++++ protobuf-2.5.0/editors/protobuf-mode.el
+@@ -66,6 +66,7 @@
+ (require 'cc-mode)
+
+ (eval-when-compile
++ (require 'cl)
+ (require 'cc-langs)
+ (require 'cc-fonts))
+
diff --git a/dev-libs/protobuf/files/protobuf-2.5.0-x32.patch b/dev-libs/protobuf/files/protobuf-2.5.0-x32.patch
new file mode 100644
index 000000000000..5c8d47831807
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-2.5.0-x32.patch
@@ -0,0 +1,15 @@
+fix from upstream for building w/x32
+
+https://code.google.com/p/protobuf/issues/detail?id=474
+
+--- src/google/protobuf/stubs/atomicops.h (revision 491)
++++ src/google/protobuf/stubs/atomicops.h (revision 492)
+@@ -66,7 +66,7 @@ typedef int32 Atomic32;
+ #ifdef GOOGLE_PROTOBUF_ARCH_64_BIT
+ // We need to be able to go between Atomic64 and AtomicWord implicitly. This
+ // means Atomic64 and AtomicWord should be the same type on 64-bit.
+-#if defined(GOOGLE_PROTOBUF_OS_NACL)
++#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL)
+ // NaCl's intptr_t is not actually 64-bits on 64-bit!
+ // http://code.google.com/p/nativeclient/issues/detail?id=1162
+ typedef int64 Atomic64;
diff --git a/dev-libs/protobuf/files/protobuf-2.6.1-protoc-cmdline.patch b/dev-libs/protobuf/files/protobuf-2.6.1-protoc-cmdline.patch
new file mode 100644
index 000000000000..894f2ffd095f
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-2.6.1-protoc-cmdline.patch
@@ -0,0 +1,256 @@
+https://github.com/google/protobuf/pull/235
+
+From 18f71a50a9000e7558ae48a971fa301d76220ff0 Mon Sep 17 00:00:00 2001
+From: Prathmesh Prabhu <pprabhu@chromium.org>
+Date: Tue, 10 Mar 2015 17:04:40 -0400
+Subject: [PATCH] protoc: Add options to redirect input/output to files.
+
+When using protoc to encode/decode protobufs, the input/output was from
+stdin/stdout only. This patch adds command line flags to specify files to read
+the protobuf from and and write the encoded/decoded protobuf to.
+---
+ .../protobuf/compiler/command_line_interface.cc | 99 +++++++++++++++++-----
+ .../protobuf/compiler/command_line_interface.h | 11 ++-
+ .../compiler/command_line_interface_unittest.cc | 25 +++++-
+ 3 files changed, 110 insertions(+), 25 deletions(-)
+
+diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
+index 567238a..1db85c9 100644
+--- a/src/google/protobuf/compiler/command_line_interface.cc
++++ b/src/google/protobuf/compiler/command_line_interface.cc
+@@ -745,6 +745,28 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
+ }
+
+ if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) {
++ bool success = false;
++ int in_fd = STDIN_FILENO;
++ int out_fd = STDOUT_FILENO;
++
++ if (!protobuf_in_path_.empty()) {
++ in_fd = open(protobuf_in_path_.c_str(), O_RDONLY);
++ if (in_fd == -1) {
++ cerr << protobuf_in_path_ << ": error: failed to open file." << endl;
++ return 1;
++ }
++ }
++ if (!protobuf_out_path_.empty()) {
++ out_fd = open(protobuf_out_path_.c_str(),
++ O_WRONLY | O_CREAT | O_TRUNC,
++ 0644);
++ if (out_fd == -1) {
++ cerr << protobuf_out_path_ << ": error: failed to open file." << endl;
++ close(in_fd);
++ return 1;
++ }
++ }
++
+ if (codec_type_.empty()) {
+ // HACK: Define an EmptyMessage type to use for decoding.
+ DescriptorPool pool;
+@@ -753,13 +775,20 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
+ file.add_message_type()->set_name("EmptyMessage");
+ GOOGLE_CHECK(pool.BuildFile(file) != NULL);
+ codec_type_ = "EmptyMessage";
+- if (!EncodeOrDecode(&pool)) {
+- return 1;
+- }
++ success = EncodeOrDecode(&pool, in_fd, out_fd);
+ } else {
+- if (!EncodeOrDecode(importer.pool())) {
+- return 1;
+- }
++ success = EncodeOrDecode(importer.pool(), in_fd, out_fd);
++ }
++
++ if (in_fd != STDIN_FILENO) {
++ close(in_fd);
++ }
++ if (out_fd != STDOUT_FILENO) {
++ close(out_fd);
++ }
++
++ if (!success) {
++ return 1;
+ }
+ }
+
+@@ -873,6 +902,11 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
+ if (status != PARSE_ARGUMENT_DONE_AND_CONTINUE)
+ return status;
+ }
++ if (mode_ == MODE_COMPILE &&
++ (!protobuf_in_path_.empty() || !protobuf_out_path_.empty())) {
++ cerr << "--protobuf_in and --protobuf_out are only valid with "
++ << "decode operations. Ignoring.";
++ }
+
+ // If no --proto_path was given, use the current working directory.
+ if (proto_path_.empty()) {
+@@ -1123,6 +1157,12 @@ CommandLineInterface::InterpretArgument(const string& name,
+
+ codec_type_ = value;
+
++ } else if (name == "--protobuf_in") {
++ protobuf_in_path_ = value;
++
++ } else if (name == "--protobuf_out") {
++ protobuf_out_path_ = value;
++
+ } else if (name == "--error_format") {
+ if (value == "gcc") {
+ error_format_ = ERROR_FORMAT_GCC;
+@@ -1238,18 +1278,29 @@ void CommandLineInterface::PrintHelpText() {
+ " --version Show version info and exit.\n"
+ " -h, --help Show this text and exit.\n"
+ " --encode=MESSAGE_TYPE Read a text-format message of the given type\n"
+-" from standard input and write it in binary\n"
+-" to standard output. The message type must\n"
+-" be defined in PROTO_FILES or their imports.\n"
+-" --decode=MESSAGE_TYPE Read a binary message of the given type from\n"
+-" standard input and write it in text format\n"
+-" to standard output. The message type must\n"
++" an write it in binary. The message type must\n"
+ " be defined in PROTO_FILES or their imports.\n"
+-" --decode_raw Read an arbitrary protocol message from\n"
+-" standard input and write the raw tag/value\n"
+-" pairs in text format to standard output. No\n"
++" The input/output protobuf files are specified\n"
++" using the --protobuf_in and --protobuf_out\n"
++" command line flags.\n"
++" --decode=MESSAGE_TYPE Read a binary message of the given type and\n"
++" write it in text format. The message type\n"
++" must be defined in PROTO_FILES or their\n"
++" imports. The input/output protobuf files are\n"
++" specified using the --protobuf_in and \n"
++" --protobuf_out command line flags.\n"
++" --decode_raw Read an arbitrary protocol message and write\n"
++" the raw tag/value pairs in text format. No\n"
+ " PROTO_FILES should be given when using this\n"
+-" flag.\n"
++" flag. The input/output protobuf files are\n"
++" specified using the --protobuf_in and \n"
++" --protobuf_out command line flags.\n"
++" --protobuf_in Absolute path to the protobuf file to read to\n"
++" encode/decode. If omitted, file will be read\n"
++" from STDIN.\n"
++" --protobuf_out Absolute path to the protobuf file to write to\n"
++" after encode/decode operation. If omitted,\n"
++" output is written to STDOUT.\n"
+ " -oFILE, Writes a FileDescriptorSet (a protocol buffer,\n"
+ " --descriptor_set_out=FILE defined in descriptor.proto) containing all of\n"
+ " the input files to FILE.\n"
+@@ -1490,7 +1541,9 @@ bool CommandLineInterface::GeneratePluginOutput(
+ return true;
+ }
+
+-bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
++bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool,
++ int in_fd,
++ int out_fd) {
+ // Look up the type.
+ const Descriptor* type = pool->FindMessageTypeByName(codec_type_);
+ if (type == NULL) {
+@@ -1502,15 +1555,15 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
+ google::protobuf::scoped_ptr<Message> message(dynamic_factory.GetPrototype(type)->New());
+
+ if (mode_ == MODE_ENCODE) {
+- SetFdToTextMode(STDIN_FILENO);
+- SetFdToBinaryMode(STDOUT_FILENO);
++ SetFdToTextMode(in_fd);
++ SetFdToBinaryMode(out_fd);
+ } else {
+- SetFdToBinaryMode(STDIN_FILENO);
+- SetFdToTextMode(STDOUT_FILENO);
++ SetFdToBinaryMode(in_fd);
++ SetFdToTextMode(out_fd);
+ }
+
+- io::FileInputStream in(STDIN_FILENO);
+- io::FileOutputStream out(STDOUT_FILENO);
++ io::FileInputStream in(in_fd);
++ io::FileOutputStream out(out_fd);
+
+ if (mode_ == MODE_ENCODE) {
+ // Input is text.
+diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h
+index 7e611c4..b6fc38a 100644
+--- a/src/google/protobuf/compiler/command_line_interface.h
++++ b/src/google/protobuf/compiler/command_line_interface.h
+@@ -244,7 +244,9 @@ class LIBPROTOC_EXPORT CommandLineInterface {
+ string* error);
+
+ // Implements --encode and --decode.
+- bool EncodeOrDecode(const DescriptorPool* pool);
++ bool EncodeOrDecode(const DescriptorPool* pool,
++ int in_fd,
++ int out_fd);
+
+ // Implements the --descriptor_set_out option.
+ bool WriteDescriptorSet(const vector<const FileDescriptor*> parsed_files);
+@@ -357,6 +359,13 @@ class LIBPROTOC_EXPORT CommandLineInterface {
+ // decoding. (Empty string indicates --decode_raw.)
+ string codec_type_;
+
++ // When using --encode / --decode / --decode_raw absolute path to the output
++ // file. (Empty string indicates write to STDOUT).
++ string protobuf_out_path_;
++ // When using --encode / --decode / --decode_raw, absolute path to the input
++ // file. (Empty string indicates read from STDIN).
++ string protobuf_in_path_;
++
+ // If --descriptor_set_out was given, this is the filename to which the
+ // FileDescriptorSet should be written. Otherwise, empty.
+ string descriptor_set_name_;
+diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc
+index 2b26f3b..78ff2cf 100644
+--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
++++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
+@@ -94,7 +94,7 @@ class CommandLineInterfaceTest : public testing::Test {
+ virtual void SetUp();
+ virtual void TearDown();
+
+- // Runs the CommandLineInterface with the given command line. The
++ // Run the CommandLineInterface with the given command line. The
+ // command is automatically split on spaces, and the string "$tmpdir"
+ // is replaced with TestTempDir().
+ void Run(const string& command);
+@@ -1680,6 +1680,17 @@ class EncodeDecodeTest : public testing::Test {
+ EXPECT_EQ(StripCR(expected_text), StripCR(captured_stderr_));
+ }
+
++ void ExpectBinaryFilesMatch(const string &expected_file,
++ const string &actual_file) {
++ string expected_output, actual_output;
++ ASSERT_TRUE(File::ReadFileToString(expected_file, &expected_output));
++ ASSERT_TRUE(File::ReadFileToString(actual_file, &actual_output));
++
++ // Don't use EXPECT_EQ because we don't want to print raw binary data to
++ // stdout on failure.
++ EXPECT_TRUE(expected_output == actual_output);
++ }
++
+ private:
+ int duped_stdin_;
+ string captured_stdout_;
+@@ -1745,6 +1756,18 @@ TEST_F(EncodeDecodeTest, ProtoParseError) {
+ "google/protobuf/no_such_file.proto: File not found.\n");
+ }
+
++TEST_F(EncodeDecodeTest, RedirectInputOutput) {
++ string out_file = TestTempDir() + "/golden_message_out.pbf";
++ string cmd = "";
++ cmd += "google/protobuf/unittest.proto ";
++ cmd += "--encode=protobuf_unittest.TestAllTypes ";
++ cmd += "--protobuf_in=" + TestSourceDir() +
++ "/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt ";
++ cmd += "--protobuf_out=" + out_file;
++ EXPECT_TRUE(Run(cmd));
++ ExpectBinaryFilesMatch(out_file, TestSourceDir() + "/google/protobuf/testdata/golden_message_oneof_implemented");
++}
++
+ } // anonymous namespace
+
+ } // namespace compiler
+--
+2.3.1
+
diff --git a/dev-libs/protobuf/files/protobuf-3.0.0_beta2-disable-local-gmock.patch b/dev-libs/protobuf/files/protobuf-3.0.0_beta2-disable-local-gmock.patch
new file mode 100644
index 000000000000..341d1128aa1a
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-3.0.0_beta2-disable-local-gmock.patch
@@ -0,0 +1,89 @@
+diff -Naur a/configure.ac b/configure.ac
+--- a/configure.ac 2015-12-30 22:21:46.000000000 +0100
++++ b/configure.ac 2016-04-16 17:46:54.858904639 +0200
+@@ -176,9 +176,9 @@
+ # HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
+ # since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
+ # too.
+-export CFLAGS
+-export CXXFLAGS
+-AC_CONFIG_SUBDIRS([gmock])
++#export CFLAGS
++#export CXXFLAGS
++#AC_CONFIG_SUBDIRS([gmock])
+
+ AC_CONFIG_FILES([Makefile src/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
+ AC_OUTPUT
+diff -Naur a/Makefile.am b/Makefile.am
+--- a/Makefile.am 2015-12-30 22:21:46.000000000 +0100
++++ b/Makefile.am 2016-04-16 17:46:25.355751203 +0200
+@@ -17,9 +17,10 @@
+ # want "make install" to recurse into gmock since we don't want to overwrite
+ # the installed version of gmock if there is one.
+ check-local:
+- @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
+- @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
+- @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
++ @echo "Making of gmock disabled"
++# @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
++# @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
++# @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
+
+ # We would like to clean gmock when "make clean" is invoked. But we have to
+ # be careful because clean-local is also invoked during "make distclean", but
+diff -Naur a/src/Makefile.am b/src/Makefile.am
+--- a/src/Makefile.am 2015-12-30 22:21:46.000000000 +0100
++++ b/src/Makefile.am 2016-04-16 17:47:07.026967535 +0200
+@@ -669,11 +669,8 @@
+ protobuf-lite-test test_plugin protobuf-lite-arena-test \
+ $(GZCHECKPROGRAMS)
+ protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \
+- -I$(srcdir)/../gmock/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_test_CPPFLAGS = -I/usr/include
+ # Disable optimization for tests unless the user explicitly asked for it,
+ # since test_util.cc takes forever to compile with optimization (with GCC).
+ # See configure.ac for more info.
+@@ -753,11 +750,8 @@
+ # Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.
+ protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
+ libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include \
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lazy_descriptor_test_CPPFLAGS = -I/usr/include \
+ -DPROTOBUF_TEST_NO_DESCRIPTORS
+ protobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lazy_descriptor_test_SOURCES = \
+@@ -788,11 +782,8 @@
+ # gtest when building the test internally our memory sanitizer doesn't detect
+ # memory leaks (don't know why).
+ protobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lite_arena_test_CPPFLAGS = -I/usr/include
+ protobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lite_arena_test_SOURCES = \
+ google/protobuf/lite_arena_unittest.cc \
+@@ -801,8 +792,8 @@
+
+ # Test plugin binary.
+ test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la
+-test_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgtest
++test_plugin_CPPFLAGS = -I/usr/include
+ test_plugin_SOURCES = \
+ google/protobuf/compiler/mock_code_generator.cc \
+ google/protobuf/testing/file.cc \
diff --git a/dev-libs/protobuf/files/protobuf-3.0.2-disable-local-gmock.patch b/dev-libs/protobuf/files/protobuf-3.0.2-disable-local-gmock.patch
new file mode 100644
index 000000000000..a2dda8aafac1
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-3.0.2-disable-local-gmock.patch
@@ -0,0 +1,101 @@
+diff -Naur protobuf-3.0.2.orig/Makefile.am protobuf-3.0.2/Makefile.am
+--- protobuf-3.0.2.orig/Makefile.am 2016-09-06 15:40:51.000000000 -0700
++++ protobuf-3.0.2/Makefile.am 2016-12-14 14:44:50.516520874 -0800
+@@ -17,9 +17,10 @@
+ # want "make install" to recurse into gmock since we don't want to overwrite
+ # the installed version of gmock if there is one.
+ check-local:
+- @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
+- @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
+- @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
++ @echo "Making of gmock disabled"
++# @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
++# @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
++# @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
+
+ # We would like to clean gmock when "make clean" is invoked. But we have to
+ # be careful because clean-local is also invoked during "make distclean", but
+diff -Naur protobuf-3.0.2.orig/configure.ac protobuf-3.0.2/configure.ac
+--- protobuf-3.0.2.orig/configure.ac 2016-09-06 15:40:51.000000000 -0700
++++ protobuf-3.0.2/configure.ac 2016-12-14 14:44:50.516520874 -0800
+@@ -181,9 +181,9 @@
+ # HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
+ # since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
+ # too.
+-export CFLAGS
+-export CXXFLAGS
+-AC_CONFIG_SUBDIRS([gmock])
++#export CFLAGS
++#export CXXFLAGS
++#AC_CONFIG_SUBDIRS([gmock])
+
+ AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
+ AC_OUTPUT
+diff -Naur protobuf-3.0.2.orig/src/Makefile.am protobuf-3.0.2/src/Makefile.am
+--- protobuf-3.0.2.orig/src/Makefile.am 2016-09-06 15:40:51.000000000 -0700
++++ protobuf-3.0.2/src/Makefile.am 2016-12-14 14:44:50.517520885 -0800
+@@ -688,11 +688,8 @@
+ protobuf-lite-test test_plugin protobuf-lite-arena-test \
+ no-warning-test $(GZCHECKPROGRAMS)
+ protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \
+- -I$(srcdir)/../gmock/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_test_CPPFLAGS = -I/usr/include
+ # Disable optimization for tests unless the user explicitly asked for it,
+ # since test_util.cc takes forever to compile with optimization (with GCC).
+ # See configure.ac for more info.
+@@ -775,11 +772,8 @@
+ # Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.
+ protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
+ libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include \
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lazy_descriptor_test_CPPFLAGS = -I/usr/include \
+ -DPROTOBUF_TEST_NO_DESCRIPTORS
+ protobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lazy_descriptor_test_SOURCES = \
+@@ -810,11 +804,8 @@
+ # gtest when building the test internally our memory sanitizer doesn't detect
+ # memory leaks (don't know why).
+ protobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lite_arena_test_CPPFLAGS = -I/usr/include
+ protobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lite_arena_test_SOURCES = \
+ google/protobuf/lite_arena_unittest.cc \
+@@ -823,8 +814,8 @@
+
+ # Test plugin binary.
+ test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la
+-test_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgtest
++test_plugin_CPPFLAGS = -I/usr/include
+ test_plugin_SOURCES = \
+ google/protobuf/compiler/mock_code_generator.cc \
+ google/protobuf/testing/file.cc \
+@@ -853,9 +844,8 @@
+ echo "TEST(NoWarningTest, Empty) {}" >> no_warning_test.cc
+
+ no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/gtest/lib/libgtest_main.la
+-no_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgtest -lgtest_main
++no_warning_test_CPPFLAGS = -I/usr/include
+ no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \
+ -Wall -Werror
+ nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs)
diff --git a/dev-libs/protobuf/files/protobuf-3.3.0-disable-local-gmock.patch b/dev-libs/protobuf/files/protobuf-3.3.0-disable-local-gmock.patch
new file mode 100644
index 000000000000..25dc7bd074bf
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-3.3.0-disable-local-gmock.patch
@@ -0,0 +1,115 @@
+diff -Naur protobuf-3.3.0.orig/Makefile.am protobuf-3.3.0/Makefile.am
+--- protobuf-3.3.0.orig/Makefile.am 2017-05-01 20:04:35.448840428 -0700
++++ protobuf-3.3.0/Makefile.am 2017-05-01 20:04:48.855978898 -0700
+@@ -17,9 +17,10 @@
+ # want "make install" to recurse into gmock since we don't want to overwrite
+ # the installed version of gmock if there is one.
+ check-local:
+- @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
+- @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
+- @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
++ @echo "Making of gmock disabled"
++# @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
++# @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
++# @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
+
+ # We would like to clean gmock when "make clean" is invoked. But we have to
+ # be careful because clean-local is also invoked during "make distclean", but
+diff -Naur protobuf-3.3.0.orig/configure.ac protobuf-3.3.0/configure.ac
+--- protobuf-3.3.0.orig/configure.ac 2017-05-01 20:04:35.497840933 -0700
++++ protobuf-3.3.0/configure.ac 2017-05-01 20:04:48.856978908 -0700
+@@ -203,9 +203,9 @@
+ # HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
+ # since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
+ # too.
+-export CFLAGS
+-export CXXFLAGS
+-AC_CONFIG_SUBDIRS([gmock])
++#export CFLAGS
++#export CXXFLAGS
++#AC_CONFIG_SUBDIRS([gmock])
+
+ AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
+ AC_OUTPUT
+diff -Naur protobuf-3.3.0.orig/src/Makefile.am protobuf-3.3.0/src/Makefile.am
+--- protobuf-3.3.0.orig/src/Makefile.am 2017-05-01 20:04:35.549841471 -0700
++++ protobuf-3.3.0/src/Makefile.am 2017-05-01 20:06:46.307191948 -0700
+@@ -748,11 +748,8 @@
+ protobuf-lite-test test_plugin protobuf-lite-arena-test \
+ no-warning-test $(GZCHECKPROGRAMS)
+ protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \
+- -I$(srcdir)/../gmock/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_test_CPPFLAGS = -I/usr/include
+ # Disable optimization for tests unless the user explicitly asked for it,
+ # since test_util.cc takes forever to compile with optimization (with GCC).
+ # See configure.ac for more info.
+@@ -837,11 +834,8 @@
+ # Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.
+ protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
+ libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include \
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lazy_descriptor_test_CPPFLAGS = -I/usr/include \
+ -DPROTOBUF_TEST_NO_DESCRIPTORS
+ protobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lazy_descriptor_test_SOURCES = \
+@@ -862,11 +856,8 @@
+ # full runtime and we want to make sure this test builds without full
+ # runtime.
+ protobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lite_test_CPPFLAGS= -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lite_test_CPPFLAGS = -I/usr/include
+ protobuf_lite_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lite_test_SOURCES = \
+ google/protobuf/lite_unittest.cc \
+@@ -877,11 +868,8 @@
+ # gtest when building the test internally our memory sanitizer doesn't detect
+ # memory leaks (don't know why).
+ protobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgmock -lgmock_main -lgtest
++protobuf_lite_arena_test_CPPFLAGS = -I/usr/include
+ protobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lite_arena_test_SOURCES = \
+ google/protobuf/lite_arena_unittest.cc \
+@@ -890,8 +878,8 @@
+
+ # Test plugin binary.
+ test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la
+-test_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgtest
++test_plugin_CPPFLAGS = -I/usr/include
+ test_plugin_SOURCES = \
+ google/protobuf/compiler/mock_code_generator.cc \
+ google/protobuf/testing/file.cc \
+@@ -920,9 +908,8 @@
+ echo "TEST(NoWarningTest, Empty) {}" >> no_warning_test.cc
+
+ no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/gtest/lib/libgtest_main.la
+-no_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
++ -L/usr/lib -lgtest -lgtest_main
++no_warning_test_CPPFLAGS = -I/usr/include
+ no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \
+ -Wall -Werror
+ nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs)
diff --git a/dev-libs/protobuf/files/protobuf-3.4.0-disable_no-warning-test.patch b/dev-libs/protobuf/files/protobuf-3.4.0-disable_no-warning-test.patch
new file mode 100644
index 000000000000..373dc7935a89
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-3.4.0-disable_no-warning-test.patch
@@ -0,0 +1,19 @@
+Disable no-warning-test which is compiled with -Werror option and whose only purpose is checking if compilation results in any warnings.
+
+--- /src/Makefile.am
++++ /src/Makefile.am
+@@ -750,7 +750,7 @@
+
+ check_PROGRAMS = protoc protobuf-test protobuf-lazy-descriptor-test \
+ protobuf-lite-test test_plugin protobuf-lite-arena-test \
+- no-warning-test $(GZCHECKPROGRAMS)
++ $(GZCHECKPROGRAMS)
+ protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+ ../gmock/gtest/lib/libgtest.la \
+ ../gmock/lib/libgmock.la \
+@@ -931,4 +931,4 @@
+
+ TESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \
+ google/protobuf/compiler/zip_output_unittest.sh $(GZTESTS) \
+- protobuf-lite-arena-test no-warning-test
++ protobuf-lite-arena-test
diff --git a/dev-libs/protobuf/files/protobuf-3.4.0-protoc_input_output_files.patch b/dev-libs/protobuf/files/protobuf-3.4.0-protoc_input_output_files.patch
new file mode 100644
index 000000000000..a7d338e99289
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-3.4.0-protoc_input_output_files.patch
@@ -0,0 +1,233 @@
+https://github.com/google/protobuf/pull/235
+
+--- /src/google/protobuf/compiler/command_line_interface.cc
++++ /src/google/protobuf/compiler/command_line_interface.cc
+@@ -942,6 +942,28 @@
+ }
+
+ if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) {
++ bool success = false;
++ int in_fd = STDIN_FILENO;
++ int out_fd = STDOUT_FILENO;
++
++ if (!protobuf_in_path_.empty()) {
++ in_fd = open(protobuf_in_path_.c_str(), O_RDONLY);
++ if (in_fd == -1) {
++ std::cerr << protobuf_in_path_ << ": error: failed to open file." << std::endl;
++ return 1;
++ }
++ }
++ if (!protobuf_out_path_.empty()) {
++ out_fd = open(protobuf_out_path_.c_str(),
++ O_WRONLY | O_CREAT | O_TRUNC,
++ 0644);
++ if (out_fd == -1) {
++ std::cerr << protobuf_out_path_ << ": error: failed to open file." << std::endl;
++ close(in_fd);
++ return 1;
++ }
++ }
++
+ if (codec_type_.empty()) {
+ // HACK: Define an EmptyMessage type to use for decoding.
+ DescriptorPool pool;
+@@ -950,13 +972,20 @@
+ file.add_message_type()->set_name("EmptyMessage");
+ GOOGLE_CHECK(pool.BuildFile(file) != NULL);
+ codec_type_ = "EmptyMessage";
+- if (!EncodeOrDecode(&pool)) {
+- return 1;
+- }
++ success = EncodeOrDecode(&pool, in_fd, out_fd);
+ } else {
+- if (!EncodeOrDecode(descriptor_pool.get())) {
+- return 1;
+- }
++ success = EncodeOrDecode(descriptor_pool.get(), in_fd, out_fd);
++ }
++
++ if (in_fd != STDIN_FILENO) {
++ close(in_fd);
++ }
++ if (out_fd != STDOUT_FILENO) {
++ close(out_fd);
++ }
++
++ if (!success) {
++ return 1;
+ }
+ }
+
+@@ -994,6 +1023,11 @@
+ for (int i = 0; i < proto_path_.size(); i++) {
+ source_tree->MapPath(proto_path_[i].first, proto_path_[i].second);
+ }
++ if (mode_ == MODE_COMPILE &&
++ (!protobuf_in_path_.empty() || !protobuf_out_path_.empty())) {
++ std::cerr << "--protobuf_in and --protobuf_out are only valid with "
++ << "decode operations. Ignoring.";
++ }
+
+ // Map input files to virtual paths if possible.
+ if (!MakeInputsBeProtoPathRelative(source_tree)) {
+@@ -1561,6 +1595,12 @@
+
+ codec_type_ = value;
+
++ } else if (name == "--protobuf_in") {
++ protobuf_in_path_ = value;
++
++ } else if (name == "--protobuf_out") {
++ protobuf_out_path_ = value;
++
+ } else if (name == "--error_format") {
+ if (value == "gcc") {
+ error_format_ = ERROR_FORMAT_GCC;
+@@ -1684,18 +1724,29 @@
+ " --version Show version info and exit.\n"
+ " -h, --help Show this text and exit.\n"
+ " --encode=MESSAGE_TYPE Read a text-format message of the given type\n"
+-" from standard input and write it in binary\n"
+-" to standard output. The message type must\n"
+-" be defined in PROTO_FILES or their imports.\n"
+-" --decode=MESSAGE_TYPE Read a binary message of the given type from\n"
+-" standard input and write it in text format\n"
+-" to standard output. The message type must\n"
++" an write it in binary. The message type must\n"
+ " be defined in PROTO_FILES or their imports.\n"
+-" --decode_raw Read an arbitrary protocol message from\n"
+-" standard input and write the raw tag/value\n"
+-" pairs in text format to standard output. No\n"
++" The input/output protobuf files are specified\n"
++" using the --protobuf_in and --protobuf_out\n"
++" command line flags.\n"
++" --decode=MESSAGE_TYPE Read a binary message of the given type and\n"
++" write it in text format. The message type\n"
++" must be defined in PROTO_FILES or their\n"
++" imports. The input/output protobuf files are\n"
++" specified using the --protobuf_in and \n"
++" --protobuf_out command line flags.\n"
++" --decode_raw Read an arbitrary protocol message and write\n"
++" the raw tag/value pairs in text format. No\n"
+ " PROTO_FILES should be given when using this\n"
+-" flag.\n"
++" flag. The input/output protobuf files are\n"
++" specified using the --protobuf_in and \n"
++" --protobuf_out command line flags.\n"
++" --protobuf_in Absolute path to the protobuf file to read to\n"
++" encode/decode. If omitted, file will be read\n"
++" from STDIN.\n"
++" --protobuf_out Absolute path to the protobuf file to write to\n"
++" after encode/decode operation. If omitted,\n"
++" output is written to STDOUT.\n"
+ " --descriptor_set_in=FILES Specifies a delimited list of FILES\n"
+ " each containing a FileDescriptorSet (a\n"
+ " protocol buffer defined in descriptor.proto).\n"
+@@ -1957,7 +2008,9 @@
+ return true;
+ }
+
+-bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
++bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool,
++ int in_fd,
++ int out_fd) {
+ // Look up the type.
+ const Descriptor* type = pool->FindMessageTypeByName(codec_type_);
+ if (type == NULL) {
+@@ -1969,15 +2022,15 @@
+ google::protobuf::scoped_ptr<Message> message(dynamic_factory.GetPrototype(type)->New());
+
+ if (mode_ == MODE_ENCODE) {
+- SetFdToTextMode(STDIN_FILENO);
+- SetFdToBinaryMode(STDOUT_FILENO);
++ SetFdToTextMode(in_fd);
++ SetFdToBinaryMode(out_fd);
+ } else {
+- SetFdToBinaryMode(STDIN_FILENO);
+- SetFdToTextMode(STDOUT_FILENO);
++ SetFdToBinaryMode(in_fd);
++ SetFdToTextMode(out_fd);
+ }
+
+- io::FileInputStream in(STDIN_FILENO);
+- io::FileOutputStream out(STDOUT_FILENO);
++ io::FileInputStream in(in_fd);
++ io::FileOutputStream out(out_fd);
+
+ if (mode_ == MODE_ENCODE) {
+ // Input is text.
+--- /src/google/protobuf/compiler/command_line_interface.h
++++ /src/google/protobuf/compiler/command_line_interface.h
+@@ -269,7 +269,9 @@
+ GeneratorContext* generator_context, string* error);
+
+ // Implements --encode and --decode.
+- bool EncodeOrDecode(const DescriptorPool* pool);
++ bool EncodeOrDecode(const DescriptorPool* pool,
++ int in_fd,
++ int out_fd);
+
+ // Implements the --descriptor_set_out option.
+ bool WriteDescriptorSet(
+@@ -402,6 +404,13 @@
+ // parsed FileDescriptorSets to be used for loading protos. Otherwise, empty.
+ std::vector<string> descriptor_set_in_names_;
+
++ // When using --encode / --decode / --decode_raw absolute path to the output
++ // file. (Empty string indicates write to STDOUT).
++ string protobuf_out_path_;
++ // When using --encode / --decode / --decode_raw, absolute path to the input
++ // file. (Empty string indicates read from STDIN).
++ string protobuf_in_path_;
++
+ // If --descriptor_set_out was given, this is the filename to which the
+ // FileDescriptorSet should be written. Otherwise, empty.
+ string descriptor_set_out_name_;
+--- /src/google/protobuf/compiler/command_line_interface_unittest.cc
++++ /src/google/protobuf/compiler/command_line_interface_unittest.cc
+@@ -95,7 +95,7 @@
+ virtual void SetUp();
+ virtual void TearDown();
+
+- // Runs the CommandLineInterface with the given command line. The
++ // Run the CommandLineInterface with the given command line. The
+ // command is automatically split on spaces, and the string "$tmpdir"
+ // is replaced with TestTempDir().
+ void Run(const string& command);
+@@ -2308,6 +2308,17 @@
+ EXPECT_EQ(StripCR(expected_text), StripCR(captured_stderr_));
+ }
+
++ void ExpectBinaryFilesMatch(const string &expected_file,
++ const string &actual_file) {
++ string expected_output, actual_output;
++ ASSERT_TRUE(File::ReadFileToString(expected_file, &expected_output));
++ ASSERT_TRUE(File::ReadFileToString(actual_file, &actual_output));
++
++ // Don't use EXPECT_EQ because we don't want to print raw binary data to
++ // stdout on failure.
++ EXPECT_TRUE(expected_output == actual_output);
++ }
++
+ private:
+ void WriteUnittestProtoDescriptorSet() {
+ unittest_proto_descriptor_set_filename_ =
+@@ -2398,6 +2409,18 @@
+ "google/protobuf/no_such_file.proto: No such file or directory\n");
+ }
+
++TEST_P(EncodeDecodeTest, RedirectInputOutput) {
++ string out_file = TestTempDir() + "/golden_message_out.pbf";
++ string cmd = "";
++ cmd += "google/protobuf/unittest.proto ";
++ cmd += "--encode=protobuf_unittest.TestAllTypes ";
++ cmd += "--protobuf_in=" + TestSourceDir() +
++ "/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt ";
++ cmd += "--protobuf_out=" + out_file;
++ EXPECT_TRUE(Run(cmd));
++ ExpectBinaryFilesMatch(out_file, TestSourceDir() + "/google/protobuf/testdata/golden_message_oneof_implemented");
++}
++
+ INSTANTIATE_TEST_CASE_P(FileDescriptorSetSource,
+ EncodeDecodeTest,
+ testing::Values(PROTO_PATH, DESCRIPTOR_SET_IN));
diff --git a/dev-libs/protobuf/files/protobuf-3.4.0-system_libraries.patch b/dev-libs/protobuf/files/protobuf-3.4.0-system_libraries.patch
new file mode 100644
index 000000000000..424ad5ff58c3
--- /dev/null
+++ b/dev-libs/protobuf/files/protobuf-3.4.0-system_libraries.patch
@@ -0,0 +1,117 @@
+--- /Makefile.am
++++ /Makefile.am
+@@ -8,31 +8,12 @@
+ # the right time.
+ SUBDIRS = . src
+
+-# Always include gmock in distributions.
+-DIST_SUBDIRS = $(subdirs) src conformance benchmarks
++DIST_SUBDIRS = src conformance benchmarks
+
+-# Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS
+-# because then "make check" would also build and run all of gmock's own tests,
+-# which takes a lot of time and is generally not useful to us. Also, we don't
+-# want "make install" to recurse into gmock since we don't want to overwrite
+-# the installed version of gmock if there is one.
+ check-local:
+- @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
+- @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
+- @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
+
+-# We would like to clean gmock when "make clean" is invoked. But we have to
+-# be careful because clean-local is also invoked during "make distclean", but
+-# "make distclean" already recurses into gmock because it's listed among the
+-# DIST_SUBDIRS. distclean will delete gmock/Makefile, so if we then try to
+-# cd to the directory again and "make clean" it will fail. So, check that the
+-# Makefile exists before recursing.
+ clean-local:
+- @if test -e gmock/Makefile; then \
+- echo "Making clean in gmock"; \
+- cd gmock && $(MAKE) $(AM_MAKEFLAGS) clean; \
+- fi; \
+- if test -e conformance/Makefile; then \
++ @if test -e conformance/Makefile; then \
+ echo "Making clean in conformance"; \
+ cd conformance && $(MAKE) $(AM_MAKEFLAGS) clean; \
+ fi; \
+--- /configure.ac
++++ /configure.ac
+@@ -200,12 +200,5 @@
+
+ AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
+
+-# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
+-# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
+-# too.
+-export CFLAGS
+-export CXXFLAGS
+-AC_CONFIG_SUBDIRS([gmock])
+-
+ AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
+ AC_OUTPUT
+--- /src/Makefile.am
++++ /src/Makefile.am
+@@ -752,11 +752,7 @@
+ protobuf-lite-test test_plugin protobuf-lite-arena-test \
+ no-warning-test $(GZCHECKPROGRAMS)
+ protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \
+- -I$(srcdir)/../gmock/include
++ -lgtest -lgmock -lgmock_main
+ # Disable optimization for tests unless the user explicitly asked for it,
+ # since test_util.cc takes forever to compile with optimization (with GCC).
+ # See configure.ac for more info.
+@@ -843,12 +839,8 @@
+ # Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.
+ protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
+ libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include \
+- -DPROTOBUF_TEST_NO_DESCRIPTORS
++ -lgtest -lgmock -lgmock_main
++protobuf_lazy_descriptor_test_CPPFLAGS = -DPROTOBUF_TEST_NO_DESCRIPTORS
+ protobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lazy_descriptor_test_SOURCES = \
+ google/protobuf/compiler/cpp/cpp_unittest.cc \
+@@ -868,11 +860,7 @@
+ # full runtime and we want to make sure this test builds without full
+ # runtime.
+ protobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lite_test_CPPFLAGS= -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include
++ -lgtest -lgmock -lgmock_main
+ protobuf_lite_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lite_test_SOURCES = \
+ google/protobuf/lite_unittest.cc \
+@@ -883,11 +871,7 @@
+ # gtest when building the test internally our memory sanitizer doesn't detect
+ # memory leaks (don't know why).
+ protobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
+- ../gmock/gtest/lib/libgtest.la \
+- ../gmock/lib/libgmock.la \
+- ../gmock/lib/libgmock_main.la
+-protobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include \
+- -I$(srcdir)/../gmock/gtest/include
++ -lgtest -lgmock -lgmock_main
+ protobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
+ protobuf_lite_arena_test_SOURCES = \
+ google/protobuf/lite_arena_unittest.cc \
+@@ -896,8 +880,7 @@
+
+ # Test plugin binary.
+ test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
+- ../gmock/gtest/lib/libgtest.la
+-test_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
++ -lgtest
+ test_plugin_SOURCES = \
+ google/protobuf/compiler/mock_code_generator.cc \
+ google/protobuf/testing/file.cc \