From dce7bb8458d7f822e170acbc6cabea36ab2abec2 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Mon, 25 Mar 2024 13:57:03 +0800 Subject: [PATCH 01/10] Patch cargo toolchain for noble Signed-off-by: Yadunund --- zenoh_c_vendor/CMakeLists.txt | 1 + zenoh_c_vendor/package.xml | 3 +- zenoh_c_vendor/patches/cargo_toolchain.patch | 56 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 zenoh_c_vendor/patches/cargo_toolchain.patch diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 73246032..032412bf 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -31,6 +31,7 @@ ament_vendor(zenoh_c_vendor VCS_VERSION 10176b911096cb92b8ee46bc491b78079ee26c20 CMAKE_ARGS "-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}" + PATCHES patches ) # set(INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-prefix/install") diff --git a/zenoh_c_vendor/package.xml b/zenoh_c_vendor/package.xml index 6515c1e9..3848c24a 100644 --- a/zenoh_c_vendor/package.xml +++ b/zenoh_c_vendor/package.xml @@ -12,7 +12,8 @@ ament_cmake ament_cmake_vendor_package - + + cargo clang diff --git a/zenoh_c_vendor/patches/cargo_toolchain.patch b/zenoh_c_vendor/patches/cargo_toolchain.patch new file mode 100644 index 00000000..c5a399d8 --- /dev/null +++ b/zenoh_c_vendor/patches/cargo_toolchain.patch @@ -0,0 +1,56 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 00aa5ca..eacd7d6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -27,7 +27,6 @@ declare_cache_var_true_if_vscode(ZENOHC_BUILD_IN_SOURCE_TREE "Do build inside so + declare_cache_var(ZENOHC_BUILD_WITH_LOGGER_AUTOINIT TRUE BOOL "Enable logger-autoinit zenoh-c feature") + declare_cache_var(ZENOHC_BUILD_WITH_SHARED_MEMORY TRUE BOOL "Enable shared-memory zenoh-c feature") + declare_cache_var(ZENOHC_CUSTOM_TARGET "" STRING "Rust target for cross compilation, 'aarch64-unknown-linux-gnu' for example") +-declare_cache_var(ZENOHC_CARGO_CHANNEL "stable" STRING "Cargo channel selected: stable or nightly") + declare_cache_var(ZENOHC_CARGO_FLAGS "" STRING "Additional cargo flags") + declare_cache_var(ZENOHC_LIB_STATIC FALSE BOOL "Alias zenohc::lib target to zenohc::static if TRUE, to zenohc::shared if FALSE") + +@@ -47,9 +46,9 @@ status_print(project_version) + # + # There are 3 possible variants of placement generated Cargo.toml files: + # 1. Build in source tree (in IDE usually), using single config generator (Ninja, Makefiles) +-# ++# + # In this case Cargo.toml is placed at the root of source tree to make it visible for rust-analyzer. When release or debug +-# configuration is selected, Cargo.toml is updated accordingly ++# configuration is selected, Cargo.toml is updated accordingly + # + # 2. Build in source tree (in IDE usually), using multi config generator (Visual Studio, Ninja Multi-Config) + # +@@ -112,7 +111,7 @@ function(configure_cargo_toml cargo_toml_dir CARGO_PROJECT_VERSION CARGO_LIB_NAM + ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.lock + ${CMAKE_CURRENT_SOURCE_DIR}/rust-toolchain.toml + DESTINATION ${cargo_toml_dir}) +- endif() ++ endif() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml.in" "${cargo_toml_dir}/Cargo.toml" @ONLY) + endfunction() + +@@ -173,9 +172,9 @@ set_genexpr_condition(libs DEBUG $ "${libsd}" "${libsr}") + # + + # Combine "--release" and "--manifest-path" options under DEBUG condition to avoid passing empty parameter to cargo command line in `add_custom_command`, causing build failure +-# This empty item ($;,--release>) can't be filtered out by `list(FILTER ...)` because it becomes empty only on ++# This empty item ($;,--release>) can't be filtered out by `list(FILTER ...)` because it becomes empty only on + # build stage when generator expressions are evaluated. +-set_genexpr_condition(cargo_flags DEBUG $ ++set_genexpr_condition(cargo_flags DEBUG $ + "--manifest-path=${cargo_toml_dir_debug}/Cargo.toml" + "--release;--manifest-path=${cargo_toml_dir_release}/Cargo.toml") + set(cargo_flags ${cargo_flags} ${ZENOHC_CARGO_FLAGS}) +@@ -198,8 +197,8 @@ file(GLOB_RECURSE rust_sources "Cargo.toml.in" "src/*.rs" "build.rs" "splitguide + add_custom_command( + OUTPUT ${libs} + COMMAND ${CMAKE_COMMAND} -E echo \"RUSTFLAGS = $$RUSTFLAGS\" +- COMMAND ${CMAKE_COMMAND} -E echo \"cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\" +- COMMAND cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags} ++ COMMAND ${CMAKE_COMMAND} -E echo \"cargo build ${cargo_flags}\" ++ COMMAND cargo build ${cargo_flags} + VERBATIM + COMMAND_EXPAND_LISTS + DEPENDS "${rust_sources}" From b421813fb438b4ec5f25c7ec03e0f694f613c822 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Mon, 25 Mar 2024 16:14:22 +0800 Subject: [PATCH 02/10] Add tmp build for noble job Signed-off-by: Yadunund --- .github/workflows/build.yaml | 2 +- .github/workflows/tmp_build_noble.yaml | 36 ++++++++++++++++++++++++++ zenoh_c_vendor/CMakeLists.txt | 8 ++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tmp_build_noble.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 07c90a86..2ca84342 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - docker_image: ['ros:iron-ros-base', 'ros:rolling-ros-base'] + docker_image: ['ros:iron-ros-base'] container: image: ${{ matrix.docker_image }} timeout-minutes: 30 diff --git a/.github/workflows/tmp_build_noble.yaml b/.github/workflows/tmp_build_noble.yaml new file mode 100644 index 00000000..17d9fe2e --- /dev/null +++ b/.github/workflows/tmp_build_noble.yaml @@ -0,0 +1,36 @@ +name: build_noble +on: + pull_request: + push: + branches: [ rolling ] + workflow_dispatch: +defaults: + run: + shell: bash +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + docker_image: ['ubuntu:noble-20240225'] + container: + image: ${{ matrix.docker_image }} + timeout-minutes: 30 + steps: + - name: Setup rolling + run: | + apt update && apt install curl -y + curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + apt update && apt install ros-dev-tools -y + apt install ros-rolling-ros-base -y + - uses: actions/checkout@v2 + - name: rosdep + run: | + rosdep init + rosdep update + rosdep install --from-paths . --rosdistro rolling -yir + - name: build + run: | + source /opt/ros/rolling/setup.bash + colcon build diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 032412bf..5de23078 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -24,6 +24,14 @@ find_package(ament_cmake_vendor_package REQUIRED) # when expanded. set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transport_tcp zenoh/shared-memory") +# Apply the patch the zenoh-c CMakeLists.txt only if building an ROS 2 version +# newer than Iron. +set(pathces "") +string(SUBSTRING "$ENV{ROS_DISTRO}" 0 1 first_char) +if("${first_char}" STRGREATER "i") + set(patches "patches") +endif() + # Set VCS_VERSION to include changes from https://github.com/eclipse-zenoh/zenoh/pull/802 # which was synced to zenoh-c in https://github.com/eclipse-zenoh/zenoh-c/pull/272. ament_vendor(zenoh_c_vendor From 0f568c8cfb8e7cfee9d30a85cb44dd557cabfcf0 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Mon, 25 Mar 2024 16:29:38 +0800 Subject: [PATCH 03/10] Try to fix iron Signed-off-by: Yadunund --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2ca84342..d57d1c5d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,7 +21,7 @@ jobs: run: | apt update && apt install -y curl - name: Setup Rust - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@1.75.0 - uses: actions/checkout@v2 - name: rosdep run: | From af9140248e610ef30175ef067a9c63e9bc2254d8 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Mon, 25 Mar 2024 17:19:26 +0800 Subject: [PATCH 04/10] Patch even for iron builds Signed-off-by: Yadunund --- zenoh_c_vendor/CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 5de23078..59493e62 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -23,15 +23,6 @@ find_package(ament_cmake_vendor_package REQUIRED) # latter is a list separater in cmake and hence the string will be split into two # when expanded. set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transport_tcp zenoh/shared-memory") - -# Apply the patch the zenoh-c CMakeLists.txt only if building an ROS 2 version -# newer than Iron. -set(pathces "") -string(SUBSTRING "$ENV{ROS_DISTRO}" 0 1 first_char) -if("${first_char}" STRGREATER "i") - set(patches "patches") -endif() - # Set VCS_VERSION to include changes from https://github.com/eclipse-zenoh/zenoh/pull/802 # which was synced to zenoh-c in https://github.com/eclipse-zenoh/zenoh-c/pull/272. ament_vendor(zenoh_c_vendor From 3edb8e6e8bc949ae448fc90c0c2003326ee853f0 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Tue, 26 Mar 2024 20:54:04 +0800 Subject: [PATCH 05/10] Force build with 1.75.0 on jammy Signed-off-by: Yadunund --- .github/workflows/build.yaml | 3 ++- .github/workflows/style.yaml | 1 + README.md | 6 ++++-- zenoh_c_vendor/CMakeLists.txt | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d57d1c5d..7dd4881f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,8 +11,9 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - docker_image: ['ros:iron-ros-base'] + docker_image: ['ros:iron-ros-base', 'ros:rolling-ros-base'] container: image: ${{ matrix.docker_image }} timeout-minutes: 30 diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index 5c3a7160..04f818b1 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -10,6 +10,7 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: docker_image: ['ros:iron-ros-base', 'ros:rolling-ros-base'] container: diff --git a/README.md b/README.md index 1d831c3c..278ebc26 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,12 @@ For information about the Design please visit [design](docs/design.md) page. ## Setup -Install latest rustc. -> Note: The version of rustc that can be installed via apt is outdated. +Install latest rustc via `rustup` if building on Ubuntu Jammy. +Skip this step if building on Ubuntu Noble as `cargo` and `rustc` will be +installed via `rosdep`. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +rustup install 1.75.0 ``` Build `rmw_zenoh_cpp` diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 59493e62..8e013f6e 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -23,6 +23,21 @@ find_package(ament_cmake_vendor_package REQUIRED) # latter is a list separater in cmake and hence the string will be split into two # when expanded. set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transport_tcp zenoh/shared-memory") + +# Always force rustc 1.75.0. +# This this is default version of rustc available via apt in Ubuntu Noble. +# We explictly use the +1.75.0 toolchain when building on Ubuntu Jammy. +set(ZENOHC_CARGO_CHANNEL "1.75.0") + +# Apply the patch the zenoh-c CMakeLists.txt only if building an ROS 2 version +# newer than Iron. The patch removes the ability to set ZENOHC_CARGO_CHANNEL +# via cmake args +set(pathces "") +string(SUBSTRING "$ENV{ROS_DISTRO}" 0 1 first_char) +if("${first_char}" STRGREATER "i") + set(patches "patches") +endif() + # Set VCS_VERSION to include changes from https://github.com/eclipse-zenoh/zenoh/pull/802 # which was synced to zenoh-c in https://github.com/eclipse-zenoh/zenoh-c/pull/272. ament_vendor(zenoh_c_vendor @@ -30,6 +45,7 @@ ament_vendor(zenoh_c_vendor VCS_VERSION 10176b911096cb92b8ee46bc491b78079ee26c20 CMAKE_ARGS "-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}" + "-DZENOHC_CARGO_CHANNEL=${ZENOHC_CARGO_CHANNEL}" PATCHES patches ) From 783803af78e4705e2d0dc283e05d55c3f811cd1a Mon Sep 17 00:00:00 2001 From: Yadu Date: Tue, 26 Mar 2024 21:31:52 +0800 Subject: [PATCH 06/10] Update zenoh_c_vendor/CMakeLists.txt Co-authored-by: Chris Lalancette Signed-off-by: Yadu --- zenoh_c_vendor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 8e013f6e..afc55f71 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -25,7 +25,7 @@ find_package(ament_cmake_vendor_package REQUIRED) set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transport_tcp zenoh/shared-memory") # Always force rustc 1.75.0. -# This this is default version of rustc available via apt in Ubuntu Noble. +# This is the default version of rustc available via apt in Ubuntu Noble. # We explictly use the +1.75.0 toolchain when building on Ubuntu Jammy. set(ZENOHC_CARGO_CHANNEL "1.75.0") From a48a0e50b0d7c057b512a25d19f2497e194bef59 Mon Sep 17 00:00:00 2001 From: Yadu Date: Tue, 26 Mar 2024 21:31:59 +0800 Subject: [PATCH 07/10] Update zenoh_c_vendor/CMakeLists.txt Co-authored-by: Chris Lalancette Signed-off-by: Yadu --- zenoh_c_vendor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index afc55f71..71a33066 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -29,7 +29,7 @@ set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transp # We explictly use the +1.75.0 toolchain when building on Ubuntu Jammy. set(ZENOHC_CARGO_CHANNEL "1.75.0") -# Apply the patch the zenoh-c CMakeLists.txt only if building an ROS 2 version +# Apply the patch to the zenoh-c CMakeLists.txt only if building an ROS 2 version # newer than Iron. The patch removes the ability to set ZENOHC_CARGO_CHANNEL # via cmake args set(pathces "") From 5b98e67c0458a8f485c2624981bbeac76e1bd3c0 Mon Sep 17 00:00:00 2001 From: Yadu Date: Tue, 26 Mar 2024 21:32:13 +0800 Subject: [PATCH 08/10] Update zenoh_c_vendor/CMakeLists.txt Co-authored-by: Chris Lalancette Signed-off-by: Yadu --- zenoh_c_vendor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 71a33066..114be3ee 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -32,7 +32,7 @@ set(ZENOHC_CARGO_CHANNEL "1.75.0") # Apply the patch to the zenoh-c CMakeLists.txt only if building an ROS 2 version # newer than Iron. The patch removes the ability to set ZENOHC_CARGO_CHANNEL # via cmake args -set(pathces "") +set(patches "") string(SUBSTRING "$ENV{ROS_DISTRO}" 0 1 first_char) if("${first_char}" STRGREATER "i") set(patches "patches") From f2be32cd82bbc2762688d756023dfade6a1aed89 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Tue, 26 Mar 2024 22:30:54 +0800 Subject: [PATCH 09/10] Patch zenoh-c based on cargo toolchain availability Signed-off-by: Yadunund --- zenoh_c_vendor/CMakeLists.txt | 28 +++++++++++++++++----------- zenoh_c_vendor/package.xml | 3 +-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 114be3ee..8d238a37 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -24,18 +24,24 @@ find_package(ament_cmake_vendor_package REQUIRED) # when expanded. set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transport_tcp zenoh/shared-memory") -# Always force rustc 1.75.0. -# This is the default version of rustc available via apt in Ubuntu Noble. -# We explictly use the +1.75.0 toolchain when building on Ubuntu Jammy. -set(ZENOHC_CARGO_CHANNEL "1.75.0") - -# Apply the patch to the zenoh-c CMakeLists.txt only if building an ROS 2 version -# newer than Iron. The patch removes the ability to set ZENOHC_CARGO_CHANNEL -# via cmake args +# Depending on how cargo is installed, the +stable toolchain may be unavailable. +# In such cases we patch zenoh-c to not set ZENOHC_CARGO_CHANNEL to +stable. set(patches "") -string(SUBSTRING "$ENV{ROS_DISTRO}" 0 1 first_char) -if("${first_char}" STRGREATER "i") +set(toolchain_error "") +set(CARGO_CMD "cargo") +set(CARGO_ARG "+stable") +execute_process( + COMMAND ${CARGO_CMD} ${CARGO_ARG} + ERROR_VARIABLE toolchain_error +) +if(NOT "${toolchain_error}" STREQUAL "") + # The stable toolchain is unavailable and hence we patch zenoh-c. set(patches "patches") +else() + # Always force rustc 1.75.0. + # This is the default version of rustc available via apt in Ubuntu Noble. + # We explictly use the +1.75.0 toolchain when building on Ubuntu Jammy. + set(ZENOHC_CARGO_CHANNEL "-DZENOHC_CARGO_CHANNEL=1.75.0") endif() # Set VCS_VERSION to include changes from https://github.com/eclipse-zenoh/zenoh/pull/802 @@ -45,7 +51,7 @@ ament_vendor(zenoh_c_vendor VCS_VERSION 10176b911096cb92b8ee46bc491b78079ee26c20 CMAKE_ARGS "-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}" - "-DZENOHC_CARGO_CHANNEL=${ZENOHC_CARGO_CHANNEL}" + "${ZENOHC_CARGO_CHANNEL}" PATCHES patches ) diff --git a/zenoh_c_vendor/package.xml b/zenoh_c_vendor/package.xml index 3848c24a..55c17616 100644 --- a/zenoh_c_vendor/package.xml +++ b/zenoh_c_vendor/package.xml @@ -12,8 +12,7 @@ ament_cmake ament_cmake_vendor_package - - cargo + cargo clang From 3f8474879d2ccfca6cb0dfaf05679e47ae25999f Mon Sep 17 00:00:00 2001 From: Yadunund Date: Sun, 31 Mar 2024 17:56:36 +0800 Subject: [PATCH 10/10] Make patch from zenoh-c PR #301 Signed-off-by: Yadunund --- zenoh_c_vendor/CMakeLists.txt | 23 +------- zenoh_c_vendor/patches/cargo_toolchain.patch | 56 -------------------- zenoh_c_vendor/patches/pr_301.patch | 24 +++++++++ 3 files changed, 26 insertions(+), 77 deletions(-) delete mode 100644 zenoh_c_vendor/patches/cargo_toolchain.patch create mode 100644 zenoh_c_vendor/patches/pr_301.patch diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 8d238a37..da56c50a 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -24,34 +24,15 @@ find_package(ament_cmake_vendor_package REQUIRED) # when expanded. set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=zenoh/transport_tcp zenoh/shared-memory") -# Depending on how cargo is installed, the +stable toolchain may be unavailable. -# In such cases we patch zenoh-c to not set ZENOHC_CARGO_CHANNEL to +stable. -set(patches "") -set(toolchain_error "") -set(CARGO_CMD "cargo") -set(CARGO_ARG "+stable") -execute_process( - COMMAND ${CARGO_CMD} ${CARGO_ARG} - ERROR_VARIABLE toolchain_error -) -if(NOT "${toolchain_error}" STREQUAL "") - # The stable toolchain is unavailable and hence we patch zenoh-c. - set(patches "patches") -else() - # Always force rustc 1.75.0. - # This is the default version of rustc available via apt in Ubuntu Noble. - # We explictly use the +1.75.0 toolchain when building on Ubuntu Jammy. - set(ZENOHC_CARGO_CHANNEL "-DZENOHC_CARGO_CHANNEL=1.75.0") -endif() - # Set VCS_VERSION to include changes from https://github.com/eclipse-zenoh/zenoh/pull/802 # which was synced to zenoh-c in https://github.com/eclipse-zenoh/zenoh-c/pull/272. +# Apply patches: +# - https://github.com/eclipse-zenoh/zenoh-c/pull/301 ament_vendor(zenoh_c_vendor VCS_URL https://github.com/eclipse-zenoh/zenoh-c.git VCS_VERSION 10176b911096cb92b8ee46bc491b78079ee26c20 CMAKE_ARGS "-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}" - "${ZENOHC_CARGO_CHANNEL}" PATCHES patches ) diff --git a/zenoh_c_vendor/patches/cargo_toolchain.patch b/zenoh_c_vendor/patches/cargo_toolchain.patch deleted file mode 100644 index c5a399d8..00000000 --- a/zenoh_c_vendor/patches/cargo_toolchain.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 00aa5ca..eacd7d6 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -27,7 +27,6 @@ declare_cache_var_true_if_vscode(ZENOHC_BUILD_IN_SOURCE_TREE "Do build inside so - declare_cache_var(ZENOHC_BUILD_WITH_LOGGER_AUTOINIT TRUE BOOL "Enable logger-autoinit zenoh-c feature") - declare_cache_var(ZENOHC_BUILD_WITH_SHARED_MEMORY TRUE BOOL "Enable shared-memory zenoh-c feature") - declare_cache_var(ZENOHC_CUSTOM_TARGET "" STRING "Rust target for cross compilation, 'aarch64-unknown-linux-gnu' for example") --declare_cache_var(ZENOHC_CARGO_CHANNEL "stable" STRING "Cargo channel selected: stable or nightly") - declare_cache_var(ZENOHC_CARGO_FLAGS "" STRING "Additional cargo flags") - declare_cache_var(ZENOHC_LIB_STATIC FALSE BOOL "Alias zenohc::lib target to zenohc::static if TRUE, to zenohc::shared if FALSE") - -@@ -47,9 +46,9 @@ status_print(project_version) - # - # There are 3 possible variants of placement generated Cargo.toml files: - # 1. Build in source tree (in IDE usually), using single config generator (Ninja, Makefiles) --# -+# - # In this case Cargo.toml is placed at the root of source tree to make it visible for rust-analyzer. When release or debug --# configuration is selected, Cargo.toml is updated accordingly -+# configuration is selected, Cargo.toml is updated accordingly - # - # 2. Build in source tree (in IDE usually), using multi config generator (Visual Studio, Ninja Multi-Config) - # -@@ -112,7 +111,7 @@ function(configure_cargo_toml cargo_toml_dir CARGO_PROJECT_VERSION CARGO_LIB_NAM - ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.lock - ${CMAKE_CURRENT_SOURCE_DIR}/rust-toolchain.toml - DESTINATION ${cargo_toml_dir}) -- endif() -+ endif() - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml.in" "${cargo_toml_dir}/Cargo.toml" @ONLY) - endfunction() - -@@ -173,9 +172,9 @@ set_genexpr_condition(libs DEBUG $ "${libsd}" "${libsr}") - # - - # Combine "--release" and "--manifest-path" options under DEBUG condition to avoid passing empty parameter to cargo command line in `add_custom_command`, causing build failure --# This empty item ($;,--release>) can't be filtered out by `list(FILTER ...)` because it becomes empty only on -+# This empty item ($;,--release>) can't be filtered out by `list(FILTER ...)` because it becomes empty only on - # build stage when generator expressions are evaluated. --set_genexpr_condition(cargo_flags DEBUG $ -+set_genexpr_condition(cargo_flags DEBUG $ - "--manifest-path=${cargo_toml_dir_debug}/Cargo.toml" - "--release;--manifest-path=${cargo_toml_dir_release}/Cargo.toml") - set(cargo_flags ${cargo_flags} ${ZENOHC_CARGO_FLAGS}) -@@ -198,8 +197,8 @@ file(GLOB_RECURSE rust_sources "Cargo.toml.in" "src/*.rs" "build.rs" "splitguide - add_custom_command( - OUTPUT ${libs} - COMMAND ${CMAKE_COMMAND} -E echo \"RUSTFLAGS = $$RUSTFLAGS\" -- COMMAND ${CMAKE_COMMAND} -E echo \"cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\" -- COMMAND cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags} -+ COMMAND ${CMAKE_COMMAND} -E echo \"cargo build ${cargo_flags}\" -+ COMMAND cargo build ${cargo_flags} - VERBATIM - COMMAND_EXPAND_LISTS - DEPENDS "${rust_sources}" diff --git a/zenoh_c_vendor/patches/pr_301.patch b/zenoh_c_vendor/patches/pr_301.patch new file mode 100644 index 00000000..68008fd9 --- /dev/null +++ b/zenoh_c_vendor/patches/pr_301.patch @@ -0,0 +1,24 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 00aa5ca..d236e99 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -27,7 +27,7 @@ declare_cache_var_true_if_vscode(ZENOHC_BUILD_IN_SOURCE_TREE "Do build inside so + declare_cache_var(ZENOHC_BUILD_WITH_LOGGER_AUTOINIT TRUE BOOL "Enable logger-autoinit zenoh-c feature") + declare_cache_var(ZENOHC_BUILD_WITH_SHARED_MEMORY TRUE BOOL "Enable shared-memory zenoh-c feature") + declare_cache_var(ZENOHC_CUSTOM_TARGET "" STRING "Rust target for cross compilation, 'aarch64-unknown-linux-gnu' for example") +-declare_cache_var(ZENOHC_CARGO_CHANNEL "stable" STRING "Cargo channel selected: stable or nightly") ++declare_cache_var(ZENOHC_CARGO_CHANNEL "" STRING "Cargo channel parameter. Should be '+stable', '+nightly' or empty value") + declare_cache_var(ZENOHC_CARGO_FLAGS "" STRING "Additional cargo flags") + declare_cache_var(ZENOHC_LIB_STATIC FALSE BOOL "Alias zenohc::lib target to zenohc::static if TRUE, to zenohc::shared if FALSE") + +@@ -198,8 +198,8 @@ file(GLOB_RECURSE rust_sources "Cargo.toml.in" "src/*.rs" "build.rs" "splitguide + add_custom_command( + OUTPUT ${libs} + COMMAND ${CMAKE_COMMAND} -E echo \"RUSTFLAGS = $$RUSTFLAGS\" +- COMMAND ${CMAKE_COMMAND} -E echo \"cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\" +- COMMAND cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags} ++ COMMAND ${CMAKE_COMMAND} -E echo \"cargo ${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\" ++ COMMAND cargo ${ZENOHC_CARGO_CHANNEL} build ${cargo_flags} + VERBATIM + COMMAND_EXPAND_LISTS + DEPENDS "${rust_sources}"