Skip to content

Commit 1459878

Browse files
committed
Remove inner RCL public macros for each of the modified classes and introduce a separate configure_rclcpp.cmake
Signed-off-by: Sachin Suresh Bhat <[email protected]>
1 parent 6f15f30 commit 1459878

File tree

17 files changed

+71
-237
lines changed

17 files changed

+71
-237
lines changed

rclcpp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2323
endif()
2424

2525
include_directories(include)
26+
include(cmake/configure_rclcpp.cmake)
2627

2728
set(${PROJECT_NAME}_SRCS
2829
src/rclcpp/any_executable.cpp
@@ -109,7 +110,7 @@ ament_target_dependencies(${PROJECT_NAME}
109110
"rosidl_typesupport_cpp"
110111
"rosidl_generator_cpp")
111112

112-
configure_rcl(${PROJECT_NAME})
113+
configure_rclcpp(${PROJECT_NAME})
113114
# Causes the visibility macros to use dllexport rather than dllimport,
114115
# which is appropriate when building the dll but not consuming it.
115116
target_compile_definitions(${PROJECT_NAME}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright 2019 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# Configures ros client library with custom settings.
16+
# The custom settings are all related to library symbol visibility, see:
17+
# https://gcc.gnu.org/wiki/Visibility
18+
# http://www.ibm.com/developerworks/aix/library/au-aix-symbol-visibility/
19+
#
20+
# Below code is heavily referenced from a similar functionality in rmw:
21+
# https://github.com/ros2/rmw/blob/master/rmw/cmake/configure_rmw_library.cmake
22+
#
23+
# :param library_target: the library target
24+
# :type library_target: string
25+
# :param LANGUAGE: Optional flag for the language of the library.
26+
# Allowed values are "C" and "CXX". The default is "CXX".
27+
# :type LANGUAGE: string
28+
#
29+
# @public
30+
#
31+
macro(configure_rclcpp library_target)
32+
cmake_parse_arguments(_ARG "" "LANGUAGE" "" ${ARGN})
33+
if(_ARG_UNPARSED_ARGUMENTS)
34+
message(FATAL_ERROR "configure_rclcpp() called with unused arguments: ${_ARG_UNPARSED_ARGUMENTS}")
35+
endif()
36+
37+
if(NOT _ARG_LANGUAGE)
38+
set(_ARG_LANGUAGE "CXX")
39+
endif()
40+
41+
if(_ARG_LANGUAGE STREQUAL "C")
42+
# Set the visibility to hidden by default if possible
43+
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
44+
# Set the visibility of symbols to hidden by default for gcc and clang
45+
# (this is already the default on Windows)
46+
set_target_properties(${library_target}
47+
PROPERTIES
48+
COMPILE_FLAGS "-fvisibility=hidden"
49+
)
50+
endif()
51+
52+
elseif(_ARG_LANGUAGE STREQUAL "CXX")
53+
# Set the visibility to hidden by default if possible
54+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
55+
# Set the visibility of symbols to hidden by default for gcc and clang
56+
# (this is already the default on Windows)
57+
set_target_properties(${library_target}
58+
PROPERTIES
59+
COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden"
60+
)
61+
endif()
62+
63+
else()
64+
message(FATAL_ERROR "configure_rclcpp() called with unsupported LANGUAGE: '${_ARG_LANGUAGE}'")
65+
endif()
66+
endmacro()

rclcpp/include/rclcpp/client.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,21 @@ class RCLCPP_PUBLIC ClientBase
5454
public:
5555
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(ClientBase)
5656

57-
RCLCPP_PUBLIC
5857
ClientBase(
5958
rclcpp::node_interfaces::NodeBaseInterface * node_base,
6059
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph);
6160

62-
RCLCPP_PUBLIC
6361
virtual ~ClientBase();
6462

65-
RCLCPP_PUBLIC
6663
const char *
6764
get_service_name() const;
6865

69-
RCLCPP_PUBLIC
7066
std::shared_ptr<rcl_client_t>
7167
get_client_handle();
7268

73-
RCLCPP_PUBLIC
7469
std::shared_ptr<const rcl_client_t>
7570
get_client_handle() const;
7671

77-
RCLCPP_PUBLIC
7872
bool
7973
service_is_ready() const;
8074

@@ -96,15 +90,12 @@ class RCLCPP_PUBLIC ClientBase
9690
protected:
9791
RCLCPP_DISABLE_COPY(ClientBase)
9892

99-
RCLCPP_PUBLIC
10093
bool
10194
wait_for_service_nanoseconds(std::chrono::nanoseconds timeout);
10295

103-
RCLCPP_PUBLIC
10496
rcl_node_t *
10597
get_rcl_node_handle();
10698

107-
RCLCPP_PUBLIC
10899
const rcl_node_t *
109100
get_rcl_node_handle() const;
110101

rclcpp/include/rclcpp/executor.hpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ class RCLCPP_PUBLIC Executor
9999

100100
/// Default constructor.
101101
// \param[in] ms The memory strategy to be used with this executor.
102-
RCLCPP_PUBLIC
103102
explicit Executor(const ExecutorArgs & args = ExecutorArgs());
104103

105104
/// Default destructor.
106-
RCLCPP_PUBLIC
107105
virtual ~Executor();
108106

109107
/// Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
@@ -119,12 +117,10 @@ class RCLCPP_PUBLIC Executor
119117
* the executor is blocked at the rmw layer while waiting for work and it is notified that a new
120118
* node was added, it will wake up.
121119
*/
122-
RCLCPP_PUBLIC
123120
virtual void
124121
add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify = true);
125122

126123
/// Convenience function which takes Node and forwards NodeBaseInterface.
127-
RCLCPP_PUBLIC
128124
virtual void
129125
add_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true);
130126

@@ -135,12 +131,10 @@ class RCLCPP_PUBLIC Executor
135131
* This is useful if the last node was removed from the executor while the executor was blocked
136132
* waiting for work in another thread, because otherwise the executor would never be notified.
137133
*/
138-
RCLCPP_PUBLIC
139134
virtual void
140135
remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify = true);
141136

142137
/// Convenience function which takes Node and forwards NodeBaseInterface.
143-
RCLCPP_PUBLIC
144138
virtual void
145139
remove_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true);
146140

@@ -180,12 +174,10 @@ class RCLCPP_PUBLIC Executor
180174
/**
181175
* \param[in] node Shared pointer to the node to add.
182176
*/
183-
RCLCPP_PUBLIC
184177
void
185178
spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node);
186179

187180
/// Convenience function which takes Node and forwards NodeBaseInterface.
188-
RCLCPP_PUBLIC
189181
void
190182
spin_node_some(std::shared_ptr<rclcpp::Node> node);
191183

@@ -200,11 +192,9 @@ class RCLCPP_PUBLIC Executor
200192
* Note that spin_some() may take longer than this time as it only returns once max_duration has
201193
* been exceeded.
202194
*/
203-
RCLCPP_PUBLIC
204195
virtual void
205196
spin_some(std::chrono::nanoseconds max_duration = std::chrono::nanoseconds(0));
206197

207-
RCLCPP_PUBLIC
208198
virtual void
209199
spin_once(std::chrono::nanoseconds timeout = std::chrono::nanoseconds(-1));
210200

@@ -269,7 +259,6 @@ class RCLCPP_PUBLIC Executor
269259

270260
/// Cancel any running spin* function, causing it to return.
271261
/* This function can be called asynchonously from any thread. */
272-
RCLCPP_PUBLIC
273262
void
274263
cancel();
275264

@@ -279,12 +268,10 @@ class RCLCPP_PUBLIC Executor
279268
* unintended consequences.
280269
* \param[in] memory_strategy Shared pointer to the memory strategy to set.
281270
*/
282-
RCLCPP_PUBLIC
283271
void
284272
set_memory_strategy(memory_strategy::MemoryStrategy::SharedPtr memory_strategy);
285273

286274
protected:
287-
RCLCPP_PUBLIC
288275
void
289276
spin_node_once_nanoseconds(
290277
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
@@ -294,53 +281,41 @@ class RCLCPP_PUBLIC Executor
294281
/** \param[in] any_exec Union structure that can hold any executable type (timer, subscription,
295282
* service, client).
296283
*/
297-
RCLCPP_PUBLIC
298284
void
299285
execute_any_executable(AnyExecutable & any_exec);
300286

301-
RCLCPP_PUBLIC
302287
static void
303288
execute_subscription(
304289
rclcpp::SubscriptionBase::SharedPtr subscription);
305290

306-
RCLCPP_PUBLIC
307291
static void
308292
execute_intra_process_subscription(
309293
rclcpp::SubscriptionBase::SharedPtr subscription);
310294

311-
RCLCPP_PUBLIC
312295
static void
313296
execute_timer(rclcpp::TimerBase::SharedPtr timer);
314297

315-
RCLCPP_PUBLIC
316298
static void
317299
execute_service(rclcpp::ServiceBase::SharedPtr service);
318300

319-
RCLCPP_PUBLIC
320301
static void
321302
execute_client(rclcpp::ClientBase::SharedPtr client);
322303

323-
RCLCPP_PUBLIC
324304
void
325305
wait_for_work(std::chrono::nanoseconds timeout = std::chrono::nanoseconds(-1));
326306

327-
RCLCPP_PUBLIC
328307
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
329308
get_node_by_group(rclcpp::callback_group::CallbackGroup::SharedPtr group);
330309

331-
RCLCPP_PUBLIC
332310
rclcpp::callback_group::CallbackGroup::SharedPtr
333311
get_group_by_timer(rclcpp::TimerBase::SharedPtr timer);
334312

335-
RCLCPP_PUBLIC
336313
void
337314
get_next_timer(AnyExecutable & any_exec);
338315

339-
RCLCPP_PUBLIC
340316
bool
341317
get_next_ready_executable(AnyExecutable & any_executable);
342318

343-
RCLCPP_PUBLIC
344319
bool
345320
get_next_executable(
346321
AnyExecutable & any_executable,

rclcpp/include/rclcpp/intra_process_manager.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,9 @@ class RCLCPP_PUBLIC IntraProcessManager
127127
public:
128128
RCLCPP_SMART_PTR_DEFINITIONS(IntraProcessManager)
129129

130-
RCLCPP_PUBLIC
131130
explicit IntraProcessManager(
132131
IntraProcessManagerImplBase::SharedPtr state = create_default_impl());
133132

134-
RCLCPP_PUBLIC
135133
virtual ~IntraProcessManager();
136134

137135
/// Register a subscription with the manager, returns subscriptions unique id.
@@ -147,7 +145,6 @@ class RCLCPP_PUBLIC IntraProcessManager
147145
* \param subscription the Subscription to register.
148146
* \return an unsigned 64-bit integer which is the subscription's unique id.
149147
*/
150-
RCLCPP_PUBLIC
151148
uint64_t
152149
add_subscription(SubscriptionBase::SharedPtr subscription);
153150

@@ -157,7 +154,6 @@ class RCLCPP_PUBLIC IntraProcessManager
157154
*
158155
* \param intra_process_subscription_id id of the subscription to remove.
159156
*/
160-
RCLCPP_PUBLIC
161157
void
162158
remove_subscription(uint64_t intra_process_subscription_id);
163159

@@ -206,7 +202,6 @@ class RCLCPP_PUBLIC IntraProcessManager
206202
*
207203
* \param intra_process_publisher_id id of the publisher to remove.
208204
*/
209-
RCLCPP_PUBLIC
210205
void
211206
remove_publisher(uint64_t intra_process_publisher_id);
212207

@@ -342,17 +337,14 @@ class RCLCPP_PUBLIC IntraProcessManager
342337
}
343338

344339
/// Return true if the given rmw_gid_t matches any stored Publishers.
345-
RCLCPP_PUBLIC
346340
bool
347341
matches_any_publishers(const rmw_gid_t * id) const;
348342

349343
/// Return the number of intraprocess subscriptions to a topic, given the publisher id.
350-
RCLCPP_PUBLIC
351344
size_t
352345
get_subscription_count(uint64_t intra_process_publisher_id) const;
353346

354347
private:
355-
RCLCPP_PUBLIC
356348
static uint64_t
357349
get_next_unique_id();
358350

0 commit comments

Comments
 (0)