Skip to content

Commit

Permalink
Add support for FastDDS versions earlier than 2.13
Browse files Browse the repository at this point in the history
Signed-off-by: Irene Bandera <irenebandera@eprosima.com>
  • Loading branch information
irenebm committed Jan 11, 2024
1 parent 16b1acb commit 9e6d5aa
Show file tree
Hide file tree
Showing 222 changed files with 18,225 additions and 23 deletions.
17 changes: 14 additions & 3 deletions ddspipe_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,20 @@ compile_library(
# Test
###############################################################################
# Compile tests if CMake options requires it
compile_test_library(
"${PROJECT_SOURCE_DIR}/test" # Test directory
)

# Determine Fast DDS version
if ("${fastrtps_VERSION}" VERSION_LESS 2.13)
set(FASTDDS_SUBDIRECTORY "/v2/")
else()
set(FASTDDS_SUBDIRECTORY "/v1/")
endif()

file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/test/")
foreach(TEST_FILE ${TEST_FILES})
if(NOT TEST_FILE MATCHES ${FASTDDS_SUBDIRECTORY})
compile_test_tool(${TEST_FILE})
endif()
endforeach()

###############################################################################
# Packaging
Expand Down
15 changes: 11 additions & 4 deletions ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

set(TEST_NAME dtypes_idl_tests)

# Determine Fast DDS version
if ("${fastrtps_VERSION}" VERSION_LESS 2.13)
set(FASTDDS_SUBDIRECTORY "v1")
else()
set(FASTDDS_SUBDIRECTORY "v2")
endif()

# Add to test sources every FastDDSGen file generated
file(GLOB DATATYPE_SOURCES_CXX "types/**/*.cxx")
file(GLOB DATATYPE_SOURCES_CXX "types/${FASTDDS_SUBDIRECTORY}/**/*.cxx")
set(TEST_SOURCES
dtypes_idl_tests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_idl.cpp
Expand All @@ -42,7 +49,7 @@ file(
RESULT_SOURCES_IDL
RELATIVE
"${CMAKE_CURRENT_SOURCE_DIR}"
"types/idls/*.idl")
"types/${FASTDDS_SUBDIRECTORY}/idls/*.idl")

set(TEST_NEEDED_SOURCES
${RESULT_SOURCES_IDL}
Expand All @@ -63,7 +70,7 @@ add_unittest_executable(
set(TEST_NAME dtypes_msg_tests)

# Add to test sources every FastDDSGen file generated
file(GLOB DATATYPE_SOURCES_CXX "types/**/*.cxx")
file(GLOB DATATYPE_SOURCES_CXX "types/${FASTDDS_SUBDIRECTORY}/**/*.cxx")
set(TEST_SOURCES
dtypes_msg_tests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_msg.cpp
Expand All @@ -86,7 +93,7 @@ file(
RESULT_SOURCES_MSG
RELATIVE
"${CMAKE_CURRENT_SOURCE_DIR}"
"types/msgs/*.msg")
"types/${FASTDDS_SUBDIRECTORY}/msgs/*.msg")

set(TEST_NEEDED_SOURCES
${RESULT_SOURCES_MSG}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@

#include <ddspipe_core/types/dynamic_types/schema.hpp>

#include "types/all_types.hpp"
#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
#include "types/v1/all_types.hpp"
#else
#include "types/v2/all_types.hpp"
#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13

using namespace eprosima;

Expand All @@ -39,7 +43,11 @@ std::string read_idl_from_file_(
std::string file_name_by_type(
SupportedType type)
{
return std::string("types/idls/") + to_string(type) + ".idl";
#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
return std::string("types/v1/idls/") + to_string(type) + ".idl";
#else
return std::string("types/v2/idls/") + to_string(type) + ".idl";
#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
}

void compare_schemas(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#include <cpp_utils/file/file_utils.hpp>
#include <fastrtps/types/DynamicTypePtr.h>
#include <ddspipe_core/types/dynamic_types/schema.hpp>
#include "types/all_types.hpp"
#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
#include "types/v1/all_types.hpp"
#else
#include "types/v2/all_types.hpp"
#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13

using namespace eprosima;

Expand All @@ -34,7 +38,11 @@ std::string read_msg_from_file_(
std::string file_name_by_type(
SupportedType type)
{
return std::string("types/msgs/") + to_string(type) + ".msg";
#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
return std::string("types/v1/msgs/") + to_string(type) + ".msg";
#else
return std::string("types/v2/msgs/") + to_string(type) + ".msg";
#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
}

void compare_schemas(
Expand Down
Loading

0 comments on commit 9e6d5aa

Please sign in to comment.