Skip to main content
Using Gradle makes building WPILib very straightforward. It only has a few dependencies on outside tools, such as the ARM cross compiler for creating roboRIO binaries.

Requirements

JDK 17

Note that the JRE is insufficient; the full JDK is required.

C++ Compiler

  • Linux: Install GCC 11 or greater
  • Windows: Install Visual Studio Community 2022 and select the C++ programming language during installation
    • Note: Gradle can’t use the build tools for Visual Studio - you need the full IDE
  • macOS: Install the Xcode command-line build tools via xcode-select --install
    • Xcode 14 or later is required

ARM Compiler Toolchain

Run the following command after cloning the repository:
./gradlew installRoboRioToolchain
If you used the WPILib installer, this toolchain is already installed.

Raspberry Pi Toolchain (Optional)

For Raspberry Pi development:
./gradlew installArm32Toolchain

macOS ARM Additional Requirement

On macOS ARM, run:
softwareupdate --install-rosetta
This is necessary to be able to use the macOS x86 roboRIO toolchain on ARM.

Setup

1

Clone the Repository

Clone the WPILib repository and follow the instructions above for installing any required tooling.
git clone https://github.com/wpilibsuite/allwpilib.git
cd allwpilib
The build process uses versioning information from git. Downloading the source as a ZIP is not sufficient to run the build.
2

Install wpiformat (Optional)

For code formatting, see the styleguide README for wpiformat setup instructions.
3

Generate Java Dependencies

If opening from a fresh clone, generated Java dependencies will not exist. Most IDEs will not run the generation tasks, which will cause lots of IDE errors.
./gradlew compileJava
After running this command, refresh your IDE’s configuration (in VS Code, open settings.gradle and save).

Building

All build steps are executed using the Gradle wrapper, gradlew. Each target that Gradle can build is referred to as a task.

Build Everything

The most common Gradle task is build. This will build all the outputs created by WPILib:
./gradlew build

Build a Specific Subproject

To build a specific subproject, such as WPILibC, use :subproject_name:task_name:
./gradlew :wpilibc:build
The gradlew wrapper only exists in the root of the main project, so be sure to run all commands from there. Gradle automatically determines and rebuilds dependencies, so if you make a change in the HAL and then run ./gradlew :wpilibc:build, the HAL will be rebuilt, then WPILibC.

Using Build Cache

Run with --build-cache on the command-line to use the shared build cache artifacts generated by the continuous integration server:
./gradlew build --build-cache
This can significantly speed up builds if you have an internet connection.

Faster Builds

./gradlew build builds everything, which includes debug and release builds for desktop and all installed cross compilers. For common development and testing tasks, use these shortcuts:

Test Desktop C++

./gradlew testDesktopCpp

Test Desktop Java

./gradlew testDesktopJava

Test Both

./gradlew testDesktop

Test Specific Projects

The following projects also support testDesktopCpp, testDesktopJava, and testDesktop tasks:
  • apriltag
  • cameraserver
  • cscore
  • hal
  • ntcore
  • wpilibNewCommands
  • wpimath
  • wpinet
  • wpiunits
  • wpiutil
  • romiVendordep
  • xrpVendordep
Run with:
./gradlew :projectName:task

Build Examples

Compile examples without running them:
./gradlew buildDesktopCpp  # C++ examples
./gradlew buildDesktopJava # Java examples

Custom Toolchain Location

If you have installed the FRC Toolchain to a directory other than the default, or if the Toolchain location is not on your System PATH, you can pass the toolChainPath property:
./gradlew build -PtoolChainPath=some/path/to/frc/toolchain/bin

Available Tasks

To see all available tasks, run the meta-task:
./gradlew tasks
This will print a list of all available tasks with a description of each task.

Running Examples in Simulation

Examples can be run in simulation with the following commands:
./gradlew wpilibcExamples:runExample  # C++
./gradlew wpilibjExamples:runExample  # Java
Replace Example with the example’s folder name.

Alternative Build Systems

CMake

CMake is also supported for building. See README-CMake.md.

Bazel

Bazel is also supported for building. See README-Bazel.md.

Next Steps

Build docs developers (and LLMs) love