@@ -38,78 +38,8 @@ fn main() {
38
38
println ! ( "cargo:rustc-check-cfg=cfg(ros_distro, values(\" humble\" , \" jazzy\" , \" rolling\" ))" ) ;
39
39
println ! ( "cargo:rustc-cfg=ros_distro=\" {ros_distro}\" " ) ;
40
40
41
- let mut builder = bindgen:: Builder :: default ( )
42
- . header ( BINDGEN_WRAPPER )
43
- . derive_copy ( false )
44
- . allowlist_type ( "rcl_.*" )
45
- . allowlist_type ( "rmw_.*" )
46
- . allowlist_type ( "rcutils_.*" )
47
- . allowlist_type ( "rosidl_.*" )
48
- . allowlist_function ( "rcl_.*" )
49
- . allowlist_function ( "rmw_.*" )
50
- . allowlist_function ( "rcutils_.*" )
51
- . allowlist_function ( "rosidl_.*" )
52
- . allowlist_var ( "rcl_.*" )
53
- . allowlist_var ( "rmw_.*" )
54
- . allowlist_var ( "rcutils_.*" )
55
- . allowlist_var ( "rosidl_.*" )
56
- . layout_tests ( false )
57
- . default_enum_style ( bindgen:: EnumVariation :: Rust {
58
- non_exhaustive : false ,
59
- } )
60
- . parse_callbacks ( Box :: new ( bindgen:: CargoCallbacks :: new ( ) ) ) ;
61
-
62
- // Invalidate the built crate whenever this script or the wrapper changes
63
- println ! ( "cargo:rerun-if-changed=build.rs" ) ;
64
- println ! ( "cargo:rerun-if-changed={BINDGEN_WRAPPER}" ) ;
65
-
66
- // #############
67
- // # ALGORITHM #
68
- // #############
69
- //
70
- // For each prefix in ${AMENT_PREFIX_PATH}:
71
- // Search through ament index at ${prefix}/share/ament_index/resource_index/packages/ to find packages to include
72
- // The include root will be located at either:
73
- // - ${prefix}/include/ (old style)
74
- // - ${prefix}/include/${package_name} (new style)
75
- // - ${prefix}/include/CycloneDDS (special case, match for this)
76
- // End of loop
77
- // Compiled libraries are always at ${prefix}/lib
78
- //
79
- // See REP 122 for more details: https://www.ros.org/reps/rep-0122.html#filesystem-layout
80
-
81
41
let ament_prefix_paths = get_env_var_or_abort ( AMENT_PREFIX_PATH ) ;
82
42
for ament_prefix_path in ament_prefix_paths. split ( ':' ) . map ( Path :: new) {
83
- // Locate the ament index
84
- let ament_index = ament_prefix_path. join ( "share/ament_index/resource_index/packages" ) ;
85
- if !ament_index. is_dir ( ) {
86
- continue ;
87
- }
88
-
89
- // Old-style include directory
90
- let include_dir = ament_prefix_path. join ( "include" ) ;
91
-
92
- // Including the old-style packages
93
- builder = builder. clang_arg ( format ! ( "-isystem{}" , include_dir. display( ) ) ) ;
94
-
95
- // Search for and include new-style-converted package paths
96
- for dir_entry in read_dir ( & ament_index) . unwrap ( ) . filter_map ( |p| p. ok ( ) ) {
97
- let package = dir_entry. file_name ( ) ;
98
- let package_include_dir = include_dir. join ( & package) ;
99
-
100
- if package_include_dir. is_dir ( ) {
101
- let new_style_include_dir = package_include_dir. join ( & package) ;
102
-
103
- // CycloneDDS is a special case - it needs to be included as if it were a new-style path, but
104
- // doesn't actually have a secondary folder within it called "CycloneDDS"
105
- // TODO(jhdcs): if this changes in future, remove this check
106
- if package == "CycloneDDS" || new_style_include_dir. is_dir ( ) {
107
- builder =
108
- builder. clang_arg ( format ! ( "-isystem{}" , package_include_dir. display( ) ) ) ;
109
- }
110
- }
111
- }
112
-
113
43
// Link the native libraries
114
44
let library_path = ament_prefix_path. join ( "lib" ) ;
115
45
println ! ( "cargo:rustc-link-search=native={}" , library_path. display( ) ) ;
@@ -120,11 +50,4 @@ fn main() {
120
50
println ! ( "cargo:rustc-link-lib=dylib=rcutils" ) ;
121
51
println ! ( "cargo:rustc-link-lib=dylib=rmw" ) ;
122
52
println ! ( "cargo:rustc-link-lib=dylib=rmw_implementation" ) ;
123
-
124
- let bindings = builder. generate ( ) . expect ( "Unable to generate bindings" ) ;
125
-
126
- let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
127
- bindings
128
- . write_to_file ( out_path. join ( "rcl_bindings_generated.rs" ) )
129
- . expect ( "Couldn't write bindings!" ) ;
130
53
}
0 commit comments