9.1. Experimental Bazel Support in Everest

Note

This feature is currently experimental and subject to change.

9.1.1. Introduction

EVerest now offers experimental support for Bazel <https://bazel.build/>. With Bazel, you can efficiently build, test and deploy software projects of any size.

For EVerest developers, Bazel offers a couple advantages:

  • While developing features, that span multiple modules, Bazel can swiftly rebuild only the necessary parts of the project.

  • If you have already setup Bazel in your project, EVerest framework can be integrated with it.

This tutorial will guide you through the process of setting up and using Bazel in your Everest projects.

9.1.2. Getting Started

To install Bazel, it’s recommended to use bazelisk, which is a tool that downloads and runs the correct version of Bazel for your project. You can install bazelisk by following the instructions on the official GitHub repository <https://github.com/bazelbuild/bazelisk?tab=readme-ov-file#installation>.

Note

Bazelisk provides a bazel command, and the rest of this tutorial will refer to it as bazel.

C/C++ Compilers: At the moment, Bazel will use the default C/C++ compilers on your system. If it is not the desired compiler to build EVerest, you can set the environment variables CC and CXX to the desired compiler.

All other dependencies are fetched by Bazel as needed.

9.1.3. Using Bazel Commands

Once Bazel is configured, you can use various Bazel commands to build, test and run.

Most useful commands are:

  • bazel build //… - Build all targets in the project.

  • bazel test //… - Run all tests in the project.

9.1.4. Dependency Management

There are a few different ways of managing dependencies in EVerest.

  • Dependencies that CMake takes from the system (e.g. boost). These dependencies are configured in the third_party/bazel/repos.bzl file.

  • Dependencies that are described in the ./dependencies.yaml file. These dependencies are pulled automatically by Bazel with help of edm tool.

  • Rust dependencies are managed by cargo, and are described in the Cargo.toml file. Cargo dependencies are automatically picked up by Bazel.

9.1.5. Defining C++ EVerest Modules

Let’s assume, you have a module named Example with a single interface implementation named example. This module depends on the sigslot library. For a more realistic scenario, the module has two extra files utils.cpp and utils.hpp.

The manifest.yaml file for the module looks like this:

To build this module with Bazel, you need to create a BUILD.bazel file in the module directory, next to the manifest.yaml file.

In the BUILD.bazel, use predefined macros to define the module:

9.1.6. Defining Rust EVerest Modules

To define a Rust module in EVerest, you need to create a BUILD.bazel file in the module directory. Generic rust_binary and rust_test are used at the moment.

9.1.7. Using EVerest in external Bazel projects

TBD