[Buildroot] [PATCH] package/zenoh-c: new package

Michel Alex Alex.Michel at wiedemann-group.com
Mon Nov 6 09:53:29 UTC 2023


Hello Thomas,

I fixed all issues you found in my first patch and there is the second version of my patch in the end of this email:

-----Original Message-----
From: Thomas Petazzoni <thomas.petazzoni at bootlin.com> 
Sent: Wednesday, November 1, 2023 6:47 PM
To: Michel Alex <Alex.Michel at wiedemann-group.com>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH] package/zenoh-c: new package

> However, I have some other questions:
> 
> - You're using cargo to build this package, but at
>   https://github.com/eclipse-zenoh/zenoh-c they suggest to use CMake.
>   Any opinion on this?

When using CMake, I have to additionally specify some RUSTFLAGS which are needed for cross compilation,
because the cmake uses rustc command to build the package:

ZENOH_C_CONF_ENV = RUSTFLAGS="-Clinker=arm-linux-gnueabihf-gcc -Car=arm-linux-gnueabihf-ar"
ZENOH_C_MAKE_ENV = RUSTFLAGS="-Clinker=arm-linux-gnueabihf-gcc -Car=arm-linux-gnueabihf-ar"
ZENOH_C_CONF_OPTS = -DZENOHC_CUSTOM_TARGET="arm-unknown-linux-gnueabihf"

All the 3 lines are passed automatically when building with cargo infrastructure.


> - When using cargo to build,
>  https://github.com/eclipse-zenoh/zenoh-c/blob/master/Cargo.toml is
>  used, and I'm worried by the following lines:
>
> zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "master", features = [ "shared-memory", "unstable" ] } zenoh-protocol = { git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "master", features = [ "shared-memory" ] } zenoh-util = { git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "master" }

Please look at the 0.10.0-rc version instead of master as you did -> https://github.com/eclipse-zenoh/zenoh-c/blob/0.10.0-rc/Cargo.toml 

zenoh = { version = "0.10.0-rc", features = [ "shared-memory", "unstable" ] }
zenoh-protocol = { version = "0.10.0-rc", features = [ "shared-memory" ] }
zenoh-util = { version = "0.10.0-rc" }


Here is the patch:

From 9e7425a785d87fd177a0541802b24772df3fc466 Mon Sep 17 00:00:00 2001
From: Alex Michel <alex.michel at wiedemann-group.com>
Date: Wed, 18 Oct 2023 10:05:57 +0200
Subject: [PATCH v2] package/libzenoh-c: new package

This package provides a C binding based on the main
Zenoh implementation written in Rust.

https://github.com/eclipse-zenoh/zenoh-c

Signed-off-by: Alex Michel <alex.michel at wiedemann-group.com>

---
Changes v1 -> v2:
  - renamed zenoh-c to libzenoh-c
  - added myself to DEVELOPERS
  - fixed LICENSE
  - install shared libraries to staging and to target
---
 DEVELOPERS                         |  1 +
 package/Config.in                  |  1 +
 package/libzenoh-c/Config.in       |  9 +++++++++
 package/libzenoh-c/libzenoh-c.hash |  3 +++
 package/libzenoh-c/libzenoh-c.mk   | 26 ++++++++++++++++++++++++++
 5 files changed, 40 insertions(+)
 create mode 100644 package/libzenoh-c/Config.in
 create mode 100644 package/libzenoh-c/libzenoh-c.hash
 create mode 100644 package/libzenoh-c/libzenoh-c.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index ac277423a1..08c3d9a5a1 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -75,6 +75,7 @@ N:      Alessandro Partesotti <a.partesotti at gmail.com>
 F:      package/oatpp/

 N:     Alex Michel <alex.michel at wiedemann-group.com>
+F:     package/libzenoh-c/
 F:     package/libzenoh-pico/
 F:     package/network-manager-openvpn/

diff --git a/package/Config.in b/package/Config.in
index cd687a682b..af1ee30585 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1996,6 +1996,7 @@ menu "Networking"
        source "package/libwebsock/Config.in"
        source "package/libwebsockets/Config.in"
        source "package/libyang/Config.in"
+       source "package/libzenoh-c/Config.in"
        source "package/libzenoh-pico/Config.in"
        source "package/lksctp-tools/Config.in"
        source "package/mbuffer/Config.in"
diff --git a/package/libzenoh-c/Config.in b/package/libzenoh-c/Config.in
new file mode 100644
index 0000000000..d22807c047
--- /dev/null
+++ b/package/libzenoh-c/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_LIBZENOH_C
+       bool "libzenoh-c"
+       depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+       select BR2_PACKAGE_HOST_RUSTC
+       help
+         This package provides a C binding based on the main
+         Zenoh implementation written in Rust.
+
+         https://github.com/eclipse-zenoh/zenoh-c
diff --git a/package/libzenoh-c/libzenoh-c.hash b/package/libzenoh-c/libzenoh-c.hash
new file mode 100644
index 0000000000..4a7da25233
--- /dev/null
+++ b/package/libzenoh-c/libzenoh-c.hash
@@ -0,0 +1,3 @@
+# Locally computed
+sha256  43c77a6768439681e804c8f02627dcb293f6ebec22d5c67ceb50d42f6c7badda  libzenoh-c-0.10.0-rc.tar.gz
+sha256  01a44774f7b1a453595c7c6d7f7308284ba6a1059dc49e14dad6647e1d44a338  LICENSE
diff --git a/package/libzenoh-c/libzenoh-c.mk b/package/libzenoh-c/libzenoh-c.mk
new file mode 100644
index 0000000000..b1452c1a97
--- /dev/null
+++ b/package/libzenoh-c/libzenoh-c.mk
@@ -0,0 +1,26 @@
+################################################################################
+#
+# libzenoh-c
+#
+################################################################################
+
+LIBZENOH_C_VERSION = 0.10.0-rc
+LIBZENOH_C_SITE = $(call github,eclipse-zenoh,zenoh-c,$(LIBZENOH_C_VERSION))
+LIBZENOH_C_LICENSE = Apache-2.0 or EPL-2.0
+LIBZENOH_C_LICENSE_FILES = LICENSE
+
+define LIBZENOH_C_INSTALL_FILES
+       $(INSTALL) -D -m 644 $(@D)/target/*/release/libzenohc.so $(1)/usr/lib/libzenohc.so
+       mkdir -p $(STAGING_DIR)/usr/include/
+       cp -dpfr $(@D)/include/* $(STAGING_DIR)/usr/include/
+endef
+
+define LIBZENOH_C_INSTALL_TARGET_CMDS
+       $(call LIBZENOH_C_INSTALL_FILES,$(TARGET_DIR))
+endef
+
+define LIBZENOH_C_INSTALL_STAGING_CMDS
+       $(call LIBZENOH_C_INSTALL_FILES,$(STAGING_DIR))
+endef
+
+$(eval $(cargo-package))
--
2.34.1


More information about the buildroot mailing list