Skip to contentSkip to conversation

nanopb: Updates and package split

PATCH In review William A. Kennington III 2 participants 8 messages Feb 10, 2024 – Feb 12, 2024

lore
Share & tools
lore
#0 lore raw

cover nanopb: Updates and package split

This change aims to bring nanopb up to date, and split the 2 distinct components of codegeneration from the runtime. We maintain a packagegroup for legacy users which have not yet migrated to the new names.

William A. Kennington III (3):
nanopb: Update 0.4.7 -> 0.4.8
nanopb: Split into 2 packages
nanopb-runtime: Enable shared library

 .../nanopb/nanopb-generator_0.4.8.bb          | 14 ++++
 .../nanopb/nanopb-runtime_0.4.8.bb            | 17 +++++
 .../recipes-devtools/nanopb/nanopb.bb         | 17 +++++
 .../recipes-devtools/nanopb/nanopb.inc        | 13 ++++
 ...llow-to-set-PYTHON_INSTDIR-from-outs.patch | 67 -------------------
 .../recipes-devtools/nanopb/nanopb_0.4.7.bb   | 33 ---------
 6 files changed, 61 insertions(+), 100 deletions(-)
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-generator_0.4.8.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb.inc
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb/0001-CMakeLists.txt-allow-to-set-PYTHON_INSTDIR-from-outs.patch
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.7.bb
Signature · 1 line
2.43.0.687.g38aa6559b0-goog
#1 lore raw

PATCH 1/3 nanopb: Update 0.4.7 -> 0.4.8

Uses the new nanopb_PYTHON_INSTDIR_OVERRIDE to drop the previous patch.

Maintains compatability with 0.4.7 and older by adding symlinks to the old header paths.

---
 ...llow-to-set-PYTHON_INSTDIR-from-outs.patch | 67 -------------------
 .../recipes-devtools/nanopb/nanopb_0.4.7.bb   | 33 ---------
 .../recipes-devtools/nanopb/nanopb_0.4.8.bb   | 29 ++++++++
 3 files changed, 29 insertions(+), 100 deletions(-)
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb/0001-CMakeLists.txt-allow-to-set-PYTHON_INSTDIR-from-outs.patch
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.7.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.8.bb
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb/0001-CMakeLists.txt-allow-to-set-PYTHON_INSTDIR-from-outs.patch deleted +0 -67
deleted file mode 100644
index 474f0f158..000000000
@@ -1,67 +0,0 @@
-From 30c79d1b49839a15c05a0d0ca7e54787cd7988c6 Mon Sep 17 00:00:00 2001
-From: Martin Jansa <[email protected]>
-Date: Thu, 4 May 2023 07:17:57 +0000
-Subject: [PATCH] CMakeLists.txt: allow to set PYTHON_INSTDIR from outside
-
-CMakeLists.txt used:
-
-find_package(Python REQUIRED COMPONENTS Interpreter)
-execute_process(
-    COMMAND ${Python_EXECUTABLE} -c
-        "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
-    OUTPUT_VARIABLE PYTHON_INSTDIR
-    OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-but with python3native this returns:
-
-nanopb/0.4.7-r0/git $ ../recipe-sysroot-native/usr/bin/python3-native/python3 -c "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
-lib/python3.11/site-packages
-
-which doesn't respect target libdir which might be lib64 with multilib and with python3targetconfig
-it also doesn't work right because of the long relative path:
-
-nanopb/0.4.7-r0/build $ ../recipe-sysroot-native/usr/bin/python3-native/python3 -c "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
-../../../../../../../../../../../../usr/lib64/python3.11/site-packages
-
-CMake Error at cmake_install.cmake:46 (file):
-  file cannot create directory:
-  /OE/lge/build/starfish/nanbield/BUILD/work/o22-starfish-linux/nanopb/0.4.7-r0/image/usr/../../../../../../../../../../../../usr/lib64/python3.11/site-packages/proto.
-  Maybe need administrative privileges.
-
-Let CMake variable to be passed from the recipe to avoid this as we're already using
-${D}${PYTHON_SITEPACKAGES_DIR} in do_install:append anyway.
-
-Signed-off-by: Martin Jansa <[email protected]>
-Upstream-Status: Pending
----
- CMakeLists.txt | 16 +++++++++-------
- 1 file changed, 9 insertions(+), 7 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 8d241c5..7d3f993 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -39,13 +39,15 @@ if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR)
-     set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/nanopb")
- endif()
- 
--find_package(Python REQUIRED COMPONENTS Interpreter)
--execute_process(
--    COMMAND ${Python_EXECUTABLE} -c
--        "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
--    OUTPUT_VARIABLE PYTHON_INSTDIR
--    OUTPUT_STRIP_TRAILING_WHITESPACE
--)
-+if(NOT DEFINED PYTHON_INSTDIR)
-+    find_package(Python REQUIRED COMPONENTS Interpreter)
-+    execute_process(
-+        COMMAND ${Python_EXECUTABLE} -c
-+            "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
-+        OUTPUT_VARIABLE PYTHON_INSTDIR
-+        OUTPUT_STRIP_TRAILING_WHITESPACE
-+    )
-+endif()
- 
- if(nanopb_BUILD_GENERATOR)
-     set(generator_protos nanopb)
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.7.bb deleted +0 -33
deleted file mode 100644
index 9ad558146..000000000
@@ -1,33 +0,0 @@
-DESCRIPTION="Protocol Buffers with small code size"
-LICENSE="Zlib"
-LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9db4b73a55a3994384112efcdb37c01f"
-
-DEPENDS = "protobuf-native"
-
-SRC_URI = "git://github.com/nanopb/nanopb.git;branch=master;protocol=https \
-    file://0001-CMakeLists.txt-allow-to-set-PYTHON_INSTDIR-from-outs.patch \
-"
-SRCREV = "b97aa657a706d3ba4a9a6ccca7043c9d6fe41cba"
-
-S = "${WORKDIR}/git"
-
-inherit cmake python3native
-
-EXTRA_OECMAKE += "-DPYTHON_INSTDIR=${PYTHON_SITEPACKAGES_DIR}"
-
-do_install:append() {
-    install -Dm 0755 ${S}/generator/nanopb_generator.py ${D}${bindir}/nanopb_generator.py
-    install -Dm 0755 ${S}/generator/protoc-gen-nanopb ${D}${bindir}/protoc-gen-nanopb
-    install -Dm 0755 ${S}/generator/proto/__init__.py ${D}${PYTHON_SITEPACKAGES_DIR}/proto/__init__.py
-}
-
-FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}"
-FILES:${PN}-dev += "${libdir}/cmake/${BPN}"
-
-RDEPENDS:${PN} += "\
-   ${PYTHON_PN}-protobuf \
-   protobuf-compiler \
-"
-
-BBCLASSEXTEND = "native nativesdk"
-
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.8.bb new file +29 -0
new file mode 100644
index 000000000..d282bf1b2
@@ -0,0 +1,29 @@
+DESCRIPTION="Protocol Buffers with small code size"
+LICENSE="Zlib"
+LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9db4b73a55a3994384112efcdb37c01f"
+
+DEPENDS = "protobuf-native"
+
+SRC_URI = "git://github.com/nanopb/nanopb.git;branch=master;protocol=https"
+SRCREV = "6cfe48d6f1593f8fa5c0f90437f5e6522587745e"
+
+S = "${WORKDIR}/git"
+
+inherit cmake python3-dir
+
+EXTRA_OECMAKE += "-Dnanopb_PYTHON_INSTDIR_OVERRIDE=${PYTHON_SITEPACKAGES_DIR}"
+
+RDEPENDS:${PN} += "${PYTHON_PN}-protobuf"
+
+# Maintain compatability with old header locations for packages
+# which haven't yet migrated to `nanopb/pb*.h`
+do_install:append() {
+  for hdr in ${D}${includedir}/nanopb/*; do
+	ln -sv nanopb/$(basename "$hdr") ${D}${includedir}/
+  done
+}
+
+FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}"
+
+BBCLASSEXTEND = "native nativesdk"
+
Signature · 1 line
2.43.0.687.g38aa6559b0-goog
#2 lore raw

PATCH 2/3 nanopb: Split into 2 packages

In reply to William A. Kennington III

This makes it possible to avoid building components which are not used in the native or runtime tooling. Most users of nanopb just want to build nanopb-generator-native and nanopb-runtime and not the other two combinations as they are building software for their target leveraging nanopb.

---
 .../nanopb/nanopb-generator_0.4.8.bb          | 14 +++++++++
 .../nanopb/nanopb-runtime_0.4.8.bb            | 16 ++++++++++
 .../recipes-devtools/nanopb/nanopb.bb         | 17 +++++++++++
 .../recipes-devtools/nanopb/nanopb.inc        | 13 +++++++++
 .../recipes-devtools/nanopb/nanopb_0.4.8.bb   | 29 -------------------
 5 files changed, 60 insertions(+), 29 deletions(-)
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-generator_0.4.8.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb.inc
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.8.bb
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-generator_0.4.8.bb new file +14 -0
new file mode 100644
index 000000000..c86750f8b
@@ -0,0 +1,14 @@
+require nanopb.inc
+
+inherit python3-dir
+
+DEPENDS = "protobuf-native"
+RDEPENDS:${PN} += "python3-protobuf"
+
+EXTRA_OECMAKE += " \
+  -Dnanopb_PYTHON_INSTDIR_OVERRIDE=${PYTHON_SITEPACKAGES_DIR} \
+  -Dnanopb_BUILD_RUNTIME=OFF \
+  -Dnanopb_BUILD_GENERATOR=ON \
+  "
+
+FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}"
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb new file +16 -0
new file mode 100644
index 000000000..e36abf808
@@ -0,0 +1,16 @@
+require nanopb.inc
+
+EXTRA_OECMAKE += " \
+  -Dnanopb_PROTOC_PATH=/bin/false \
+  -Dnanopb_BUILD_RUNTIME=ON \
+  -Dnanopb_BUILD_GENERATOR=OFF \
+  "
+
+# Maintain compatability with old header locations for packages
+# which haven't yet migrated to `nanopb/pb*.h`
+do_install:append() {
+  for hdr in ${D}${includedir}/nanopb/*; do
+	ln -sv nanopb/$(basename "$hdr") ${D}${includedir}/
+  done
+}
+
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb.bb new file +17 -0
new file mode 100644
index 000000000..7ad6a3278
@@ -0,0 +1,17 @@
+SUMMARY = "Combined nanopb package"
+PV = "1.0"
+PR = "r1"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit packagegroup
+
+DEPENDS = " \
+    nanopb-generator \
+    nanopb-runtime \
+"
+
+RDEPENDS:${PN} = " \
+    nanopb-generator \
+    nanopb-runtime \
+"
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb.inc new file +13 -0
new file mode 100644
index 000000000..87dbc73e6
@@ -0,0 +1,13 @@
+DESCRIPTION="Protocol Buffers with small code size"
+LICENSE="Zlib"
+LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9db4b73a55a3994384112efcdb37c01f"
+
+SRC_URI = "git://github.com/nanopb/nanopb.git;branch=master;protocol=https"
+SRCREV = "6cfe48d6f1593f8fa5c0f90437f5e6522587745e"
+
+S = "${WORKDIR}/git"
+
+inherit cmake
+
+BBCLASSEXTEND = "native nativesdk"
+
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb_0.4.8.bb deleted +0 -29
deleted file mode 100644
index d282bf1b2..000000000
@@ -1,29 +0,0 @@
-DESCRIPTION="Protocol Buffers with small code size"
-LICENSE="Zlib"
-LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9db4b73a55a3994384112efcdb37c01f"
-
-DEPENDS = "protobuf-native"
-
-SRC_URI = "git://github.com/nanopb/nanopb.git;branch=master;protocol=https"
-SRCREV = "6cfe48d6f1593f8fa5c0f90437f5e6522587745e"
-
-S = "${WORKDIR}/git"
-
-inherit cmake python3-dir
-
-EXTRA_OECMAKE += "-Dnanopb_PYTHON_INSTDIR_OVERRIDE=${PYTHON_SITEPACKAGES_DIR}"
-
-RDEPENDS:${PN} += "${PYTHON_PN}-protobuf"
-
-# Maintain compatability with old header locations for packages
-# which haven't yet migrated to `nanopb/pb*.h`
-do_install:append() {
-  for hdr in ${D}${includedir}/nanopb/*; do
-	ln -sv nanopb/$(basename "$hdr") ${D}${includedir}/
-  done
-}
-
-FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}"
-
-BBCLASSEXTEND = "native nativesdk"
-
Signature · 1 line
2.43.0.687.g38aa6559b0-goog
#3 lore raw

PATCH 3/3 nanopb-runtime: Enable shared library

In reply to William A. Kennington III

Some users would like to be able to share library code between multiple applications without embedding a static copy.

---
 .../meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb  | 1 +
 1 file changed, 1 insertion(+)
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb +1 -0
index e36abf808..e43931a4e 100644
@@ -2,6 +2,7 @@ require nanopb.inc
 
 EXTRA_OECMAKE += " \
   -Dnanopb_PROTOC_PATH=/bin/false \
+  -DBUILD_SHARED_LIBS=ON \
   -Dnanopb_BUILD_RUNTIME=ON \
   -Dnanopb_BUILD_GENERATOR=OFF \
   "
Signature · 1 line
2.43.0.687.g38aa6559b0-goog
#4 lore raw

Re: [oe] [meta-oe][PATCH 3/3] nanopb-runtime: Enable shared library

Quoted 2 lines · William A. Kennington III via lists.openembedded.org

Some users would like to be able to share library code between multiple applications without embedding a static copy.

Some CMake based recipes have a PACKAGECONFIG for this:

PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF"

Particularly for permissive licenses I personally prefer static linking due to performance benefits.

regards,
Christian

Quoted 19 lines
---
 .../meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb  | 1 +
 1 file changed, 1 insertion(+)
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb +1 -0
index e36abf808..e43931a4e 100644
@@ -2,6 +2,7 @@ require nanopb.inc
 
 EXTRA_OECMAKE += " \
   -Dnanopb_PROTOC_PATH=/bin/false \
+  -DBUILD_SHARED_LIBS=ON \
   -Dnanopb_BUILD_RUNTIME=ON \
   -Dnanopb_BUILD_GENERATOR=OFF \
   "
#5 lore raw

Re: [oe] [meta-oe][PATCH 3/3] nanopb-runtime: Enable shared library

Quoted 11 lines · Christian Eggers
Quoted 2 lines · William A. Kennington III via lists.openembedded.org

Some users would like to be able to share library code between multiple applications without embedding a static copy.

Some CMake based recipes have a PACKAGECONFIG for this:

PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF"

Particularly for permissive licenses I personally prefer static linking due to performance benefits.

You could still statically link if you want to, this just builds both sets of libraries instead of the static library only. I don't mind adding the option though.

Quoted 27 lines

regards,
Christian

Quoted 19 lines
---
 .../meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb  | 1 +
 1 file changed, 1 insertion(+)
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb +1 -0
index e36abf808..e43931a4e 100644
@@ -2,6 +2,7 @@ require nanopb.inc
 
 EXTRA_OECMAKE += " \
   -Dnanopb_PROTOC_PATH=/bin/false \
+  -DBUILD_SHARED_LIBS=ON \
   -Dnanopb_BUILD_RUNTIME=ON \
   -Dnanopb_BUILD_GENERATOR=OFF \
   "
#6 lore raw

Re: [oe] [meta-oe][PATCH 3/3] nanopb-runtime: Enable shared library

Quoted 8 lines · William Kennington
Quoted 7 lines · Christian Eggers
Quoted 2 lines · William A. Kennington III via lists.openembedded.org

Some users would like to be able to share library code between multiple applications without embedding a static copy.

Some CMake based recipes have a PACKAGECONFIG for this:

Quoted 8 lines
Quoted 4 lines

PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF"

Particularly for permissive licenses I personally prefer static linking due to performance benefits.

You could still statically link if you want to, this just builds both sets of libraries instead of the static library only. I don't mind adding the option though.

I didn't actually try, but this sounds fine for me.

From usual CMake projects am I am used to get either shared or static libraries, depending on BUILD_SHARED_LIBS.

Quoted 29 lines
Quoted 28 lines

regards,
Christian

Quoted 19 lines
---
 .../meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb  | 1 +
 1 file changed, 1 insertion(+)
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb +1 -0
index e36abf808..e43931a4e 100644
@@ -2,6 +2,7 @@ require nanopb.inc
 
 EXTRA_OECMAKE += " \
   -Dnanopb_PROTOC_PATH=/bin/false \
+  -DBUILD_SHARED_LIBS=ON \
   -Dnanopb_BUILD_RUNTIME=ON \
   -Dnanopb_BUILD_GENERATOR=OFF \
   "
#7 lore raw

Re: [oe] [meta-oe][PATCH 3/3] nanopb-runtime: Enable shared library

Quoted 15 lines · Christian Eggers
Quoted 13 lines · William Kennington
Quoted 11 lines · Christian Eggers
Quoted 2 lines · William A. Kennington III via lists.openembedded.org

Some users would like to be able to share library code between multiple applications without embedding a static copy.

Some CMake based recipes have a PACKAGECONFIG for this:

PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF"

Particularly for permissive licenses I personally prefer static linking due to performance benefits.

Quoted 8 lines
Quoted 3 lines

You could still statically link if you want to, this just builds both sets of libraries instead of the static library only. I don't mind adding the option though.

I didn't actually try, but this sounds fine for me.

From usual CMake projects am I am used to get either shared or static libraries, depending on BUILD_SHARED_LIBS.

Theirs happens to do both
https://github.com/nanopb/nanopb/blob/0.4.8/CMakeLists.txt#L11

IIRC most CMake projects I've encountered allow building both this way.

Quoted 34 lines
Quoted 30 lines
Quoted 29 lines

regards,
Christian

Quoted 19 lines
---
 .../meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb  | 1 +
 1 file changed, 1 insertion(+)
meta-oe/dynamic-layers/meta-python/recipes-devtools/nanopb/nanopb-runtime_0.4.8.bb +1 -0
index e36abf808..e43931a4e 100644
@@ -2,6 +2,7 @@ require nanopb.inc
 
 EXTRA_OECMAKE += " \
   -Dnanopb_PROTOC_PATH=/bin/false \
+  -DBUILD_SHARED_LIBS=ON \
   -Dnanopb_BUILD_RUNTIME=ON \
   -Dnanopb_BUILD_GENERATOR=OFF \
   "