File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
rosidl_cli/rosidl_cli/command/generate Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 14
14
15
15
import contextlib
16
16
import json
17
+ import os
17
18
import pathlib
18
19
import tempfile
19
20
@@ -110,3 +111,31 @@ def legacy_generator_arguments_file(
110
111
}))
111
112
tmp .flush ()
112
113
yield tmp .name
114
+
115
+
116
+ def generate_visibility_control_file (
117
+ * ,
118
+ package_name ,
119
+ template_path ,
120
+ output_path
121
+ ):
122
+ """
123
+ Generate a visibility control file from a template.
124
+
125
+ :param package_name: Name of the ROS package for which
126
+ to generate the file.
127
+ :param template_path: Path to template visibility control file.
128
+ May contain @PROJECT_NAME@ and @PROJECT_NAME_UPPER@ placeholders,
129
+ to be substituted by the package name, accordingly.
130
+ :param output_path: Path to visibility control file after interpolation.
131
+ """
132
+ os .makedirs (os .path .dirname (output_path ), exist_ok = True )
133
+
134
+ with open (template_path , 'r' ) as fd :
135
+ content = fd .read ()
136
+
137
+ content = content .replace ('@PROJECT_NAME@' , package_name )
138
+ content = content .replace ('@PROJECT_NAME_UPPER@' , package_name .upper ())
139
+
140
+ with open (output_path , 'w' ) as fd :
141
+ fd .write (content )
You can’t perform that action at this time.
0 commit comments