A collection of bazel utilities for FRC
You can include BazelRIO in your project like so:
http_archive(
name = "bazelrio",
url = "https://github.com/bazelRio/bazelRio/archive/refs/tags/0.10.0.zip",
sha256 = "18b109dbd5204910600823e6c9ff405fa7ed7c43d0a78f24077f8187311745a9",
strip_prefix = "bazelRio-0.10.0/bazelrio",
)
load("@bazelrio//:deps.bzl", "setup_bazelrio_dependencies")
setup_bazelrio_dependencies()
load("@bazelrio//:defs.bzl", "setup_bazelrio")
setup_bazelrio()
You must copy the .bazelrc
file from the C++ or Java example into your project workspace and update your BUILD
and WORKSPACE
files in the same fashion.
Language | Compilation | Simulation | Deployment |
---|---|---|---|
C++ | 🟢 | 🟢 | 🟢 |
Java | 🟢 | 🔴 | 🟢 |
Kotlin | 🟢 | 🔴 | 🟢 |
Python | 🔴 | 🔴 | 🔴 |
BazelRIO provides a RoboRIO target for easy cross-compilation.
bazel build <target> --platforms=@bazelrio//platforms/roborio
BazelRIO will automatically download an official roboRIO toolchain (from WPILib) for your host OS and use it.
BazelRIO provides rules for robot code targets of multiple languages.
load("@bazelrio//:defs.bzl", "robot_cc_binary")
robot_cc_binary(
name = "hello",
team_number = 1337,
srcs = ["hello.cpp"],
)
BazelRIO will create a cc_binary
target named hello
, as well as a special target named hello.deploy
that can be used to deploy your binary:
bazel run //:hello.deploy --platforms=@bazelrio//platforms/roborio
...
Attempting to connect to roborio-1337-frc.local...
Connected to roborio-1337-frc.local.
Attempting to deploy bazel-out/darwin-fastbuild/bin/hello...
Deployed bazel-out/darwin-fastbuild/bin/hello. Exiting.
robot_java_binary(
name = "hello",
main_class = "frc.robot.Main",
team_number = 1337,
runtime_deps = [
"//src/main/java/frc/robot",
],
)
BazelRIO will create a java_binary
target named hello
, as well as a special target named hello.deploy
that can be used to deploy your binary. If you are using Kotlin, you must build your code as a kt_jvm_library
and add it to runtime_deps
, rather than adding Kotlin files directly to srcs
.
BazelRIO containts library targets for WPILib and some vendor libraries:
@bazelrio//libraries/cpp/wpilib/wpilibc
@bazelrio//libraries/java/wpilib/wpilibj
@bazelrio//libraries/cpp/ctre/phoenix
@bazelrio//libraries/cpp/rev/sparkmax
@bazelrio//libraries/cpp/rev/revlib
@bazelrio//libraries/cpp/rev/colorsensor
@bazelrio//libraries/cpp/kauailabs/navx
Simulations (alongside halsim extensions) are supported! Take a look at the C++ example to get started.