Skip to content

Commit

Permalink
[rosidl] Ensure *_defs data is added to *_py and *_cc targets
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI committed Oct 26, 2023
1 parent 198c389 commit 0b754cd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
45 changes: 35 additions & 10 deletions bazel_ros2_rules/ros2/rosidl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ def rosidl_c_library(
group,
interfaces,
includes = [],
data = [],
deps = [],
cc_library_rule = native.cc_library,
**kwargs):
Expand Down Expand Up @@ -460,6 +461,7 @@ def rosidl_c_library(
srcs = generated_c_sources,
hdrs = generated_c_headers,
includes = [include],
data = data,
deps = deps,
**kwargs
)
Expand All @@ -469,6 +471,7 @@ def rosidl_cc_library(
group,
interfaces,
includes = [],
data = [],
deps = [],
cc_library_rule = native.cc_library,
**kwargs):
Expand Down Expand Up @@ -518,6 +521,7 @@ def rosidl_cc_library(
name = name,
hdrs = generated_cc_headers,
includes = [include],
data = data,
deps = deps + [
REPOSITORY_ROOT + ":rosidl_runtime_cpp_cc",
],
Expand All @@ -533,6 +537,7 @@ def rosidl_py_library(
interfaces,
typesupports,
includes = [],
data = [],
c_deps = [],
py_deps = [],
cc_binary_rule = native.cc_binary,
Expand Down Expand Up @@ -637,7 +642,7 @@ def rosidl_py_library(
name = name,
srcs = generated_py_sources,
imports = [import_],
data = py_data,
data = data + py_data,
deps = py_deps,
**kwargs
)
Expand All @@ -647,6 +652,7 @@ def rosidl_typesupport_fastrtps_cc_library(
group,
interfaces,
includes = [],
data = [],
deps = [],
cc_binary_rule = native.cc_binary,
cc_library_rule = native.cc_library,
Expand Down Expand Up @@ -702,6 +708,7 @@ def rosidl_typesupport_fastrtps_cc_library(
cc_binary_rule(
name = name,
srcs = generated_cc_sources,
data = data,
deps = deps + [
_make_private_label(name, "_hdrs"),
REPOSITORY_ROOT + ":fastcdr_cc",
Expand All @@ -719,6 +726,7 @@ def rosidl_typesupport_fastrtps_c_library(
group,
interfaces,
includes = [],
data = [],
deps = [],
cc_binary_rule = native.cc_binary,
cc_library_rule = native.cc_library,
Expand Down Expand Up @@ -775,6 +783,7 @@ def rosidl_typesupport_fastrtps_c_library(
name = name,
srcs = generated_c_sources,
linkshared = True,
data = data,
deps = deps + [
_make_private_label(name, "_hdrs"),
REPOSITORY_ROOT + ":fastcdr_cc",
Expand All @@ -792,6 +801,7 @@ def rosidl_typesupport_introspection_c_library(
group,
interfaces,
includes = [],
data = [],
deps = [],
cc_binary_rule = native.cc_binary,
cc_library_rule = native.cc_library,
Expand Down Expand Up @@ -849,6 +859,7 @@ def rosidl_typesupport_introspection_c_library(
name = name,
srcs = generated_c_sources,
linkshared = True,
data = data,
deps = deps + [
_make_private_label(name, "_hdrs"),
REPOSITORY_ROOT + ":rosidl_typesupport_introspection_c_cc",
Expand All @@ -861,6 +872,7 @@ def rosidl_typesupport_introspection_cc_library(
group,
interfaces,
includes = [],
data = [],
deps = [],
cc_binary_rule = native.cc_binary,
cc_library_rule = native.cc_library,
Expand Down Expand Up @@ -918,6 +930,7 @@ def rosidl_typesupport_introspection_cc_library(
name = name,
srcs = generated_cc_sources,
linkshared = True,
data = data,
deps = deps + [
_make_private_label(name, "_hdrs"),
REPOSITORY_ROOT + ":rosidl_runtime_c_cc",
Expand All @@ -934,6 +947,7 @@ def rosidl_typesupport_c_library(
interfaces,
typesupports,
includes = [],
data = [],
deps = [],
cc_binary_rule = native.cc_binary,
**kwargs):
Expand Down Expand Up @@ -982,7 +996,7 @@ def rosidl_typesupport_c_library(
srcs = generated_sources,
includes = [include],
linkshared = True,
data = typesupports.values(),
data = data + typesupports.values(),
deps = deps + [
_make_private_label(label, "_hdrs")
for label in typesupports.values()
Expand All @@ -1000,6 +1014,7 @@ def rosidl_typesupport_cc_library(
interfaces,
typesupports,
includes = [],
data = [],
deps = [],
cc_binary_rule = native.cc_binary,
**kwargs):
Expand Down Expand Up @@ -1044,7 +1059,7 @@ def rosidl_typesupport_cc_library(
cc_binary_rule(
name = name,
srcs = generated_cc_sources,
data = typesupports.values(),
data = data + typesupports.values(),
includes = [include],
linkshared = True,
deps = deps + [
Expand All @@ -1062,6 +1077,7 @@ def rosidl_typesupport_cc_library(
def rosidl_cc_support(
name,
interfaces,
data,
deps,
group = None,
cc_binary_rule = native.cc_binary,
Expand Down Expand Up @@ -1158,6 +1174,7 @@ def rosidl_cc_support(
srcs = [
_make_public_label(name, "__rosidl_typesupport_cpp"),
] + typesupports.values(),
data = data,
deps = [_make_private_label(name, "__rosidl_cpp")],
linkstatic = True,
**kwargs
Expand All @@ -1166,6 +1183,7 @@ def rosidl_cc_support(
def rosidl_py_support(
name,
interfaces,
data,
deps,
group = None,
cc_binary_rule = native.cc_binary,
Expand Down Expand Up @@ -1277,6 +1295,7 @@ def rosidl_py_support(
group = group or name,
interfaces = interfaces,
includes = [_make_public_label(dep, "_defs") for dep in deps],
data = data,
py_deps = [_make_public_label(dep, "_py") for dep in deps],
c_deps = [_make_public_label(name, "_c")] + [
_make_public_label(dep, "_c")
Expand All @@ -1291,6 +1310,7 @@ def rosidl_py_support(
def rosidl_interfaces_group(
name,
interfaces,
data = [],
deps = [],
group = None,
cc_binary_rule = native.cc_binary,
Expand Down Expand Up @@ -1328,8 +1348,11 @@ def rosidl_interfaces_group(
if group != None:
name = group

defs_name = _make_public_name(name, "_defs")
data = data + [defs_name]

rosidl_definitions_filegroup(
name = _make_public_name(name, "_defs"),
name = defs_name,
group = group or name,
interfaces = interfaces,
includes = [_make_public_label(dep, "_defs") for dep in deps],
Expand All @@ -1338,19 +1361,21 @@ def rosidl_interfaces_group(

rosidl_cc_support(
name,
interfaces,
deps,
group,
interfaces = interfaces,
data = data,
deps = deps,
group = group,
cc_binary_rule = cc_binary_rule,
cc_library_rule = cc_library_rule,
**kwargs
)

rosidl_py_support(
name,
interfaces,
deps,
group,
interfaces = interfaces,
data = data,
deps = deps,
group = group,
cc_binary_rule = cc_binary_rule,
cc_library_rule = cc_library_rule,
py_library_rule = py_library_rule,
Expand Down
7 changes: 4 additions & 3 deletions ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,12 @@ ros_py_test(
srcs = ["test/custom_message_list_test.py"],
data = [
# This is the main key. You must provide the generated definitions as
# a dependency. It can come through data as is done here, or via any
# dependency, such as the C++ (*_cc) or Python (*_py) targets.
# a dependency. It can come through data such as the C++ (*_cc) or
# Python (*_py) targets as is done here, or directly via the
# definitions targets (*_defs).
# Otherwise, `ros2 interface ...` will indicate the message type is
# invalid.
":ros2_example_apps_msgs_defs",
":ros2_example_apps_msgs_py",
"@ros2",
],
main = "test/custom_message_list_test.py",
Expand Down

0 comments on commit 0b754cd

Please sign in to comment.