Functions that are useful in the common kernel package (usually //common).

common_kernel

Macro for an Android Common Kernel.

The following targets are declared as public API:

  • <name>_sources (e.g. kernel_aarch64_sources)
    • Convenience filegroups that refers to all sources required to build <name> and related targets.
  • <name> (e.g. kernel_aarch64): kernel_build()
    • This build the main kernel build artifacts, e.g. vmlinux, etc.
  • <name>_uapi_headers (e.g. kernel_aarch64_uapi_headers)
    • build kernel-uapi-headers.tar.gz.
  • <name>_modules (e.g. kernel_aarch64_modules)
  • <name>_additional_artifacts (e.g. kernel_aarch64_additional_artifacts)
    • contains additional artifacts that may be added to a distribution. This includes:
      • Images, including system_dlkm, etc.
      • kernel-headers.tar.gz
  • <name>_dist (e.g. kernel_aarch64_dist)
    • can be run to obtain a distribution outside the workspace.

ABI monitoring If kmi_symbol_list is set, ABI monitoring is turned on.

  • <name>_abi (e.g. kernel_aarch64_abi): kernel_abi()
  • <name>_abi_dist (e.g. kernel_aarch64_abi_dist)

Usually, for ABI monitoring to be fully turned on, you should set:

  • kmi_symbol_list
  • additional_kmi_symbol_lists
  • protected_exports_list
  • protected_modules_list
  • trim_nonlisted_kmi to True
  • kmi_symbol_list_strict_mode to True
  • abi_definition_stg to the ABI definition
  • kmi_enforced to True

PARAMETERS

NameDescriptionDefault Value
namename of the kernel_build().none
outsSee kernel_build.outsnone
makefileSee kernel_build.makefileNone
archSee kernel_build.archNone
visibilitydefault visibility for some targets instantiated with this macroNone
defconfigSee kernel_build.defconfigNone
pre_defconfig_fragmentsSee kernel_build.pre_defconfig_fragmentsNone
post_defconfig_fragmentsSee kernel_build.post_defconfig_fragmentsNone
kmi_symbol_listSee kernel_build.kmi_symbol_listNone
additional_kmi_symbol_listsSee kernel_build.additional_kmi_symbol_listsNone
trim_nonlisted_kmiSee kernel_build.trim_nonlisted_kmiNone
kmi_symbol_list_strict_modeSee kernel_build.kmi_symbol_list_strict_modeNone
kmi_symbol_list_add_onlySee kernel_abi.kmi_symbol_list_add_onlyNone
module_implicit_outsSee kernel_build.module_implicit_outsNone
protected_exports_listSee kernel_build.protected_exports_listNone
protected_modules_listSee kernel_build.protected_modules_listNone
gki_system_dlkm_modulessystem_dlkm module_listNone
make_goalsSee kernel_build.make_goalsNone
abi_definition_stgSee kernel_abi.abi_definition_stgNone
kmi_enforcedSee kernel_abi.kmi_enforcedNone
build_gki_artifactsnonconfigurable. If true, build GKI artifacts under target name <name>_gki_artifacts.None
gki_boot_img_sizesgki_artifacts.boot_img_sizesNone
page_sizeSee kernel_build.page_sizeNone
deprecationIf set, mark target deprecated with given message.None
ddk_headers_archivenonconfigurable. Target to the archive packing DDK headersNone
ddk_module_headersSee kernel_build.ddk_module_headersNone
extra_distextra targets added to <name>_distNone
kcflagskernel_build.kcflagsNone
system_dlkm_extra_archive_filessystem_dlkm_image.internal_extra_archive_filesNone
clang_autofdo_profileSee kernel_build.clang_autofdo_profileNone

define_prebuilts

Define --use_prebuilt_gki and relevant targets.

You may set the argument --use_prebuilt_gki to a GKI prebuilt build number on ci.android.com or your custom CI host. The format is:

bazel <command> --use_prebuilt_gki=<build_number> <targets>

For example, the following downloads GKI artifacts of build number 8077484 (assuming the current package is //common):

bazel build --use_prebuilt_gki=8077484 //common:kernel_aarch64_download_or_build

If you leave out the --use_prebuilt_gki argument, the command is equivalent to bazel build //common:kernel_aarch64, which builds kernel from source.

<name>_download_or_build targets builds <name> from source if the use_prebuilt_gki is not set, and downloads artifacts of the build number from ci.android.com (or your custom CI host) if it is set.

  • kernel_aarch64_download_or_build
    • kernel_aarch64_additional_artifacts_download_or_build
    • kernel_aarch64_uapi_headers_download_or_build

Note: If a device should build against downloaded prebuilts unconditionally, set --use_prebuilt_gki and a fixed build number in device.bazelrc. For example:

# device.bazelrc
build --use_prebuilt_gki
build --action_env=KLEAF_DOWNLOAD_BUILD_NUMBER_MAP="gki_prebuilts=8077484"

This is equivalent to specifying --use_prebuilt_gki=8077484 for all Bazel commands.

You may set --use_signed_prebuilts to download the signed boot images instead of the unsigned one. This requires --use_prebuilt_gki to be set to a signed build.

PARAMETERS

NameDescriptionDefault Value
kwargscommon kwargs to internal targets.none

DEPRECATED

See build/kernel/kleaf/docs/ddk/workspace.md for new ways to define prebuilts.