Skip to content
Open
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 ros2/cc_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@

load("@com_github_mvukov_rules_ros2//ros2:ament.bzl", "sh_exec_launcher", "split_kwargs")
load("@com_github_mvukov_rules_ros2//ros2:cc_opts.bzl", "C_COPTS")
load("@com_github_mvukov_rules_ros2//ros2:cc_opts.bzl", "CPP_LINKOPTS")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

def _ros2_cc_target(target, lang, name, ros2_package_name, **kwargs):
if lang == "c":
all_copts = C_COPTS
all_linkopts = []
elif lang == "cpp":
all_copts = []
all_linkopts = CPP_LINKOPTS
else:
fail("lang must be set to c or cpp!")
all_copts = all_copts + kwargs.pop("copts", [])
all_linkopts = all_linkopts + kwargs.pop("linkopts", [])

ros2_package_name = ros2_package_name or name
all_local_defines = ["ROS_PACKAGE_NAME=\\\"{}\\\"".format(ros2_package_name)]
Expand All @@ -23,6 +27,7 @@ def _ros2_cc_target(target, lang, name, ros2_package_name, **kwargs):
target(
name = name,
copts = all_copts,
linkopts = all_linkopts,
local_defines = all_local_defines,
**kwargs
)
Expand Down
6 changes: 6 additions & 0 deletions ros2/cc_opts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
"""

C_COPTS = ["-std=c11"]

# Export dynamic symbols for pluginlib/class_loader with LLVM toolchain.
CPP_LINKOPTS = select({
"@rules_cc//cc/compiler:clang": ["-rdynamic"],
"//conditions:default": [],
})
Loading