From f16956ee919b7d12f0b5b3666c547026adf38325 Mon Sep 17 00:00:00 2001 From: Dennis Potman Date: Tue, 1 Aug 2023 11:18:35 +0200 Subject: [PATCH] Replace type_discovery option with typelib This replaces the enable_type_discovery build option with enable_typelib, which reflects a similar change in Cyclone C. Additionally a missing include directive for ddsi_typelib.h is added. Signed-off-by: Dennis Potman --- .azure/templates/build-test.yml | 2 +- .github/workflows/misra-regressions-check.yml | 2 +- CMakeLists.txt | 20 +++++++++---------- README.md | 4 ++-- azure-pipelines.yml | 4 ++-- features.hpp.in | 2 +- .../eclipse/cyclonedds/topic/TopicTraits.hpp | 10 +++++++--- .../eclipse/cyclonedds/topic/datatopic.hpp | 4 ++-- src/ddscxx/tests/CMakeLists.txt | 2 +- src/idlcxx/src/traits.c | 4 ++-- 10 files changed, 29 insertions(+), 25 deletions(-) diff --git a/.azure/templates/build-test.yml b/.azure/templates/build-test.yml index 076cb6b3..bb1263cf 100644 --- a/.azure/templates/build-test.yml +++ b/.azure/templates/build-test.yml @@ -106,7 +106,7 @@ steps: -DCMAKE_PREFIX_PATH="${BUILD_SOURCESDIRECTORY}/iceoryx/build/install" \ -DSANITIZER=${SANITIZER:-none} \ -DENABLE_SHM=${ICEORYX:-off} \ - -DENABLE_TYPE_DISCOVERY=${TYPE_DISCOVERY:-on} \ + -DENABLE_TYPELIB=${TYPELIB:-on} \ -DENABLE_TOPIC_DISCOVERY=${TOPIC_DISCOVERY:-on} \ ${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" .. cmake --build . --config ${BUILD_TYPE} --target install -- ${BUILD_TOOL_OPTIONS} diff --git a/.github/workflows/misra-regressions-check.yml b/.github/workflows/misra-regressions-check.yml index 1b26db3c..3c47d261 100644 --- a/.github/workflows/misra-regressions-check.yml +++ b/.github/workflows/misra-regressions-check.yml @@ -67,7 +67,7 @@ jobs: - name: Build Cyclone DDS CXX run: | mkdir build - cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_PREFIX_PATH="$CYCLONEDDS_HOME" -DENABLE_TOPIC_DISCOVERY=TRUE -DENABLE_TYPE_DISCOVERY=TRUE -B build + cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_PREFIX_PATH="$CYCLONEDDS_HOME" -DENABLE_TOPIC_DISCOVERY=TRUE -DENABLE_TYPELIB=TRUE -B build cmake --build build - name: Perform CodeQL Analysis diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e11e84b..785bb52b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,15 +244,15 @@ elseif(cyclonedds_has_shm) message(FATAL_ERROR "Cyclone DDS is compiled with support for shared memory") endif() -get_target_property(cyclonedds_has_type_discovery CycloneDDS::ddsc TYPE_DISCOVERY_IS_AVAILABLE) -mark_as_advanced(cyclonedds_has_type_discovery) -option(ENABLE_TYPE_DISCOVERY "Enable Type Discovery support" ${cyclonedds_has_type_discovery}) -if(ENABLE_TYPE_DISCOVERY) - if (NOT cyclonedds_has_type_discovery) - message(FATAL_ERROR "Cyclone DDS is not compiled with type discovery enabled") +get_target_property(cyclonedds_has_typelib CycloneDDS::ddsc TYPELIB_IS_AVAILABLE) +mark_as_advanced(cyclonedds_has_typelib) +option(ENABLE_TYPELIB "Enable Type Library support" ${cyclonedds_has_typelib}) +if(ENABLE_TYPELIB) + if (NOT cyclonedds_has_typelib) + message(FATAL_ERROR "Cyclone DDS is not compiled with type library enabled") endif() - message(STATUS "Compiling with type discovery support") - set(DDSCXX_HAS_TYPE_DISCOVERY "1") + message(STATUS "Compiling with type library support") + set(DDSCXX_HAS_TYPELIB "1") endif() get_target_property(cyclonedds_has_topic_discovery CycloneDDS::ddsc TOPIC_DISCOVERY_IS_AVAILABLE) @@ -262,8 +262,8 @@ if(ENABLE_TOPIC_DISCOVERY) if (NOT cyclonedds_has_topic_discovery) message(FATAL_ERROR "Cyclone DDS is not compiled with topic discovery enabled") endif() - if(NOT ENABLE_TYPE_DISCOVERY) - message(FATAL_ERROR "ENABLE_TOPIC_DISCOVERY requires ENABLE_TYPE_DISCOVERY to be enabled") + if(NOT ENABLE_TYPELIB) + message(FATAL_ERROR "ENABLE_TOPIC_DISCOVERY requires ENABLE_TYPELIB to be enabled") endif() message(STATUS "Compiling with topic discovery support") set(DDSCXX_HAS_TOPIC_DISCOVERY "1") diff --git a/README.md b/README.md index 5a84a699..3eb0dd10 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ There are some configuration options specified using CMake defines in addition t * `-DBUILD_EXAMPLES=ON`: to build examples * `-DENABLE_LEGACY=YES`: to enable legacy c++11 mode, adds boost as dependency (otherwise it uses c++17) * `-DENABLE_SHM=YES`: to enable shared memory support -* `-DENABLE_TYPE_DISCOVERY=YES`: to enable type discovery support -* `-DENABLE_TOPIC_DISCOVERY=YES`: to enable topic discovery support +* `-DENABLE_TYPELIB=YES`: to enable type library support +* `-DENABLE_TOPIC_DISCOVERY=YES`: to enable topic discovery support * `-DENABLE_COVERAGE=YES`: to enable coverage build ### For application developers diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ad225b70..e746c409 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -85,12 +85,12 @@ strategy: cc: clang-12 cxx: clang++-12 legacy: on - 'Ubuntu 22.04 LTS with GCC 12 (Debug, x86_64, no type discovery)': + 'Ubuntu 22.04 LTS with GCC 12 (Debug, x86_64, no type lib)': image: ubuntu-22.04 sanitizer: address cc: gcc-12 cxx: g++-12 - type_discovery: off + type_lib: off topic_discovery: off 'macOS 11 with Clang 12 (Debug, x86_64)': image: macOS-11 diff --git a/features.hpp.in b/features.hpp.in index e34497a5..9fabb50d 100644 --- a/features.hpp.in +++ b/features.hpp.in @@ -5,7 +5,7 @@ #cmakedefine DDSCXX_HAS_SHM @DDSCXX_HAS_SHM@ /* Whether or not support for type discovery is included */ -#cmakedefine DDSCXX_HAS_TYPE_DISCOVERY @DDSCXX_HAS_TYPE_DISCOVERY@ +#cmakedefine DDSCXX_HAS_TYPELIB @DDSCXX_HAS_TYPELIB@ /* Whether or not support for topic discovery is included */ #cmakedefine DDSCXX_HAS_TOPIC_DISCOVERY @DDSCXX_HAS_TOPIC_DISCOVERY@ diff --git a/src/ddscxx/include/org/eclipse/cyclonedds/topic/TopicTraits.hpp b/src/ddscxx/include/org/eclipse/cyclonedds/topic/TopicTraits.hpp index d6d8762a..3f3e70ab 100644 --- a/src/ddscxx/include/org/eclipse/cyclonedds/topic/TopicTraits.hpp +++ b/src/ddscxx/include/org/eclipse/cyclonedds/topic/TopicTraits.hpp @@ -7,7 +7,7 @@ // http://www.eclipse.org/org/documents/edl-v10.php. // // SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - + /** * @file */ @@ -20,6 +20,10 @@ #include "org/eclipse/cyclonedds/core/cdr/cdr_enums.hpp" #include "dds/features.hpp" +#ifdef DDSCXX_HAS_TYPELIB +#include "dds/ddsi/ddsi_typelib.h" +#endif + //forward declaration of c++ sertype wrapper template class ddscxx_sertype; @@ -149,7 +153,7 @@ template class TopicTraits return extensibility::ext_final; } -#ifdef DDSCXX_HAS_TYPE_DISCOVERY +#ifdef DDSCXX_HAS_TYPELIB /** * @brief Returns the typeid for TOPIC. * @@ -247,7 +251,7 @@ template class TopicTraits { return nullptr; } -#endif //DDSCXX_HAS_TYPE_DISCOVERY +#endif //DDSCXX_HAS_TYPELIB /** * @brief Returns a pointer to the derived sertype. diff --git a/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp b/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp index 135f8b53..e00772b5 100644 --- a/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp +++ b/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp @@ -989,7 +989,7 @@ struct ddscxx_sertype_ops: public ddsi_sertype_ops { sertype_free_samples, sertype_equal, sertype_hash, - #ifdef DDSCXX_HAS_TYPE_DISCOVERY + #ifdef DDSCXX_HAS_TYPELIB TopicTraits::getTypeId, TopicTraits::getTypeMap, TopicTraits::getTypeInfo, @@ -997,7 +997,7 @@ struct ddscxx_sertype_ops: public ddsi_sertype_ops { nullptr, nullptr, nullptr, - #endif //DDSCXX_HAS_TYPE_DISCOVERY + #endif //DDSCXX_HAS_TYPELIB TopicTraits::deriveSertype, sertype_get_serialized_size, sertype_serialize_into diff --git a/src/ddscxx/tests/CMakeLists.txt b/src/ddscxx/tests/CMakeLists.txt index e06e4262..48332ea1 100644 --- a/src/ddscxx/tests/CMakeLists.txt +++ b/src/ddscxx/tests/CMakeLists.txt @@ -71,7 +71,7 @@ set(sources DeferredDestruction.cpp KeyHash.cpp) -if (ENABLE_TYPE_DISCOVERY AND ENABLE_TOPIC_DISCOVERY) +if (ENABLE_TYPELIB AND ENABLE_TOPIC_DISCOVERY) # Add topic/type discovery tests list(APPEND sources FindTopic.cpp diff --git a/src/idlcxx/src/traits.c b/src/idlcxx/src/traits.c index c5fce36b..3d318a99 100644 --- a/src/idlcxx/src/traits.c +++ b/src/idlcxx/src/traits.c @@ -128,7 +128,7 @@ emit_traits( " return extensibility::ext_%2$s;\n" "}\n\n"; static const char *type_info_decl1 = - "#ifdef DDSCXX_HAS_TYPE_DISCOVERY\n" + "#ifdef DDSCXX_HAS_TYPELIB\n" "template<> constexpr unsigned int TopicTraits<%1$s>::type_map_blob_sz() { return %2$u; }\n" "template<> constexpr unsigned int TopicTraits<%1$s>::type_info_blob_sz() { return %3$u; }\n" "template<> inline const uint8_t * TopicTraits<%1$s>::type_map_blob() {\n" @@ -143,7 +143,7 @@ emit_traits( "};\n" " return blob;\n" "}\n" - "#endif //DDSCXX_HAS_TYPE_DISCOVERY\n\n"; + "#endif //DDSCXX_HAS_TYPELIB\n\n"; if (IDL_PRINTA(&name, get_cpp11_fully_scoped_name, node, gen) < 0 || idl_fprintf(gen->header.handle, fmt, name, name+2) < 0)