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

feat: generate filepaths for rosout and rosmaster #18

Merged
merged 2 commits into from
Jun 16, 2024
Merged
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
35 changes: 28 additions & 7 deletions third_party/ros/roslaunch/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@rules_ros_pip_deps//:requirements.bzl", "requirement")
load("//build_tools:pylint.bzl", "pylint")
load("//third_party:expand_template.bzl", "expand_template")

expand_template(
genrule(
name = "deps",
out = "deps.py",
data = ["roscore.xml"],
substitutions = {"{roscore_xml_path}": "$(rootpath roscore.xml)"},
template = "deps.py.tpl",
outs = ["deps.py"],
cmd = """
ROSMASTER=($(rootpaths @ros_comm//:rosmaster))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hacky solution IMO, it would be cleaner to go with a symlink as I originally proposed. Right now this is fine, but the contents of $(rootpaths @ros_comm//:rosmaster) could change and then this could break. To be fixed when needed.

cat <<EOF > $@
ROSMASTER_PATH = '$${ROSMASTER}'
ROSCORE_XML_PATH = '$(rootpath roscore.xml)'
EOF""",
srcs = [
"roscore.xml",
"@ros_comm//:rosmaster",
],
)

genrule(
name = "roscore_xml",
outs = ["roscore.xml"],
cmd = """
ROS_COMM=$(rootpaths @ros_comm//:rosout)
cat <<EOF > $@
<launch>
<group ns="/">
<node type="$${ROS_COMM}" name="rosout" respawn="true"/>
</group>
</launch>
EOF""",
srcs = ["@ros_comm//:rosout"],
)

py_library(
name = "roslaunch",
srcs = glob(["*.py"]) + [":deps"],
data = [
"roscore.xml",
":roscore_xml",
"@ros_comm//:rosmaster",
"@ros_comm//:rosout",
],
Expand Down
2 changes: 0 additions & 2 deletions third_party/ros/roslaunch/deps.py.tpl

This file was deleted.

5 changes: 0 additions & 5 deletions third_party/ros/roslaunch/roscore.xml

This file was deleted.