-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #3061. Added code generating packages rosidl_typesupport_fastrtp…
…s_c(pp).
- Loading branch information
1 parent
02783b9
commit eb7d8e3
Showing
32 changed files
with
2,912 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(rosidl_typesupport_fastrtps_c) | ||
|
||
set(FASTRTPS_STATIC_DISABLE $ENV{FASTRTPS_STATIC_DISABLE} | ||
CACHE BOOL "If fastrtps Static should be disabled.") | ||
|
||
# Default to C99 | ||
if(NOT CMAKE_C_STANDARD) | ||
set(CMAKE_C_STANDARD 99) | ||
endif() | ||
|
||
# Default to C++14 | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 14) | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
find_package(ament_cmake REQUIRED) | ||
|
||
find_package(fastrtps_cmake_module REQUIRED) | ||
find_package(fastcdr REQUIRED CONFIG) | ||
find_package(fastrtps REQUIRED CONFIG) | ||
find_package(FastRTPS REQUIRED MODULE) | ||
if(FASTRTPS_STATIC_DISABLE) | ||
ament_package() | ||
message(STATUS "fastrtps static rmw implementation explicitly disabled - skipping '${PROJECT_NAME}'") | ||
return() | ||
endif() | ||
|
||
find_package(ament_cmake_python REQUIRED) | ||
find_package(rosidl_typesupport_fastrtps_cpp REQUIRED) | ||
|
||
ament_export_dependencies(rmw) | ||
ament_export_dependencies(rosidl_cmake) | ||
ament_export_dependencies(rosidl_generator_c) | ||
ament_export_dependencies(rosidl_generator_dds_idl) | ||
ament_export_dependencies(rosidl_typesupport_fastrtps_cpp) | ||
ament_export_include_directories(include) | ||
|
||
ament_python_install_package(${PROJECT_NAME}) | ||
|
||
add_library(${PROJECT_NAME} SHARED src/identifier.cpp) | ||
if(WIN32) | ||
target_compile_definitions(${PROJECT_NAME} | ||
PRIVATE "ROSIDL_TYPESUPPORT_FASTRTPS_C_BUILDING_DLL") | ||
endif() | ||
target_include_directories(${PROJECT_NAME} PUBLIC include) | ||
ament_target_dependencies(${PROJECT_NAME} "rosidl_typesupport_fastrtps_cpp") | ||
ament_export_libraries(${PROJECT_NAME}) | ||
|
||
ament_index_register_resource("rosidl_typesupport_c") | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package( | ||
CONFIG_EXTRAS "rosidl_typesupport_fastrtps_c-extras.cmake.in" | ||
) | ||
|
||
install( | ||
PROGRAMS bin/rosidl_typesupport_fastrtps_c | ||
DESTINATION lib/rosidl_typesupport_fastrtps_c | ||
) | ||
|
||
install( | ||
DIRECTORY cmake resource | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION include | ||
) | ||
|
||
install( | ||
TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
) |
44 changes: 44 additions & 0 deletions
44
rosidl_typesupport_fastrtps_c/bin/rosidl_typesupport_fastrtps_c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import os | ||
import sys | ||
|
||
from rosidl_cmake import read_generator_arguments | ||
from rosidl_parser import UnknownMessageType | ||
from rosidl_typesupport_fastrtps_c import generate_typesupport_fastrtps_c | ||
|
||
|
||
def is_valid_file(parser, file_name): | ||
if not os.path.exists(file_name): | ||
parser.error("File does not exist: '{0}'".format(file_name)) | ||
file_name_abs = os.path.abspath(file_name) | ||
if not os.path.isfile(file_name_abs): | ||
parser.error("Path exists but is not a file: '{0}'".format(file_name_abs)) | ||
return file_name | ||
|
||
|
||
def main(argv=sys.argv[1:]): | ||
parser = argparse.ArgumentParser( | ||
description='Generate the C interfaces for fastrtps.', | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
parser.add_argument( | ||
'--generator-arguments-file', | ||
required=True, | ||
help='The location of the file containing the generator arguments') | ||
args = parser.parse_args(argv) | ||
|
||
generator_args = read_generator_arguments(args.generator_arguments_file) | ||
|
||
try: | ||
rc = generate_typesupport_fastrtps_c(generator_args) | ||
except UnknownMessageType as e: | ||
print(str(e), file=sys.stderr) | ||
return 1 | ||
if rc: | ||
return rc | ||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Oops, something went wrong.