Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/protobuf/files/, dev-libs/protobuf/
Date: Mon, 31 May 2021 23:04:13
Message-Id: 1622502099.4e8424d265ec5bc202e6661f5818c38777e6aca6.floppym@gentoo
1 commit: 4e8424d265ec5bc202e6661f5818c38777e6aca6
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Fri May 28 00:00:00 2021 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Mon May 31 23:01:39 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4e8424d2
7
8 dev-libs/protobuf: Version bump (3.16.0).
9
10 Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
11 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
12
13 dev-libs/protobuf/Manifest | 1 +
14 ...protobuf-3.16.0-protoc_input_output_files.patch | 240 +++++++++++++++++++++
15 .../files/protobuf-3.16.0-system_libraries.patch | 121 +++++++++++
16 dev-libs/protobuf/protobuf-3.16.0.ebuild | 140 ++++++++++++
17 4 files changed, 502 insertions(+)
18
19 diff --git a/dev-libs/protobuf/Manifest b/dev-libs/protobuf/Manifest
20 index 0737b49db14..42ad9a885e5 100644
21 --- a/dev-libs/protobuf/Manifest
22 +++ b/dev-libs/protobuf/Manifest
23 @@ -9,3 +9,4 @@ DIST protobuf-3.15.5.tar.gz 5283712 BLAKE2B 0da6255302014c885aee47d48344a75ee480
24 DIST protobuf-3.15.6.tar.gz 5284018 BLAKE2B 5895f618e233edd5744253821036857aa23f64b76ee3318b99f3530d9dd0c49cc8c386ef15c7394475c2bf0fa33fb631e481fa3fb927c2ab8a88af31234bd0b1 SHA512 673d61b492ce0e85f5c63f3fd7a0174737cc65f7871f79d24380bffa59ea1b312065137ecc63b0f4d4ffa3eb168a09e9c1129c21b0e6c5c3a8c2fabb2cecabb5
25 DIST protobuf-3.15.7.tar.gz 5284817 BLAKE2B 43821bb283a0c1f87930593046a5c55f6efae3f644337289fd438c0612a9b7ef9531b61e48940b74dc5d20253ee1b6a805b902284a442dec2efe8c79f82c5aad SHA512 2b18ccba1ff8a0623c52abed0e0674bc6cfa2cd10d49764031a47e68f654f54083f4a4f9e3a94d833a6808426904ee642f173641063e79cb41a61fc348d603ac
26 DIST protobuf-3.15.8.tar.gz 5285277 BLAKE2B 798fc011ac03cdc2406acf5845c667d8482082044bdace06c2c1d02b5b1b69c1b1f30e29774180dc1801a1d21d62e2ce50325105859564a1e36d3fe478e64d8b SHA512 56fc6df2dae14eee0fb67dd4204fc1ec54a18d994a69c9e42c7888d0cd50d269d1c5e1445d74f0fa705850d4ac86a22d86781e09769a716e5c6f829b15b05592
27 +DIST protobuf-3.16.0.tar.gz 5299781 BLAKE2B 9ace02a6038c31b7393671fb2ccd6a4866a3f8b7d87d2bc8371f49d65b9180f10792ca2430a83449dfa7d785a1244dac23c20756414c9d1e7c7e871a8038b123 SHA512 0191e5a6a23d03f691e883e259f6d06a0ac8eef427455bc7d1cc70b6f0ed260e4ad8f360c836fd4bdc95ec0ca314c887cbf7acbcda60e03cdfe69e4cd275bff5
28
29 diff --git a/dev-libs/protobuf/files/protobuf-3.16.0-protoc_input_output_files.patch b/dev-libs/protobuf/files/protobuf-3.16.0-protoc_input_output_files.patch
30 new file mode 100644
31 index 00000000000..7295e805a19
32 --- /dev/null
33 +++ b/dev-libs/protobuf/files/protobuf-3.16.0-protoc_input_output_files.patch
34 @@ -0,0 +1,240 @@
35 +https://github.com/protocolbuffers/protobuf/pull/235
36 +
37 +--- /src/google/protobuf/compiler/command_line_interface.cc
38 ++++ /src/google/protobuf/compiler/command_line_interface.cc
39 +@@ -1110,6 +1110,28 @@
40 + }
41 +
42 + if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) {
43 ++ bool success = false;
44 ++ int in_fd = STDIN_FILENO;
45 ++ int out_fd = STDOUT_FILENO;
46 ++
47 ++ if (!protobuf_in_path_.empty()) {
48 ++ in_fd = open(protobuf_in_path_.c_str(), O_RDONLY);
49 ++ if (in_fd == -1) {
50 ++ std::cerr << protobuf_in_path_ << ": error: failed to open file." << std::endl;
51 ++ return 1;
52 ++ }
53 ++ }
54 ++ if (!protobuf_out_path_.empty()) {
55 ++ out_fd = open(protobuf_out_path_.c_str(),
56 ++ O_WRONLY | O_CREAT | O_TRUNC,
57 ++ 0644);
58 ++ if (out_fd == -1) {
59 ++ std::cerr << protobuf_out_path_ << ": error: failed to open file." << std::endl;
60 ++ close(in_fd);
61 ++ return 1;
62 ++ }
63 ++ }
64 ++
65 + if (codec_type_.empty()) {
66 + // HACK: Define an EmptyMessage type to use for decoding.
67 + DescriptorPool pool;
68 +@@ -1118,13 +1140,20 @@
69 + file.add_message_type()->set_name("EmptyMessage");
70 + GOOGLE_CHECK(pool.BuildFile(file) != NULL);
71 + codec_type_ = "EmptyMessage";
72 +- if (!EncodeOrDecode(&pool)) {
73 +- return 1;
74 +- }
75 ++ success = EncodeOrDecode(&pool, in_fd, out_fd);
76 + } else {
77 +- if (!EncodeOrDecode(descriptor_pool.get())) {
78 +- return 1;
79 +- }
80 ++ success = EncodeOrDecode(descriptor_pool.get(), in_fd, out_fd);
81 ++ }
82 ++
83 ++ if (in_fd != STDIN_FILENO) {
84 ++ close(in_fd);
85 ++ }
86 ++ if (out_fd != STDOUT_FILENO) {
87 ++ close(out_fd);
88 ++ }
89 ++
90 ++ if (!success) {
91 ++ return 1;
92 + }
93 + }
94 +
95 +@@ -1163,6 +1192,11 @@
96 + for (int i = 0; i < proto_path_.size(); i++) {
97 + source_tree->MapPath(proto_path_[i].first, proto_path_[i].second);
98 + }
99 ++ if (mode_ == MODE_COMPILE &&
100 ++ (!protobuf_in_path_.empty() || !protobuf_out_path_.empty())) {
101 ++ std::cerr << "--protobuf_in and --protobuf_out are only valid with "
102 ++ << "decode operations. Ignoring.";
103 ++ }
104 +
105 + // Map input files to virtual paths if possible.
106 + if (!MakeInputsBeProtoPathRelative(source_tree, fallback_database)) {
107 +@@ -1885,6 +1919,12 @@
108 + } else if (name == "--deterministic_output") {
109 + deterministic_output_ = true;
110 +
111 ++ } else if (name == "--protobuf_in") {
112 ++ protobuf_in_path_ = value;
113 ++
114 ++ } else if (name == "--protobuf_out") {
115 ++ protobuf_out_path_ = value;
116 ++
117 + } else if (name == "--error_format") {
118 + if (value == "gcc") {
119 + error_format_ = ERROR_FORMAT_GCC;
120 +@@ -2018,22 +2058,38 @@
121 + --version Show version info and exit.
122 + -h, --help Show this text and exit.
123 + --encode=MESSAGE_TYPE Read a text-format message of the given type
124 +- from standard input and write it in binary
125 +- to standard output. The message type must
126 ++ from input protobuf file and write it in binary
127 ++ to output protobuf file. The message type must
128 + be defined in PROTO_FILES or their imports.
129 ++ The input/output protobuf files are specified
130 ++ using the --protobuf_in and --protobuf_out
131 ++ command line flags.
132 + --deterministic_output When using --encode, ensure map fields are
133 + deterministically ordered. Note that this order
134 + is not canonical, and changes across builds or
135 + releases of protoc.
136 + --decode=MESSAGE_TYPE Read a binary message of the given type from
137 +- standard input and write it in text format
138 +- to standard output. The message type must
139 ++ input protobuf file and write it in text format
140 ++ to output protobuf file. The message type must
141 + be defined in PROTO_FILES or their imports.
142 ++ The input/output protobuf files are specified
143 ++ using the --protobuf_in and --protobuf_out
144 ++ command line flags.
145 + --decode_raw Read an arbitrary protocol message from
146 +- standard input and write the raw tag/value
147 +- pairs in text format to standard output. No
148 ++ input protobuf file and write the raw tag/value
149 ++ pairs in text format to output protobuf file. No
150 + PROTO_FILES should be given when using this
151 +- flag.
152 ++ flag. The input/output protobuf files are
153 ++ specified using the --protobuf_in and
154 ++ --protobuf_out command line flags.
155 ++ --protobuf_in=FILE Absolute path to the protobuf file from which
156 ++ input of encoding/decoding operation will be
157 ++ read. If omitted, input will be read from
158 ++ standard input.
159 ++ --protobuf_out=FILE Absolute path to the protobuf file to which
160 ++ output of encoding/decoding operation will be
161 ++ written. If omitted, output will be written to
162 ++ standard output.
163 + --descriptor_set_in=FILES Specifies a delimited list of FILES
164 + each containing a FileDescriptorSet (a
165 + protocol buffer defined in descriptor.proto).
166 +@@ -2344,7 +2400,9 @@
167 + return true;
168 + }
169 +
170 +-bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
171 ++bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool,
172 ++ int in_fd,
173 ++ int out_fd) {
174 + // Look up the type.
175 + const Descriptor* type = pool->FindMessageTypeByName(codec_type_);
176 + if (type == NULL) {
177 +@@ -2356,15 +2414,15 @@
178 + std::unique_ptr<Message> message(dynamic_factory.GetPrototype(type)->New());
179 +
180 + if (mode_ == MODE_ENCODE) {
181 +- SetFdToTextMode(STDIN_FILENO);
182 +- SetFdToBinaryMode(STDOUT_FILENO);
183 ++ SetFdToTextMode(in_fd);
184 ++ SetFdToBinaryMode(out_fd);
185 + } else {
186 +- SetFdToBinaryMode(STDIN_FILENO);
187 +- SetFdToTextMode(STDOUT_FILENO);
188 ++ SetFdToBinaryMode(in_fd);
189 ++ SetFdToTextMode(out_fd);
190 + }
191 +
192 +- io::FileInputStream in(STDIN_FILENO);
193 +- io::FileOutputStream out(STDOUT_FILENO);
194 ++ io::FileInputStream in(in_fd);
195 ++ io::FileOutputStream out(out_fd);
196 +
197 + if (mode_ == MODE_ENCODE) {
198 + // Input is text.
199 +--- /src/google/protobuf/compiler/command_line_interface.h
200 ++++ /src/google/protobuf/compiler/command_line_interface.h
201 +@@ -292,7 +292,9 @@
202 + GeneratorContext* generator_context, std::string* error);
203 +
204 + // Implements --encode and --decode.
205 +- bool EncodeOrDecode(const DescriptorPool* pool);
206 ++ bool EncodeOrDecode(const DescriptorPool* pool,
207 ++ int in_fd,
208 ++ int out_fd);
209 +
210 + // Implements the --descriptor_set_out option.
211 + bool WriteDescriptorSet(
212 +@@ -427,6 +429,13 @@
213 + // parsed FileDescriptorSets to be used for loading protos. Otherwise, empty.
214 + std::vector<std::string> descriptor_set_in_names_;
215 +
216 ++ // When using --encode / --decode / --decode_raw absolute path to the output
217 ++ // file. (Empty string indicates write to STDOUT).
218 ++ std::string protobuf_out_path_;
219 ++ // When using --encode / --decode / --decode_raw, absolute path to the input
220 ++ // file. (Empty string indicates read from STDIN).
221 ++ std::string protobuf_in_path_;
222 ++
223 + // If --descriptor_set_out was given, this is the filename to which the
224 + // FileDescriptorSet should be written. Otherwise, empty.
225 + std::string descriptor_set_out_name_;
226 +--- /src/google/protobuf/compiler/command_line_interface_unittest.cc
227 ++++ /src/google/protobuf/compiler/command_line_interface_unittest.cc
228 +@@ -99,7 +99,7 @@
229 + virtual void SetUp();
230 + virtual void TearDown();
231 +
232 +- // Runs the CommandLineInterface with the given command line. The
233 ++ // Run the CommandLineInterface with the given command line. The
234 + // command is automatically split on spaces, and the string "$tmpdir"
235 + // is replaced with TestTempDir().
236 + void Run(const std::string& command);
237 +@@ -2626,6 +2626,17 @@
238 + std::string::npos);
239 + }
240 +
241 ++ void ExpectBinaryFilesMatch(const string &expected_file,
242 ++ const string &actual_file) {
243 ++ string expected_output, actual_output;
244 ++ ASSERT_TRUE(File::ReadFileToString(expected_file, &expected_output));
245 ++ ASSERT_TRUE(File::ReadFileToString(actual_file, &actual_output));
246 ++
247 ++ // Don't use EXPECT_EQ because we don't want to print raw binary data to
248 ++ // stdout on failure.
249 ++ EXPECT_TRUE(expected_output == actual_output);
250 ++ }
251 ++
252 + private:
253 + void WriteUnittestProtoDescriptorSet() {
254 + unittest_proto_descriptor_set_filename_ =
255 +@@ -2749,6 +2760,19 @@
256 + "Can only use --deterministic_output with --encode.\n");
257 + }
258 +
259 ++TEST_P(EncodeDecodeTest, RedirectInputOutput) {
260 ++ string out_file = TestTempDir() + "/golden_message_out.pbf";
261 ++ EXPECT_TRUE(
262 ++ Run(TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto") +
263 ++ " --encode=protobuf_unittest.TestAllTypes" +
264 ++ " --protobuf_in=" + TestUtil::GetTestDataPath(
265 ++ "net/proto2/internal/"
266 ++ "testdata/text_format_unittest_data_oneof_implemented.txt") +
267 ++ " --protobuf_out=" + out_file));
268 ++ ExpectBinaryFilesMatch(out_file, TestUtil::GetTestDataPath(
269 ++ "net/proto2/internal/testdata/golden_message_oneof_implemented"));
270 ++}
271 ++
272 + INSTANTIATE_TEST_SUITE_P(FileDescriptorSetSource, EncodeDecodeTest,
273 + testing::Values(PROTO_PATH, DESCRIPTOR_SET_IN));
274 + } // anonymous namespace
275
276 diff --git a/dev-libs/protobuf/files/protobuf-3.16.0-system_libraries.patch b/dev-libs/protobuf/files/protobuf-3.16.0-system_libraries.patch
277 new file mode 100644
278 index 00000000000..5b6f4101e9c
279 --- /dev/null
280 +++ b/dev-libs/protobuf/files/protobuf-3.16.0-system_libraries.patch
281 @@ -0,0 +1,121 @@
282 +--- /Makefile.am
283 ++++ /Makefile.am
284 +@@ -11,28 +11,10 @@
285 + # Always include third_party directories in distributions.
286 + DIST_SUBDIRS = src conformance benchmarks third_party/googletest
287 +
288 +-# Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS
289 +-# because then "make check" would also build and run all of gmock's own tests,
290 +-# which takes a lot of time and is generally not useful to us. Also, we don't
291 +-# want "make install" to recurse into gmock since we don't want to overwrite
292 +-# the installed version of gmock if there is one.
293 + check-local:
294 +- @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
295 +- @cd third_party/googletest/googletest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
296 +- @cd third_party/googletest/googlemock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
297 +
298 +-# We would like to clean gmock when "make clean" is invoked. But we have to
299 +-# be careful because clean-local is also invoked during "make distclean", but
300 +-# "make distclean" already recurses into gmock because it's listed among the
301 +-# DIST_SUBDIRS. distclean will delete gmock/Makefile, so if we then try to
302 +-# cd to the directory again and "make clean" it will fail. So, check that the
303 +-# Makefile exists before recursing.
304 + clean-local:
305 +- @if test -e third_party/googletest/Makefile; then \
306 +- echo "Making clean in googletest"; \
307 +- cd third_party/googletest && $(MAKE) $(AM_MAKEFLAGS) clean; \
308 +- fi; \
309 +- if test -e conformance/Makefile; then \
310 ++ @if test -e conformance/Makefile; then \
311 + echo "Making clean in conformance"; \
312 + cd conformance && $(MAKE) $(AM_MAKEFLAGS) clean; \
313 + fi; \
314 +--- /configure.ac
315 ++++ /configure.ac
316 +@@ -236,12 +236,5 @@
317 + fi
318 + AC_SUBST([LIBLOG_LIBS])
319 +
320 +-# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
321 +-# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
322 +-# too.
323 +-export CFLAGS
324 +-export CXXFLAGS
325 +-AC_CONFIG_SUBDIRS([third_party/googletest])
326 +-
327 + AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
328 + AC_OUTPUT
329 +--- /src/Makefile.am
330 ++++ /src/Makefile.am
331 +@@ -703,19 +703,11 @@
332 + google/protobuf/testing/file.cc \
333 + google/protobuf/testing/file.h
334 +
335 +-GOOGLETEST_BUILD_DIR=../third_party/googletest/googletest
336 +-GOOGLEMOCK_BUILD_DIR=../third_party/googletest/googlemock
337 +-GOOGLETEST_SRC_DIR=$(srcdir)/../third_party/googletest/googletest
338 +-GOOGLEMOCK_SRC_DIR=$(srcdir)/../third_party/googletest/googlemock
339 + check_PROGRAMS = protoc protobuf-test protobuf-lazy-descriptor-test \
340 + protobuf-lite-test test_plugin protobuf-lite-arena-test \
341 + $(GZCHECKPROGRAMS)
342 + protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
343 +- $(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
344 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
345 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
346 +-protobuf_test_CPPFLAGS = -I$(GOOGLETEST_SRC_DIR)/include \
347 +- -I$(GOOGLEMOCK_SRC_DIR)/include
348 ++ -lgtest -lgmock -lgmock_main
349 + # Disable optimization for tests unless the user explicitly asked for it,
350 + # since test_util.cc takes forever to compile with optimization (with GCC).
351 + # See configure.ac for more info.
352 +@@ -807,12 +799,8 @@
353 + # Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.
354 + protobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
355 + libprotoc.la \
356 +- $(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
357 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
358 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
359 +-protobuf_lazy_descriptor_test_CPPFLAGS = -I$(GOOGLEMOCK_SRC_DIR)/include \
360 +- -I$(GOOGLETEST_SRC_DIR)/include \
361 +- -DPROTOBUF_TEST_NO_DESCRIPTORS
362 ++ -lgtest -lgmock -lgmock_main
363 ++protobuf_lazy_descriptor_test_CPPFLAGS = -DPROTOBUF_TEST_NO_DESCRIPTORS
364 + protobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
365 + protobuf_lazy_descriptor_test_SOURCES = \
366 + google/protobuf/compiler/cpp/cpp_unittest.cc \
367 +@@ -833,11 +821,7 @@
368 + # full runtime and we want to make sure this test builds without full
369 + # runtime.
370 + protobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
371 +- $(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
372 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
373 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
374 +-protobuf_lite_test_CPPFLAGS= -I$(GOOGLEMOCK_SRC_DIR)/include \
375 +- -I$(GOOGLETEST_SRC_DIR)/include
376 ++ -lgtest -lgmock -lgmock_main
377 + protobuf_lite_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
378 + protobuf_lite_test_SOURCES = \
379 + google/protobuf/lite_unittest.cc \
380 +@@ -849,11 +833,7 @@
381 + # gtest when building the test internally our memory sanitizer doesn't detect
382 + # memory leaks (don't know why).
383 + protobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \
384 +- $(GOOGLETEST_BUILD_DIR)/lib/libgtest.la \
385 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock.la \
386 +- $(GOOGLEMOCK_BUILD_DIR)/lib/libgmock_main.la
387 +-protobuf_lite_arena_test_CPPFLAGS = -I$(GOOGLEMOCK_SRC_DIR)/include \
388 +- -I$(GOOGLETEST_SRC_DIR)/include
389 ++ -lgtest -lgmock -lgmock_main
390 + protobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
391 + protobuf_lite_arena_test_SOURCES = \
392 + google/protobuf/lite_arena_unittest.cc \
393 +@@ -863,8 +843,7 @@
394 +
395 + # Test plugin binary.
396 + test_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
397 +- $(GOOGLETEST_BUILD_DIR)/lib/libgtest.la
398 +-test_plugin_CPPFLAGS = -I$(GOOGLETEST_SRC_DIR)/include
399 ++ -lgtest
400 + test_plugin_SOURCES = \
401 + google/protobuf/compiler/mock_code_generator.cc \
402 + google/protobuf/testing/file.cc \
403
404 diff --git a/dev-libs/protobuf/protobuf-3.16.0.ebuild b/dev-libs/protobuf/protobuf-3.16.0.ebuild
405 new file mode 100644
406 index 00000000000..ed6e85a966f
407 --- /dev/null
408 +++ b/dev-libs/protobuf/protobuf-3.16.0.ebuild
409 @@ -0,0 +1,140 @@
410 +# Copyright 2008-2021 Gentoo Authors
411 +# Distributed under the terms of the GNU General Public License v2
412 +
413 +EAPI="7"
414 +
415 +inherit autotools elisp-common flag-o-matic multilib-minimal toolchain-funcs
416 +
417 +if [[ "${PV}" == "9999" ]]; then
418 + inherit git-r3
419 +
420 + EGIT_REPO_URI="https://github.com/protocolbuffers/protobuf"
421 + EGIT_SUBMODULES=()
422 +fi
423 +
424 +DESCRIPTION="Google's Protocol Buffers - Extensible mechanism for serializing structured data"
425 +HOMEPAGE="https://developers.google.com/protocol-buffers/ https://github.com/protocolbuffers/protobuf"
426 +if [[ "${PV}" == "9999" ]]; then
427 + SRC_URI=""
428 +else
429 + SRC_URI="https://github.com/protocolbuffers/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
430 +fi
431 +
432 +LICENSE="BSD"
433 +SLOT="0/27"
434 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos"
435 +IUSE="emacs examples static-libs test zlib"
436 +RESTRICT="!test? ( test )"
437 +
438 +BDEPEND="emacs? ( app-editors/emacs:* )"
439 +DEPEND="test? ( >=dev-cpp/gtest-1.9[${MULTILIB_USEDEP}] )
440 + zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )"
441 +RDEPEND="emacs? ( app-editors/emacs:* )
442 + zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )"
443 +
444 +PATCHES=(
445 + "${FILESDIR}/${PN}-3.15.0-disable_no-warning-test.patch"
446 + "${FILESDIR}/${PN}-3.16.0-system_libraries.patch"
447 + "${FILESDIR}/${PN}-3.16.0-protoc_input_output_files.patch"
448 +)
449 +
450 +DOCS=(CHANGES.txt CONTRIBUTORS.txt README.md)
451 +
452 +src_prepare() {
453 + default
454 +
455 + # https://github.com/protocolbuffers/protobuf/issues/7413
456 + sed -e "/^AC_PROG_CXX_FOR_BUILD$/d" -i configure.ac || die
457 +
458 + # https://github.com/protocolbuffers/protobuf/issues/8082
459 + sed -e "/^TEST_F(IoTest, LargeOutput) {$/,/^}$/d" -i src/google/protobuf/io/zero_copy_stream_unittest.cc || die
460 +
461 + # https://github.com/protocolbuffers/protobuf/issues/8459
462 + sed \
463 + -e "/^TEST(ArenaTest, BlockSizeSmallerThanAllocation) {$/a\\ if (sizeof(void*) == 4) {\n GTEST_SKIP();\n }" \
464 + -e "/^TEST(ArenaTest, SpaceAllocated_and_Used) {$/a\\ if (sizeof(void*) == 4) {\n GTEST_SKIP();\n }" \
465 + -i src/google/protobuf/arena_unittest.cc || die
466 +
467 + # https://github.com/protocolbuffers/protobuf/issues/8460
468 + sed -e "/^TEST(AnyTest, TestPackFromSerializationExceedsSizeLimit) {$/a\\ if (sizeof(void*) == 4) {\n GTEST_SKIP();\n }" -i src/google/protobuf/any_test.cc || die
469 +
470 + eautoreconf
471 +}
472 +
473 +src_configure() {
474 + append-cppflags -DGOOGLE_PROTOBUF_NO_RTTI
475 +
476 + if tc-ld-is-gold; then
477 + # https://sourceware.org/bugzilla/show_bug.cgi?id=24527
478 + tc-ld-disable-gold
479 + fi
480 +
481 + multilib-minimal_src_configure
482 +}
483 +
484 +multilib_src_configure() {
485 + local options=(
486 + $(use_enable static-libs static)
487 + $(use_with zlib)
488 + )
489 +
490 + if tc-is-cross-compiler; then
491 + # Build system uses protoc when building, so protoc copy runnable on host is needed.
492 + mkdir -p "${WORKDIR}/build" || die
493 + pushd "${WORKDIR}/build" > /dev/null || die
494 + ECONF_SOURCE="${S}" econf_build "${options[@]}"
495 + options+=(--with-protoc="$(pwd)/src/protoc")
496 + popd > /dev/null || die
497 + fi
498 +
499 + ECONF_SOURCE="${S}" econf "${options[@]}"
500 +}
501 +
502 +src_compile() {
503 + multilib-minimal_src_compile
504 +
505 + if use emacs; then
506 + elisp-compile editors/protobuf-mode.el
507 + fi
508 +}
509 +
510 +multilib_src_compile() {
511 + if tc-is-cross-compiler; then
512 + emake -C "${WORKDIR}/build/src" protoc
513 + fi
514 +
515 + default
516 +}
517 +
518 +multilib_src_test() {
519 + emake check
520 +}
521 +
522 +multilib_src_install_all() {
523 + find "${ED}" -name "*.la" -delete || die
524 +
525 + insinto /usr/share/vim/vimfiles/syntax
526 + doins editors/proto.vim
527 + insinto /usr/share/vim/vimfiles/ftdetect
528 + doins "${FILESDIR}/proto.vim"
529 +
530 + if use emacs; then
531 + elisp-install ${PN} editors/protobuf-mode.el*
532 + elisp-site-file-install "${FILESDIR}/70${PN}-gentoo.el"
533 + fi
534 +
535 + if use examples; then
536 + DOCS+=(examples)
537 + docompress -x /usr/share/doc/${PF}/examples
538 + fi
539 +
540 + einstalldocs
541 +}
542 +
543 +pkg_postinst() {
544 + use emacs && elisp-site-regen
545 +}
546 +
547 +pkg_postrm() {
548 + use emacs && elisp-site-regen
549 +}