This pulls in Drake and builds it from source via Bazel's WORKSPACE mechanism, which is deprecated as of Bazel 8 and will be removed in Bazel 9. Therefore, we will be rewriting this example to use Bazel modules ("bzlmod") in the near future. Stay tuned!
For an introduction to Bazel, refer to Getting Started with Bazel.
First, run the install_prereqs
script to download the drake source and run
drake's source setup script to install the required Ubuntu packages:
setup/install_prereqs.sh
Then, to build and test all apps:
bazel test //...
As an example to run a binary directly:
bazel run //apps:simple_logging_example
You may also run the binary directly per the bazel-bin/...
path that the
above command prints out; however, be aware that your working directories may
cause differences. This is important when using tools like
drake::FindResource
/ pydrake.common.FindResource
.
You may generally want to stick to using bazel run
when able.
By default, Python 3 is the Python interpreter that Drake will use when built with Bazel. To see which Python versions are supported, see the supported configurations.