ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Build Ros Nodes with bazel

asked 2017-11-16 16:25:07 -0600

manan gravatar image

updated 2017-11-16 17:00:55 -0600

ahendrix gravatar image

Is it possible to Build ROS nodes with Bazel? e.g. could we build below example with Bazel? http://wiki.ros.org/ROS/Tutorials/Wri...

Please share your views.

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2017-11-16 17:10:52 -0600

ahendrix gravatar image

Unless you have a very compelling reason to use bazel, don't. It does a lot of things that aren't terribly compatible with the ROS package management system or traditional open-source build systems and package management.

The company that I work for uses bazel for our internal build system, and we have custom build rules for all of the ROS packages that we use, and a custom compatibility layer between bazel packages and ROS packages. Our rules are pretty specific to our application and are a pretty invasive modification to ROS, so we're not willing to open source them.

Bazel doesn't have any way to import local packages that are build by other tools (it can't read pkgconfig files or cmake find-package files), so it isn't easy to bring in external packages.

In theory you could install the precompiled ROS packages for Ubuntu or build and install ROS the normal way, and then add those libraries to bazel's WORKSPACE file, but that's still quite a bit of setup and you lose all of the inter-package dependencies that are defined in the cmake files and the package.xml files, so you'd have to either lump all of the ROS libraries into a single target, or redefine all of the packages and their dependencies within bazel.

edit flag offensive delete link more

Comments

Update: https://github.com/bazelbuild/rules_f... allows building libraries with CMake inside bazel project.

@ahendrix does this new functionality affect your view at all?

robarnes gravatar image robarnes  ( 2018-08-28 17:31:20 -0600 )edit

I don't think that substantially changes my position. Those rules might save you some time importing C++ packages (but it's not clear how to handle dependencies between imported cmake projects), but they don't help at all with python or for making package management in ROS and bazel work together.

ahendrix gravatar image ahendrix  ( 2018-08-28 18:17:49 -0600 )edit

Just an fyi: for ROS2 there is apparently a colcon compatibility pkg for Bazel: colcon/colcon-ros-bazel. That is the opposite direction of what the OP (and probably @robames) ask for, but I thought I'd mention it none-the-less.

gvdhoorn gravatar image gvdhoorn  ( 2018-08-29 01:39:44 -0600 )edit
1

answered 2020-01-18 17:57:22 -0600

nicolov gravatar image

I published a demo of how you would go about building ROS nodes in Bazel: https://github.com/nicolov/ros-bazel

It imports a pre-built ROS distribution, so there's no need to maintain separate Bazel definitions for the whole ecosystem. Your custom code (including C++ and Python message generation) is built and tested by Bazel.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-11-16 16:25:07 -0600

Seen: 2,346 times

Last updated: Nov 16 '17