fix rolling compilation issues
This commit is contained in:
parent
174fb233c1
commit
ac3a9b0485
|
|
@ -42,12 +42,15 @@ fn main() {
|
|||
let ament_prefix_var = env::var(ament_prefix_var_name).expect("Source your ROS!");
|
||||
|
||||
for ament_prefix_path in ament_prefix_var.split(':') {
|
||||
builder = builder.clang_arg(format!("-I{}/include", ament_prefix_path));
|
||||
println!(
|
||||
"added include search dir: {}",
|
||||
format!("-I{}/include", ament_prefix_path)
|
||||
);
|
||||
println!("cargo:rustc-link-search=native={}/lib", ament_prefix_path);
|
||||
if let Some(include_path) = r2r_common::guess_cmake_include_path(Path::new(ament_prefix_path)) {
|
||||
if let Some(s) = include_path.to_str() {
|
||||
builder = builder.clang_arg(format!("-I{}", s));
|
||||
};
|
||||
}
|
||||
let lib_path = Path::new(ament_prefix_path).join("lib");
|
||||
lib_path.to_str().map(|s| {
|
||||
println!("cargo:rustc-link-search=native={}", s);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,15 +70,21 @@ fn main() {
|
|||
.allowlist_type("rcl_action_goal_handle_t")
|
||||
.opaque_type("rcl_action_goal_handle_t")
|
||||
.allowlist_type("rcl_action_cancel_request_t")
|
||||
.allowlist_type("rcl_action_cancel_request_s")
|
||||
.opaque_type("rcl_action_cancel_request_s")
|
||||
.allowlist_type("rcl_action_cancel_response_t")
|
||||
.allowlist_type("rcl_action_cancel_response_s")
|
||||
.allowlist_type("rcl_action_goal_event_t")
|
||||
.allowlist_type("rcl_action_goal_event_e")
|
||||
.allowlist_type("rcl_action_goal_state_t")
|
||||
.opaque_type("rcl_action_goal_state_t")
|
||||
.allowlist_type("rcl_action_goal_status_array_t")
|
||||
.opaque_type("rcl_action_goal_status_array_t")
|
||||
.allowlist_function("rcl_action_.*")
|
||||
.allowlist_type("rcl_action_client_options_t")
|
||||
.opaque_type("rcl_action_client_options_t")
|
||||
.allowlist_type("rcl_action_server_options_t")
|
||||
.opaque_type("rcl_action_server_options_t")
|
||||
.allowlist_var("RCL_RET_ACTION_.*")
|
||||
.generate_comments(false)
|
||||
.generate()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,35 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
// Hack to build rolling after https://github.com/ros2/rcl/pull/959 was merged.
|
||||
//
|
||||
// The problem is that now we need to use CMAKE to properly find the
|
||||
// include paths. But we don't want to do that so we hope that the ros
|
||||
// developers use the same convention everytime they move the include
|
||||
// files to a subdirectory.
|
||||
//
|
||||
// The convention is to put include files in include/${PROJECT_NAME}
|
||||
//
|
||||
// So we check if there is a double directory on the form
|
||||
// include/${PROJECT_NAME}/${PROJECT_NAME}, and if so append it only once.
|
||||
//
|
||||
// Should work mostly, and shouldn't really change often, so manual
|
||||
// intervention could be applied. But yes it is hacky.
|
||||
pub fn guess_cmake_include_path(path: &Path) -> Option<PathBuf> {
|
||||
if let Some(leaf) = path.file_name() {
|
||||
let double_include_path = Path::new(path).join("include").join(leaf).join(leaf);
|
||||
if double_include_path.is_dir() {
|
||||
// double dir detected, append the package name
|
||||
return Some(path.to_owned().join("include").join(leaf));
|
||||
} else {
|
||||
// dont append
|
||||
return Some(path.to_owned().join("include"));
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
pub fn print_cargo_watches() {
|
||||
println!("cargo:rerun-if-env-changed=AMENT_PREFIX_PATH");
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ fn main() {
|
|||
} else {
|
||||
let ament_prefix_var = env::var("AMENT_PREFIX_PATH").expect("Source your ROS!");
|
||||
for p in ament_prefix_var.split(':') {
|
||||
builder = builder.clang_arg(format!("-I{}/include", p));
|
||||
let path = Path::new(p).join("include");
|
||||
if let Some(s) = path.to_str() {
|
||||
builder = builder.clang_arg(format!("-I{}", s));
|
||||
}
|
||||
}
|
||||
let paths = ament_prefix_var
|
||||
.split(':')
|
||||
|
|
|
|||
|
|
@ -15,45 +15,66 @@ use std::collections::HashMap;
|
|||
|
||||
use std::ffi::CStr;
|
||||
|
||||
// because the c enum has been named between galactic and the next release,
|
||||
// we cannot know its name. therefor we use the constants as is and hope we notice
|
||||
// when they change.
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT = 1,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_DOUBLE = 2,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_LONG_DOUBLE = 3,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_CHAR = 4,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_WCHAR = 5,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_BOOLEAN = 6,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_OCTET = 7,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_UINT8 = 8,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_INT8 = 9,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_UINT16 = 10,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_INT16 = 11,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_UINT32 = 12,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_INT32 = 13,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_UINT64 = 14,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_INT64 = 15,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_STRING = 16,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_WSTRING = 17,
|
||||
// rosidl_typesupport_introspection_c__ROS_TYPE_MESSAGE = 18,
|
||||
fn field_type(t: u8) -> String {
|
||||
// lovely...
|
||||
// move to common
|
||||
if t == (rosidl_typesupport_introspection_c__ROS_TYPE_STRING as u8) {
|
||||
if t == 16 {
|
||||
"std::string::String".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_WSTRING as u8) {
|
||||
} else if t == 17 {
|
||||
"std::string::String".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_BOOLEAN as u8) {
|
||||
} else if t == 6 {
|
||||
"bool".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_CHAR as u8) {
|
||||
} else if t == 4 {
|
||||
"i8".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_WCHAR as u8) {
|
||||
"u16".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_OCTET as u8) {
|
||||
"u8".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_UINT8 as u8) {
|
||||
"u8".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_INT8 as u8) {
|
||||
"i8".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_UINT16 as u8) {
|
||||
"u16".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_INT16 as u8) {
|
||||
} else if t == 5 {
|
||||
"i16".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_UINT32 as u8) {
|
||||
} else if t == 7 {
|
||||
"u8".to_owned()
|
||||
} else if t == 8 {
|
||||
"u8".to_owned()
|
||||
} else if t == 9 {
|
||||
"i8".to_owned()
|
||||
} else if t == 10 {
|
||||
"u16".to_owned()
|
||||
} else if t == 11 {
|
||||
"i16".to_owned()
|
||||
} else if t == 12 {
|
||||
"u32".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_INT32 as u8) {
|
||||
} else if t == 13 {
|
||||
"i32".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_UINT64 as u8) {
|
||||
} else if t == 14 {
|
||||
"u64".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_INT64 as u8) {
|
||||
} else if t == 15 {
|
||||
"i64".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT as u8) {
|
||||
} else if t == 1 {
|
||||
"f32".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_DOUBLE as u8) {
|
||||
} else if t == 2 {
|
||||
"f64".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_LONG_DOUBLE as u8) {
|
||||
} else if t == 3 {
|
||||
// f128 does not exist in rust
|
||||
"u128".to_owned()
|
||||
} else if t == (rosidl_typesupport_introspection_c__ROS_TYPE_MESSAGE as u8) {
|
||||
} else if t == 18 {
|
||||
"message".to_owned()
|
||||
} else {
|
||||
panic!("ros native type not implemented: {}", t);
|
||||
|
|
|
|||
|
|
@ -47,12 +47,15 @@ fn main() {
|
|||
let ament_prefix_var = env::var(ament_prefix_var_name).expect("Source your ROS!");
|
||||
|
||||
for ament_prefix_path in ament_prefix_var.split(':') {
|
||||
builder = builder.clang_arg(format!("-I{}/include", ament_prefix_path));
|
||||
println!(
|
||||
"added include search dir: {}",
|
||||
format!("-I{}/include", ament_prefix_path)
|
||||
);
|
||||
println!("cargo:rustc-link-search=native={}/lib", ament_prefix_path);
|
||||
if let Some(include_path) = r2r_common::guess_cmake_include_path(Path::new(ament_prefix_path)) {
|
||||
if let Some(s) = include_path.to_str() {
|
||||
builder = builder.clang_arg(format!("-I{}", s));
|
||||
};
|
||||
}
|
||||
let lib_path = Path::new(ament_prefix_path).join("lib");
|
||||
lib_path.to_str().map(|s| {
|
||||
println!("cargo:rustc-link-search=native={}", s);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -460,10 +460,7 @@ mod tests {
|
|||
let type_id = (*member).type_id_;
|
||||
let is_array = (*member).is_array_;
|
||||
assert_eq!(field_name, "data");
|
||||
assert_eq!(
|
||||
type_id,
|
||||
rosidl_typesupport_introspection_c__ROS_TYPE_STRING as u8
|
||||
);
|
||||
assert_eq!(type_id, 16u8); // rosidl_typesupport_introspection_c__ROS_TYPE_STRING as u8
|
||||
assert!(!is_array);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue