xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-oe/recipes-devtools/protobuf/protobuf_3.19.6.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1SUMMARY = "Protocol Buffers - structured data serialisation mechanism"
2DESCRIPTION = "Protocol Buffers are a way of encoding structured data in an \
3efficient yet extensible format. Google uses Protocol Buffers for almost \
4all of its internal RPC protocols and file formats."
5HOMEPAGE = "https://github.com/google/protobuf"
6SECTION = "console/tools"
7LICENSE = "BSD-3-Clause"
8LIC_FILES_CHKSUM = "file://LICENSE;md5=37b5762e07f0af8c74ce80a8bda4266b"
9
10DEPENDS = "zlib"
11DEPENDS:append:class-target = " protobuf-native"
12
13SRCREV = "c9297981b7c35ad9c2bf258e7c8d786a04d13378"
14
15SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=3.19.x;protocol=https \
16           file://run-ptest \
17           file://0001-protobuf-fix-configure-error.patch \
18           file://0001-Makefile.am-include-descriptor.cc-when-building-libp.patch \
19           file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
20           file://0001-Fix-linking-error-with-ld-gold.patch \
21           file://0001-Lower-init-prio-for-extension-attributes.patch \
22           "
23SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
24SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
25
26S = "${WORKDIR}/git"
27
28inherit autotools-brokensep pkgconfig ptest
29
30PACKAGECONFIG ??= ""
31PACKAGECONFIG[python] = ",,"
32
33EXTRA_OECONF += "--with-protoc=echo"
34
35TEST_SRC_DIR = "examples"
36LANG_SUPPORT = "cpp ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python', '', d)}"
37
38do_compile_ptest() {
39	mkdir -p "${B}/${TEST_SRC_DIR}"
40
41	# Add the location of the cross-compiled header and library files
42	# which haven't been installed yet.
43	cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc"
44	sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
45	sed -e 's|Cflags:|Cflags: -I${S}/src|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
46	sed -e 's|Libs:|Libs: -L${B}/src/.libs|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
47	export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}"
48
49	# Save the pkgcfg sysroot variable, and update it to nothing so
50	# that it doesn't append the sysroot to the beginning of paths.
51	# The header and library files aren't installed to the target
52	# system yet.  So the absolute paths were specified above.
53	save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR
54	export PKG_CONFIG_SYSROOT_DIR=
55
56	# Compile the tests
57	for lang in ${LANG_SUPPORT}; do
58		oe_runmake -C "${S}/${TEST_SRC_DIR}" ${lang}
59	done
60
61	# Restore the pkgconfig sysroot variable
62	export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir
63}
64
65do_install_ptest() {
66	local olddir=`pwd`
67
68	cd "${S}/${TEST_SRC_DIR}"
69	install -d "${D}/${PTEST_PATH}"
70	for i in add_person* list_people*; do
71		if [ -x "$i" ]; then
72			install "$i" "${D}/${PTEST_PATH}"
73		fi
74	done
75	cp "${S}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}"
76	cd "$olddir"
77}
78
79PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite"
80
81FILES:${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}"
82FILES:${PN}-lite = "${libdir}/libprotobuf-lite${SOLIBS}"
83
84RDEPENDS:${PN}-compiler = "${PN}"
85RDEPENDS:${PN}-dev += "${PN}-compiler"
86RDEPENDS:${PN}-ptest = "bash ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python-protobuf', '', d)}"
87
88MIPS_INSTRUCTION_SET = "mips"
89
90BBCLASSEXTEND = "native nativesdk"
91
92LDFLAGS:append:arm = " -latomic"
93LDFLAGS:append:mips = " -latomic"
94LDFLAGS:append:powerpc = " -latomic"
95LDFLAGS:append:mipsel = " -latomic"
96