From d0b07f8ec5cb220b04d037ab8c2e17cc31712398 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 6 Apr 2024 07:10:59 -0400 Subject: [PATCH] support for integration as a west module in zephyr (#395) Integrate zenoh as a west module and enable adding zenoh as a library using kconfig. This will allows easier integration with zephyr by including in the west manifest (west.yml), i.e.: @@ -2,7 +2,13 @@ manifest: remotes: - name: upstream url-base: https://github.com/zephyrproject-rtos + - name: zenoh + url-base: https://github.com/eclipse-zenoh projects: + - name: zenoh-pico + revision: main + path: external/zenoh-pico + remote: zenoh - name: canopennode revision: dec12fa3f0d790cafa8414a4c2930ea71ab72ffd path: modules/lib/canopennode and then enabling the publication example with: CONFIG_ZENOH_PICO=y CONFIG_ZENOH_PICO_LINK_SERIAL=y CONFIG_ZENOH_PICO_PUBLICATION=y application can then be built with west: west build -b reel_board zephyr/samples/publication Signed-off-by: Anas Nashif --- zephyr/CMakeLists.txt | 46 +++++++++++++++++++++++++++++ zephyr/Kconfig.zenoh | 69 +++++++++++++++++++++++++++++++++++++++++++ zephyr/module.yml | 4 +-- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 zephyr/CMakeLists.txt create mode 100644 zephyr/Kconfig.zenoh diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt new file mode 100644 index 000000000..a3e7f145a --- /dev/null +++ b/zephyr/CMakeLists.txt @@ -0,0 +1,46 @@ +if(CONFIG_ZENOH_PICO) + +zephyr_compile_definitions(ZENOH_ZEPHYR) +zephyr_include_directories(../include) +zephyr_library() + +function(configure_zenoh_feature config) + string(REPLACE CONFIG_ZENOH_PICO Z_FEATURE feature ${config}) + if(${config}) + zephyr_compile_definitions(${feature}=1) + else() + zephyr_compile_definitions(${feature}=0) + endif() +endfunction() + + +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_SERIAL) +configure_zenoh_feature(CONFIG_ZENOH_PICO_MULTI_THREAD) +configure_zenoh_feature(CONFIG_ZENOH_PICO_PUBLICATION) +configure_zenoh_feature(CONFIG_ZENOH_PICO_SUBSCRIPTION) +configure_zenoh_feature(CONFIG_ZENOH_PICO_QUERY) +configure_zenoh_feature(CONFIG_ZENOH_PICO_QUERYABLE) +configure_zenoh_feature(CONFIG_ZENOH_PICO_RAWETH_TRANSPORT) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_TCP) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_UDP_UNICAST) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_UDP_MULTICAST) +configure_zenoh_feature(CONFIG_ZENOH_PICO_SCOUTING_UDP) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_WS) + + +file(GLOB_RECURSE Sources + "../src/api/*.c" + "../src/collections/*.c" + "../src/deprecated/*.c" + "../src/link/*.c" + "../src/net/*.c" + "../src/protocol/*.c" + "../src/session/*.c" + "../src/transport/*.c" + "../src/utils/*.c" +) + +file (GLOB Sources_Zephyr "../src/system/zephyr/*.c") +list(APPEND Sources ${Sources_Zephyr}) +zephyr_library_sources(${Sources}) +endif() diff --git a/zephyr/Kconfig.zenoh b/zephyr/Kconfig.zenoh new file mode 100644 index 000000000..fce27a370 --- /dev/null +++ b/zephyr/Kconfig.zenoh @@ -0,0 +1,69 @@ +config ZENOH_PICO + bool "Zenoh PICO library" + help + Enable Zenoh pico support + +if ZENOH_PICO + +config ZENOH_PICO_LINK_SERIAL + bool "Serial Link" + help + Use serial link + +config ZENOH_PICO_MULTI_THREAD + bool "Multithreading support" + help + Multithreading support + +config ZENOH_PICO_PUBLICATION + bool "Publication Support" + help + Publication support + +config ZENOH_PICO_SUBSCRIPTION + bool "Subscription Support" + help + Subscription Support + +config ZENOH_PICO_QUERY + bool "Query Support" + help + Query Support + +config ZENOH_PICO_QUERYABLE + bool "Queryable Support" + help + Queryable Support + +config ZENOH_PICO_RAWETH_TRANSPORT + bool "Raw Ethernet Support" + help + Raw Ethernet Support + +config ZENOH_PICO_LINK_TCP + bool "TCP Link" + help + TCP Link + +config ZENOH_PICO_LINK_UDP_UNICAST + bool "UDP Unicast" + help + UDP Unicast + +config ZENOH_PICO_LINK_UDP_MULTICAST + bool "UDP Multicast" + help + UDP Multicast + +config ZENOH_PICO_SCOUTING_UDP + bool "Scouting UDP" + help + Scouting UDP + +config ZENOH_PICO_LINK_WS + bool "WS Link" + help + WS Link + +endif + diff --git a/zephyr/module.yml b/zephyr/module.yml index 31f5d4f30..507856e5e 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -1,4 +1,4 @@ name: zenoh-pico build: - cmake-ext: True - kconfig-ext: True + cmake: zephyr/ + kconfig: zephyr/Kconfig.zenoh