Mobile Monitoring Solutions

Close this search box.

Bazel 7 Released With New Dependency Management System and More

MMS Founder
MMS Sergio De Simone

Article originally posted on InfoQ. Visit InfoQ

Recently announced at BazelCon 23, Bazel 7 materializes several new features that have been in development for multiple years, including the new modular external dependency management system Bzlmod, a new optimizing “Build without the Bytes” mode, improved multi-target build performance thanks to Project Skymeld, and more.

Bzlmod is a new modular external dependency management system replacing the old WORKSPACE mechanism. A Bazel module is a project that can have multiple versions, with each version depending on a set of dependencies, as shown in the following snippet:

module(name = "my-module", version = "1.0")

bazel_dep(name = "rules_cc", version = "0.0.1")
bazel_dep(name = "protobuf", version = "3.19.0")

Bzlmod, the new external dependency subsystem, does not directly work with repo definitions. Instead, it builds a dependency graph from modules, runs extensions on top of the graph, and defines repos accordingly.

Bzlmod is now enabled by default, which means that if a project does not have a MODULE.bazel file, Bazel will create an empty one. Bazel 7 will still work with the previous system for compatibility, but developers should migrate to Bzlmod before Bazel 8 is released.

Build without the Bytes (BwoB) reduces the amount of data that Bazel transfers for remote builds by only downloading a subset of intermediate files.

In the past, Bazel’s default behaviour was to download every output file of an action after it had executed the action remotely, or hit a remote cache. However, the sum of all output files in a large build will often be in the tens or even hundreds of gigabytes. The benefits of remote execution and caching may be outweighed by the costs of this download, especially if the network connection is poor.

While it has been available for a long time, BwoB is now stable and has been made reliable for edge cases so it can be used as the new default.

Skymeld is another feature aimed at boosting productivity, specifically for builds with multiple top-level targets. It brings an evaluation mode that eliminates the barrier between analysis and execution phases and enables targets to be independently executed as soon as their analysis finishes to improve build speeds.

As a final note, Bazel 7 now enables by default platform-based toolchain resolution for its Android and C++ rules. This change aims at streamlining the toolchain resolution API across all rulesets, thus obviating the need for language-specific flags such as --android_cpu and --crosstool_top.

Android projects will need to stop passing the legacy flag --fat_apk_cpu, and instead use --android_platforms using platforms defined with the @platforms//os:android constraint.

There is much more to Bazel 7 than can be covered here, so do not miss the official release notes for the full details.

About the Author

Subscribe for MMS Newsletter

By signing up, you will receive updates about our latest information.

  • This field is for validation purposes and should be left unchanged.