Skip to content

Commit b54d147

Browse files
committed
Support available typesupport specification in CLI extension
Signed-off-by: Michel Hidalgo <[email protected]>
1 parent 316a273 commit b54d147

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

rosidl_generator_py/rosidl_generator_py/cli.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626

2727
class GeneratePython(GenerateCommandExtension):
2828

29+
def __init__(self, name, *, typesupport_implementations=None, **kwargs):
30+
super().__init__(name, **kwargs)
31+
if typesupport_implementations is None:
32+
typesupport_implementations = ['rosidl_typesupport_c']
33+
typesupport_implementations.extend(
34+
get_resources('rosidl_typesupport_c'))
35+
self.__typesupport_implementations = typesupport_implementations
36+
2937
def generate(
3038
self,
3139
package_name,
@@ -55,10 +63,6 @@ def generate(
5563
))
5664

5765
# Generate code
58-
typesupport_implementations = ['rosidl_typesupport_c']
59-
typesupport_implementations.extend(
60-
get_resources('rosidl_typesupport_c')
61-
)
6266
with legacy_generator_arguments_file(
6367
package_name=package_name,
6468
interface_files=idl_interface_files,
@@ -68,4 +72,4 @@ def generate(
6872
) as path_to_arguments_file:
6973
return generate_py(
7074
path_to_arguments_file,
71-
typesupport_implementations)
75+
self.__typesupport_implementations)

rosidl_generator_py/test/test_cli_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ def test_cli_extension_for_smoke(tmp_path):
2323
generate(
2424
package_name='rosidl_generator_py',
2525
interface_files=[PACKAGE_DIR + ':msg/StringArrays.msg'],
26-
types=['py'],
26+
types=['py[typesupport_implementations:[rosidl_typesupport_c]]'],
2727
output_path=tmp_path
2828
)

0 commit comments

Comments
 (0)