@@ -16,6 +16,9 @@ const INCLUDE_PACKAGES: &[&str] = &[
1616] ;
1717
1818fn main ( ) {
19+ // Declare custom cfg for auto-detection
20+ println ! ( "cargo:rustc-check-cfg=cfg(has_test_msgs)" ) ;
21+
1922 // Get AMENT_PREFIX_PATH from the environment
2023 let ament_prefix = env:: var ( "AMENT_PREFIX_PATH" ) . expect ( "AMENT_PREFIX_PATH is missing!" ) ;
2124
@@ -39,11 +42,14 @@ fn main() {
3942 . clang_args ( include_args)
4043 . allowlist_function ( "rcl_.*" )
4144 . allowlist_function ( "rmw_get_gid_for_publisher" )
45+ . allowlist_function ( "rmw_publisher_count_matched_subscriptions" )
46+ . allowlist_function ( "rmw_subscription_count_matched_publishers" )
4247 . allowlist_function ( "rosidl_typesupport_c__get_service_type_support_handle__type_description_interfaces__srv__GetTypeDescription" )
4348 . allowlist_type ( "rcl_.*" )
4449 . blocklist_type ( "rmw_qos_profile_s" )
4550 . blocklist_type ( "rmw_qos_.*_policy_e" )
4651 . allowlist_var ( "RCL_.*" )
52+ . allowlist_var ( "RMW_.*" )
4753 // .no_default("rmw_qos_profile_s")
4854 . default_enum_style ( bindgen:: EnumVariation :: Rust {
4955 non_exhaustive : false ,
@@ -128,11 +134,23 @@ fn main() {
128134
129135 println ! ( "cargo:rustc-link-search=native=/usr/local/lib" ) ;
130136 println ! ( "cargo:rustc-link-search=native={ament_prefix}/lib/" ) ;
137+
138+ println ! ( "cargo:rustc-link-lib=dylib=rcl" ) ;
131139 println ! ( "cargo:rustc-link-lib=dylib=rmw" ) ;
132140 println ! ( "cargo:rustc-link-lib=dylib=rcutils" ) ;
133141 println ! ( "cargo:rustc-link-lib=dylib=fastcdr" ) ;
134142 println ! ( "cargo:rustc-link-lib=dylib=rosidl_runtime_c" ) ;
135143 println ! ( "cargo:rustc-link-lib=dylib=rosidl_typesupport_fastrtps_c" ) ;
136144 println ! ( "cargo:rustc-link-lib=dylib=rosidl_typesupport_fastrtps_cpp" ) ;
137145 println ! ( "cargo:rustc-link-lib=dylib=type_description_interfaces__rosidl_typesupport_c" ) ;
146+
147+ // Link test_msgs for tests
148+ #[ cfg( feature = "test-msgs" ) ]
149+ {
150+ // Explicit feature: always link (fail if not available)
151+ println ! ( "cargo:rustc-link-lib=dylib=test_msgs__rosidl_generator_c" ) ;
152+ println ! ( "cargo:rustc-link-lib=dylib=test_msgs__rosidl_typesupport_c" ) ;
153+ println ! ( "cargo:rustc-link-lib=dylib=test_msgs__rosidl_typesupport_fastrtps_c" ) ;
154+ println ! ( "cargo:rustc-link-lib=dylib=test_msgs__rosidl_typesupport_fastrtps_cpp" ) ;
155+ }
138156}
0 commit comments