Skip to content

Commit 4cb5bd3

Browse files
committed
Silence cfg and ffi warnings. Fixes #108.
1 parent d8fe90b commit 4cb5bd3

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

r2r/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ use filenames::*;
3636

3737
fn main() {
3838
r2r_common::print_cargo_watches();
39+
// Declare all the custom cfg directives we use
40+
// to silence cargo warnings.
41+
r2r_common::print_cargo_used_cfgs(&[
42+
"r2r__rosgraph_msgs__msg__Clock",
43+
"r2r__action_msgs__msg__GoalStatus",
44+
"r2r__test_msgs__msg__Defaults",
45+
"r2r__test_msgs__msg__Arrays",
46+
"r2r__test_msgs__msg__WStrings",
47+
"r2r__example_interfaces__srv__AddTwoInts",
48+
"r2r__std_srvs__srv__Empty",
49+
"r2r__example_interfaces__action__Fibonacci",
50+
]);
3951
r2r_common::print_cargo_ros_distro();
4052

4153
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());

r2r_common/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,19 @@ pub fn print_cargo_ros_distro() {
150150
}
151151
}
152152

153+
pub fn print_cargo_used_cfgs(message_cfgs: &[&str]) {
154+
// Declare all supported ros distros as cfg directives for cargo
155+
for d in SUPPORTED_ROS_DISTROS {
156+
println!("cargo::rustc-check-cfg=cfg(r2r__ros__distro__{d})");
157+
}
158+
159+
// additionally we have conditional tests and features based on some
160+
// optional ros message packages.
161+
for c in message_cfgs {
162+
println!("cargo::rustc-check-cfg=cfg({c})");
163+
}
164+
}
165+
153166
pub fn print_cargo_link_search() {
154167
let ament_prefix_var_name = "AMENT_PREFIX_PATH";
155168
if let Some(paths) = env::var_os(ament_prefix_var_name) {

r2r_rcl/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#![allow(non_snake_case)]
44
#![allow(improper_ctypes)]
55
#![allow(dead_code)]
6+
// Silence "`extern` fn uses type `u128`, which is not FFI-safe"
7+
// As of rustc 1.78, this has been fixed.
8+
// It could be good to still warn if building with an older rust version.
9+
#![allow(improper_ctypes)]
610
include!(concat!(env!("OUT_DIR"), "/rcl_bindings.rs"));
711

812
use std::ffi::{CStr, CString};

tests/build_minimal_node.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Use the local version of r2r when building the minimal node.
4+
rm /r2r/r2r_minimal_node/r2r_minimal_node/Cargo.lock
45
cat >> /r2r/r2r_minimal_node/r2r_minimal_node/Cargo.toml << EOF
56
67
[patch.crates-io]

0 commit comments

Comments
 (0)