ROS_DISTRO as configuration option.
Allows us to handle API differences between ros versions.
This commit is contained in:
parent
47ba2b075a
commit
ccdfc1ebc9
|
|
@ -17,6 +17,7 @@ const GENERATED_FILES: &[&str] = &[
|
|||
|
||||
fn main() {
|
||||
r2r_common::print_cargo_watches();
|
||||
r2r_common::print_cargo_ros_distro();
|
||||
|
||||
let env_hash = r2r_common::get_env_hash();
|
||||
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ use futures::task::LocalSpawnExt;
|
|||
// ros2 param get /demo/my_node key2 # (should return false)
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Ros version: {}", r2r::ROS_DISTRO);
|
||||
|
||||
// set up executor
|
||||
let mut pool = LocalPool::new();
|
||||
let spawner = pool.spawner();
|
||||
|
|
|
|||
|
|
@ -122,3 +122,16 @@ pub use nodes::{Node, Timer};
|
|||
|
||||
pub mod qos;
|
||||
pub use qos::QosProfile;
|
||||
|
||||
/// The ros version currently built against.
|
||||
#[cfg(r2r__ros__distro__foxy)]
|
||||
pub const ROS_DISTRO: &str = "foxy";
|
||||
#[cfg(r2r__ros__distro__galactic)]
|
||||
pub const ROS_DISTRO: &str = "galactic";
|
||||
#[cfg(r2r__ros__distro__humble)]
|
||||
pub const ROS_DISTRO: &str = "humble";
|
||||
#[cfg(r2r__ros__distro__rolling)]
|
||||
pub const ROS_DISTRO: &str = "rolling";
|
||||
#[cfg(not(any(r2r__ros__distro__foxy, r2r__ros__distro__galactic,
|
||||
r2r__ros__distro__humble, r2r__ros__distro__rolling)))]
|
||||
pub const ROS_DISTRO: &str = "unknown";
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ const BINDINGS_FILENAME: &str = "action_bindings.rs";
|
|||
|
||||
fn main() {
|
||||
r2r_common::print_cargo_watches();
|
||||
r2r_common::print_cargo_ros_distro();
|
||||
|
||||
run_bindgen();
|
||||
run_dynlink();
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@ use std::fs::{self, File};
|
|||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
|
||||
const SUPPORTED_ROS_DISTROS: &[&str] = &[
|
||||
"foxy",
|
||||
"galactic",
|
||||
"humble",
|
||||
"rolling",
|
||||
];
|
||||
|
||||
const WATCHED_ENV_VARS: &[&str] = &[
|
||||
"AMENT_PREFIX_PATH",
|
||||
"CMAKE_INCLUDE_DIRS",
|
||||
"CMAKE_LIBRARIES",
|
||||
"CMAKE_IDL_PACKAGES",
|
||||
"IDL_PACKAGE_FILTER",
|
||||
"ROS_DISTRO",
|
||||
];
|
||||
|
||||
pub fn get_env_hash() -> String {
|
||||
|
|
@ -111,6 +119,17 @@ pub fn setup_bindgen_builder() -> bindgen::Builder {
|
|||
builder
|
||||
}
|
||||
|
||||
pub fn print_cargo_ros_distro() {
|
||||
let ros_distro = env::var("ROS_DISTRO")
|
||||
.unwrap_or_else(|_| panic!("ROS_DISTRO not set: Source your ROS!"));
|
||||
|
||||
if SUPPORTED_ROS_DISTROS.iter().any(|d| d == &ros_distro) {
|
||||
println!("cargo:rustc-cfg=r2r__ros__distro__{ros_distro}");
|
||||
} else {
|
||||
panic!("ROS_DISTRO not supported: {ros_distro}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_cargo_link_search() {
|
||||
if env::var("CMAKE_INCLUDE_DIRS").is_ok() {
|
||||
if let Ok(paths) = env::var("CMAKE_LIBRARIES") {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ const GENERATED_FILES: &[&str] = &[
|
|||
|
||||
fn main() {
|
||||
r2r_common::print_cargo_watches();
|
||||
r2r_common::print_cargo_ros_distro();
|
||||
|
||||
let msg_list = r2r_common::get_wanted_messages();
|
||||
run_bindgen(&msg_list);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use std::path::PathBuf;
|
|||
|
||||
fn main() {
|
||||
r2r_common::print_cargo_watches();
|
||||
r2r_common::print_cargo_ros_distro();
|
||||
run_bindgen();
|
||||
run_dynlink();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue