Skip to content

Commit 6f65002

Browse files
committed
Attempt to add fastrtps as dds vendor alternative
1 parent ca50ff9 commit 6f65002

11 files changed

+391
-6
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ build:clang --repo_env=CC=clang
3030
build:clang --repo_env=CXX=clang++
3131
build:clang --linkopt="-fuse-ld=lld"
3232

33+
# CycloneDDS is used as DDS vendor in the ROS Middleware by default in this repo.
34+
# To use FastDDS, invoke Bazel with `--config=fastdds`.
35+
build:fastdds --@ros2_rmw_implementation//:dds_vendor=fastdds
36+
3337
# Load any settings specific to the current user.
3438
# user.bazelrc should appear in .gitignore so that settings are not shared with
3539
# team members. This needs to be last statement in this config,

repositories/fastcdr.BUILD.bazel

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
""" Builds FastCDR.
2+
"""
3+
4+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
5+
6+
filegroup(
7+
name = "all_srcs",
8+
srcs = glob(["**"]),
9+
)
10+
11+
cache_entries = {
12+
"CMAKE_BUILD_TYPE": "Release",
13+
"CMAKE_POSITION_INDEPENDENT_CODE": "ON", # Must be set!
14+
"BUILD_SHARED_LIBS": "OFF",
15+
# FastCDR specific options.
16+
"EPROSIMA_INSTALLER": "OFF",
17+
"EPROSIMA_BUILD": "OFF",
18+
"EPROSIMA_BUILD_TESTS": "OFF",
19+
"APPEND_PROJECT_NAME_TO_INCLUDEDIR": "OFF",
20+
"BUILD_DOCUMENTATION": "OFF",
21+
"CHECK_DOCUMENTATION": "OFF",
22+
}
23+
24+
cmake(
25+
name = "fastcdr",
26+
build_args = [
27+
"--",
28+
"-j4",
29+
],
30+
cache_entries = cache_entries,
31+
lib_source = ":all_srcs",
32+
out_static_libs = ["libfastcdr.a"],
33+
visibility = ["//visibility:public"],
34+
)

repositories/fastrtps.BUILD.bazel

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
""" Builds FastDDS.
2+
"""
3+
4+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
5+
6+
filegroup(
7+
name = "all_srcs",
8+
srcs = glob(["**"]),
9+
)
10+
11+
cache_entries = {
12+
"CMAKE_BUILD_TYPE": "Release",
13+
"CMAKE_POSITION_INDEPENDENT_CODE": "ON", # Must be set!
14+
"BUILD_SHARED_LIBS": "OFF",
15+
# FastDDS specific options.
16+
"SECURITY": "OFF",
17+
"NO_TLS": "ON",
18+
"SHM_TRANSPORT_DEFAULT": "OFF",
19+
"COMPILE_TOOLS": "OFF",
20+
"INSTALL_TOOLS": "OFF",
21+
"FASTDDS_STATISTICS": "OFF",
22+
"COMPILE_EXAMPLES": "OFF",
23+
"INSTALL_EXAMPLES": "OFF",
24+
"BUILD_DOCUMENTATION": "OFF",
25+
"CHECK_DOCUMENTATION": "OFF",
26+
}
27+
28+
cmake(
29+
name = "fastrtps",
30+
build_args = [
31+
"--",
32+
"-j4",
33+
],
34+
cache_entries = cache_entries,
35+
lib_source = ":all_srcs",
36+
linkopts = select(
37+
{
38+
"@platforms//os:linux": ["-lpthread"],
39+
"@platforms//os:macos": ["-lpthread"],
40+
"@platforms//os:qnx": [],
41+
},
42+
no_match_error = "Only Linux, macOS and QNX are supported!",
43+
),
44+
out_static_libs = ["libfastrtps.a"],
45+
visibility = ["//visibility:public"],
46+
deps = [
47+
"@fastcdr",
48+
"@asio",
49+
"@tinyxml2",
50+
"@foonathan_memory",
51+
"@openssl",
52+
],
53+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
""" Builds foonathan_memory.
2+
"""
3+
4+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
5+
6+
filegroup(
7+
name = "all_srcs",
8+
srcs = glob(["**"]),
9+
)
10+
11+
cache_entries = {
12+
"CMAKE_BUILD_TYPE": "Release",
13+
"CMAKE_POSITION_INDEPENDENT_CODE": "ON", # Must be set!
14+
"BUILD_SHARED_LIBS": "OFF",
15+
# foonathan_memory specific options.
16+
"FOONATHAN_MEMORY_BUILD_EXAMPLES": "OFF",
17+
"FOONATHAN_MEMORY_BUILD_TESTS": "OFF",
18+
}
19+
20+
cmake(
21+
name = "foonathan_memory",
22+
build_args = [
23+
"--",
24+
"-j4",
25+
],
26+
cache_entries = cache_entries,
27+
lib_source = ":all_srcs",
28+
out_static_libs = ["libfoonathan_memory-0.7.3.a"],
29+
visibility = ["//visibility:public"],
30+
)

repositories/rclcpp.BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ ros2_cpp_library(
9191
"@ros2_rosidl//:rosidl_runtime_cpp",
9292
"@ros2_rosidl_typesupport//:rosidl_typesupport_c",
9393
"@ros2_rosidl_typesupport//:rosidl_typesupport_cpp",
94+
"@ros2_rosidl_typesupport_fastrtps//:rosidl_typesupport_fastrtps_c",
95+
"@ros2_rosidl_typesupport_fastrtps//:rosidl_typesupport_fastrtps_cpp",
9496
"@ros2_tracing//:tracetools",
9597
],
9698
)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
""" Builds rmw_fastrtps.
2+
"""
3+
4+
load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl",
5+
"ros2_cpp_binary", "ros2_cpp_library")
6+
7+
ros2_cpp_library(
8+
name = "rmw_fastrtps_shared_cpp",
9+
srcs = glob([
10+
"rmw_fastrtps_shared_cpp/include/**/*.h",
11+
"rmw_fastrtps_shared_cpp/include/**/*.hpp",
12+
"rmw_fastrtps_shared_cpp/src/*.cpp",
13+
"rmw_fastrtps_shared_cpp/src/**/*.hpp",
14+
]),
15+
includes = ["rmw_fastrtps_shared_cpp/include"],
16+
deps = [
17+
"@fastrtps",
18+
"@ros2_rcpputils//:rcpputils",
19+
"@ros2_rcutils//:rcutils",
20+
"@ros2_rmw//:rmw",
21+
"@ros2_rmw//:rmw_cpp",
22+
"@ros2_rmw_dds_common//:rmw_dds_common_lib",
23+
"@ros2_rosidl//:rosidl_runtime_c",
24+
"@ros2_rosidl//:rosidl_typesupport_introspection_c",
25+
"@ros2_rosidl//:rosidl_typesupport_introspection_cpp",
26+
"@ros2_tracing//:tracetools",
27+
],
28+
)
29+
30+
31+
ros2_cpp_binary(
32+
name = "rmw_fastrtps",
33+
srcs = glob([
34+
"rmw_fastrtps_cpp/include/**/*.h",
35+
"rmw_fastrtps_cpp/include/**/*.hpp",
36+
"rmw_fastrtps_cpp/src/*.cpp",
37+
"rmw_fastrtps_cpp/src/*.hpp",
38+
]),
39+
copts = ["-fvisibility=hidden"],
40+
includes = ["rmw_fastrtps_cpp/include"],
41+
linkopts = ["-fvisibility=hidden"],
42+
linkshared = True,
43+
visibility = ["//visibility:public"],
44+
deps = [
45+
":rmw_fastrtps_shared_cpp",
46+
"@ros2_rosidl_typesupport_fastrtps//:rosidl_typesupport_fastrtps_cpp",
47+
],
48+
)

repositories/rmw_implementation.BUILD.bazel

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
""" Builds rmw_implementation.
22
"""
33

4+
load("@bazel_skylib//lib:selects.bzl", "selects")
5+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
46
load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", "ros2_cpp_library")
57

8+
string_flag(
9+
name = "dds_vendor",
10+
build_setting_default = "cyclonedds",
11+
values = ["cyclonedds", "fastdds"],
12+
)
13+
14+
config_setting(
15+
name = "use_cyclonedds",
16+
flag_values = {":dds_vendor": "cyclonedds"},
17+
visibility = ["//visibility:public"],
18+
)
19+
20+
config_setting(
21+
name = "use_fastdds",
22+
flag_values = {":dds_vendor": "fastdds"},
23+
visibility = ["//visibility:public"],
24+
)
25+
626
ros2_cpp_library(
727
name = "rmw_implementation",
828
srcs = [
@@ -11,13 +31,21 @@ ros2_cpp_library(
1131
"rmw_implementation/src/visibility_control.h",
1232
],
1333
copts = ["-w"],
14-
data = [
15-
"@ros2_rmw_cyclonedds//:rmw_cyclonedds",
16-
],
34+
data = select(
35+
{
36+
":use_cyclonedds": ["@ros2_rmw_cyclonedds//:rmw_cyclonedds"],
37+
":use_fastdds": ["@ros2_rmw_fastrtps//:rmw_fastrtps"],
38+
},
39+
no_match_error = "Unsupported dds vendor",
40+
),
1741
includes = ["include"],
18-
local_defines = [
19-
"RMW_LIBRARY_PATH=\\\"$(rootpath @ros2_rmw_cyclonedds//:rmw_cyclonedds)\\\"",
20-
],
42+
local_defines = select(
43+
{
44+
":use_cyclonedds": ["RMW_LIBRARY_PATH=\\\"$(rootpath @ros2_rmw_cyclonedds//:rmw_cyclonedds)\\\""],
45+
":use_fastdds": ["RMW_LIBRARY_PATH=\\\"$(rootpath @ros2_rmw_fastrtps//:rmw_fastrtps)\\\""],
46+
},
47+
no_match_error = "Unsupported dds vendor",
48+
),
2149
visibility = ["//visibility:public"],
2250
deps = [
2351
"@ros2_rcpputils//:rcpputils",

repositories/ros2_repo_mappings.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ repositories:
1515
cyclonedds:
1616
name: cyclonedds
1717
build_file: "@com_github_mvukov_rules_ros2//repositories:cyclonedds.BUILD.bazel"
18+
fastcdr:
19+
name: fastcdr
20+
build_file: "@com_github_mvukov_rules_ros2//repositories:fastcdr.BUILD.bazel"
21+
fastrtps:
22+
name: fastrtps
23+
build_file: "@com_github_mvukov_rules_ros2//repositories:fastrtps.BUILD.bazel"
24+
foonathan_memory:
25+
name: foonathan_memory
26+
build_file: "@com_github_mvukov_rules_ros2//repositories:foonathan_memory.BUILD.bazel"
1827
geometry2:
1928
name: ros2_geometry2
2029
build_file: "@com_github_mvukov_rules_ros2//repositories:geometry2.BUILD.bazel"
@@ -93,6 +102,9 @@ repositories:
93102
rmw_dds_common:
94103
name: ros2_rmw_dds_common
95104
build_file: "@com_github_mvukov_rules_ros2//repositories:rmw_dds_common.BUILD.bazel"
105+
rmw_fastrtps:
106+
name: ros2_rmw_fastrtps
107+
build_file: "@com_github_mvukov_rules_ros2//repositories:rmw_fastrtps.BUILD.bazel"
96108
rmw_implementation:
97109
name: ros2_rmw_implementation
98110
build_file: "@com_github_mvukov_rules_ros2//repositories:rmw_implementation.BUILD.bazel"

repositories/ros2_repositories_impl.bzl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,33 @@ def ros2_repositories_impl():
4848
url = "https://github.com/eclipse-cyclonedds/cyclonedds/archive/refs/tags/0.9.1.tar.gz",
4949
)
5050

51+
maybe(
52+
http_archive,
53+
name = "fastcdr",
54+
build_file = "@com_github_mvukov_rules_ros2//repositories:fastcdr.BUILD.bazel",
55+
sha256 = "5c4b2ad5493abd30b9475b14856641a8944c98077a36bd0760c1d83c65216e67",
56+
strip_prefix = "Fast-CDR-1.1.0",
57+
url = "https://github.com/eProsima/Fast-CDR/archive/refs/tags/v1.1.0.tar.gz",
58+
)
59+
60+
maybe(
61+
http_archive,
62+
name = "fastrtps",
63+
build_file = "@com_github_mvukov_rules_ros2//repositories:fastrtps.BUILD.bazel",
64+
sha256 = "0dca5e455e939c6aeeeb0c82d78ad94f2103b44c188c647f0940d827dd0819b4",
65+
strip_prefix = "Fast-DDS-2.7.1",
66+
url = "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.7.1.tar.gz",
67+
)
68+
69+
maybe(
70+
http_archive,
71+
name = "foonathan_memory",
72+
build_file = "@com_github_mvukov_rules_ros2//repositories:foonathan_memory.BUILD.bazel",
73+
sha256 = "4203d15db22a94a3978eeb1afb59a37d35c57c0f148733f0f1a53a6281cb74dd",
74+
strip_prefix = "memory-0.7-3",
75+
url = "https://github.com/foonathan/memory/archive/refs/tags/v0.7-3.tar.gz",
76+
)
77+
5178
maybe(
5279
http_archive,
5380
name = "ros2_geometry2",
@@ -244,6 +271,15 @@ def ros2_repositories_impl():
244271
url = "https://github.com/ros2/rmw_dds_common/archive/refs/tags/1.6.0.tar.gz",
245272
)
246273

274+
maybe(
275+
http_archive,
276+
name = "ros2_rmw_fastrtps",
277+
build_file = "@com_github_mvukov_rules_ros2//repositories:rmw_fastrtps.BUILD.bazel",
278+
sha256 = "a0145b414207a2528fd56e98a56bd6d4c3f0353dcd58f4b3a65224af8bd52284",
279+
strip_prefix = "rmw_fastrtps-6.2.3",
280+
url = "https://github.com/ros2/rmw_fastrtps/archive/refs/tags/6.2.3.tar.gz",
281+
)
282+
247283
maybe(
248284
http_archive,
249285
name = "ros2_rmw_implementation",
@@ -344,6 +380,15 @@ def ros2_repositories_impl():
344380
url = "https://github.com/ros2/rosidl_typesupport/archive/refs/tags/2.0.0.tar.gz",
345381
)
346382

383+
maybe(
384+
http_archive,
385+
name = "ros2_rosidl_typesupport_fastrtps",
386+
build_file = "@com_github_mvukov_rules_ros2//repositories:rosidl_typesupport_fastrtps.BUILD.bazel",
387+
sha256 = "41deed571ab95f7d2a191af6e4536536f13266df059b0b11f6469be8e44cf304",
388+
strip_prefix = "rosidl_typesupport_fastrtps-2.2.1",
389+
url = "https://github.com/ros2/rosidl_typesupport_fastrtps/archive/refs/tags/2.2.1.tar.gz",
390+
)
391+
347392
maybe(
348393
http_archive,
349394
name = "ros2_rpyutils",

0 commit comments

Comments
 (0)