From 4ef823f7bd58045229d3a2cbe76378d6e7ab81d5 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Tue, 12 Dec 2023 07:19:29 -0800 Subject: [PATCH 1/3] move get_expr implementation from impl to api.hxx which solves multiple declaration of get_keyexpr issue --- include/zenohcxx/api.hxx | 4 ++-- include/zenohcxx/impl.hxx | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/include/zenohcxx/api.hxx b/include/zenohcxx/api.hxx index c2b9cd29..cab9e317 100644 --- a/include/zenohcxx/api.hxx +++ b/include/zenohcxx/api.hxx @@ -1616,7 +1616,7 @@ class Subscriber : public Owned<::z_owned_subscriber_t> { #ifdef __ZENOHCXX_ZENOHC /// @brief Get the key expression of the subscriber /// @return ``zenoh::KeyExpr`` value - z::KeyExpr get_keyexpr() const; + z::KeyExpr get_keyexpr() const { return ::z_subscriber_keyexpr(loan()); } #endif }; @@ -1701,7 +1701,7 @@ class Publisher : public Owned<::z_owned_publisher_t> { #ifdef __ZENOHCXX_ZENOHC /// @brief Get the key expression of the publisher /// @return ``zenoh::KeyExpr`` value - z::KeyExpr get_keyexpr() const; + z::KeyExpr get_keyexpr() const { return ::z_publisher_keyexpr(loan()); } #endif #ifdef __ZENOHCXX_ZENOHC diff --git a/include/zenohcxx/impl.hxx b/include/zenohcxx/impl.hxx index 9e0b0604..6eee4be1 100644 --- a/include/zenohcxx/impl.hxx +++ b/include/zenohcxx/impl.hxx @@ -313,14 +313,6 @@ inline bool z::Publisher::put_owned_impl(z::Payload&& payload, const z::Publishe #endif -#ifdef __ZENOHCXX_ZENOHC -z::KeyExpr z::Publisher::get_keyexpr() const { return ::z_publisher_keyexpr(loan()); } -#endif - -#ifdef __ZENOHCXX_ZENOHC -z::KeyExpr z::Subscriber::get_keyexpr() const { return ::z_subscriber_keyexpr(loan()); } -#endif - inline bool scout(z::ScoutingConfig&& config, ClosureHello&& callback, ErrNo& error) { auto c = config.take(); auto cb = callback.take(); From 590483f68b9abf987911258297e2ec3a65e31265 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Thu, 14 Dec 2023 07:54:29 -0800 Subject: [PATCH 2/3] standalone example that shows multiple declaration issue --- .github/workflows/ci.yml | 7 +++++++ examples/standalone/CMakeLists.txt | 9 +++++++++ examples/standalone/foo.cpp | 4 ++++ examples/standalone/foo.hpp | 6 ++++++ examples/standalone/main.cpp | 10 ++++++++++ 5 files changed, 36 insertions(+) create mode 100644 examples/standalone/CMakeLists.txt create mode 100644 examples/standalone/foo.cpp create mode 100644 examples/standalone/foo.hpp create mode 100644 examples/standalone/main.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 725ffaa9..87c5027e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,13 @@ jobs: cmake ../examples -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHCXX_SOURCE=PACKAGE cmake --build . --config Release + - name: make standalone example with zenoh-cpp as installed package + shell: bash + run: | + mkdir -p build_examples_standalone_findproj && cd build_examples_standalone_findproj + cmake ../examples/standalone -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHCXX_SOURCE=PACKAGE + cmake --build . --config Release + - name: make tests shell: bash run: | diff --git a/examples/standalone/CMakeLists.txt b/examples/standalone/CMakeLists.txt new file mode 100644 index 00000000..67a140e0 --- /dev/null +++ b/examples/standalone/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.16) +project(zenoh_foo) + +find_package(zenohc REQUIRED) +find_package(zenohcxx REQUIRED) + +add_executable(foo main.cpp foo.cpp) +target_link_libraries(foo zenohcxx::zenohc::lib) +set_property(TARGET foo PROPERTY CXX_STANDARD 17) diff --git a/examples/standalone/foo.cpp b/examples/standalone/foo.cpp new file mode 100644 index 00000000..e0d553c6 --- /dev/null +++ b/examples/standalone/foo.cpp @@ -0,0 +1,4 @@ +#include +#include + +#include "foo.hpp" diff --git a/examples/standalone/foo.hpp b/examples/standalone/foo.hpp new file mode 100644 index 00000000..60268c35 --- /dev/null +++ b/examples/standalone/foo.hpp @@ -0,0 +1,6 @@ +#ifndef FOO_HXX +#define FOO_HXX + +#include "zenohc.hxx" + +#endif // FOO_HXX diff --git a/examples/standalone/main.cpp b/examples/standalone/main.cpp new file mode 100644 index 00000000..4874b6df --- /dev/null +++ b/examples/standalone/main.cpp @@ -0,0 +1,10 @@ +#include + +#include + +#include "foo.hpp" + +int main() +{ + return 0; +} From f9b78fdc7973885452e94aa87de1215d6251b665 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Thu, 14 Dec 2023 08:16:44 -0800 Subject: [PATCH 3/3] test building of the standalone project in github action --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87c5027e..7a46f6b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,40 +19,35 @@ jobs: steps: - uses: actions/checkout@v2 + with: + path: zenoh-cpp - name: install zenoh-cpp shell: bash run: | mkdir -p build_install && cd build_install - cmake ../install -DCMAKE_INSTALL_PREFIX=~/local + cmake ../zenoh-cpp/install -DCMAKE_INSTALL_PREFIX=~/local cmake --install . - name: make examples shell: bash run: | mkdir -p build && cd build - cmake .. + cmake ../zenoh-cpp cmake --build . --target examples - name: make examples with zenoh-cpp as subbroject shell: bash run: | mkdir -p build_examples_subproj && cd build_examples_subproj - cmake ../examples -DCMAKE_BUILD_TYPE=Debug + cmake ../zenoh-cpp/examples -DCMAKE_BUILD_TYPE=Debug cmake --build . --config Debug - name: make examples with zenoh-cpp as installed package shell: bash run: | mkdir -p build_examples_findproj && cd build_examples_findproj - cmake ../examples -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHCXX_SOURCE=PACKAGE - cmake --build . --config Release - - - name: make standalone example with zenoh-cpp as installed package - shell: bash - run: | - mkdir -p build_examples_standalone_findproj && cd build_examples_standalone_findproj - cmake ../examples/standalone -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHCXX_SOURCE=PACKAGE + cmake ../zenoh-cpp/examples -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHCXX_SOURCE=PACKAGE cmake --build . --config Release - name: make tests @@ -69,6 +64,28 @@ jobs: cd build ctest + # build zenoh-c and standalone project that needs zenoh-cpp and zenoh-c + # probably this belongs in a different action yaml + - name: get zenoh-c + uses: actions/checkout@v3 + with: + repository: eclipse-zenoh/zenoh-c + path: zenoh-c + + - name: install zenoh-c + shell: bash + run: | + mkdir -p zenohc_build_install && cd zenohc_build_install + cmake ../zenoh-c -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local + cmake --build . --target install --config Release + + - name: make standalone example with zenoh-cpp as installed package + shell: bash + run: | + mkdir -p build_examples_standalone_findproj && cd build_examples_standalone_findproj + cmake ../zenoh-cpp/examples/standalone -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local + cmake --build . --config Release + - name: Upload artifact uses: actions/upload-artifact@v2 with: