From d9daf66b11dab5bb3806404a9f0cc266645f80ca Mon Sep 17 00:00:00 2001 From: Hongxu Jia Date: Fri, 21 Mar 2025 13:34:14 +0800 Subject: protobuf: 4.25.5 -> 5.29.4 Refresh local patches - 0001-Fix-build-on-mips-clang.patch - 0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch Fix protobuf-native build failure with gcc 10 Fix dev-elf QA issue: |ERROR: protobuf-5.29.4-r0 do_package_qa: QA Issue: -dev package protobuf-dev contains non-symlink .so '/usr/lib/libutf8_range.so' [dev-elf] |ERROR: protobuf-5.29.4-r0 do_package_qa: QA Issue: -dev package protobuf-dev contains non-symlink .so '/usr/lib/libutf8_validity.so' [dev-elf] Changelog: https://github.com/protocolbuffers/protobuf/releases/tag/v29.4 Signed-off-by: Hongxu Jia Signed-off-by: Khem Raj --- .../protobuf/0001-Fix-build-on-mips-clang.patch | 26 +++-- ...kefile-respect-CXX-LDFLAGS-variables-fix-.patch | 31 +++--- ...protobuf-native-build-failure-with-gcc-10.patch | 46 ++++++++ ...range-add-version-marker-to-library-19009.patch | 43 +++++++ .../recipes-devtools/protobuf/protobuf_4.25.5.bb | 122 -------------------- .../recipes-devtools/protobuf/protobuf_5.29.4.bb | 124 +++++++++++++++++++++ 6 files changed, 246 insertions(+), 146 deletions(-) create mode 100644 meta-oe/recipes-devtools/protobuf/protobuf/0001-fix-protobuf-native-build-failure-with-gcc-10.patch create mode 100644 meta-oe/recipes-devtools/protobuf/protobuf/0001-utf8_range-add-version-marker-to-library-19009.patch delete mode 100644 meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb create mode 100644 meta-oe/recipes-devtools/protobuf/protobuf_5.29.4.bb diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch index 9f6116c4c4..1e0d04dc8d 100644 --- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch @@ -1,6 +1,6 @@ -From 08e46feb6553af670754e65d94c3bb6fcd4e0cf9 Mon Sep 17 00:00:00 2001 +From cd6c5f36c0dc38e4734b74b03923489b7bfb9aba Mon Sep 17 00:00:00 2001 From: Khem Raj -Date: Sun, 31 Oct 2021 23:39:44 -0700 +Date: Mon, 10 Mar 2025 19:59:19 -0700 Subject: [PATCH] Fix build on mips/clang clang13 crashes on mips, until its fixed upstream disable tailcall on @@ -10,17 +10,25 @@ https://bugs.llvm.org/show_bug.cgi?id=52367 Upstream-Status: Inappropriate [Clang workaround] Signed-off-by: Khem Raj + +Rebase to v5.29.4 +Signed-off-by: Hongxu Jia --- - src/google/protobuf/port_def.inc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + src/google/protobuf/port_def.inc | 1 + + 1 file changed, 1 insertion(+) +diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc +index 56f995e45..428d096b3 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc -@@ -255,6 +255,7 @@ +@@ -227,6 +227,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), #error PROTOBUF_TAILCALL was previously defined #endif - #if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \ + #if ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && !defined(__arm__) && \ + !defined(__mips__) && \ - !defined(_ARCH_PPC) && !defined(__wasm__) && \ - !(defined(_MSC_VER) && defined(_M_IX86)) && \ - !(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24) + !defined(_ARCH_PPC) && !defined(__wasm__) && \ + !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__) + // Compilation fails on ARM32: b/195943306 +-- +2.25.1 + diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch index 7c4bf260eb..7a8906a9a4 100644 --- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch @@ -1,13 +1,12 @@ -From e3fa241637ab5a7fa78c0d474802134cff75f91e Mon Sep 17 00:00:00 2001 +From f6a3554e37fb39f93e4b47a75318bbda53cfdb46 Mon Sep 17 00:00:00 2001 From: Martin Jansa -Date: Fri, 28 Jun 2019 13:50:52 +0000 -Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables, fix build - with gold +Date: Thu, 20 Mar 2025 20:33:02 -0700 +Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables * move pkg-config call to separate variable, so that the final version of the whole command so it's shown in log.do_compile_ptest_base * add ../src/google/protobuf/.libs/timestamp.pb.o when linking - add_person_cpp otherwise it fails to link with gold: + add_person_cpp otherwise it fails: i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` /tmp/cccjSJQs.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto' /tmp/cccjSJQs.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto' @@ -25,37 +24,39 @@ Upstream-Status: Pending Signed-off-by: Martin Jansa Signed-off-by: Leon Anavi +Rebase to 5.29.4 +Signed-off-by: Hongxu Jia --- examples/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/Makefile b/examples/Makefile -index ef7a4ef58..7206e14e1 100644 +index f7ee9b116..8cd1359e2 100644 --- a/examples/Makefile +++ b/examples/Makefile -@@ -2,6 +2,8 @@ +@@ -4,6 +4,8 @@ - .PHONY: all cpp java python clean + all: cpp java python +PROTOBUF := $(shell pkg-config --cflags --libs protobuf) + - all: cpp java python - cpp: add_person_cpp list_people_cpp -@@ -41,11 +43,11 @@ protoc_middleman_dart: addressbook.proto + dart: add_person_dart list_people_dart + go: add_person_go list_people_go +@@ -46,11 +48,11 @@ protoc_middleman_ruby: addressbook.proto add_person_cpp: add_person.cc protoc_middleman pkg-config --cflags protobuf # fails if protobuf is not installed - c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` -+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp #$(CXX) -std=c++17 $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp list_people_cpp: list_people.cc protoc_middleman pkg-config --cflags protobuf # fails if protobuf is not installed - c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf` -+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp #$(CXX) -std=c++17 $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp add_person_dart: add_person.dart protoc_middleman_dart --- -2.34.1 +-- +2.25.1 diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-fix-protobuf-native-build-failure-with-gcc-10.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-fix-protobuf-native-build-failure-with-gcc-10.patch new file mode 100644 index 0000000000..2edba6b7eb --- /dev/null +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-fix-protobuf-native-build-failure-with-gcc-10.patch @@ -0,0 +1,46 @@ +From 213f29fb63473304db098b3d12a0393fd50e4914 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 17 Mar 2025 13:28:13 +0800 +Subject: [PATCH] fix protobuf-native build failure with gcc 10 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Build protobuf-native failed on ubuntu 20.04 which has gcc 10 + +protobuf-native/4.30.0/git/src/google/protobuf/port_def.inc:105:48: +error: static assertion failed: Protobuf only supports C+ + ↪ +17 and newer. + | 105 | #define PROTOBUF_CPLUSPLUS_MIN(x) (__cplusplus >= x) + | | ~~~~~~~~~~~~~^~~~~ + | /home/kraj01/yoe/build/tmp/work/x86_64-linux/protobuf-native/4.30.0/git/src/google/protobuf/port_def.inc:119:15: +note: in expansion of macro ‘PROTOBUF_CPLUSPLUS_MIN’ + | 119 | static_assert(PROTOBUF_CPLUSPLUS_MIN(201703L), + | | ^~~~~~~~~~~~~~~~~~~~~~ + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +Signed-off-by: Hongxu Jia +--- + CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e90cb8aa2..3ffac1307 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -14,6 +14,10 @@ endif() + # Project + project(protobuf C CXX) + ++set(CMAKE_CXX_STANDARD 17) ++set(CMAKE_CXX_STANDARD_REQUIRED ON) ++set(CMAKE_CXX_EXTENSIONS OFF) ++ + if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE) + if(CMAKE_PROJECT_NAME STREQUAL "protobuf") + get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY) +-- +2.25.1 + diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-utf8_range-add-version-marker-to-library-19009.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-utf8_range-add-version-marker-to-library-19009.patch new file mode 100644 index 0000000000..e58fdc1d19 --- /dev/null +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-utf8_range-add-version-marker-to-library-19009.patch @@ -0,0 +1,43 @@ +From fd020ef700dbf2d324aecd087b8fcb6ff329feb6 Mon Sep 17 00:00:00 2001 +From: Jan Engelhardt +Date: Thu, 21 Nov 2024 11:30:17 -0800 +Subject: [PATCH] utf8_range: add version marker to library (#19009) + +Unversioned libraries / libraries without due ABI indicators are not allowed in certain Linux distributions because it precludes the concurrent presence of multiple versions. + +If you have both /usr/lib/libprotobuf-lite.so.28.3.0 and /usr/lib/libprotobuf-lite.so.29.0.0, both of them want libutf8_validity.so, but if the ABI is different between utf8_range 28 and utf8_range 29, that's a problem. + +Closes #19009 + +COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/19009 from jengelh:master 1a5f8682be2f2b84da07fcdd32474baae8088959 +PiperOrigin-RevId: 698855702 + +Upstream-Status: Backport [https://github.com/protocolbuffers/protobuf/commit/ced605d0e6a7ad20985375b596b2ca6720e07737] +Signed-off-by: Hongxu Jia +--- + third_party/utf8_range/CMakeLists.txt | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/third_party/utf8_range/CMakeLists.txt b/third_party/utf8_range/CMakeLists.txt +index 4276b97290..e054893c63 100644 +--- a/third_party/utf8_range/CMakeLists.txt ++++ b/third_party/utf8_range/CMakeLists.txt +@@ -19,6 +19,15 @@ add_library (utf8_range + # A heavier-weight C++ wrapper that supports Abseil. + add_library (utf8_validity utf8_validity.cc utf8_range.c) + ++set_target_properties(utf8_range PROPERTIES ++ VERSION ${protobuf_VERSION} ++ OUTPUT_NAME ${LIB_PREFIX}utf8_range ++) ++set_target_properties(utf8_validity PROPERTIES ++ VERSION ${protobuf_VERSION} ++ OUTPUT_NAME ${LIB_PREFIX}utf8_validity ++) ++ + # Load Abseil dependency. + if (NOT TARGET absl::strings) + if (NOT ABSL_ROOT_DIR) +-- +2.34.1 + diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb b/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb deleted file mode 100644 index a470a7c643..0000000000 --- a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb +++ /dev/null @@ -1,122 +0,0 @@ -SUMMARY = "Protocol Buffers - structured data serialisation mechanism" -DESCRIPTION = "Protocol Buffers are a way of encoding structured data in an \ -efficient yet extensible format. Google uses Protocol Buffers for almost \ -all of its internal RPC protocols and file formats." -HOMEPAGE = "https://github.com/google/protobuf" -SECTION = "console/tools" -LICENSE = "BSD-3-Clause & MIT" -LIC_FILES_CHKSUM = " \ - file://LICENSE;md5=37b5762e07f0af8c74ce80a8bda4266b \ - file://third_party/lunit/LICENSE;md5=99f08e72434dfa34fe0581d3dfb2d7f4 \ - file://third_party/utf8_range/LICENSE;md5=d4974d297231477b2ff507c35d61c13c \ -" - -DEPENDS = "zlib abseil-cpp jsoncpp" -DEPENDS:append:class-target = " protobuf-native" - -SRCREV = "9d0ec0f92b5b5fdeeda11f9dcecc1872ff378014" - -SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=25.x;protocol=https \ - file://run-ptest \ - file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \ - " -SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch " -SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch " - -UPSTREAM_CHECK_GITTAGREGEX = "v(?P.(25\.(\d+)))" - -S = "${WORKDIR}/git" - -CVE_PRODUCT = "google:protobuf protobuf:protobuf google-protobuf protobuf-cpp" - -inherit cmake pkgconfig ptest - -PACKAGECONFIG ??= "" -PACKAGECONFIG:class-native ?= "compiler" -PACKAGECONFIG:class-nativesdk ?= "compiler" -PACKAGECONFIG[python] = ",," -PACKAGECONFIG[compiler] = "-Dprotobuf_BUILD_PROTOC_BINARIES=ON,-Dprotobuf_BUILD_PROTOC_BINARIES=OFF" - -EXTRA_OECMAKE += "\ - -Dprotobuf_BUILD_SHARED_LIBS=ON \ - -Dprotobuf_BUILD_LIBPROTOC=ON \ - -Dprotobuf_BUILD_TESTS=OFF \ - -Dprotobuf_BUILD_EXAMPLES=OFF \ - -Dprotobuf_ABSL_PROVIDER="package" \ - -Dprotobuf_JSONCPP_PROVIDER="package" \ -" - -TEST_SRC_DIR = "examples" -LANG_SUPPORT = "cpp ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python', '', d)}" - -do_compile_ptest() { - mkdir -p "${B}/${TEST_SRC_DIR}" - - # Add the location of the cross-compiled header and library files - # which haven't been installed yet. - cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc" - cp ${S}/${TEST_SRC_DIR}/*.cc "${B}/${TEST_SRC_DIR}/" - cp ${S}/${TEST_SRC_DIR}/*.proto "${B}/${TEST_SRC_DIR}/" - cp ${S}/${TEST_SRC_DIR}/*.py "${B}/${TEST_SRC_DIR}/" - cp ${S}/${TEST_SRC_DIR}/Makefile "${B}/${TEST_SRC_DIR}/" - # Adapt protobuf.pc - sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - sed -e 's|Cflags:|Cflags: -I${S}/src |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - sed -e 's|Cflags:|Cflags: -I${WORKDIR}/recipe-sysroot${includedir} |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - sed -e 's|Libs:|Libs: -L${B}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - sed -e 's|Libs:|Libs: -L${WORKDIR}/recipe-sysroot/usr/lib |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - sed -e 's|Libs:|Libs: -labsl_log_internal_check_op |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - sed -e 's|Libs:|Libs: -labsl_log_internal_message |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" - # Adapt uf8_range.pc - cp "${B}/third_party/utf8_range/utf8_range.pc" "${B}/${TEST_SRC_DIR}/utf8_range.pc" - sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/utf8_range.pc" - sed -e 's|Libs:|Libs= -L${B}/third_party/utf8_range |' -i "${B}/${TEST_SRC_DIR}/utf8_range.pc" - # Until out-of-tree build of examples is supported, we have to use this approach - 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" - export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}" - - # Save the pkgcfg sysroot variable, and update it to nothing so - # that it doesn't append the sysroot to the beginning of paths. - # The header and library files aren't installed to the target - # system yet. So the absolute paths were specified above. - save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR - export PKG_CONFIG_SYSROOT_DIR= - - # Compile the tests - for lang in ${LANG_SUPPORT}; do - oe_runmake -C "${B}/${TEST_SRC_DIR}" ${lang} - done - - # Restore the pkgconfig sysroot variable - export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir -} - -do_install_ptest() { - local olddir=`pwd` - - cd "${S}/${TEST_SRC_DIR}" - install -d "${D}/${PTEST_PATH}" - for i in add_person* list_people*; do - if [ -x "$i" ]; then - install "$i" "${D}/${PTEST_PATH}" - fi - done - cp "${B}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}" - cd "$olddir" -} - -PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite" - -FILES:${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}" -FILES:${PN}-lite = "${libdir}/libprotobuf-lite${SOLIBS}" - -# CMake requires protoc binary to exist in sysroot, even if it has wrong architecture. -SYSROOT_DIRS += "${bindir}" - -RDEPENDS:${PN}-compiler = "${PN}" -RDEPENDS:${PN}-dev += "${@bb.utils.contains('PACKAGECONFIG', 'compiler', '${PN}-compiler', '', d)}" -RDEPENDS:${PN}-ptest = "bash ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3-protobuf', '', d)}" - -MIPS_INSTRUCTION_SET = "mips" - -BBCLASSEXTEND = "native nativesdk" diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_5.29.4.bb b/meta-oe/recipes-devtools/protobuf/protobuf_5.29.4.bb new file mode 100644 index 0000000000..777378369e --- /dev/null +++ b/meta-oe/recipes-devtools/protobuf/protobuf_5.29.4.bb @@ -0,0 +1,124 @@ +SUMMARY = "Protocol Buffers - structured data serialisation mechanism" +DESCRIPTION = "Protocol Buffers are a way of encoding structured data in an \ +efficient yet extensible format. Google uses Protocol Buffers for almost \ +all of its internal RPC protocols and file formats." +HOMEPAGE = "https://github.com/google/protobuf" +SECTION = "console/tools" +LICENSE = "BSD-3-Clause & MIT" +LIC_FILES_CHKSUM = " \ + file://LICENSE;md5=37b5762e07f0af8c74ce80a8bda4266b \ + file://third_party/lunit/LICENSE;md5=99f08e72434dfa34fe0581d3dfb2d7f4 \ + file://third_party/utf8_range/LICENSE;md5=d4974d297231477b2ff507c35d61c13c \ +" + +DEPENDS = "zlib abseil-cpp jsoncpp" +DEPENDS:append:class-target = " protobuf-native" + +SRCREV = "1be1c9d0ea6efa2a25bd7b76186844d1669be78a" + +SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=29.x;protocol=https \ + file://run-ptest \ + file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \ + file://0001-fix-protobuf-native-build-failure-with-gcc-10.patch \ + file://0001-utf8_range-add-version-marker-to-library-19009.patch \ + " +SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch " +SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch " + +UPSTREAM_CHECK_GITTAGREGEX = "v(?P.(25\.(\d+)))" + +S = "${WORKDIR}/git" + +CVE_PRODUCT = "google:protobuf protobuf:protobuf google-protobuf protobuf-cpp" + +inherit cmake pkgconfig ptest + +PACKAGECONFIG ??= "" +PACKAGECONFIG:class-native ?= "compiler" +PACKAGECONFIG:class-nativesdk ?= "compiler" +PACKAGECONFIG[python] = ",," +PACKAGECONFIG[compiler] = "-Dprotobuf_BUILD_PROTOC_BINARIES=ON,-Dprotobuf_BUILD_PROTOC_BINARIES=OFF" + +EXTRA_OECMAKE += "\ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -Dprotobuf_BUILD_LIBPROTOC=ON \ + -Dprotobuf_BUILD_TESTS=OFF \ + -Dprotobuf_BUILD_EXAMPLES=OFF \ + -Dprotobuf_ABSL_PROVIDER="package" \ + -Dprotobuf_JSONCPP_PROVIDER="package" \ +" + +TEST_SRC_DIR = "examples" +LANG_SUPPORT = "cpp ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python', '', d)}" + +do_compile_ptest() { + mkdir -p "${B}/${TEST_SRC_DIR}" + + # Add the location of the cross-compiled header and library files + # which haven't been installed yet. + cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc" + cp ${S}/${TEST_SRC_DIR}/*.cc "${B}/${TEST_SRC_DIR}/" + cp ${S}/${TEST_SRC_DIR}/*.proto "${B}/${TEST_SRC_DIR}/" + cp ${S}/${TEST_SRC_DIR}/*.py "${B}/${TEST_SRC_DIR}/" + cp ${S}/${TEST_SRC_DIR}/Makefile "${B}/${TEST_SRC_DIR}/" + # Adapt protobuf.pc + sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + sed -e 's|Cflags:|Cflags: -I${S}/src |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + sed -e 's|Cflags:|Cflags: -I${WORKDIR}/recipe-sysroot${includedir} |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + sed -e 's|Libs:|Libs: -L${B}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + sed -e 's|Libs:|Libs: -L${WORKDIR}/recipe-sysroot/usr/lib |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + sed -e 's|Libs:|Libs: -labsl_log_internal_check_op |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + sed -e 's|Libs:|Libs: -labsl_log_internal_message |' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" + # Adapt uf8_range.pc + cp "${B}/third_party/utf8_range/utf8_range.pc" "${B}/${TEST_SRC_DIR}/utf8_range.pc" + sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/utf8_range.pc" + sed -e 's|Libs:|Libs= -L${B}/third_party/utf8_range |' -i "${B}/${TEST_SRC_DIR}/utf8_range.pc" + # Until out-of-tree build of examples is supported, we have to use this approach + 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" + export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}" + + # Save the pkgcfg sysroot variable, and update it to nothing so + # that it doesn't append the sysroot to the beginning of paths. + # The header and library files aren't installed to the target + # system yet. So the absolute paths were specified above. + save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR + export PKG_CONFIG_SYSROOT_DIR= + + # Compile the tests + for lang in ${LANG_SUPPORT}; do + oe_runmake -C "${B}/${TEST_SRC_DIR}" ${lang} + done + + # Restore the pkgconfig sysroot variable + export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir +} + +do_install_ptest() { + local olddir=`pwd` + + cd "${S}/${TEST_SRC_DIR}" + install -d "${D}/${PTEST_PATH}" + for i in add_person* list_people*; do + if [ -x "$i" ]; then + install "$i" "${D}/${PTEST_PATH}" + fi + done + cp "${B}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}" + cd "$olddir" +} + +PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite" + +FILES:${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}" +FILES:${PN}-lite = "${libdir}/libprotobuf-lite${SOLIBS}" + +# CMake requires protoc binary to exist in sysroot, even if it has wrong architecture. +SYSROOT_DIRS += "${bindir}" + +RDEPENDS:${PN}-compiler = "${PN}" +RDEPENDS:${PN}-dev += "${@bb.utils.contains('PACKAGECONFIG', 'compiler', '${PN}-compiler', '', d)}" +RDEPENDS:${PN}-ptest = "bash ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3-protobuf', '', d)}" + +MIPS_INSTRUCTION_SET = "mips" + +BBCLASSEXTEND = "native nativesdk" -- cgit v1.2.3-54-g00ecf