blob: 0bc9cbedc0843997e5d6d9a2f52ff8a3b0a33591 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001SUMMARY = "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 = "ab840345966d0fa8e7100d771c92a73bfbadd25c"
14
15SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=21.x;protocol=https \
16 file://run-ptest \
17 file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
18 file://0001-Fix-linking-error-with-ld-gold.patch \
19 "
20SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
21SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
22
23S = "${WORKDIR}/git"
24
25inherit cmake pkgconfig ptest
26
27PACKAGECONFIG ??= ""
28PACKAGECONFIG:class-native ?= "compiler"
29PACKAGECONFIG[python] = ",,"
30PACKAGECONFIG[compiler] = "-Dprotobuf_BUILD_PROTOC_BINARIES=ON,-Dprotobuf_BUILD_PROTOC_BINARIES=OFF"
31
32EXTRA_OECMAKE += "\
33 -Dprotobuf_BUILD_SHARED_LIBS=ON \
34 -Dprotobuf_BUILD_LIBPROTOC=ON \
35 -Dprotobuf_BUILD_TESTS=OFF \
36 -Dprotobuf_BUILD_EXAMPLES=OFF \
37"
38
39TEST_SRC_DIR = "examples"
40LANG_SUPPORT = "cpp ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python', '', d)}"
41
42do_compile_ptest() {
43 mkdir -p "${B}/${TEST_SRC_DIR}"
44
45 # Add the location of the cross-compiled header and library files
46 # which haven't been installed yet.
47 cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc"
48 cp ${S}/${TEST_SRC_DIR}/*.cc "${B}/${TEST_SRC_DIR}/"
49 cp ${S}/${TEST_SRC_DIR}/*.proto "${B}/${TEST_SRC_DIR}/"
50 cp ${S}/${TEST_SRC_DIR}/*.py "${B}/${TEST_SRC_DIR}/"
51 cp ${S}/${TEST_SRC_DIR}/Makefile "${B}/${TEST_SRC_DIR}/"
52 sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
53 sed -e 's|Cflags:|Cflags: -I${S}/src|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
54 sed -e 's|Libs:|Libs: -L${B}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
55 # Until out-of-tree build of examples is supported, we have to use this approach
56 sed -e 's|../src/google/protobuf/.libs/timestamp.pb.o|${B}/CMakeFiles/libprotobuf.dir/src/google/protobuf/timestamp.pb.cc.o|' -i "${B}/${TEST_SRC_DIR}/Makefile"
57 export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}"
58
59 # Save the pkgcfg sysroot variable, and update it to nothing so
60 # that it doesn't append the sysroot to the beginning of paths.
61 # The header and library files aren't installed to the target
62 # system yet. So the absolute paths were specified above.
63 save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR
64 export PKG_CONFIG_SYSROOT_DIR=
65
66 # Compile the tests
67 for lang in ${LANG_SUPPORT}; do
68 oe_runmake -C "${B}/${TEST_SRC_DIR}" ${lang}
69 done
70
71 # Restore the pkgconfig sysroot variable
72 export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir
73}
74
75do_install_ptest() {
76 local olddir=`pwd`
77
78 cd "${S}/${TEST_SRC_DIR}"
79 install -d "${D}/${PTEST_PATH}"
80 for i in add_person* list_people*; do
81 if [ -x "$i" ]; then
82 install "$i" "${D}/${PTEST_PATH}"
83 fi
84 done
85 cp "${B}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}"
86 cd "$olddir"
87}
88
89PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite"
90
91FILES:${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}"
92FILES:${PN}-lite = "${libdir}/libprotobuf-lite${SOLIBS}"
93
94RDEPENDS:${PN}-compiler = "${PN}"
95RDEPENDS:${PN}-dev += "${PN}-compiler"
96RDEPENDS:${PN}-ptest = "bash ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3-protobuf', '', d)}"
97
98MIPS_INSTRUCTION_SET = "mips"
99
100BBCLASSEXTEND = "native nativesdk"
101
102LDFLAGS:append:arm = " -latomic"
103LDFLAGS:append:mips = " -latomic"
104LDFLAGS:append:powerpc = " -latomic"
105LDFLAGS:append:mipsel = " -latomic"