diff --git a/r2r/build.rs b/r2r/build.rs index 61465ebd8..ec3ce513d 100644 --- a/r2r/build.rs +++ b/r2r/build.rs @@ -36,6 +36,18 @@ use filenames::*; fn main() { r2r_common::print_cargo_watches(); + // Declare all the custom cfg directives we use + // to silence cargo warnings. + r2r_common::print_cargo_used_cfgs(&[ + "r2r__rosgraph_msgs__msg__Clock", + "r2r__action_msgs__msg__GoalStatus", + "r2r__test_msgs__msg__Defaults", + "r2r__test_msgs__msg__Arrays", + "r2r__test_msgs__msg__WStrings", + "r2r__example_interfaces__srv__AddTwoInts", + "r2r__std_srvs__srv__Empty", + "r2r__example_interfaces__action__Fibonacci", + ]); r2r_common::print_cargo_ros_distro(); let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); diff --git a/r2r_common/src/lib.rs b/r2r_common/src/lib.rs index ffe30b08f..36f333a7b 100644 --- a/r2r_common/src/lib.rs +++ b/r2r_common/src/lib.rs @@ -150,6 +150,19 @@ pub fn print_cargo_ros_distro() { } } +pub fn print_cargo_used_cfgs(message_cfgs: &[&str]) { + // Declare all supported ros distros as cfg directives for cargo + for d in SUPPORTED_ROS_DISTROS { + println!("cargo::rustc-check-cfg=cfg(r2r__ros__distro__{d})"); + } + + // additionally we have conditional tests and features based on some + // optional ros message packages. + for c in message_cfgs { + println!("cargo::rustc-check-cfg=cfg({c})"); + } +} + pub fn print_cargo_link_search() { let ament_prefix_var_name = "AMENT_PREFIX_PATH"; if let Some(paths) = env::var_os(ament_prefix_var_name) { diff --git a/r2r_rcl/src/lib.rs b/r2r_rcl/src/lib.rs index efb189ed3..9a3348647 100644 --- a/r2r_rcl/src/lib.rs +++ b/r2r_rcl/src/lib.rs @@ -3,6 +3,10 @@ #![allow(non_snake_case)] #![allow(improper_ctypes)] #![allow(dead_code)] +// Silence "`extern` fn uses type `u128`, which is not FFI-safe" +// As of rustc 1.78, this has been fixed. +// It could be good to still warn if building with an older rust version. +#![allow(improper_ctypes)] include!(concat!(env!("OUT_DIR"), "/rcl_bindings.rs")); use std::ffi::{CStr, CString}; diff --git a/tests/build_minimal_node.bash b/tests/build_minimal_node.bash index a478386e9..bf38e6dce 100755 --- a/tests/build_minimal_node.bash +++ b/tests/build_minimal_node.bash @@ -1,6 +1,7 @@ #!/bin/bash # Use the local version of r2r when building the minimal node. +rm /r2r/r2r_minimal_node/r2r_minimal_node/Cargo.lock cat >> /r2r/r2r_minimal_node/r2r_minimal_node/Cargo.toml << EOF [patch.crates-io]