Skip to content

Commit

Permalink
[core] force symbol hiding for ecal_core(_c).so. (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller authored Nov 11, 2024
1 parent 0a47c89 commit 4bccca8
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 121 deletions.
25 changes: 22 additions & 3 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,14 @@ add_library(eCAL::${PROJECT_NAME}_c ALIAS ${PROJECT_NAME}_c)
target_link_libraries(${PROJECT_NAME}_c ${PROJECT_NAME})

target_compile_definitions(${PROJECT_NAME}_c
INTERFACE ECAL_C_DLL
INTERFACE
ECAL_C_DLL # This is deprecated
ECAL_CORE_C_IMPORTS
PUBLIC
ASIO_STANDALONE
ASIO_DISABLE_VISIBILITY
PRIVATE
eCAL_EXPORTS
ECAL_CORE_C_EXPORTS
ECAL_NO_DEPRECATION_WARNINGS
)

Expand All @@ -638,13 +640,30 @@ target_compile_definitions(${PROJECT_NAME}
ASIO_STANDALONE
ASIO_DISABLE_VISIBILITY
PRIVATE
eCAL_EXPORTS
ECAL_CORE_EXPORTS
$<$<BOOL:${ECAL_HAS_CLOCKLOCK_MUTEX}>:ECAL_HAS_CLOCKLOCK_MUTEX>
$<$<BOOL:${ECAL_HAS_ROBUST_MUTEX}>:ECAL_HAS_ROBUST_MUTEX>
$<$<BOOL:${ECAL_USE_CLOCKLOCK_MUTEX}>:ECAL_USE_CLOCKLOCK_MUTEX>
ECAL_NO_DEPRECATION_WARNINGS
INTERFACE
ECAL_CORE_IMPORTS
)

set_target_properties(${PROJECT_NAME}_c
PROPERTIES
CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)

set_target_properties(${PROJECT_NAME}
PROPERTIES
CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)


set(ECAL_CORE_FEATURES
ECAL_CORE_CONFIGURATION
ECAL_CORE_COMMAND_LINE
Expand Down
18 changes: 9 additions & 9 deletions ecal/core/include/ecal/cimpl/ecal_time_cimpl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,21 +37,21 @@ extern "C"
*
* @return Get time sync interface name.
**/
ECAL_API int eCAL_Time_GetName(void* name_, int name_len_);
ECALC_API int eCAL_Time_GetName(void* name_, int name_len_);

/**
* @brief Get current time
*
* @return current time in us.
**/
ECAL_API long long eCAL_Time_GetMicroSeconds();
ECALC_API long long eCAL_Time_GetMicroSeconds();

/**
* @brief Get current time
*
* @return current time in ns.
**/
ECAL_API long long eCAL_Time_GetNanoSeconds();
ECALC_API long long eCAL_Time_GetNanoSeconds();

/**
* @brief Set current time in nano seconds if host is time master.
Expand All @@ -60,21 +60,21 @@ extern "C"
*
* @return Zero if succeeded non zero otherwise.
**/
ECAL_API int eCAL_Time_SetNanoSeconds(long long time_);
ECALC_API int eCAL_Time_SetNanoSeconds(long long time_);

/**
* @brief Returns time synchronization state.
*
* @return Non zero if process is time synchronized.
**/
ECAL_API int eCAL_Time_IsTimeSynchronized();
ECALC_API int eCAL_Time_IsTimeSynchronized();

/**
* @brief Checks whether this host is time master.
*
* @return Non zero if host is time master.
**/
ECAL_API int eCAL_Time_IsTimeMaster();
ECALC_API int eCAL_Time_IsTimeMaster();

/**
* @brief Blocks for the given amount of nanoseconds.
Expand All @@ -86,7 +86,7 @@ extern "C"
*
* @param duration_nsecs_ the duration in nanoseconds
**/
ECAL_API void eCAL_Time_SleepForNanoseconds(long long duration_nsecs_);
ECALC_API void eCAL_Time_SleepForNanoseconds(long long duration_nsecs_);

/**
* @brief Get the current error code and status message
Expand All @@ -104,7 +104,7 @@ extern "C"
* @param max_len_ [in] The length of the allocated memory for the status_message_, ECAL_ALOCATE_4ME if the function has to allocate memory or -1 if not interested in the message.
* @return
**/
ECAL_API int eCAL_Time_GetStatus(int* error_, char** status_message_, const int max_len_);
ECALC_API int eCAL_Time_GetStatus(int* error_, char** status_message_, const int max_len_);

#ifdef __cplusplus
}
Expand Down
55 changes: 36 additions & 19 deletions ecal/core/include/ecal/ecal_client.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,33 +41,37 @@ namespace eCAL
/**
* @brief Service client wrapper class.
**/
class CServiceClient
class ECAL_API_CLASS CServiceClient
{
public:
/**
* @brief Constructor.
**/
ECAL_API CServiceClient();
ECAL_API_EXPORTED_MEMBER
CServiceClient();

/**
* @brief Constructor.
*
* @param service_name_ Unique service name.
**/
ECAL_API explicit CServiceClient(const std::string& service_name_);
ECAL_API_EXPORTED_MEMBER
explicit CServiceClient(const std::string& service_name_);

/**
* @brief Constructor.
*
* @param service_name_ Unique service name.
* @param method_information_map_ Map of method names and corresponding datatype information.
**/
ECAL_API explicit CServiceClient(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);
ECAL_API_EXPORTED_MEMBER
explicit CServiceClient(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);

/**
* @brief Destructor.
**/
ECAL_API virtual ~CServiceClient();
ECAL_API_EXPORTED_MEMBER
virtual ~CServiceClient();

/**
* @brief CServiceClients are non-copyable
Expand All @@ -86,7 +90,8 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool Create(const std::string& service_name_);
ECAL_API_EXPORTED_MEMBER
bool Create(const std::string& service_name_);

/**
* @brief Creates this object.
Expand All @@ -96,14 +101,16 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool Create(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);
ECAL_API_EXPORTED_MEMBER
bool Create(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);

/**
* @brief Destroys this object.
*
* @return True if successful.
**/
ECAL_API bool Destroy();
ECAL_API_EXPORTED_MEMBER
bool Destroy();

/**
* @brief Change the host name filter for that client instance
Expand All @@ -112,7 +119,8 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool SetHostName(const std::string& host_name_);
ECAL_API_EXPORTED_MEMBER
bool SetHostName(const std::string& host_name_);

/**
* @brief Call a method of this service, responses will be returned by callback.
Expand All @@ -123,7 +131,8 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool Call(const std::string& method_name_, const std::string& request_, int timeout_ = -1);
ECAL_API_EXPORTED_MEMBER
bool Call(const std::string& method_name_, const std::string& request_, int timeout_ = -1);

/**
* @brief Call a method of this service, all responses will be returned in service_response_vec_.
Expand All @@ -135,7 +144,8 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool Call(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT* service_response_vec_);
ECAL_API_EXPORTED_MEMBER
bool Call(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT* service_response_vec_);

/**
* @brief Call a method of this service asynchronously, responses will be returned by callback.
Expand All @@ -146,7 +156,8 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool CallAsync(const std::string& method_name_, const std::string& request_, int timeout_ = -1);
ECAL_API_EXPORTED_MEMBER
bool CallAsync(const std::string& method_name_, const std::string& request_, int timeout_ = -1);

/**
* @brief Add server response callback.
Expand All @@ -155,14 +166,16 @@ namespace eCAL
*
* @return True if successful.
**/
ECAL_API bool AddResponseCallback(const ResponseCallbackT& callback_);
ECAL_API_EXPORTED_MEMBER
bool AddResponseCallback(const ResponseCallbackT& callback_);

/**
* @brief Remove server response callback.
*
* @return True if successful.
**/
ECAL_API bool RemResponseCallback();
ECAL_API_EXPORTED_MEMBER
bool RemResponseCallback();

/**
* @brief Add client event callback function.
Expand All @@ -172,7 +185,8 @@ namespace eCAL
*
* @return True if succeeded, false if not.
**/
ECAL_API bool AddEventCallback(eCAL_Client_Event type_, ClientEventCallbackT callback_);
ECAL_API_EXPORTED_MEMBER
bool AddEventCallback(eCAL_Client_Event type_, ClientEventCallbackT callback_);

/**
* @brief Remove client event callback function.
Expand All @@ -181,21 +195,24 @@ namespace eCAL
*
* @return True if succeeded, false if not.
**/
ECAL_API bool RemEventCallback(eCAL_Client_Event type_);
ECAL_API_EXPORTED_MEMBER
bool RemEventCallback(eCAL_Client_Event type_);

/**
* @brief Retrieve service name.
*
* @return The service name.
**/
ECAL_API std::string GetServiceName();
ECAL_API_EXPORTED_MEMBER
std::string GetServiceName();

/**
* @brief Check connection state.
*
* @return True if connected, false if not.
**/
ECAL_API bool IsConnected();
ECAL_API_EXPORTED_MEMBER
bool IsConnected();

protected:
std::shared_ptr<eCAL::CServiceClientImpl> m_service_client_impl;
Expand Down
60 changes: 37 additions & 23 deletions ecal/core/include/ecal/ecal_os.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,30 +48,44 @@
#endif

#ifdef _MSC_VER
#ifdef eCAL_EXPORTS
#define ECALC_API __declspec(dllexport)
#else /* eCAL_EXPORTS */
#define ECALC_API __declspec(dllimport)
#endif /* eCAL_EXPORTS */
#ifdef ECAL_C_DLL
#ifdef ECAL_CORE_EXPORTS
#define ECAL_API __declspec(dllexport)
#elif defined(ECAL_CORE_IMPORTS)
#define ECAL_API __declspec(dllimport)
#else
#define ECAL_API
#else /* ECAL_C_DLL */
#define ECAL_API ECALC_API
#endif /* ECAL_C_DLL */
#else /* _MSC_VER */
#define ECALC_API
#define ECAL_API
#endif
#endif

#ifdef _MSC_VER
#ifdef eCAL_EXPORTS
#define ECAL_API_CLASS
#define ECAL_API_EXPORTED_MEMBER ECAL_API

#ifdef ECAL_CORE_C_EXPORTS
#define ECALC_API __declspec(dllexport)
#define ECALC_API_DEPRECATED __declspec(dllexport deprecated)
#else /* eCAL_EXPORTS */
#elif defined(ECAL_CORE_C_IMPORTS)
#define ECALC_API __declspec(dllimport)
#define ECALC_API_DEPRECATED __declspec(dllimport deprecated)
#endif /* eCAL_EXPORTS */
#elif defined(__GNUC__) || defined(__clang__)
#define ECALC_API_DEPRECATED __attribute__((deprecated))
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define ECALC_API_DEPRECATED
#else
#define ECALC_API
#define ECALC_API_DEPRECATED __declspec(deprecated)
#endif


#else /* _MSC_VER */
#define ECAL_API_CLASS __attribute__((visibility("default")))
#ifdef ECAL_CORE_EXPORTS
#define ECAL_API __attribute__((visibility("default")))
#else
#define ECAL_API
#endif

#define ECAL_API_CLASS __attribute__((visibility("default")))
#define ECAL_API_EXPORTED_MEMBER

#ifdef ECAL_CORE_C_EXPORTS
#define ECALC_API __attribute__((visibility("default")))
#else
#define ECALC_API
#endif
#define ECALC_API_DEPRECATED __attribute__((deprecated)) ECALC_API
#endif
Loading

0 comments on commit 4bccca8

Please sign in to comment.