Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed poco dependency #59

Merged
merged 10 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions rosidl_typesupport_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

find_package(ament_cmake_ros REQUIRED)
# provides FindPoco.cmake and Poco on platforms without it
find_package(poco_vendor)
find_package(Poco COMPONENTS Foundation)
find_package(rcpputils REQUIRED)
find_package(rosidl_generator_c REQUIRED)

link_directories(${Poco_LIBRARY_DIR})

ament_export_dependencies(rosidl_typesupport_interface)

ament_export_include_directories(include)
Expand All @@ -35,10 +30,6 @@ add_library(${PROJECT_NAME}
src/message_type_support_dispatch.cpp
src/service_type_support_dispatch.cpp
src/type_support_dispatch.cpp)
if(Poco_FOUND)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "ROSIDL_TYPESUPPORT_C_USE_POCO")
endif()
if(WIN32)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "ROSIDL_TYPESUPPORT_C_BUILDING_DLL")
Expand All @@ -48,9 +39,6 @@ target_include_directories(${PROJECT_NAME}
include
)

if(Poco_FOUND)
ament_target_dependencies(${PROJECT_NAME} "Poco")
endif()
ament_target_dependencies(${PROJECT_NAME} "rcpputils" "rosidl_generator_c")
ament_export_libraries(${PROJECT_NAME})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ else()
message(FATAL_ERROR "Multiple typesupports [${typesupports}] but static "
"linking was requested")
endif()
if(NOT rosidl_typesupport_c_SUPPORTS_POCO)
message(FATAL_ERROR "Multiple typesupports [${typesupports}] but Poco was "
"not available when rosidl_typesupport_c was built")
endif()
endif()

ament_target_dependencies(${rosidl_generate_interfaces_TARGET}${_target_suffix}
Expand Down
4 changes: 0 additions & 4 deletions rosidl_typesupport_c/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>

<depend>rcpputils</depend>
<build_depend>libpoco-dev</build_depend>
<build_depend>poco_vendor</build_depend>
<build_depend>rosidl_generator_c</build_depend>
<!--
Bloom does not support group_depend so entries below duplicate the group rosidl_typesupport_c_packages.
Expand All @@ -25,8 +23,6 @@
<build_export_depend>rmw_implementation</build_export_depend>
<build_export_depend>rosidl_generator_c</build_export_depend>

<exec_depend>libpoco-dev</exec_depend>
<exec_depend>poco_vendor</exec_depend>
<exec_depend>rosidl_typesupport_interface</exec_depend>

<test_depend>ament_lint_auto</test_depend>
Expand Down
2 changes: 0 additions & 2 deletions rosidl_typesupport_c/rosidl_typesupport_c-extras.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ ament_register_extension(
"rosidl_typesupport_c"
"rosidl_typesupport_c_generate_interfaces.cmake")

set(rosidl_typesupport_c_SUPPORTS_POCO @Poco_FOUND@)

set(rosidl_typesupport_c_BIN
"${rosidl_typesupport_c_DIR}/../../../lib/rosidl_typesupport_c/rosidl_typesupport_c")
normalize_path(rosidl_typesupport_c_BIN
Expand Down
34 changes: 21 additions & 13 deletions rosidl_typesupport_c/src/type_support_dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
#include <cstdio>
#include <cstring>

#include <memory>
#include <stdexcept>
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
#include <list>
#include <string>

#ifdef ROSIDL_TYPESUPPORT_C_USE_POCO
#include "Poco/SharedLibrary.h"
#endif

#include "rcpputils/find_library.hpp"
#include "rcpputils/shared_library.hpp"
#include "rosidl_typesupport_c/identifier.h"
#include "rosidl_typesupport_c/type_support_map.h"

Expand All @@ -44,15 +43,15 @@ get_typesupport_handle_function(
return handle;
}

#ifdef ROSIDL_TYPESUPPORT_C_USE_POCO
if (handle->typesupport_identifier == rosidl_typesupport_c__typesupport_identifier) {
const type_support_map_t * map = \
static_cast<const type_support_map_t *>(handle->data);
for (size_t i = 0; i < map->size; ++i) {
if (strcmp(map->typesupport_identifier[i], identifier) != 0) {
continue;
}
Poco::SharedLibrary * lib = nullptr;
rcpputils::SharedLibrary * lib = nullptr;

if (!map->data[i]) {
char library_name[1024];
snprintf(
Expand All @@ -63,25 +62,34 @@ get_typesupport_handle_function(
fprintf(stderr, "Failed to find library '%s'\n", library_name);
return nullptr;
}
lib = new Poco::SharedLibrary(library_path);

try {
lib = new rcpputils::SharedLibrary(library_path.c_str());
} catch (const std::runtime_error & e) {
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
throw std::runtime_error(
"Could not load library " + library_path + " :" +
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
std::string(e.what()));
} catch (const std::bad_alloc & e) {
throw std::runtime_error(
"Could not load library " + library_path + " :" +
std::string(e.what()));
}
map->data[i] = lib;
}
auto clib = static_cast<const Poco::SharedLibrary *>(map->data[i]);
lib = const_cast<Poco::SharedLibrary *>(clib);
if (!lib->hasSymbol(map->symbol_name[i])) {
auto clib = static_cast<const rcpputils::SharedLibrary *>(map->data[i]);
lib = const_cast<rcpputils::SharedLibrary *>(clib);
if (!lib->has_symbol(map->symbol_name[i])) {
fprintf(stderr, "Failed to find symbol '%s' in library\n", map->symbol_name[i]);
return nullptr;
}
void * sym = lib->getSymbol(map->symbol_name[i]);
void * sym = lib->get_symbol(map->symbol_name[i]);

typedef const TypeSupport * (* funcSignature)(void);
funcSignature func = reinterpret_cast<funcSignature>(sym);
const TypeSupport * ts = func();
return ts;
}
}
#endif

return nullptr;
}

Expand Down
12 changes: 0 additions & 12 deletions rosidl_typesupport_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

find_package(ament_cmake_ros REQUIRED)
# provides FindPoco.cmake and Poco on platforms without it
find_package(poco_vendor)
find_package(Poco COMPONENTS Foundation)
find_package(rcpputils REQUIRED)
find_package(rosidl_generator_c REQUIRED)

link_directories(${Poco_LIBRARY_DIR})

ament_export_dependencies(rosidl_typesupport_interface)
ament_export_dependencies(rosidl_typesupport_c)

Expand All @@ -32,10 +27,6 @@ add_library(${PROJECT_NAME}
src/message_type_support_dispatch.cpp
src/service_type_support_dispatch.cpp
src/type_support_dispatch.cpp)
if(Poco_FOUND)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "ROSIDL_TYPESUPPORT_CPP_USE_POCO")
endif()
if(WIN32)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "ROSIDL_TYPESUPPORT_CPP_BUILDING_DLL")
Expand All @@ -45,9 +36,6 @@ target_include_directories(${PROJECT_NAME}
include
)

if(Poco_FOUND)
ament_target_dependencies(${PROJECT_NAME} "Poco")
endif()
ament_target_dependencies(${PROJECT_NAME} "rcpputils" "rosidl_generator_c")
ament_export_libraries(${PROJECT_NAME})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ else()
message(FATAL_ERROR "Multiple typesupports [${typesupports}] but static "
"linking was requested")
endif()
if(NOT rosidl_typesupport_cpp_SUPPORTS_POCO)
message(FATAL_ERROR "Multiple typesupports [${typesupports}] but Poco was "
"not available when rosidl_typesupport_cpp was built")
endif()
endif()

ament_target_dependencies(${rosidl_generate_interfaces_TARGET}${_target_suffix}
Expand Down
4 changes: 0 additions & 4 deletions rosidl_typesupport_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>

<depend>rcpputils</depend>
<build_depend>libpoco-dev</build_depend>
<build_depend>poco_vendor</build_depend>
<build_depend>rosidl_generator_c</build_depend>
<!--
Bloom does not support group_depend so entries below duplicate the group rosidl_typesupport_cpp_packages.
Expand All @@ -26,8 +24,6 @@
<build_export_depend>rosidl_generator_c</build_export_depend>
<build_export_depend>rosidl_typesupport_c</build_export_depend>

<exec_depend>libpoco-dev</exec_depend>
<exec_depend>poco_vendor</exec_depend>
<exec_depend>rosidl_typesupport_interface</exec_depend>

<test_depend>ament_lint_auto</test_depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ ament_register_extension(
"rosidl_typesupport_cpp"
"rosidl_typesupport_cpp_generate_interfaces.cmake")

set(rosidl_typesupport_cpp_SUPPORTS_POCO @Poco_FOUND@)

set(rosidl_typesupport_cpp_BIN
"${rosidl_typesupport_cpp_DIR}/../../../lib/rosidl_typesupport_cpp/rosidl_typesupport_cpp")
normalize_path(rosidl_typesupport_cpp_BIN
Expand Down
35 changes: 22 additions & 13 deletions rosidl_typesupport_cpp/src/type_support_dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <memory>
#include <stdexcept>

#include <string>

#ifdef ROSIDL_TYPESUPPORT_CPP_USE_POCO
#include "Poco/SharedLibrary.h"
#endif

#include "rcpputils/find_library.hpp"
#include "rcpputils/shared_library.hpp"
#include "rosidl_typesupport_cpp/type_support_map.h"

namespace rosidl_typesupport_cpp
Expand All @@ -42,15 +41,15 @@ get_typesupport_handle_function(
return handle;
}

#ifdef ROSIDL_TYPESUPPORT_CPP_USE_POCO
if (handle->typesupport_identifier == rosidl_typesupport_cpp::typesupport_identifier) {
const type_support_map_t * map = \
static_cast<const type_support_map_t *>(handle->data);
for (size_t i = 0; i < map->size; ++i) {
if (strcmp(map->typesupport_identifier[i], identifier) != 0) {
continue;
}
Poco::SharedLibrary * lib = nullptr;
rcpputils::SharedLibrary * lib = nullptr;

if (!map->data[i]) {
char library_name[1024];
snprintf(
Expand All @@ -61,25 +60,35 @@ get_typesupport_handle_function(
fprintf(stderr, "Failed to find library '%s'\n", library_name);
return nullptr;
}
lib = new Poco::SharedLibrary(library_path);

try {
lib = new rcpputils::SharedLibrary(library_path.c_str());
} catch (const std::runtime_error & e) {
throw std::runtime_error(
"Could not load library " + library_path + " :" +
std::string(e.what()));
} catch (const std::bad_alloc & e) {
throw std::runtime_error(
"Could not load library " + library_path + " :" +
std::string(e.what()));
}
map->data[i] = lib;
}
auto clib = static_cast<const Poco::SharedLibrary *>(map->data[i]);
lib = const_cast<Poco::SharedLibrary *>(clib);
if (!lib->hasSymbol(map->symbol_name[i])) {
auto clib = static_cast<const rcpputils::SharedLibrary *>(map->data[i]);
lib = const_cast<rcpputils::SharedLibrary *>(clib);
if (!lib->has_symbol(map->symbol_name[i])) {
fprintf(stderr, "Failed to find symbol '%s' in library\n", map->symbol_name[i]);
return nullptr;
}
void * sym = lib->getSymbol(map->symbol_name[i]);
void * sym = lib->get_symbol(map->symbol_name[i]);


typedef const TypeSupport * (* funcSignature)(void);
funcSignature func = reinterpret_cast<funcSignature>(sym);
const TypeSupport * ts = func();
return ts;
}
}
#endif

return nullptr;
}

Expand Down