forked from ros2-rust/ros2_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_bindings.py
More file actions
executable file
·61 lines (58 loc) · 2.32 KB
/
Copy pathgenerate_bindings.py
File metadata and controls
executable file
·61 lines (58 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
import ament_index_python
import os
import subprocess
import sys
def main():
if len(sys.argv) != 4:
print("Usage: generate_bindings.py <header_file> <ros_distribution> <output_directory>")
sys.exit(1)
header_file = sys.argv[1]
ros_distribution = sys.argv[2]
output_directory = sys.argv[3]
bindgen_command = []
bindgen_command.append('bindgen')
bindgen_command.append(header_file)
bindgen_command.append('-o')
bindgen_command.append(f'{output_directory}/rcl_bindings_generated_{ros_distribution}.rs')
bindgen_command.append('--rust-edition')
bindgen_command.append('2021')
bindgen_command.append('--rust-target')
bindgen_command.append('1.85')
bindgen_command.append('--no-derive-copy')
bindgen_command.append('--allowlist-type')
bindgen_command.append('rcl_.*')
bindgen_command.append('--allowlist-type')
bindgen_command.append('rmw_.*')
bindgen_command.append('--allowlist-type')
bindgen_command.append('rcutils_.*')
bindgen_command.append('--allowlist-type')
bindgen_command.append('rosidl_.*')
bindgen_command.append('--allowlist-function')
bindgen_command.append('rcl_.*')
bindgen_command.append('--allowlist-function')
bindgen_command.append('rmw_.*')
bindgen_command.append('--allowlist-function')
bindgen_command.append('rcutils_.*')
bindgen_command.append('--allowlist-function')
bindgen_command.append('rosidl_.*')
bindgen_command.append('--allowlist-var')
bindgen_command.append('rcl_.*')
bindgen_command.append('--allowlist-var')
bindgen_command.append('rmw_.*')
bindgen_command.append('--allowlist-var')
bindgen_command.append('rcutils_.*')
bindgen_command.append('--allowlist-var')
bindgen_command.append('rosidl_.*')
bindgen_command.append('--no-layout-tests')
bindgen_command.append('--default-enum-style')
bindgen_command.append('rust')
bindgen_command.append('--')
for package, prefix in ament_index_python.get_packages_with_prefixes().items():
package_include_dir = os.path.join(prefix, 'include', package)
if os.path.isdir(package_include_dir):
bindgen_command.append('-isystem')
bindgen_command.append(package_include_dir)
subprocess.run(bindgen_command)
if __name__ == "__main__":
main()