Skip to content

Commit

Permalink
Add support for Fast DDS versions earlier than 2.13 (#82)
Browse files Browse the repository at this point in the history
* Add support for FastDDS versions earlier than 2.13

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

* FASTDDS_SUBDIRECTORY -> DDS_TYPES_VERSION

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

* Apply changes

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

* Correct function names

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

* Update FASTRTPS version check in CommonReader and CommonWriter

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

* Uncrustify

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

* Compile test libraries in ddspipe_core

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>

---------

Signed-off-by: Irene Bandera <irenebandera@eprosima.com>
  • Loading branch information
irenebm authored Jan 23, 2024
1 parent 16b1acb commit 3b41d0d
Show file tree
Hide file tree
Showing 223 changed files with 17,281 additions and 14 deletions.
4 changes: 1 addition & 3 deletions ddspipe_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ compile_library(
# Test
###############################################################################
# Compile tests if CMake options requires it
compile_test_library(
"${PROJECT_SOURCE_DIR}/test" # Test directory
)
compile_test_library("${PROJECT_SOURCE_DIR}/test/")

###############################################################################
# Packaging
Expand Down
2 changes: 1 addition & 1 deletion ddspipe_core/project_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(MODULE_FIND_PACKAGES
cpp_utils
)

set(fastrtps_MINIMUM_VERSION "2.8")
set(fastrtps_MINIMUM_VERSION "2.10")

set(MODULE_DEPENDENCIES
$<$<BOOL:${WIN32}>:iphlpapi$<SEMICOLON>Shlwapi>
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(DDS_TYPES_VERSION "v1")
else()
set(DDS_TYPES_VERSION "v2")
endif()

# Add to test sources every FastDDSGen file generated
file(GLOB DATATYPE_SOURCES_CXX "types/**/*.cxx")
file(GLOB DATATYPE_SOURCES_CXX "types/${DDS_TYPES_VERSION}/**/*.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/${DDS_TYPES_VERSION}/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/${DDS_TYPES_VERSION}/**/*.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/${DDS_TYPES_VERSION}/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 3b41d0d

Please sign in to comment.