From dce7bb8458d7f822e170acbc6cabea36ab2abec2 Mon Sep 17 00:00:00 2001 From: Yadunund Date: Mon, 25 Mar 2024 13:57:03 +0800 Subject: [PATCH] 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}"