From c84bb67914789e13ca72fa57cd61c9c4e8c51b0f Mon Sep 17 00:00:00 2001 From: Martin Dahl Date: Fri, 7 May 2021 20:26:12 +0200 Subject: [PATCH] macos fixes --- build.rs | 10 ---------- msg_gen/build.rs | 4 +--- rcl/build.rs | 29 +++++++++++------------------ 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/build.rs b/build.rs index 58b4901..683905f 100644 --- a/build.rs +++ b/build.rs @@ -26,16 +26,6 @@ fn main() { let mut modules = String::new(); for (module, prefixes) in &msgs { - println!( - "cargo:rustc-link-lib=dylib={}__rosidl_typesupport_c", - module - ); - println!( - "cargo:rustc-link-lib=dylib={}__rosidl_typesupport_introspection_c", - module - ); - println!("cargo:rustc-link-lib=dylib={}__rosidl_generator_c", module); - modules.push_str(&format!(r#"pub mod {module}{{include!(concat!(env!("OUT_DIR"), "/{module}.rs"));}}{lf}"#, module=module, lf="\n")); let mut codegen = String::new(); diff --git a/msg_gen/build.rs b/msg_gen/build.rs index eac2f77..790c3f1 100644 --- a/msg_gen/build.rs +++ b/msg_gen/build.rs @@ -14,7 +14,6 @@ fn main() { let packages = cmake_includes.split(":").flat_map(|i| Path::new(i).parent()).collect::>(); for p in cmake_includes.split(":") { builder = builder.clang_arg(format!("-I{}", p)); - println!("adding include path: {}", p); } let deps = env::var("CMAKE_IDL_PACKAGES").unwrap_or(String::default()); let deps = deps.split(":").collect::>(); @@ -25,7 +24,6 @@ fn main() { 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)); - println!("cargo:rustc-link-search=native={}/lib", p); } let paths = ament_prefix_var.split(":").map(|i| Path::new(i)).collect::>(); @@ -96,7 +94,7 @@ fn main() { builder = builder .header(msg_includes_fn.to_str().unwrap()) .derive_copy(false) - // blacklist types that are handled by rcl bindings + // blacklist types that are handled by rcl bindings .blacklist_type("rosidl_message_type_support_t") .blacklist_type("rosidl_service_type_support_t") .blacklist_type("rosidl_runtime_c__String") diff --git a/rcl/build.rs b/rcl/build.rs index e1faaf7..745adca 100644 --- a/rcl/build.rs +++ b/rcl/build.rs @@ -1,7 +1,7 @@ extern crate bindgen; use std::env; -use std::path::PathBuf; +use std::path::{Path,PathBuf}; use itertools::Itertools; use common; @@ -18,12 +18,9 @@ fn main() { if let Some(cmake_includes) = env::var("CMAKE_INCLUDE_DIRS").ok() { // we are running from cmake, do special thing. - let cmake_libs = env::var("CMAKE_LIBRARIES").unwrap_or(String::new()); - let mut includes = cmake_includes.split(":").collect::>(); includes.sort(); includes.dedup(); - includes.iter().for_each(|l| println!("CMAKE_INCLUDE: {}", l)); for x in &includes { let clang_arg = format!("-I{}", x); @@ -31,22 +28,18 @@ fn main() { builder = builder.clang_arg(clang_arg); } - let libs = cmake_libs.split(":") + env::var("CMAKE_LIBRARIES").unwrap_or(String::new()).split(":") .into_iter() - .filter(|s| s.contains(".so")) + .filter(|s| s.contains(".so") || s.contains(".dylib")) + .flat_map(|l| Path::new(l).parent().and_then(|p| p.to_str())) .unique() - .collect::>(); - - libs.iter().for_each(|l| { - let path = PathBuf::from(l); - let pp = path.parent().and_then(|p| p.to_str()).unwrap(); - println!("cargo:rustc-link-search=native={}", pp); - // we could potentially do the below instead of hardcoding which libs we rely on. - // let filename = path.file_stem().and_then(|f| f.to_str()).unwrap(); - // let without_lib = filename.strip_prefix("lib").unwrap(); - // println!("cargo:rustc-link-lib=dylib={}", without_lib); - } - ); + .for_each(|pp| { + println!("cargo:rustc-link-search=native={}", pp) + // we could potentially do the below instead of hardcoding which libs we rely on. + // let filename = path.file_stem().and_then(|f| f.to_str()).unwrap(); + // let without_lib = filename.strip_prefix("lib").unwrap(); + // println!("cargo:rustc-link-lib=dylib={}", without_lib); + }); } else { let ament_prefix_var_name = "AMENT_PREFIX_PATH"; let ament_prefix_var = env::var(ament_prefix_var_name).expect("Source your ROS!");