diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index 96545a251..cac9e56a9 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -127,6 +127,19 @@ jobs: if: always() run: kill ${{ steps.run-zenoh.outputs.zenohd-pid }} + unstable_build: + name: Check compilation with unstable API + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build with unstable + run: | + sudo apt install -y ninja-build + Z_FEATURE_UNSTABLE_API=1 CMAKE_GENERATOR=Ninja make + + st_build: needs: zenoh_build name: Build and test in single thread on ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dfcd31fe..1cd4b89b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,7 @@ set(BATCH_UNICAST_SIZE 2048 CACHE STRING "Use this to override the maximum unica set(BATCH_MULTICAST_SIZE 2048 CACHE STRING "Use this to override the maximum multicast batch size") set(Z_CONFIG_SOCKET_TIMEOUT 100 CACHE STRING "Default socket timeout in milliseconds") +set(Z_FEATURE_UNSTABLE_API 0 CACHE STRING "Toggle unstable Zenoh-C API") set(Z_FEATURE_PUBLICATION 1 CACHE STRING "Toggle publication feature") set(Z_FEATURE_SUBSCRIPTION 1 CACHE STRING "Toggle subscription feature") set(Z_FEATURE_QUERY 1 CACHE STRING "Toggle query feature") @@ -208,6 +209,7 @@ set(Z_FEATURE_INTEREST 1 CACHE STRING "Toggle interest feature") add_compile_definitions("Z_BUILD_DEBUG=$") message(STATUS "Building with feature confing:\n\ +* UNSTABLE_API: ${Z_FEATURE_UNSTABLE_API}\n\ * MULTI-THREAD: ${Z_FEATURE_MULTI_THREAD}\n\ * PUBLICATION: ${Z_FEATURE_PUBLICATION}\n\ * SUBSCRIPTION: ${Z_FEATURE_SUBSCRIPTION}\n\ diff --git a/GNUmakefile b/GNUmakefile index 217a64342..fcbbbb4d8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -51,6 +51,7 @@ ZENOH_DEBUG?=0 # Feature config toggle # Accepted values: 0, 1 +Z_FEATURE_UNSTABLE_API?=0 Z_FEATURE_MULTI_THREAD?=1 Z_FEATURE_PUBLICATION?=1 Z_FEATURE_SUBSCRIPTION?=1 @@ -78,7 +79,7 @@ CROSSIMG_PREFIX=zenoh-pico_ # - ARM: old versions of dockcross/dockcross were creating some issues since they used an old GCC (4.8.3) which lacks (even using -std=gnu11) CMAKE_OPT=-DZENOH_DEBUG=$(ZENOH_DEBUG) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_MULTICAST=$(BUILD_MULTICAST)\ - -DZ_FEATURE_MULTI_THREAD=$(Z_FEATURE_MULTI_THREAD) -DZ_FEATURE_INTEREST=$(Z_FEATURE_INTEREST) \ + -DZ_FEATURE_MULTI_THREAD=$(Z_FEATURE_MULTI_THREAD) -DZ_FEATURE_INTEREST=$(Z_FEATURE_INTEREST) -DZ_FEATURE_UNSTABLE_API=$(Z_FEATURE_UNSTABLE_API)\ -DZ_FEATURE_PUBLICATION=$(Z_FEATURE_PUBLICATION) -DZ_FEATURE_SUBSCRIPTION=$(Z_FEATURE_SUBSCRIPTION) -DZ_FEATURE_QUERY=$(Z_FEATURE_QUERY) -DZ_FEATURE_QUERYABLE=$(Z_FEATURE_QUERYABLE)\ -DZ_FEATURE_RAWETH_TRANSPORT=$(Z_FEATURE_RAWETH_TRANSPORT) -DFRAG_MAX_SIZE=$(FRAG_MAX_SIZE) -DBATCH_UNICAST_SIZE=$(BATCH_UNICAST_SIZE) -DBATCH_MULTICAST_SIZE=$(BATCH_MULTICAST_SIZE)\ -DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H. diff --git a/PackageConfig.cmake.in b/PackageConfig.cmake.in index d3aa3d367..b84b6c3ec 100644 --- a/PackageConfig.cmake.in +++ b/PackageConfig.cmake.in @@ -17,6 +17,7 @@ set(ZENOHPICO_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) set(CMAKE_SYSTEM_NAME @CMAKE_SYSTEM_NAME@) +set(ZENOHPICO_FEATURE_UNSTABLE_API @Z_FEATURE_UNSTABLE_API@) set(ZENOHPICO_FEATURE_MULTI_THREAD @Z_FEATURE_MULTI_THREAD@) set(ZENOHPICO_FEATURE_PUBLICATION @Z_FEATURE_PUBLICATION@) set(ZENOHPICO_FEATURE_SUBSCRIPTION @Z_FEATURE_SUBSCRIPTION@) diff --git a/docs/conf.py b/docs/conf.py index adaff5535..4ad571076 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,6 +30,7 @@ language = 'c' c_autodoc_roots = ['../include/zenoh-pico/api/'] c_autodoc_compilation_args = [ + "-DZ_FEATURE_UNSTABLE_API=1", "-DZ_FEATURE_PUBLICATION=1", "-DZ_FEATURE_SUBSCRIPTION=1", "-DZ_FEATURE_QUERY=1", diff --git a/include/zenoh-pico/api/types.h b/include/zenoh-pico/api/types.h index 39dea8a86..1db2306c2 100644 --- a/include/zenoh-pico/api/types.h +++ b/include/zenoh-pico/api/types.h @@ -183,10 +183,14 @@ _Z_OWNED_TYPE_VALUE(_z_value_t, reply_err) * Represents the configuration used to configure a subscriber upon declaration :c:func:`z_declare_subscriber`. * * Members: - * z_reliability_t reliability: The subscription reliability value. + * (unstable) z_reliability_t reliability: The subscription reliability value. */ typedef struct { +#ifdef Z_FEATURE_UNSTABLE_API z_reliability_t reliability; +#else + uint8_t __dummy; // Just to avoid empty structures that might cause undefined behavior +#endif } z_subscriber_options_t; /** diff --git a/src/api/api.c b/src/api/api.c index 768efd4ba..53948ac93 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -1556,7 +1556,13 @@ void _z_subscriber_drop(_z_subscriber_t *sub) { _z_undeclare_and_clear_subscribe _Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_subscriber_t, subscriber, _z_subscriber_check, _z_subscriber_null, _z_subscriber_drop) -void z_subscriber_options_default(z_subscriber_options_t *options) { options->reliability = Z_RELIABILITY_DEFAULT; } +void z_subscriber_options_default(z_subscriber_options_t *options) { +#if Z_FEATURE_UNSTABLE_API == 1 + options->reliability = Z_RELIABILITY_DEFAULT; +#else + options->__dummy = 0; +#endif +} int8_t z_declare_subscriber(z_owned_subscriber_t *sub, const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, z_moved_closure_sample_t *callback, const z_subscriber_options_t *options) { @@ -1599,7 +1605,11 @@ int8_t z_declare_subscriber(z_owned_subscriber_t *sub, const z_loaned_session_t _z_subinfo_t subinfo = _z_subinfo_default(); if (options != NULL) { +#if Z_FEATURE_UNSTABLE_API == 1 subinfo.reliability = options->reliability; +#else + subinfo.reliability = Z_RELIABILITY_DEFAULT; +#endif } _z_subscriber_t int_sub = _z_declare_subscriber(zs, key, subinfo, callback->_this._val.call, callback->_this._val.drop, ctx); diff --git a/zenohpico.pc b/zenohpico.pc index 9d0772da5..82d230a15 100644 --- a/zenohpico.pc +++ b/zenohpico.pc @@ -3,6 +3,6 @@ prefix=/usr/local Name: zenohpico Description: URL: -Version: 1.0.20240819dev +Version: 1.0.20240822dev Cflags: -I${prefix}/include Libs: -L${prefix}/lib -lzenohpico