Skip to content

Commit e573816

Browse files
committed
Modify the generated .pb.h files to include the visibility file
1 parent d48ec42 commit e573816

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

rosidl_adapter_proto/bin/rosidl_adapter_proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ def main(argv=sys.argv[1:]):
8080
package_name = package_name
8181
)
8282

83+
# Modify the generated .pb.h to include visibility file
84+
for proto_file in proto_files:
85+
msg = os.path.splitext(os.path.basename(proto_file))[0]
86+
87+
# Just in case if the path contains another <xxx>.proto, e.g.,
88+
# /home/<xxx>.proto/<path-to-proto-file>
89+
with open(f"{cpp_out_dir}/{package_name}/msg/{msg}.pb.h", "r") as f:
90+
contents = f.readlines()
91+
92+
# Insert the visibility file on line 6
93+
contents.insert(
94+
6,
95+
f"#include \"{package_name}/rosidl_adapter_proto__visibility_control.h\"\n")
96+
with open(f"{cpp_out_dir}/{package_name}/msg/{msg}.pb.h", "w") as f:
97+
f.write("".join(contents))
98+
8399
return rc
84100

85101

0 commit comments

Comments
 (0)