File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import argparse
22
22
import sys
23
23
import pathlib
24
24
import os
25
+ import re
25
26
26
27
from rosidl_cmake import read_generator_arguments
27
28
from rosidl_adapter_proto import generate_proto
@@ -80,6 +81,22 @@ def main(argv=sys.argv[1:]):
80
81
package_name = package_name
81
82
)
82
83
84
+ # Modify the generated .pb.h to include visibility file
85
+ for proto_file in proto_files :
86
+ msg = os .path .splitext (os .path .basename (proto_file ))[0 ]
87
+
88
+ # Just in case if the path contains another <xxx>.proto, e.g.,
89
+ # /home/<xxx>.proto/<path-to-proto-file>
90
+ with open (f"{ cpp_out_dir } /{ package_name } /msg/{ msg } .pb.h" , "r" ) as f :
91
+ contents = f .readlines ()
92
+
93
+ # Insert the visibility file on line 6
94
+ contents .insert (
95
+ 6 ,
96
+ f"#include \" { package_name } /rosidl_adapter_proto__visibility_control.h\" \n " )
97
+ with open (f"{ cpp_out_dir } /{ package_name } /msg/{ msg } .pb.h" , "w" ) as f :
98
+ f .write ("" .join (contents ))
99
+
83
100
return rc
84
101
85
102
You can’t perform that action at this time.
0 commit comments