blob: 1edc21cdfc967f277982c767b354c794497b1e0c [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001SUMMARY = "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
Andrew Geissler220dafd2023-10-04 10:18:08 -050010DEPENDS = "zlib abseil-cpp"
Andrew Geissler517393d2023-01-13 08:55:19 -060011DEPENDS:append:class-target = " protobuf-native"
12
Andrew Geissler220dafd2023-10-04 10:18:08 -050013SRCREV = "2c5fa078d8e86e5f4bd34e6f4c9ea9e8d7d4d44a"
Andrew Geissler517393d2023-01-13 08:55:19 -060014
Andrew Geissler220dafd2023-10-04 10:18:08 -050015SRC_URI = "gitsm://github.com/protocolbuffers/protobuf.git;branch=23.x;protocol=https \
Andrew Geissler517393d2023-01-13 08:55:19 -060016 file://run-ptest \
17 file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060018 "
19SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
20SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
21
22S = "${WORKDIR}/git"
23
24inherit cmake pkgconfig ptest
25
26PACKAGECONFIG ??= ""
27PACKAGECONFIG:class-native ?= "compiler"
28PACKAGECONFIG:class-nativesdk ?= "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 \
Andrew Geissler220dafd2023-10-04 10:18:08 -050037 -Dprotobuf_ABSL_PROVIDER="package" \
Andrew Geissler517393d2023-01-13 08:55:19 -060038"
39
40TEST_SRC_DIR = "examples"
41LANG_SUPPORT = "cpp ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python', '', d)}"
42
43do_compile_ptest() {
44 mkdir -p "${B}/${TEST_SRC_DIR}"
45
46 # Add the location of the cross-compiled header and library files
47 # which haven't been installed yet.
48 cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc"
49 cp ${S}/${TEST_SRC_DIR}/*.cc "${B}/${TEST_SRC_DIR}/"
50 cp ${S}/${TEST_SRC_DIR}/*.proto "${B}/${TEST_SRC_DIR}/"
51 cp ${S}/${TEST_SRC_DIR}/*.py "${B}/${TEST_SRC_DIR}/"
52 cp ${S}/${TEST_SRC_DIR}/Makefile "${B}/${TEST_SRC_DIR}/"
Andrew Geissler220dafd2023-10-04 10:18:08 -050053 # Adapt protobuf.pc
Andrew Geissler517393d2023-01-13 08:55:19 -060054 sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
Andrew Geissler220dafd2023-10-04 10:18:08 -050055 sed -e 's|Cflags:|Cflags: -I${S}/src |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
56 sed -e 's|Cflags:|Cflags: -I${WORKDIR}/recipe-sysroot${includedir} |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
Andrew Geissler517393d2023-01-13 08:55:19 -060057 sed -e 's|Libs:|Libs: -L${B}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
Andrew Geissler220dafd2023-10-04 10:18:08 -050058 sed -e 's|Libs:|Libs: -L${WORKDIR}/recipe-sysroot/usr/lib |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
59 sed -e 's|Libs:|Libs: -labsl_log_internal_check_op |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
60 sed -e 's|Libs:|Libs: -labsl_log_internal_message |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
61 # Adapt uf8_range.pc
62 cp "${B}/third_party/utf8_range/utf8_range.pc" "${B}/${TEST_SRC_DIR}/utf8_range.pc"
63 sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/utf8_range.pc"
64 sed -e 's|Libs:|Libs= -L${B}/third_party/utf8_range |' -i "${B}/${TEST_SRC_DIR}/utf8_range.pc"
Andrew Geissler517393d2023-01-13 08:55:19 -060065 # Until out-of-tree build of examples is supported, we have to use this approach
66 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"
67 export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}"
68
69 # Save the pkgcfg sysroot variable, and update it to nothing so
70 # that it doesn't append the sysroot to the beginning of paths.
71 # The header and library files aren't installed to the target
72 # system yet. So the absolute paths were specified above.
73 save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR
74 export PKG_CONFIG_SYSROOT_DIR=
75
76 # Compile the tests
77 for lang in ${LANG_SUPPORT}; do
78 oe_runmake -C "${B}/${TEST_SRC_DIR}" ${lang}
79 done
80
81 # Restore the pkgconfig sysroot variable
82 export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir
83}
84
85do_install_ptest() {
86 local olddir=`pwd`
87
88 cd "${S}/${TEST_SRC_DIR}"
89 install -d "${D}/${PTEST_PATH}"
90 for i in add_person* list_people*; do
91 if [ -x "$i" ]; then
92 install "$i" "${D}/${PTEST_PATH}"
93 fi
94 done
95 cp "${B}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}"
96 cd "$olddir"
97}
98
99PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite"
100
101FILES:${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}"
102FILES:${PN}-lite = "${libdir}/libprotobuf-lite${SOLIBS}"
103
Andrew Geissler517393d2023-01-13 08:55:19 -0600104RDEPENDS:${PN}-compiler = "${PN}"
105RDEPENDS:${PN}-dev += "${PN}-compiler"
106RDEPENDS:${PN}-ptest = "bash ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3-protobuf', '', d)}"
107
108MIPS_INSTRUCTION_SET = "mips"
109
110BBCLASSEXTEND = "native nativesdk"
111
112LDFLAGS:append:arm = " -latomic"
113LDFLAGS:append:mips = " -latomic"
114LDFLAGS:append:powerpc = " -latomic"
115LDFLAGS:append:mipsel = " -latomic"