| 1 | 
   | 
    
    # Copyright 2008-2023 Gentoo Authors 
   | 
  
   | 
  1 | 
    
    # Copyright 2008-2025 Gentoo Authors 
   | 
  
  | 2 | 
  2 | 
    
    # Distributed under the terms of the GNU General Public License v2 
   | 
  
  | 3 | 
  3 | 
    
    
   | 
  
  | 4 | 
  4 | 
    
    EAPI=8 
   | 
  
  | 5 | 
  5 | 
    
    
   | 
  
  | 6 | 
   | 
    
    inherit autotools elisp-common flag-o-matic multilib-minimal toolchain-funcs 
   | 
  
   | 
  6 | 
    
    inherit cmake-multilib elisp-common 
   | 
  
  | 7 | 
  7 | 
    
    
   | 
  
  | 8 | 
  8 | 
    
    if [[ "${PV}" == *9999 ]]; then
   | 
  
  | 9 | 
  9 | 
    
    	inherit git-r3 
   | 
  
| ... | ... |  | 
  | 12 | 
  12 | 
    
    	EGIT_SUBMODULES=() 
   | 
  
  | 13 | 
  13 | 
    
    else 
   | 
  
  | 14 | 
  14 | 
    
    	SRC_URI="https://github.com/protocolbuffers/protobuf/archive/v${PV}.tar.gz -> ${P}.tar.gz"
   | 
  
  | 15 | 
   | 
    
    	KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~x64-macos" 
   | 
  
   | 
  15 | 
    
    	KEYWORDS="~alpha amd64 arm arm64 ~loong ~mips ppc64 ~riscv x86 ~amd64-linux ~x86-linux ~x64-macos" 
   | 
  
  | 16 | 
  16 | 
    
    fi 
   | 
  
  | 17 | 
  17 | 
    
    
   | 
  
  | 18 | 
  18 | 
    
    DESCRIPTION="Google's Protocol Buffers - Extensible mechanism for serializing structured data" 
   | 
  
  | 19 | 
   | 
    
    HOMEPAGE=" 
   | 
  
  | 20 | 
   | 
    
    	https://developers.google.com/protocol-buffers/ 
   | 
  
  | 21 | 
   | 
    
    " 
   | 
  
   | 
  19 | 
    
    HOMEPAGE="https://protobuf.dev/" 
   | 
  
  | 22 | 
  20 | 
    
    
   | 
  
  | 23 | 
  21 | 
    
    LICENSE="BSD" 
   | 
  
  | 24 | 
   | 
    
    SLOT="0/32" 
   | 
  
  | 25 | 
   | 
    
    IUSE="emacs examples static-libs test zlib" 
   | 
  
   | 
  22 | 
    
    SLOT="0/3.$(ver_cut 1-2).0" 
   | 
  
   | 
  23 | 
    
    IUSE="emacs examples test zlib" 
   | 
  
  | 26 | 
  24 | 
    
    RESTRICT="!test? ( test )" 
   | 
  
  | 27 | 
  25 | 
    
    
   | 
  
  | 28 | 
  26 | 
    
    BDEPEND="emacs? ( app-editors/emacs:* )" 
   | 
  
  | 29 | 
   | 
    
    DEPEND="test? ( >=dev-cpp/gtest-1.9[${MULTILIB_USEDEP}] )
   | 
  
  | 30 | 
   | 
    
    	zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )"
   | 
  
  | 31 | 
   | 
    
    RDEPEND="emacs? ( app-editors/emacs:* ) 
   | 
  
  | 32 | 
   | 
    
    	zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )"
   | 
  
   | 
  27 | 
    
    DEPEND=" 
   | 
  
   | 
  28 | 
    
    	zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )
   | 
  
   | 
  29 | 
    
    	test? ( >=dev-cpp/gtest-1.9[${MULTILIB_USEDEP}] )
   | 
  
   | 
  30 | 
    
    " 
   | 
  
   | 
  31 | 
    
    RDEPEND=" 
   | 
  
   | 
  32 | 
    
    	emacs? ( app-editors/emacs:* ) 
   | 
  
   | 
  33 | 
    
    	zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )
   | 
  
   | 
  34 | 
    
    " 
   | 
  
  | 33 | 
  35 | 
    
    
   | 
  
  | 34 | 
  36 | 
    
    PATCHES=( 
   | 
  
  | 35 | 
   | 
    
    	"${FILESDIR}/${PN}-3.19.0-disable_no-warning-test.patch"
   | 
  
  | 36 | 
   | 
    
    	"${FILESDIR}/${PN}-3.19.0-system_libraries.patch"
   | 
  
  | 37 | 
   | 
    
    	"${FILESDIR}/${PN}-3.20.2-protoc_input_output_files.patch"
   | 
  
  | 38 | 
   | 
    
    	"${FILESDIR}/${PN}-21.9-disable-32-bit-tests.patch"
   | 
  
   | 
  37 | 
    
    	"${FILESDIR}/${PN}-23.3-disable-32-bit-tests.patch"
   | 
  
   | 
  38 | 
    
    	"${FILESDIR}/${PN}-23.3-static_assert-failure.patch"
   | 
  
  | 39 | 
  39 | 
    
    ) 
   | 
  
  | 40 | 
  40 | 
    
    
   | 
  
  | 41 | 
   | 
    
    DOCS=(CHANGES.txt CONTRIBUTORS.txt README.md) 
   | 
  
  | 42 | 
   | 
    
    
   | 
  
  | 43 | 
   | 
    
    src_prepare() {
   | 
  
  | 44 | 
   | 
    
    	default 
   | 
  
  | 45 | 
   | 
    
    
   | 
  
  | 46 | 
   | 
    
    	# https://github.com/protocolbuffers/protobuf/issues/7413 
   | 
  
  | 47 | 
   | 
    
    	sed -e "/^AC_PROG_CXX_FOR_BUILD$/d" -i configure.ac || die 
   | 
  
  | 48 | 
   | 
    
    
   | 
  
  | 49 | 
   | 
    
    	# https://github.com/protocolbuffers/protobuf/issues/8082 
   | 
  
  | 50 | 
   | 
    
    	sed -e "/^TEST_F(IoTest, LargeOutput) {$/,/^}$/d" -i src/google/protobuf/io/zero_copy_stream_unittest.cc || die
   | 
  
  | 51 | 
   | 
    
    
   | 
  
  | 52 | 
   | 
    
    	# https://github.com/protocolbuffers/protobuf/issues/8459 
   | 
  
  | 53 | 
   | 
    
    	sed \ 
   | 
  
  | 54 | 
   | 
    
    		-e "/^TEST(ArenaTest, BlockSizeSmallerThanAllocation) {$/a\\  if (sizeof(void*) == 4) {\n    GTEST_SKIP();\n  }" \
   | 
  
  | 55 | 
   | 
    
    		-e "/^TEST(ArenaTest, SpaceAllocated_and_Used) {$/a\\  if (sizeof(void*) == 4) {\n    GTEST_SKIP();\n  }" \
   | 
  
  | 56 | 
   | 
    
    		-i src/google/protobuf/arena_unittest.cc || die 
   | 
  
  | 57 | 
   | 
    
    
   | 
  
  | 58 | 
   | 
    
    	# https://github.com/protocolbuffers/protobuf/issues/8460 
   | 
  
  | 59 | 
   | 
    
    	sed -e "/^TEST(AnyTest, TestPackFromSerializationExceedsSizeLimit) {$/a\\  if (sizeof(void*) == 4) {\n    GTEST_SKIP();\n  }" -i src/google/protobuf/any_test.cc || die
   | 
  
  | 60 | 
   | 
    
    
   | 
  
  | 61 | 
   | 
    
    	# https://github.com/protocolbuffers/protobuf/issues/9433 
   | 
  
  | 62 | 
   | 
    
    	sed -e "/^[[:space:]]*static_assert(alignof(U) <= 8, \"\");$/d" -i src/google/protobuf/descriptor.cc || die 
   | 
  
  | 63 | 
   | 
    
    
   | 
  
  | 64 | 
   | 
    
    	eautoreconf 
   | 
  
  | 65 | 
   | 
    
    } 
   | 
  
  | 66 | 
   | 
    
    
   | 
  
  | 67 | 
   | 
    
    src_configure() {
   | 
  
  | 68 | 
   | 
    
    	append-cppflags -DGOOGLE_PROTOBUF_NO_RTTI 
   | 
  
  | 69 | 
   | 
    
    
   | 
  
  | 70 | 
   | 
    
    	if tc-ld-is-gold; then 
   | 
  
  | 71 | 
   | 
    
    		# https://sourceware.org/bugzilla/show_bug.cgi?id=24527 
   | 
  
  | 72 | 
   | 
    
    		tc-ld-disable-gold 
   | 
  
  | 73 | 
   | 
    
    	fi 
   | 
  
  | 74 | 
   | 
    
    
   | 
  
  | 75 | 
   | 
    
    	multilib-minimal_src_configure 
   | 
  
  | 76 | 
   | 
    
    } 
   | 
  
   | 
  41 | 
    
    DOCS=( CONTRIBUTORS.txt README.md ) 
   | 
  
  | 77 | 
  42 | 
    
    
   | 
  
  | 78 | 
  43 | 
    
    multilib_src_configure() {
   | 
  
  | 79 | 
   | 
    
    	local options=( 
   | 
  
  | 80 | 
   | 
    
    		$(use_enable static-libs static) 
   | 
  
  | 81 | 
   | 
    
    		$(use_with zlib) 
   | 
  
   | 
  44 | 
    
    	local mycmakeargs=( 
   | 
  
   | 
  45 | 
    
    		-Dprotobuf_DISABLE_RTTI=ON 
   | 
  
   | 
  46 | 
    
    		-Dprotobuf_BUILD_EXAMPLES=$(usex examples) 
   | 
  
   | 
  47 | 
    
    		-Dprotobuf_WITH_ZLIB=$(usex zlib) 
   | 
  
   | 
  48 | 
    
    		-Dprotobuf_BUILD_TESTS=$(usex test) 
   | 
  
  | 82 | 
  49 | 
    
    	) 
   | 
  
   | 
  50 | 
    
    	use test && mycmakeargs+=(-Dprotobuf_USE_EXTERNAL_GTEST=ON) 
   | 
  
  | 83 | 
  51 | 
    
    
   | 
  
  | 84 | 
   | 
    
    	if tc-is-cross-compiler; then 
   | 
  
  | 85 | 
   | 
    
    		# Build system uses protoc when building, so protoc copy runnable on host is needed. 
   | 
  
  | 86 | 
   | 
    
    		mkdir -p "${WORKDIR}/build" || die
   | 
  
  | 87 | 
   | 
    
    		pushd "${WORKDIR}/build" > /dev/null || die
   | 
  
  | 88 | 
   | 
    
    		ECONF_SOURCE="${S}" econf_build "${options[@]}"
   | 
  
  | 89 | 
   | 
    
    		options+=(--with-protoc="$(pwd)/src/protoc") 
   | 
  
  | 90 | 
   | 
    
    		popd > /dev/null || die 
   | 
  
  | 91 | 
   | 
    
    	fi 
   | 
  
  | 92 | 
   | 
    
    
   | 
  
  | 93 | 
   | 
    
    	ECONF_SOURCE="${S}" econf "${options[@]}"
   | 
  
   | 
  52 | 
    
    	cmake_src_configure 
   | 
  
  | 94 | 
  53 | 
    
    } 
   | 
  
  | 95 | 
  54 | 
    
    
   | 
  
  | 96 | 
  55 | 
    
    src_compile() {
   | 
  
  | 97 | 
   | 
    
    	multilib-minimal_src_compile 
   | 
  
   | 
  56 | 
    
    	cmake-multilib_src_compile 
   | 
  
  | 98 | 
  57 | 
    
    
   | 
  
  | 99 | 
  58 | 
    
    	if use emacs; then 
   | 
  
  | 100 | 
  59 | 
    
    		elisp-compile editors/protobuf-mode.el 
   | 
  
  | 101 | 
  60 | 
    
    	fi 
   | 
  
  | 102 | 
  61 | 
    
    } 
   | 
  
  | 103 | 
  62 | 
    
    
   | 
  
  | 104 | 
   | 
    
    multilib_src_compile() {
   | 
  
  | 105 | 
   | 
    
    	if tc-is-cross-compiler; then 
   | 
  
  | 106 | 
   | 
    
    		emake -C "${WORKDIR}/build/src" protoc
   | 
  
  | 107 | 
   | 
    
    	fi 
   | 
  
  | 108 | 
   | 
    
    
   | 
  
  | 109 | 
   | 
    
    	default 
   | 
  
  | 110 | 
   | 
    
    } 
   | 
  
  | 111 | 
   | 
    
    
   | 
  
  | 112 | 
   | 
    
    multilib_src_test() {
   | 
  
  | 113 | 
   | 
    
    	emake check 
   | 
  
  | 114 | 
   | 
    
    } 
   | 
  
  | 115 | 
   | 
    
    
   | 
  
  | 116 | 
  63 | 
    
    multilib_src_install_all() {
   | 
  
  | 117 | 
  64 | 
    
    	find "${ED}" -name "*.la" -delete || die
   | 
  
  | 118 | 
  65 | 
    
    
   |