Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get list of typesupports from ament index #115

Merged
merged 10 commits into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 " ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions rosidl_generator_py/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>ament_index_python</buildtool_export_depend>
<buildtool_export_depend>python_cmake_module</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

Expand All @@ -18,6 +19,7 @@
<exec_depend>rosidl_parser</exec_depend>

<test_depend>ament_cmake_nose</test_depend>
<test_depend>ament_index_python</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>python_cmake_module</test_depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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,
)
Expand Down