Kleaf - Building Android Kernels with Bazel

Table of contents

Getting started

Introduction to Kleaf

Building your kernels and drivers with Bazel

Creating distributions

Driver Development Kit (DDK)

Cheatsheet

Configuring your build

build.sh build configs

Configuring kernel_build

ABI monitoring

Support ABI monitoring (GKI)

Support ABI monitoring (Device)

Debugging and testing

Resolving common errors

Kleaf testing

Debugging Kleaf

Advanced topics

Handling SCM version

Building against downloaded prebuilts

Customize workspace

Bzlmod support for Kleaf

Building compile_commands.json

Ensuring hermeticity

Internet Access

Toolchain resolution

Checkpatch

Kleaf Development

Configurations in command line

--config=fast: Make local builds faster

--config=local: Sandboxing

--config=release: Release builds

--config=stamp: Handling SCM version

Flags

For a full list of flags, run

$ tools/bazel help kleaf

--gcov: Keep GCOV files

--kasan: kasan

--kbuild_symtypes: KBUILD_SYMTYPES

--kgdb: GDB scripts

--lto: Configure LTO during development

--notrim: Disables TRIM_NONLISTED_KMI globally.

--btf_debug_info: Enable/disable BTF debug information

--gki_build_config_fragment: Supporting GKI_BUILD_CONFIG_FRAGMENT on Kleaf

--defconfig_fragment: Defconfig fragments

Other flags for debugging and disabling integrity checks may be found in the Debugging Kleaf page.

References

References to Bazel rules and macros for the Android Kernel