From efb7d4e6b7e53bea9b7d0d9b6134ccf6d1e00f42 Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Wed, 26 Jan 2011 15:49:40 +0100 Subject: [PATCH 1/3] typekits: generate 'extern template' definitions. Each .msg file will cause a msg_Types.hpp file to be generated, and in each package, a typekit/Types.hpp file is generated that includes all these files. As such, components using these message types will compile much faster. Signed-off-by: Peter Soetens --- rtt_ros_integration/cmake/GenerateRTTtypekit.cmake | 12 ++++++- rtt_ros_integration/src/Types.hpp.in | 10 ++++++ rtt_ros_integration/src/msg_Types.hpp.in | 35 ++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletions(-) create mode 100644 rtt_ros_integration/src/Types.hpp.in create mode 100644 rtt_ros_integration/src/msg_Types.hpp.in diff --git a/rtt_ros_integration/cmake/GenerateRTTtypekit.cmake b/rtt_ros_integration/cmake/GenerateRTTtypekit.cmake index df207a3..3491f07 100644 --- a/rtt_ros_integration/cmake/GenerateRTTtypekit.cmake +++ b/rtt_ros_integration/cmake/GenerateRTTtypekit.cmake @@ -48,6 +48,7 @@ macro(ros_generate_rtt_typekit package) #Get all .msg files rosbuild_get_msgs_external(${package} MSGS) + set(ROSPACKAGE ${package}) foreach( FILE ${MSGS} ) string(REGEX REPLACE "\(.+\).msg" "\\1" ROSMSGNAME ${FILE}) @@ -60,27 +61,36 @@ macro(ros_generate_rtt_typekit package) set(ROSMSGTRANSPORTS "${ROSMSGTRANSPORTS} if(name == \"${ROSMSGNAME}\") return ti->addProtocol(ORO_ROS_PROTOCOL_ID,new RosMsgTransporter<${ROSMSGTYPE}>()); ") + set(ROSMSGTYPESHEADERS "${ROSMSGTYPESHEADERS}#include \"${ROSMSGNAME}_Types.hpp\"\n") + # TypeInfo object: configure_file( ${rtt_ros_integration_PACKAGE_PATH}/src/ros_msg_typekit_plugin.cpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${ROSMSGNAME}_typekit_plugin.cpp @ONLY ) + # Transport for ROS: configure_file( ${rtt_ros_integration_PACKAGE_PATH}/src/ros_msg_transport_plugin.cpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${ROSMSGNAME}_transport_plugin.cpp @ONLY ) + # Types.hpp helper for extern templates: + configure_file( ${rtt_ros_integration_PACKAGE_PATH}/src/msg_Types.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/include/${package}/typekit/${ROSMSGNAME}_Types.hpp @ONLY ) + list(APPEND ROSMSG_TYPEKIT_PLUGINS ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${ROSMSGNAME}_typekit_plugin.cpp ) list(APPEND ROSMSG_TRANSPORT_PLUGIN ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${ROSMSGNAME}_transport_plugin.cpp ) endforeach( FILE ${MSGS} ) - set(ROSPACKAGE ${package}) configure_file( ${rtt_ros_integration_PACKAGE_PATH}/src/ros_msg_typekit_package.cpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${package}_typekit.cpp @ONLY ) configure_file( ${rtt_ros_integration_PACKAGE_PATH}/src/ros_msg_transport_package.cpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${package}_transport.cpp @ONLY ) + configure_file( ${rtt_ros_integration_PACKAGE_PATH}/src/Types.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/include/${package}/typekit/Types.hpp @ONLY ) + orocos_typekit( rtt-ros-${package}-typekit ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${package}_typekit.cpp ${ROSMSG_TYPEKIT_PLUGINS}) orocos_typekit( rtt-ros-${package}-transport ${CMAKE_CURRENT_SOURCE_DIR}/src/orocos/types/ros_${package}_transport.cpp ) target_link_libraries(rtt-ros-${package}-transport rtt_ros_integration-${OROCOS_TARGET}) diff --git a/rtt_ros_integration/src/Types.hpp.in b/rtt_ros_integration/src/Types.hpp.in new file mode 100644 index 0000000..d5eeecf --- /dev/null +++ b/rtt_ros_integration/src/Types.hpp.in @@ -0,0 +1,10 @@ +/* Generated from rtt_ros_integration/src/Types.hpp.in */ + +#ifndef __OROCOS_ROS_GENERATED_@ROSPACKAGE@_TYPES_HPP +#define __OROCOS_ROS_GENERATED_@ROSPACKAGE@_TYPES_HPP + +// includes Types.hpp headers for all messages: +@ROSMSGTYPESHEADERS@ + +#endif + diff --git a/rtt_ros_integration/src/msg_Types.hpp.in b/rtt_ros_integration/src/msg_Types.hpp.in new file mode 100644 index 0000000..3b22016 --- /dev/null +++ b/rtt_ros_integration/src/msg_Types.hpp.in @@ -0,0 +1,35 @@ +/* Generated from rtt_ros_integration/src/msg_Types.hpp.in */ + +#ifndef __OROCOS_ROS_GENERATED_@ROSPACKAGE@_@ROSMSGNAME@_TYPES_HPP +#define __OROCOS_ROS_GENERATED_@ROSPACKAGE@_@ROSMSGNAME@_TYPES_HPP + +// note: we preferably would include the message header instead of the boost stuff. +#include <@ROSMSGBOOSTHEADER@> + +// All these classes were generated in the typekit library: +#ifdef CORELIB_DATASOURCE_HPP + extern template class RTT::internal::DataSource< @ROSMSGTYPE@ >; + extern template class RTT::internal::AssignableDataSource< @ROSMSGTYPE@ >; +#endif +#ifdef ORO_CORELIB_DATASOURCES_HPP + extern template class RTT::internal::ValueDataSource< @ROSMSGTYPE@ >; + extern template class RTT::internal::ConstantDataSource< @ROSMSGTYPE@ >; + extern template class RTT::internal::ReferenceDataSource< @ROSMSGTYPE@ >; +#endif +#ifdef ORO_INPUT_PORT_HPP + extern template class RTT::OutputPort< @ROSMSGTYPE@ >; +#endif +#ifdef ORO_OUTPUT_PORT_HPP + extern template class RTT::InputPort< @ROSMSGTYPE@ >; +#endif +#ifdef ORO_PROPERTY_HPP + extern template class RTT::Property< @ROSMSGTYPE@ >; +#endif +#ifdef ORO_CORELIB_ATTRIBUTE_HPP + extern template class RTT::Attribute< @ROSMSGTYPE@ >; + extern template class RTT::Constant< @ROSMSGTYPE@ >; +#endif + + +#endif + -- 1.7.0.4