Android-Bazel-Makefile

Bazel is available now to build the Android kernel

Finally, you can build the Android kernel by Bazel and the old build system is going to be replaced with it. That’s excellent news. Because Bazel provides a better and clear structure to organize your project. It is human-readable and easy to understand and work with. You can learn and use it faster than Makefile.

Now Android 13 introduces building kernel with Bazel, however, you can still build it with the old build/build.sh. It’s just the first step to migrating from the current AOSP build system to Bazel. Once the migration has been completed the current AOSP toolchain(Makefile, Bazel, etc) will be replaced by Bazel.

How migration looks like

The current build toolchain will be converted to Bazel and each part should be mapped to the corresponding one in Bazel. It is obvious that the migration won’t happen overnight and needs some time to ensure that everything works how it’s been supposed to.

Kati -> Loading and analysis phase

Ninja -> Bazel execution phase

Android.bp -> BUILD.bazel or BUILD file

Android.mk -> BUILD.bazel or BUILD file

etc.

Both Android.bp and BUILD.bazel are using JSON-like descriptions to declare modules.

How to build the Android kernel with Bazel

There is no prerequisite to building the Andriod kernel with Bazel. Because everything is provided through the repo sync. So, you don’t have to worry about it. Once repo sync is completed you can start building the Android kernel through the command below:

$ tools/bazel build //common:kernel_aarch64_dist

Leave a Comment

Your email address will not be published. Required fields are marked *