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

Conversation

finn-ball
Copy link
Contributor

No description provided.

@finn-ball finn-ball mentioned this pull request May 28, 2024
@finn-ball
Copy link
Contributor Author

I should add I currently cannot test this as there is a problem with the lzma dependency on main. It does work when cherry-picked with #14

template = "deps.py.tpl",
outs = ["deps.py"],
cmd = """cat <<EOF > $@
ROSMASTER_PATH = '$(rootpath @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.

Unfortunately, you can't do rootpath on py_binary (as it has >1 files in defaultinfo, known issue). You need to wrap a binary in a symlink (feel free to copy https://github.com/mvukov/rules_ros2/blob/main/third_party/symlink.bzl) and then do rootpath on the symlink target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I cherry pick this branch to my bzl-mod branch, this is what I get:

$ cat bazel-bin/third_party/ros/roslaunch/deps.py
ROSMASTER_PATH = 'external/_main~non_module_dependencies~ros_comm/rosmaster'
ROSCORE_XML_PATH = 'third_party/ros/roslaunch/roscore.xml'

Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this patch works as far as I can see. Have you had a chance to test it out?

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, it was a bit busy here. I just left some small comments.

ROSCORE_XML_PATH = '$(rootpath roscore.xml)'
EOF""",
srcs = ["roscore.xml"],
tools = ["@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.

rosmaster should be IMO in srcs, if it's in tools then the target is going to be built in exec config.

Copy link
Contributor Author

@finn-ball finn-ball Jun 11, 2024

Choose a reason for hiding this comment

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

It'll be built in the exec config in order to get the correct path out, but is that a problem for a python script? It won't actually compile anything and it won't forward on its dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case this is a worry, I've updated it so that the tooling appears in srcs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now what I get when I cherry-pick this onto my bzlmod branch:

$ cat bazel-bin/third_party/ros/roslaunch/roscore.xml 
<launch>
  <group ns="/">
    <node type="external/_main~non_module_dependencies~ros_comm/rosout" name="rosout" respawn="true"/>
  </group>
</launch>
$ cat bazel-bin/third_party/ros/roslaunch/deps.py
ROSMASTER_PATH = 'external/_main~non_module_dependencies~ros_comm/rosmaster'
ROSCORE_XML_PATH = 'third_party/ros/roslaunch/roscore.xml'

</group>
</launch>
EOF""",
tools = ["@ros_comm//:rosout"],
Copy link
Owner

Choose a reason for hiding this comment

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

Similarly here: rosout should be IMO in srcs, if it's in tools then the target is going to be built in exec config.

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.

@mvukov
Copy link
Owner

mvukov commented Jun 16, 2024

As-is works as expected on the main branch in noblzmod mode.

@mvukov mvukov merged commit f200d4e into mvukov:main Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants