Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build for windows #217

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
shm: [false, true]
unstable: [false, true]
os: [ubuntu-latest, macOS-latest, windows-latest]
shm: [FALSE, TRUE]
unstable: [FALSE, TRUE]
pico: [ON, OFF]
exclude:
- os: windows-latest
pico: ON
- os: ubuntu-latest
pico: OFF
- os: macOS-latest
pico: OFF

steps:
- name: Clone this repository
Expand All @@ -37,31 +45,31 @@ jobs:
- name: install zenoh-cpp
shell: bash
run: |
./scripts/install_from_git.sh ~/local
./scripts/install_from_git.sh ~/local ${{ matrix.unstable }} ${{ matrix.shm }} ${{ matrix.pico }}

- name: make examples
shell: bash
run: |
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target examples
cmake --build . --target examples --config Release

- name: make stand-alone examples
shell: bash
run: |
./scripts/build_standalone_examples.sh ~/local
./scripts/build_standalone_examples.sh ~/local ${{ matrix.pico }}

- name: make tests
shell: bash
run: |
cd build
cmake --build . --target tests
cmake --build . --target tests --config Release

- name: run tests
shell: bash
run: |
cd build
ctest --output-on-failure
ctest -C Release --output-on-failure

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function(add_example file mode lib)
target_link_libraries(${target} PUBLIC ${lib})
set_property(TARGET ${target} PROPERTY LANGUAGE CXX)
set_property(TARGET ${target} PROPERTY CXX_STANDARD 17)
copy_dlls(${target})
endfunction()

function(add_examples glob mode lib)
Expand Down
7 changes: 6 additions & 1 deletion examples/simple/universal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(zenohcxx_examples LANGUAGES C CXX)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake" ${CMAKE_MODULE_PATH})
include(helpers)

if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
Expand All @@ -13,8 +16,10 @@ add_executable(zp_simple z_simple.cxx)
target_link_libraries(zp_simple PRIVATE zenohcxx::zenohpico)
set_property(TARGET zp_simple PROPERTY LANGUAGE CXX)
set_property(TARGET zp_simple PROPERTY CXX_STANDARD 17)
copy_dlls(zp_simple)

add_executable(zc_simple z_simple.cxx)
target_link_libraries(zc_simple PRIVATE zenohcxx::zenohc)
set_property(TARGET zc_simple PROPERTY LANGUAGE CXX)
set_property(TARGET zc_simple PROPERTY CXX_STANDARD 17)
set_property(TARGET zc_simple PROPERTY CXX_STANDARD 17)
copy_dlls(zc_simple)
5 changes: 4 additions & 1 deletion examples/simple/zenohc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.16)
project(zenohcxx_examples LANGUAGES C CXX)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake" ${CMAKE_MODULE_PATH})
include(helpers)

if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
Expand All @@ -11,4 +13,5 @@ find_package(zenohcxx REQUIRED)
add_executable(zc_simple zc_simple.cxx)
target_link_libraries(zc_simple PRIVATE zenohcxx::zenohc)
set_property(TARGET zc_simple PROPERTY LANGUAGE CXX)
set_property(TARGET zc_simple PROPERTY CXX_STANDARD 17)
set_property(TARGET zc_simple PROPERTY CXX_STANDARD 17)
copy_dlls(zc_simple)
4 changes: 4 additions & 0 deletions examples/simple/zenohpico/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(zenohcxx_examples LANGUAGES C CXX)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake" ${CMAKE_MODULE_PATH})
include(helpers)

if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
Expand All @@ -12,3 +15,4 @@ add_executable(zp_simple zp_simple.cxx)
target_link_libraries(zp_simple PRIVATE zenohcxx::zenohpico)
set_property(TARGET zp_simple PROPERTY LANGUAGE CXX)
set_property(TARGET zp_simple PROPERTY CXX_STANDARD 17)
copy_dlls(zp_simple)
7 changes: 7 additions & 0 deletions examples/zenohc/z_get_shm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ int _main(int argc, char **argv) {
memcpy(buf.data(), value, len);

std::cout << "Sending Query '" << expr << "'...\n";
#if __cpp_designated_initializers >= 201707L
session.get(keyexpr, "", on_reply, on_done,
{.target = Z_QUERY_TARGET_ALL, .payload = Bytes::serialize(std::move(buf))});
#else
Session::GetOptions options;
options.target = Z_QUERY_TARGET_ALL;
options.payload = Bytes::serialize(std::move(buf));
session.get(keyexpr, "", on_reply, on_done, std::move(options));
#endif

std::unique_lock lock(m);
done_signal.wait(lock, [&done] { return done; });
Expand Down
6 changes: 6 additions & 0 deletions examples/zenohc/z_pub_shm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ int _main(int argc, char **argv) {
ZShmMut &&buf = std::get<ZShmMut>(std::move(alloc_result));
memcpy(buf.data(), s.data(), len);

#if __cpp_designated_initializers >= 201707L
pub.put(Bytes::serialize(std::move(buf)), {.encoding = Encoding("text/plain")});
#else
Publisher::PutOptions options;
options.encoding = Encoding("text/plain");
pub.put(Bytes::serialize(std::move(buf)), std::move(options));
#endif
}
return 0;
}
Expand Down
8 changes: 7 additions & 1 deletion examples/zenohc/z_pub_shm_thr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ int _main(int argc, char **argv) {
auto session = Session::open(std::move(config));

std::cout << "Declaring Publisher on " << keyexpr << "...\n";
auto pub = session.declare_publisher(KeyExpr(keyexpr), {.congestion_control = Z_CONGESTION_CONTROL_BLOCK});

#if __cpp_designated_initializers >= 201707L
auto pub = session.declare_publisher(KeyExpr(keyexpr), {.congestion_control = Z_CONGESTION_CONTROL_BLOCK});
#else
Session::PublisherOptions options;
options.congestion_control = Z_CONGESTION_CONTROL_BLOCK;
auto pub = session.declare_publisher(keyexpr, std::move(options));
#endif
std::cout << "Preparing SHM Provider...\n";
constexpr auto buffers_count = 4;
PosixShmProvider provider(MemoryLayout(buffers_count * len, AllocAlignment({2})));
Expand Down
6 changes: 6 additions & 0 deletions examples/zenohc/z_queryable_shm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ int _main(int argc, char **argv) {
ZShmMut &&buf = std::get<ZShmMut>(std::move(alloc_result));
memcpy(buf.data(), value, len);

#if __cpp_designated_initializers >= 201707L
query.reply(KeyExpr(expr), Bytes::serialize(std::move(buf)), {.encoding = Encoding("text/plain")});
#else
Query::ReplyOptions options;
options.encoding = Encoding("text/plain");
query.reply(KeyExpr(expr), Bytes::serialize(std::move(buf)), std::move(options));
#endif
};

auto on_drop_queryable = []() { std::cout << "Destroying queryable\n"; };
Expand Down
1 change: 1 addition & 0 deletions include/zenoh/api/bytes.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "shm/buffer/buffer.hxx"
#endif

#include <array>
#include <cstddef>
#include <cstdint>
#include <deque>
Expand Down
9 changes: 5 additions & 4 deletions include/zenoh/api/interop.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ const OwnedType* as_owned_c_ptr(const Owned<OwnedType>& cpp_obj) {
template <
class OwnedType,
class Loaned = typename ::z_owned_to_loaned_type_t<OwnedType>::type, // SFINAE here if no loaned type declared
class LoanAvailable = std::enable_if_t<detail::is_loan_available_v<OwnedType>, Loaned> // SFINAE here if immutable
// loan is not available
class LoanAvailable = std::enable_if_t<zenoh::detail::is_loan_available_v<OwnedType>, Loaned> // SFINAE here if
// immutable loan is
// not available
>
const Loaned* as_loaned_c_ptr(const Owned<OwnedType>& cpp_obj) {
return ::z_loan(*as_owned_c_ptr(cpp_obj));
Expand All @@ -93,8 +94,8 @@ const Loaned* as_loaned_c_ptr(const Owned<OwnedType>& cpp_obj) {
template <class OwnedType,
class Loaned = typename ::z_owned_to_loaned_type_t<OwnedType>::type, // SFINAE here if no loaned type
// declared
class LoanAvailable = std::enable_if_t<detail::is_loan_mut_available_v<OwnedType>,
Loaned> // SFINAE here if immutable loan is not available
class LoanAvailable = std::enable_if_t<zenoh::detail::is_loan_mut_available_v<OwnedType>,
Loaned> // SFINAE here if mutable loan is not available
>
Loaned* as_loaned_c_ptr(Owned<OwnedType>& cpp_obj) {
return ::z_loan_mut(*as_owned_c_ptr(cpp_obj));
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ cd "$project_folder"
rm -rf ./build
mkdir ./build
cd ./build
cmake .. "${@:3}" --install-prefix "$absolute_install_location"
make
cmake .. "${@:3}" -DCMAKE_BUILD_TYPE=Release --install-prefix "$absolute_install_location"
cmake --build . --config Release
15 changes: 12 additions & 3 deletions scripts/build_standalone_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

if [ "$#" -eq 0 ]; then
echo "Usage: build_standalone_examples INSTALL_PATH"
echo "Usage: build_standalone_examples INSTALL_PATH [BUILD_PICO]"
exit
fi
BUILD_PICO="ON"
if [ "$#" -ge 2 ]; then
BUILD_PICO=$2
fi

absolute_install_location=$(cd $1; pwd)

bash $SCRIPT_DIR/build_local.sh $SCRIPT_DIR/../examples/simple/universal $absolute_install_location
bash $SCRIPT_DIR/build_local.sh $SCRIPT_DIR/../examples/simple/zenohc $absolute_install_location
bash $SCRIPT_DIR/build_local.sh $SCRIPT_DIR/../examples/simple/zenohpico $absolute_install_location

if [ "$BUILD_PICO" == "ON" ]; then
#build examples requiring zenoh-pico
bash $SCRIPT_DIR/build_local.sh $SCRIPT_DIR/../examples/simple/universal $absolute_install_location
bash $SCRIPT_DIR/build_local.sh $SCRIPT_DIR/../examples/simple/zenohpico $absolute_install_location
fi

37 changes: 30 additions & 7 deletions scripts/install_from_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,46 @@ set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

if [ "$#" -eq 0 ]; then
echo "Usage: install_from_git INSTALL_PATH"
echo "Usage: install_from_git INSTALL_PATH [BUILD_WITH_UNSTABLE_API] [BUILD_WITH_SHARED_MEMORY] [BUILD_PICO]"
exit
fi

USE_UNSTABLE="TRUE"
USE_SHARED_MEMORY="TRUE"
USE_UNSTABLE_PICO="0"
BUILD_PICO="ON"

if [ "$#" -ge 2 ]; then
USE_UNSTABLE=$2
fi

if [ "$#" -ge 3 ]; then
USE_SHARED_MEMORY=$3
fi

if ("$USE_UNSTABLE" == "TRUE"); then
USE_UNSTABLE_PICO="1"
fi

if [ "$#" -ge 4 ]; then
BUILD_PICO=$4
fi


git submodule init
git submodule update

mkdir -p $1
absolute_install_location=$(cd $1; pwd)
#build zenoh-c
bash $SCRIPT_DIR/install_local.sh $SCRIPT_DIR/../zenoh-c $absolute_install_location -DZENOHC_BUILD_WITH_UNSTABLE_API=TRUE -DZENOHC_BUILD_WITH_SHARED_MEMORY=TRUE
#build zenoh-pico
bash $SCRIPT_DIR/install_local.sh $SCRIPT_DIR/../zenoh-pico $absolute_install_location -DZ_FEATURE_UNSTABLE_API=1
bash $SCRIPT_DIR/install_local.sh $SCRIPT_DIR/../zenoh-c $absolute_install_location -DZENOHC_BUILD_WITH_UNSTABLE_API=$USE_UNSTABLE -DZENOHC_BUILD_WITH_SHARED_MEMORY=$USE_SHARED_MEMORY
if [ "$BUILD_PICO" == "ON" ]; then
#build zenoh-pico
bash $SCRIPT_DIR/install_local.sh $SCRIPT_DIR/../zenoh-pico $absolute_install_location -DZ_FEATURE_UNSTABLE_API=$USE_UNSTABLE_PICO
fi

rm -rf ./build
mkdir ./build
cd ./build
cmake .. -DZENOHCXX_ZENOHPICO=ON --install-prefix "$absolute_install_location"
make
make install
cmake .. -DCMAKE_BUILD_TYPE=Release -DZENOHCXX_ZENOHPICO=$BUILD_PICO --install-prefix "$absolute_install_location"
cmake --build . --target install --config Release
5 changes: 2 additions & 3 deletions scripts/install_from_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ bash $SCRIPT_DIR/install_local.sh $SCRIPT_DIR/../../zenoh-pico $absolute_install
rm -rf ./build
mkdir ./build
cd ./build
cmake .. -DZENOHCXX_ZENOHPICO=ON --install-prefix "$absolute_install_location"
make
make install
cmake .. -DCMAKE_BUILD_TYPE=Release -DZENOHCXX_ZENOHPICO=ON --install-prefix "$absolute_install_location"
cmake --build . --target install --config Release
3 changes: 1 addition & 2 deletions scripts/install_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ rm -rf ./build
mkdir ./build
cd ./build
cmake .. "${@:3}" --install-prefix "$absolute_install_location"
make
make install
cmake --build . --target install --config Release
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function(add_test_instance file mode lib option)
else()
add_test(NAME "test_${target}" COMMAND ${target})
endif()
copy_dlls(${target})
endfunction()

file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/universal/*.cxx")
Expand Down
Loading