diff --git a/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake b/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake index 12d3cffe8..4818b5ad4 100644 --- a/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake +++ b/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake @@ -23,9 +23,7 @@ find_package(PythonInterp 3.4 REQUIRED) find_package(python_cmake_module REQUIRED) find_package(PythonExtra MODULE) -# TODO(esteve): force opensplice and connext C type supports only, uncomment -# the following line when all typesupport implementations are ported to C -#get_rmw_typesupport(_typesupport_impls ${rmw_implementation}) +# Get a list of typesupport implementations from valid rmw implementations. rosidl_generator_py_get_typesupports(_typesupport_impls) if("${_typesupport_impls} " STREQUAL " ") diff --git a/rosidl_generator_py/cmake/rosidl_generator_py_get_typesupports.cmake b/rosidl_generator_py/cmake/rosidl_generator_py_get_typesupports.cmake index 36d302544..606c54b57 100644 --- a/rosidl_generator_py/cmake/rosidl_generator_py_get_typesupports.cmake +++ b/rosidl_generator_py/cmake/rosidl_generator_py_get_typesupports.cmake @@ -12,23 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +macro(accumulate_typesupports) + set(_typesupport_impl "") + if(NOT "${rmw_implementation}" STREQUAL "rmw_fastrtps_cpp") + get_rmw_typesupport(_typesupport_impl ${rmw_implementation} LANGUAGE "C") + list(APPEND _typesupport_impls ${_typesupport_impl}) + endif() +endmacro() + macro(rosidl_generator_py_get_typesupports TYPESUPPORT_IMPLS) - set(${TYPESUPPORT_IMPLS} "") - foreach(_extension IN LISTS AMENT_EXTENSIONS_rosidl_generate_interfaces) - string(REPLACE ":" ";" _extension_list "${_extension}") - list(LENGTH _extension_list _length) - if(NOT _length EQUAL 2) - message(FATAL_ERROR "ament_execute_extensions(${extension_point}) " - "registered extension '${_extension}' can not be split into package " - "name and cmake filename") - endif() - list(GET _extension_list 0 _pkg_name) - list(GET _extension_list 1 _cmake_filename) - if("${_pkg_name} " STREQUAL "rosidl_typesupport_opensplice_c ") - list(APPEND ${TYPESUPPORT_IMPLS} "rosidl_typesupport_opensplice_c") - endif() - if("${_pkg_name} " STREQUAL "rosidl_typesupport_connext_c ") - list(APPEND ${TYPESUPPORT_IMPLS} "rosidl_typesupport_connext_c") - endif() + set(TYPESUPPORT_IMPLS "") + set(_typesupport_impls "") + call_for_each_rmw_implementation(accumulate_typesupports) + foreach(_typesupport_impl ${_typesupport_impls}) + list_append_unique(TYPESUPPORT_IMPLS ${_typesupport_impl}) endforeach() endmacro() diff --git a/rosidl_generator_py/package.xml b/rosidl_generator_py/package.xml index ac33ec27e..d8417fc3d 100644 --- a/rosidl_generator_py/package.xml +++ b/rosidl_generator_py/package.xml @@ -9,6 +9,7 @@ ament_cmake ament_cmake + ament_index_python python_cmake_module rosidl_cmake @@ -18,6 +19,7 @@ rosidl_parser ament_cmake_nose + ament_index_python ament_lint_auto ament_lint_common python_cmake_module diff --git a/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py b/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py index ff2c722f9..ec2eda661 100644 --- a/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py +++ b/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py @@ -12,13 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import ament_index_python import importlib -type_support_map = { - 'rmw_connext_cpp': 'rosidl_typesupport_connext_c', - 'rmw_opensplice_cpp': 'rosidl_typesupport_opensplice_c', -} - class UnsupportedTypeSupport(Exception): """Raised when no supported type support can be found for a given rmw implementation.""" @@ -44,9 +40,10 @@ def import_type_support(pkg_name, subfolder, rosidl_name, rmw_implementation): :param rmw_implementation str: name of the rmw implementation :returns: the type support Python module for this specific rosidl and rmw implementation pair """ - if rmw_implementation not in type_support_map.keys(): + if not ament_index_python.has_resource('rmw_typesupport_c', rmw_implementation): raise UnsupportedTypeSupport(rmw_implementation) - type_support_name = type_support_map[rmw_implementation] + + type_support_name = ament_index_python.get_resource('rmw_typesupport_c', rmw_implementation) import_package = '{pkg_name}'.format( pkg_name=pkg_name, )