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

Refactor/exported symbols #185

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions examples/actions/py_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import threading
import time

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import rclpy
from fibonacci_msgs.action import Fibonacci
from rclpy.action import ActionServer
Expand Down
6 changes: 6 additions & 0 deletions examples/chatter/py_talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import rclpy
from rclpy import node
from std_msgs.msg import String
Expand Down
17 changes: 1 addition & 16 deletions repositories/class_loader.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,9 @@

load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

cc_binary(
name = "class_loader.so",
srcs = glob([
"src/*.cpp",
"include/class_loader/*.hpp",
]),
copts = ["-std=c++17"],
includes = ["include"],
linkshared = True,
deps = [
"@console_bridge",
"@ros2_rcpputils//:rcpputils",
],
)

cc_library(
name = "class_loader",
srcs = ["class_loader.so"],
srcs = glob(["src/*.cpp"]),
hdrs = glob(["include/class_loader/*.hpp"]),
copts = ["-std=c++17"],
includes = ["include"],
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions repositories/ros2_repo_mappings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ repositories:
rmw_cyclonedds:
name: ros2_rmw_cyclonedds
build_file: "@com_github_mvukov_rules_ros2//repositories:rmw_cyclonedds.BUILD.bazel"
patch_args: ["-p1"]
patches:
- "@com_github_mvukov_rules_ros2//repositories/patches:rmw_cyclonedds-fix-typesupport-conditions-bug.patch"
rmw_dds_common:
name: ros2_rmw_dds_common
build_file: "@com_github_mvukov_rules_ros2//repositories:rmw_dds_common.BUILD.bazel"
Expand Down
2 changes: 0 additions & 2 deletions repositories/ros2_repositories_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ def ros2_repositories_impl():
http_archive,
name = "ros2_rmw_cyclonedds",
build_file = "@com_github_mvukov_rules_ros2//repositories:rmw_cyclonedds.BUILD.bazel",
patch_args = ["-p1"],
patches = ["@com_github_mvukov_rules_ros2//repositories/patches:rmw_cyclonedds-fix-typesupport-conditions-bug.patch"],
sha256 = "58ef4fe3fd18eb723906df77eb10df1e69222b451e479c6ec85426ba48e16a8a",
strip_prefix = "rmw_cyclonedds-1.3.4",
url = "https://github.com/ros2/rmw_cyclonedds/archive/refs/tags/1.3.4.tar.gz",
Expand Down
1 change: 1 addition & 0 deletions ros2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exports_files([
"bag.bzl",
"bag.py.tpl",
"cc_defs.bzl",
"exported_symbols.lds",
"interfaces.bzl",
"launch.bzl",
"launch.py.tpl",
Expand Down
2 changes: 2 additions & 0 deletions ros2/bag.py.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

import ros2.ros2_cmd
import ros2bag.verb.convert
import ros2bag.verb.info
Expand Down
9 changes: 9 additions & 0 deletions ros2/cc_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ def _ros2_cc_target(target, lang, name, ros2_package_name, **kwargs):
fail("lang must be set to c or cpp!")
all_copts = all_copts + kwargs.pop("copts", [])

# This solution requires Bazel 6.4.0. https://github.com/bazelbuild/bazel/issues/17788
# all_linkopts = ["-Wl,--dynamic-list=$(location @com_github_mvukov_rules_ros2//ros2:exported_symbols.lds)"] + kwargs.pop("linkopts", [])
# kwargs["linkopts"] = all_linkopts
# all_additional_linker_inputs = ["@com_github_mvukov_rules_ros2//ros2:exported_symbols.lds"] + kwargs.pop("additional_linker_inputs", [])
# kwargs["additional_linker_inputs"] = all_additional_linker_inputs

all_linkopts = ["-Wl,--export-dynamic"] + kwargs.pop("linkopts", [])
kwargs["linkopts"] = all_linkopts

ros2_package_name = ros2_package_name or name
all_local_defines = ["ROS_PACKAGE_NAME=\\\"{}\\\"".format(ros2_package_name)]
all_local_defines = all_local_defines + kwargs.pop("local_defines", [])
Expand Down
5 changes: 5 additions & 0 deletions ros2/exported_symbols.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
rosidl_typesupport_introspection_c__identifier;
*rosidl_typesupport_introspection_cpp*typesupport_identifier*;
*class_loader*impl*;
};
2 changes: 2 additions & 0 deletions ros2/launch.py.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

from ros2cli import cli
from ros2launch.command import launch

Expand Down
2 changes: 2 additions & 0 deletions ros2/pytest_wrapper.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import os
import pathlib
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

import coverage
import domain_coordinator
import pytest
Expand Down
4 changes: 4 additions & 0 deletions ros2/ros2_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import ros2cli.cli
import ros2lifecycle.verb.get
import ros2lifecycle.verb.list
Expand Down
4 changes: 4 additions & 0 deletions ros2/ros2_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import ros2cli.cli
import ros2node.verb.info
import ros2node.verb.list
Expand Down
4 changes: 4 additions & 0 deletions ros2/ros2_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import ros2cli.cli
import ros2param.verb.delete
import ros2param.verb.describe
Expand Down
4 changes: 4 additions & 0 deletions ros2/ros2_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import ros2cli.cli
import ros2service.verb.call
import ros2service.verb.find
Expand Down
4 changes: 4 additions & 0 deletions ros2/ros2_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import ros2cli.cli
import ros2topic.verb.bw
import ros2topic.verb.delay
Expand Down
2 changes: 2 additions & 0 deletions ros2/test.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import contextlib
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

import domain_coordinator
import launch_testing.launch_test
import launch_testing_ros
Expand Down
7 changes: 6 additions & 1 deletion ros2/test/pluginlib/py_loader_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ros2.test.pluginlib import py_loader
import os
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

from ros2.test.pluginlib import py_loader # noqa: E402

py_loader.load_plugins()
5 changes: 5 additions & 0 deletions ros2/test/rosbag/write_to_bag_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pathlib
import sys

sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

# ruff: noqa: E402
import pytest
import rosbag2_py

Expand Down