Skip to content

Commit

Permalink
export targets in a addition to include directories / libraries
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
  • Loading branch information
dirk-thomas committed Apr 17, 2020
1 parent f25db23 commit 9350355
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
7 changes: 5 additions & 2 deletions rosidl_runtime_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ endif()
find_package(ament_cmake_ros REQUIRED)
find_package(rosidl_typesupport_interface REQUIRED)

include_directories(include)
add_library(${PROJECT_NAME}
"src/message_bounds.c"
"src/message_type_support.c"
Expand All @@ -23,6 +22,9 @@ add_library(${PROJECT_NAME}
"src/string_functions.c"
"src/u16string_functions.c"
)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
ament_target_dependencies(${PROJECT_NAME}
"rosidl_typesupport_interface")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -37,6 +39,7 @@ endif()
ament_export_dependencies(rosidl_typesupport_interface)
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(${PROJECT_NAME})

ament_index_register_resource("rosidl_runtime_packages")

Expand All @@ -50,7 +53,7 @@ install(
DESTINATION include
)
install(
TARGETS ${PROJECT_NAME}
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define ROSIDL_RUNTIME_C__PRIMITIVE_SEQUENCE(STRUCT_NAME, TYPE_NAME) \
typedef struct rosidl_runtime_c__ ## STRUCT_NAME ## __Sequence \
{ \
TYPE_NAME * data; \
TYPE_NAME * data; /*!< The pointer to an array of STRUCT_NAME */ \
size_t size; /*!< The number of valid items in data */ \
size_t capacity; /*!< The number of allocated items in data */ \
} rosidl_runtime_c__ ## STRUCT_NAME ## __Sequence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ extern "C"
{
#endif

/// Allocate the memory for the sequence.
/* Calling the function with an already allocated sequence will leak the
* previously allocated memory.
*
* \param sequence a pointer to a sequence struct
* \param size the number of items to allocate in the sequence, both sequence
* fields `size` and `capacity` are set to this parameter
* \return true if successful, false if the passed sequence pointer is null
* or the memory allocation failed
*/
/// Deallocate the memory of the sequence.
/* Calling the function with an already deallocated sequence is a no-op.
*
* \param sequence a pointer to a sequence struct
*/
#define ROSIDL_RUNTIME_C__DECLARE_PRIMITIVE_SEQUENCE_FUNCTIONS(STRUCT_NAME, TYPE_NAME) \
ROSIDL_GENERATOR_C_PUBLIC \
bool rosidl_runtime_c__ ## STRUCT_NAME ## __Sequence__init( \
Expand Down
1 change: 1 addition & 0 deletions rosidl_runtime_c/include/rosidl_runtime_c/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/// String struct
typedef struct rosidl_runtime_c__String
{
/// The pointer to the first character, the sequence ends with a null byte.
char * data;
/// The length of the string (excluding the null byte).
size_t size;
Expand Down
5 changes: 4 additions & 1 deletion rosidl_runtime_c/include/rosidl_runtime_c/string_bounds.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
#include <stddef.h>

/// String struct
/* The struct can describe the upper boundary of a rosidl_runtime_c__String
* as well as a rosidl_runtime_c__U16String.
*/
typedef struct rosidl_runtime_c__String__bounds
{
/// The length of the string (excluding the null byte).
/// The number of characters in the string (excluding the null character).
size_t bounds;
} rosidl_runtime_c__String__bounds;

Expand Down
2 changes: 1 addition & 1 deletion rosidl_runtime_c/include/rosidl_runtime_c/u16string.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/// U16String struct
typedef struct rosidl_runtime_c__U16String
{
/// The pointer to the first character.
/// The pointer to the first character, the sequence ends with a null character.
uint_least16_t * data; // using uint_least16_t to match a C++ std::u16string
/// The length of the u16string (excluding the null byte).
size_t size;
Expand Down

0 comments on commit 9350355

Please sign in to comment.