Add protoc patch from Chromium OS & sent upstream.
authorMike Frysinger <vapier@gentoo.org>
Tue, 10 Mar 2015 21:11:03 +0000 (21:11 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 10 Mar 2015 21:11:03 +0000 (21:11 +0000)
Package-Manager: portage-2.2.18/cvs/Linux x86_64
Manifest-Sign-Key: 0xD2E96200

dev-libs/protobuf/ChangeLog
dev-libs/protobuf/Manifest
dev-libs/protobuf/files/protobuf-2.6.1-protoc-cmdline.patch [new file with mode: 0644]
dev-libs/protobuf/protobuf-2.6.1-r3.ebuild [new file with mode: 0644]

index 2ef68893495b9ada05d4e65044e7b5b3d82bdfbf..08c0a00d286fc76a102c2e8cef038fe57ffc92a6 100644 (file)
@@ -1,6 +1,12 @@
 # ChangeLog for dev-libs/protobuf
 # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-libs/protobuf/ChangeLog,v 1.80 2015/03/10 17:58:44 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/protobuf/ChangeLog,v 1.81 2015/03/10 21:11:02 vapier Exp $
+
+*protobuf-2.6.1-r3 (10 Mar 2015)
+
+  10 Mar 2015; Mike Frysinger <vapier@gentoo.org>
+  +files/protobuf-2.6.1-protoc-cmdline.patch, +protobuf-2.6.1-r3.ebuild:
+  Add protoc patch from Chromium OS & sent upstream.
 
   10 Mar 2015; Mike Frysinger <vapier@gentoo.org> protobuf-2.6.1-r2.ebuild:
   Add arm64/sh love. Add cross-compile support #432106 by Dennis Schridde.
index 146b03b55883f621c551929afa98ff66c4203397..4079ea15a226fea63d882810623ac86f42dbd6d0 100644 (file)
@@ -6,6 +6,7 @@ AUX proto.vim 49 SHA256 17e7773363e3f5469c717e4173a6f6fa959a6bb30c6ee71f3bdeee15
 AUX protobuf-2.3.0-asneeded-2.patch 705 SHA256 558ea98a54e544919837f88d133b8887ad5101b4493a62737d3cea94ae58464c SHA512 2f9d047ac64ac19bab2a793990de5070ac24604bf81622520a1f9b2e86aecbd125c9cba5b62bc7e296ecc3724069dbd9b07f7d7292be280403fc37af5c52cccf WHIRLPOOL 0b943cdda7feac71d394a9e72bdcbe1dfc3d7efb390496244cf511cbd1468b4b11d9f42501a62fe02b2fab7b4bf0867eb5739cb02af8d4777d22fe781ccd841e
 AUX protobuf-2.5.0-emacs-24.4.patch 408 SHA256 1ca039e40ad6379302aeb1a2eb5391c66cef07a5e8e670fa4bac5bfa5fc4e3fb SHA512 243d468780ab65911d791f09f7584287cc4a4b368f7fb3ce517ef01345f1cf26ea5a4c2b264b857aaf5b0c110ff18a22b96020f0602019eae5bd9ddc8526e93b WHIRLPOOL 57a83062ffde2ebb2641899cc7dad57fda929a51d3c194db188dc3f53548c15ba4564eefcb13435d848a57d1ae5cfca6036e65a2987e3590c34f2e85536e2e77
 AUX protobuf-2.5.0-x32.patch 677 SHA256 8a4378b5b84cf1b91e88344eead7c3e8f3ae848540e7a850bff48994704e8752 SHA512 fa28941ff21785505f616e4da4be964e18de5d52a25224059431054ad7853693ca4281819d690e76eb4064d9d7b729eb1ad10388d43d437b975e62b66f5de1bc WHIRLPOOL 2ae6b2dd9c6d9f63ae2d8caa630e4720d66a30ac3e21bf135f10d4b567a08fecd8757b575a749a95050c6b673b787c09b18f48452cc7d0eaa019b8aa5903d3d4
+AUX protobuf-2.6.1-protoc-cmdline.patch 11184 SHA256 c931fcf5b0484d41465e9bc11598379fcdc85d58a882ea209795e5858b5fb4b4 SHA512 17855acd577412866e6e0a515e4dd754ae5aa9e75a9fdd44bb80f4061b28bda1bee5a45671819021ac1487852c20e2404f79ef13b711140cf204cbfb6142ad36 WHIRLPOOL 310f58414cc6ae642d19e29dedce7c6f2d6ae3e0962d526b7421ccf37078372ad046b29206336794898c9ee8f22cc08f0b441db44538174ef19ba50c45513af9
 DIST protobuf-2.4.0a.tar.bz2 1508837 SHA256 cef863023fb051b0f7e8f47b53fe57f7277a7743d644eae9563fb14db5bd7e4e SHA512 c099f75983a79a4fdc2c3bf44e748074000903fe89e65a74caebe191dbb46da01b3b023b5f4f1fec86f35f15c16d5863cad102ebc0c975f4c4662ab64694d9db WHIRLPOOL 5fe8b4aadefceadfcf42aee54d4133ada2c52a9f4e90e0cbe8ba1a92c887bc12c4e9eec6b2df68ab252dbe9358a85a789804c0d1f5612d62e6c03ebf380c5100
 DIST protobuf-2.4.1.tar.bz2 1440188 SHA256 cf8452347330834bbf9c65c2e68b5562ba10c95fa40d4f7ec0d2cb332674b0bf SHA512 52b0208c685e44126cb3915a74bde692ef91430f0407144b6c30b72a9f143b1ee4f1eea47a550184c689a1758b92582e7f26f0683c2d387205b957a69830f2f3 WHIRLPOOL e5462ff35f63413aff58640c24b9b561ac55749c489803ae009de21bf5d954a77516714361353ef02cfeb3c2d762620c89dc08a5fdee571e3a33b6f5c20edf6e
 DIST protobuf-2.5.0.tar.bz2 1866763 SHA256 13bfc5ae543cf3aa180ac2485c0bc89495e3ae711fc6fab4f8ffe90dfb4bb677 SHA512 5994b3669808b82fef5c860ecad36358c0767f84acac877e7bfcf722e59d972835a955714149bdd4158fbd1328a51d01397a563991d26475351ee72be48142ee WHIRLPOOL 7e6786e1f20bf253d0e386a95c2bbfe1b443f484d492f97552cadcea62c24461436aa88130e3ff20b4dc9f352c101458cb8c03686f1cc4e6e2133b6e78f5b70d
@@ -20,23 +21,24 @@ EBUILD protobuf-2.5.0.ebuild 2895 SHA256 7b68cf03751b6e799fc721746133e7fa4327834
 EBUILD protobuf-2.6.0.ebuild 2997 SHA256 8e7a679c4b2f353305c79cbe42eb59bb39138b2e6fdee6e03c8861cacbd9ea42 SHA512 00eaa39d421ce1c1a0f785d152f176714b585d24a7eea8f0248d37a58828b78927f3d6d34b6d15614b654afa8f74a30a07fb53bbdfdaaa4c3e9e8b4defadac1e WHIRLPOOL ef38db8a47623bf58cd353566307dcc602562caedb69f5c41680ba0070dc2b87d1534ae3ff6138d9206bd3f46f0e9f7e8d06f09e079d21953393eb16e420fde9
 EBUILD protobuf-2.6.1-r1.ebuild 3337 SHA256 cc3e48567a7e953bfd2cc825e7542e1c39581ed967a5c1831e4969fa57d527c8 SHA512 de3a31a1172280fa5a3fbb9b2ae930498549be290b004b17b5df736a5aaea9ca0c8dfb9d164980c6e8766179dba697c2969e2ddcc6281dcc4de9049a0544fcea WHIRLPOOL c09728fa06d082cae72dc8b349141a31c4e270e5cfc6c77252fd42a028d08a259794c0535f2fa22e51cf2ef5a15f7e0862d35e3e8a89a60bf127fa8a2dddc540
 EBUILD protobuf-2.6.1-r2.ebuild 4041 SHA256 d211e5077378c3021b69e61296e65fbbd527d3a0f377e55ef787b8a0905b91b2 SHA512 6f491877cd41ddcf5ea872f35243157ee7a73a370af14e55a5d9671ea058fdcae909ccecd5408a79811270a615bdbb3fdcdec98fbb1f10537c527c82892e75d6 WHIRLPOOL 1142de82a9e332cba3305d146f7faa3255affa0650eeecf9f600dafaae73dab91ec47cad22debd01f47b8136eb94d33d520fd24c27482cec838bdcd33c4713d4
+EBUILD protobuf-2.6.1-r3.ebuild 4096 SHA256 55cbb5fe9149b321e96463d39eb167ea27503134f0701d88e6518242c7fd77fc SHA512 8c722152334075febecd2f2dfa9a8d9bd702a07b26f16837ffea443519361a1d8dab73500baf3c46bf8290bab76d0e41e2737a5ec3cbc87a2c328aca111d6c25 WHIRLPOOL 700f6b43d0dd131d15a940006a3798c643d30acd15391132f65bb641fd7d1933277ffde1b9b8c73101702c11b1cc78c74f855ec4475e9aaf426f5babefbae8c7
 EBUILD protobuf-2.6.1.ebuild 3016 SHA256 4eeb189f80d262542237155d9bd6f82954159a4bb115e4afed0c7e580ccb80e8 SHA512 b98cf5ebd67b82e565cd81f41fbfbf2bce05375e00999f494b7d8f518001476ee42c7eccf21ce2d0bd5f01cb7db611779eb77207cee2e921c03250561a3ef3eb WHIRLPOOL 45a1a31272750d1071030d240a37150c3bad9a9c4bee0fca7719bd9e583b7a9df98356e53f0034232e454161fb925d8f7d119380fde133588a1016f43be0d8b5
-MISC ChangeLog 11352 SHA256 1e15142dbb11bf9a42381aaf6013f1330c1d3ce642a789fd71fc7a943fecf975 SHA512 8c01a26ca049245aaee07f66d53c6b4d3eb7408d86efb6f8f352059a3bfead88dcd280c1882f81c55c52776b83132bb60853a4cdf532600c0218b1da5e430679 WHIRLPOOL e9fe5ae4a5bd7105d8084f2fb98a20ebb242742c6177e6225494211818ec6e42fc170f402026d2b48564823ec369725e410b05576c0b657cab3020a7a3e5d5ad
+MISC ChangeLog 11563 SHA256 cf9b68dfa7620b8ba8c58606c379bd74c98d9a9dbd67aef227706c152346c5b1 SHA512 e0f3e2d56cb13ae60196a40664cfe814e8bdc949d3d8bb46e0aedc4004d53462b305ab6ac360466591970999710a9595c88d214b1eabe2e1d759eb5242155366 WHIRLPOOL 6a3ea24146aea1c16bb23d184c09b27dbcc121493c222a81339ddfb6ad762d6761d859e278809287f92180a77bacb9b880a904fe4f60b9f5be80433a2a932337
 MISC metadata.xml 310 SHA256 ded221b688b4ab4cd456b3036ee01a31add94142274b764939cc61e80ffebeb3 SHA512 eceedb3555bfc87b1b18c092aac4b79e53d5ea6eaa250e203e51e362bf63db29ed0c23725a276343cd78af56ae2ecbacab96c9ad1d0221b17d0560b85e5c1eda WHIRLPOOL a04e0304a373392f179b8a782719adf2d812cbd170c8eee33dc1ad178b8b09497b57a555fcb4288d104713e586346817166b6f8940661946cd71f928c52706ae
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
-iQIcBAEBCAAGBQJU/zDWAAoJEPGu1DbS6WIAA/8QAIIoWMw2AZtG86sKg0nziZBH
-sloHo/cPqLYj/xR9vPW+cO1Q6uG3XlZlYrDTcBOS1MfW/fRMqKHLJn0zm6FaavEr
-dgq80bX+jzMGMmN1AGGAL8N83VqjPNwa3gHmEF6iZWOobMjv5S2eywIK/uGRcNht
-3mXAoKVMQF6GWZrHQi2w22lovfyxqnfsH0vqcEjNnEMue565zmNUdpSPVVUvwiPK
-o7rQAC+0gbTgBzR2WjzV7ByYDmcRSIi5N1sVWsuviWy9uC3EQxQK14KjkAx1Fc7g
-Kv1sr0xuK5QavxriUXvidRJaiHOp62UwP/vT2XJ9R7bPtqNHI1SWU/dqEsMjV3CK
-ebWpkCFujpiHotBWD261RrPzNybiHOYitbvc44KBKG5lhQkCMaUr7Efhn23ONybr
-BUyd70PukKJ77a7bQOk/y0jlE8uX5zj3Gvu+IqkOZjgoBNV+POkkATglZToPT6xp
-wGywbs7x9zSrGdq2EK+se4fvSGA/ABewGDzcKo5MN3j+b2sM1uazbVo4lHUs2ZPn
-Gm5bJeB7c3nSlrHn9O56d/jh9tPNNHftwhPaGzNQmA6duM4kTGYBxnyyz0Nd6r/o
-VnrSJkpl5V9Ivzq3/DWWmi9b6VCbo1XRkX4kHlc244gXVXUDMJ06vSvsw0kgTDL4
-BvFh9nabj+wyBs0bD1cy
-=9XFv
+iQIcBAEBCAAGBQJU/13nAAoJEPGu1DbS6WIAPNYP/1CB+/p/vXL2XwIEUXyU1Ng5
+eFm60nPNmYkL0c5HueFzjhPB/pKxQG1ZHuJ3Dmxhp0lHTx2S7COVLryFVXIBu9Fd
+SeK+zFVc06IBwsZgMLq4t6OnNazNR3nDnJ94NXpPaYF+87nboehTeea69irGs6jY
+EPqWhTs44QTYJXpy/xannMapruo4m3af4UyluFvqIQ22oEkGc7exujP+vjFBnaJB
+GZFwZg9dmt4cwE8qFo99yiTXQ7JaWwyw6HE6CuAvIxA0XGxu2tWd6PT2aAlTt3Xs
+uIQqnt0qxqCnZIHiObOIcUR9qUTUpg7vKqS1TeEZXb0xpOQaJKtsAH1AIIQqNkjl
+hPj8jhUSaAQ6W+VGhxbM875p8eMQ4HXSbDjRhgEORAijEw5YngBg+Kogsj3dYe3A
+HOH7/Vz2fnw+ScaOGGmHWXu403RUlC00oLwQhCY9WNmx8W72xdAQww3VaZ/viFw/
+yPchYwmAOwAQ070dYElzzBZeOOA475PPMjJvv041hMCeHuScQh5hR5dFPOWPFB28
+4l1tt2W8XonQX7UaTLsYjFe5WUgP4q1HYnJoV+rg/saOuXYGLbeEV3fkeT5atUTs
+ac1elOuQgXPO/t18hepWZKn8RT3MgQDcrR7PyRo9mFSZchSzKc9+/5TwqfJTgMdv
+BXmkeroxBlckNw5Rcm06
+=pyzL
 -----END PGP SIGNATURE-----
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 (file)
index 0000000..60151e8
--- /dev/null
@@ -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.txt ";
++  cmd += "--protobuf_out=" + out_file;
++  EXPECT_TRUE(Run(cmd));
++  ExpectBinaryFilesMatch(out_file, "google/protobuf/testdata/golden_message");
++}
++
+ }  // anonymous namespace
+ 
+ }  // namespace compiler
+-- 
+2.3.1
+
diff --git a/dev-libs/protobuf/protobuf-2.6.1-r3.ebuild b/dev-libs/protobuf/protobuf-2.6.1-r3.ebuild
new file mode 100644 (file)
index 0000000..736bc67
--- /dev/null
@@ -0,0 +1,158 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/protobuf/protobuf-2.6.1-r3.ebuild,v 1.1 2015/03/10 21:11:02 vapier Exp $
+
+EAPI=5
+AUTOTOOLS_AUTORECONF=1
+AUTOTOOLS_PRUNE_LIBTOOL_FILES=all
+JAVA_PKG_IUSE="source"
+PYTHON_COMPAT=( python2_7 )
+DISTUTILS_OPTIONAL=1
+
+inherit autotools-multilib eutils flag-o-matic toolchain-funcs distutils-r1 java-pkg-opt-2 elisp-common
+
+DESCRIPTION="Google's Protocol Buffers -- an efficient method of encoding structured data"
+HOMEPAGE="http://code.google.com/p/protobuf/ https://github.com/google/protobuf/"
+SRC_URI="https://github.com/google/${PN}/releases/download/${PV}/${P}.tar.bz2"
+
+LICENSE="Apache-2.0"
+SLOT="0/9" # subslot = soname major version
+KEYWORDS="~amd64 ~arm ~arm64 -hppa ~ia64 ~mips -ppc -ppc64 ~sh ~x86 ~amd64-linux ~arm-linux ~x86-linux ~x64-macos ~x86-macos"
+IUSE="emacs examples java python static-libs vim-syntax zlib"
+
+CDEPEND="emacs? ( virtual/emacs )
+       python? ( ${PYTHON_DEPS} )
+       zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
+DEPEND="${CDEPEND}
+       java? ( >=virtual/jdk-1.5 )
+       python? (
+               dev-python/google-apputils[${PYTHON_USEDEP}]
+               dev-python/setuptools[${PYTHON_USEDEP}]
+       )"
+RDEPEND="${CDEPEND}
+       java? ( >=virtual/jre-1.5 )"
+
+src_prepare() {
+       append-cxxflags -DGOOGLE_PROTOBUF_NO_RTTI
+
+       # breaks Darwin, bug #472514
+       [[ ${CHOST} != *-darwin* ]] && epatch "${FILESDIR}"/${PN}-2.3.0-asneeded-2.patch
+
+       # fix build with emacs-24.4 (bug #524100)
+       epatch "${FILESDIR}"/${PN}-2.5.0-emacs-24.4.patch
+       epatch "${FILESDIR}"/${PN}-2.6.1-protoc-cmdline.patch
+
+       autotools-multilib_src_prepare
+
+       if use python; then
+               cd python && distutils-r1_src_prepare
+       fi
+}
+
+src_configure() {
+       local myeconfargs=(
+               $(use_with zlib)
+       )
+
+       if tc-is-cross-compiler; then
+               # The build system wants `protoc` when building, so we need a copy that
+               # runs on the host.  This is more hermetic than relying on the version
+               # installed in the host being the exact same version.
+               mkdir -p "${WORKDIR}"/build || die
+               pushd "${WORKDIR}"/build >/dev/null
+               ECONF_SOURCE=${S} econf_build "${myeconfargs[@]}"
+               myeconfargs+=( --with-protoc="${PWD}"/src/protoc )
+               popd >/dev/null
+       fi
+
+       autotools-multilib_src_configure
+}
+
+multilib_src_compile() {
+       default
+
+       if multilib_is_native_abi; then
+               if use python; then
+                       einfo "Compiling Python library ..."
+                       pushd "${S}"/python >/dev/null
+                       PROTOC="${BUILD_DIR}"/src/protoc distutils-r1_src_compile
+                       popd >/dev/null
+               fi
+
+               if use java; then
+                       einfo "Compiling Java library ..."
+                       pushd "${S}" >/dev/null
+                       "${BUILD_DIR}"/src/protoc --java_out=java/src/main/java --proto_path=src src/google/protobuf/descriptor.proto
+                       mkdir java/build
+                       pushd java/src/main/java >/dev/null
+                       ejavac -d ../../../build $(find . -name '*.java') || die "java compilation failed"
+                       popd >/dev/null
+                       jar cf ${PN}.jar -C java/build . || die "jar failed"
+                       popd >/dev/null
+               fi
+       fi
+}
+
+src_compile() {
+       if tc-is-cross-compiler; then
+               emake -C "${WORKDIR}"/build/src protoc
+       fi
+
+       autotools-multilib_src_compile
+
+       if use emacs; then
+               elisp-compile "${S}"/editors/protobuf-mode.el
+       fi
+}
+
+src_test() {
+       autotools-multilib_src_test check
+
+       if use python; then
+               pushd python >/dev/null
+               distutils-r1_src_test
+               popd >/dev/null
+       fi
+}
+
+src_install() {
+       autotools-multilib_src_install
+
+       dodoc CHANGES.txt CONTRIBUTORS.txt README.md
+
+       if use python; then
+               pushd python >/dev/null
+               distutils-r1_src_install
+               popd >/dev/null
+       fi
+
+       if use java; then
+               java-pkg_dojar ${PN}.jar
+               use source && java-pkg_dosrc java/src/main/java/*
+       fi
+
+       if use vim-syntax; then
+               insinto /usr/share/vim/vimfiles/syntax
+               doins editors/proto.vim
+               insinto /usr/share/vim/vimfiles/ftdetect/
+               doins "${FILESDIR}"/proto.vim
+       fi
+
+       if use emacs; then
+               elisp-install ${PN} editors/protobuf-mode.el*
+               elisp-site-file-install "${FILESDIR}"/70${PN}-gentoo.el
+       fi
+
+       if use examples; then
+               dodoc -r examples
+               docompress -x /usr/share/doc/${PF}/examples
+       fi
+}
+
+pkg_postinst() {
+       use emacs && elisp-site-regen
+}
+
+pkg_postrm() {
+       use emacs && elisp-site-regen
+}