All public rules and macros to build the kernel.
Like filegroup, but applies transitions to Android.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | Sources of the filegroup. | List of labels | optional | [] |
cpu | Architecture. | String | optional | "arm64" |
Run checkpatch.sh
at the root of this package.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
checkpatch_pl | Label to checkpatch.pl .This is usually //<common_package>:scripts/checkpatch.pl . | Label | required | |
ignorelist | checkpatch ignorelist | Label | optional | "@kleaf//build/kernel/static_analysis:checkpatch_ignorelist" |
EXPERIMENTAL. A target that can later be used to configure a ddk_module
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | See ddk_module.deps. | List of labels | optional | [] |
defconfig | The defconfig file. | Label | optional | None |
kconfigs | The extra Kconfig files for external modules that use this config.See Documentation/kbuild/kconfig-language.rst for its format. | List of labels | optional | [] |
kernel_build | kernel_build . | Label | required |
A rule that exports a list of header files to be used in DDK.
Example:
ddk_headers( name = "headers", hdrs = ["include/module.h", "template.c"], includes = ["include"], )
ddk_headers
can be chained; that is, a ddk_headers
target can re-export another ddk_headers
target. For example:
ddk_headers( name = "foo", hdrs = ["include_foo/foo.h"], includes = ["include_foo"], ) ddk_headers( name = "headers", hdrs = [":foo", "include/module.h"], includes = ["include"], )
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
hdrs | One of the following: - Local header files to be exported. You may also need to set the includes attribute. - Other ddk_headers targets to be re-exported. | List of labels | optional | [] |
defconfigs | defconfig files.Items must already be declared in kconfigs . An item not declared in Kconfig and inherited Kconfig files is silently dropped.An item declared in kconfigs without a specific value in defconfigs uses default value specified in kconfigs . | List of labels | optional | [] |
includes | A list of directories, relative to the current package, that are re-exported as include directories.ddk_module with deps including this target automatically adds the given include directory in the generated Kbuild files.You still need to add the actual header files to hdrs . | List of strings | optional | [] |
kconfigs | Kconfig files. See Documentation/kbuild/kconfig-language.rst for its format.Kconfig is optional for a ddk_module . The final Kconfig known by this module consists of the following:- Kconfig from kernel_build - Kconfig from dependent modules, if any - Kconfig of this module, if any | List of labels | optional | [] |
linux_includes | Like includes but specified in LINUXINCLUDES instead.Setting this attribute allows you to override headers from ${KERNEL_DIR} . See “Order of includes” in ddk_module for details.Like includes , linux_includes is applied to dependent ddk_module s. | List of strings | optional | [] |
textual_hdrs | DEPRECATED. Use hdrs instead.The list of header files to be textually included by sources. This is the location for declaring header files that cannot be compiled on their own; that is, they always need to be textually included by other source files to build valid code. | List of labels | optional | [] |
An archive of ddk_headers
.
The archive includes all headers, as well as a BUILD
file that is semantically identical to the original ddk_headers
definition.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | - | List of labels | optional | [] |
Wraps a <stem>.o
file so it can be used in ddk_module.srcs.
An optional .<stem>.o.cmd
file may be provided. If not provided, a fake .<stem>.o.cmd
is generated.
Example:
ddk_prebuilt_object( name = "foo", src = "foo.o", ) ddk_module( name = "mymod", deps = [":foo"], # ... )
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
src | The .o file, e.g. foo.o | Label | required | |
cmd | The .cmd file, e.g. .foo.o.cmd . If missing, an empty file is provided. | Label | optional | None |
config | If set, name of the config with the CONFIG_ prefix. The prebuilt object is only linked when the given config matches config_bool_value . | String | optional | "" |
config_bool_value | If config is set, and config_bool_value == True , the object is only included if the config is y or m . If config is set and config_bool_value == False , the object is only included if the config is not set. | Boolean | optional | False |
A rule that generates a sanitized UAPI header tarball.
Example:
ddk_uapi_headers( name = "my_headers", srcs = glob(["include/uapi/**/*.h"]), out = "my_headers.tar.gz", kernel_build = "//common:kernel_aarch64", )
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | UAPI headers files which can be sanitized by “make headers_install” | List of labels | optional | [] |
out | Name of the output tarball | String | required | |
kernel_build | kernel_build . | Label | required |
A rule that creates a Graphviz diagram file.
Inputs: A json file describing a graph as an adjacency list.
Outputs: A dependency_graph.dot
file containing the diagram representation.
NOTE: For further simplification of the resulting diagram tred utility from the CLI can be used as in the following example:
tred dependency_graph.dot > simplified.dot
Example:
dependency_graph_drawer( name = "db845c_dependency_graph", adjacency_list = ":db845c_dependencies", )
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
adjacency_list | - | Label | required | |
colorful | Whether outgoing edges from every node are colored. | Boolean | optional | False |
A rule that extracts a symbol dependency graph from a kernel build and modules.
It works by matching undefined symbols from one module with exported symbols from other.
Inputs: It receives a Kernel build target, where the analysis will run (vmlinux + in-tree modules), aditionally a list of external modules can be accepted.
Outputs: A dependency_graph.json
file describing the graph as an adjacency list.
Example:
dependency_graph_extractor( name = "db845c_dependencies", kernel_build = ":db845c", # kernel_modules = [], )
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
enable_add_vmlinux | If True enables kernel_build_add_vmlinux transition. | Boolean | optional | True |
exclude_base_kernel_modules | Whether the analysis should made for only external modules. | Boolean | optional | False |
kernel_build | - | Label | optional | None |
kernel_modules | - | List of labels | optional | [] |
Build dtb
image.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | DTB sources to add to the dtb image | List of labels | optional | [] |
out | Name of dtb image.Default to name if not set | String | optional | "" |
Build dtbo.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | List of *.dtbo files used to package the dtbo.img . This corresponds to MKDTIMG_DTBOS in build configs; see example below.Example: kernel_build( name = “tuna_kernel”, outs = [ “path/to/foo.dtbo”, “path/to/bar.dtbo”, ], ) dtbo( name = “tuna_images”, kernel_build = “:tuna_kernel”, srcs = [ “:tuna_kernel/path/to/foo.dtbo”, “:tuna_kernel/path/to/bar.dtbo”, ], ) | List of labels | optional | [] |
config_file | A config file to create dtbo image by cfg_create command. If set, use mkdtimg cfg_create with the given config file, instead of mkdtimg create | Label | optional | None |
kernel_build | The kernel_build . | Label | required |
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
src | Source abi_gki_* file. Used when kmi_symbol_list_add_only . | Label | optional | None |
enable_add_vmlinux | If True enables kernel_build_add_vmlinux transition. | Boolean | optional | True |
kernel_build | - | Label | optional | None |
kernel_modules | - | List of labels | optional | [] |
kernel_modules_exclude_list | Base name list of kernel modules to exclude from. | List of strings | optional | [] |
kmi_symbol_list_add_only | - | Boolean | optional | False |
module_grouping | - | Boolean | optional | True |
BUILD_GKI_ARTIFACTS
. Build boot images and optionally boot-img.tar.gz
as default outputs.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
arch | ARCH . | String | required | |
boot_img_sizes | A dictionary, with key is the compression algorithm, and value is the size of the boot image. For example: { "": str(64 * 1024 * 1024), # For Image and boot.img “lz4”: str(64 * 1024 * 1024), # For Image.lz4 and boot-lz4.img } | Dictionary: String -> String | optional | {} |
gki_kernel_cmdline | GKI_KERNEL_CMDLINE . | String | optional | "" |
kernel_build | The kernel_build that provides all Image and Image.* . | Label | optional | None |
mkbootimg | path to the mkbootimg.py script; MKBOOTIMG_PATH . | Label | optional | "@kleaf//tools/mkbootimg:mkbootimg.py" |
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | - | List of labels | optional | [] |
outs | - | List of strings | optional | [] |
Build initramfs.
When included in a pkg_files
target included by pkg_install
, this rule copies the following to destdir
:
initramfs.img
modules.load
modules.load.recovery
modules.load.charger
vendor_boot.modules.load
vendor_boot.modules.load.recovery
vendor_boot.modules.load.charger
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | A list of additional dependencies to build initramfs. | List of labels | optional | [] |
create_modules_order | Whether to create and keep a modules.order file generated by a postorder traversal of the kernel_modules_install sources. It defaults to True . | Boolean | optional | True |
kernel_modules_install | The kernel_modules_install . | Label | required | |
modules_blocklist | A file containing a list of modules which are blocked from being loaded. This file is copied directly to staging directory, and should be in the format: blocklist module_name | Label | optional | None |
modules_charger_list | A file containing a list of modules to load when booting intocharger mode. | Label | optional | None |
modules_list | A file containing list of modules to use for vendor_boot.modules.load . | Label | optional | None |
modules_options | a file copied to /lib/modules/<kernel_version>/modules.options on the ramdisk.Lines in the file should be of the form: options <modulename> <param1>=<val> <param2>=<val> ... | Label | optional | None |
modules_recovery_list | A file containing a list of modules to load when booting into recovery. | Label | optional | None |
ramdisk_compression | If provided it specfies the format used for any ramdisks generated.If not provided a fallback value from build.config is used. | String | optional | "" |
ramdisk_compression_args | Command line arguments passed only to lz4 command to control compression level. | String | optional | "" |
vendor_boot_name | Name of vendor_boot image.* If "vendor_boot" , build vendor_boot.img * If "vendor_kernel_boot" , build vendor_kernel_boot.img * If None , skip building vendor_boot . | String | optional | "" |
Create a build.config file by concatenating build config fragments.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | Additional build config dependencies. These include build configs that are indirectly source d by items in srcs . Unlike srcs , they are not be emitted in the output. | List of labels | optional | [] |
srcs | List of build config fragments. Order matters. To prevent buildifier from sorting the list, use the # do not sort magic line. For example:kernel_build_config( name = “build.config.foo.mixed”, srcs = [ # do not sort “build.config.mixed”, “build.config.foo”, ], ) | List of labels | optional | [] |
Define an executable that creates compile_commands.json
from kernel targets.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | The targets to extract from. The following are allowed: - kernel_build - kernel_module - ddk_module - kernel_module_group | List of labels | optional | [] |
kernel_build | The kernel_build rule to extract from.Deprecated: Use deps instead. | Label | optional | None |
EXPERIMENTAL. The API of kernel_filegroup
rapidly changes and is not backwards compatible with older builds. The usage of kernel_filegroup
is limited to the implementation detail of Kleaf (in particular, define_common_kernels
). Do not use kernel_filegroup
directly. See download_prebuilt.md
for details.
Specify a list of kernel prebuilts.
This is similar to filegroup
that gives a convenient name to a collection of targets, which can be referenced from other rules.
It can be used in the base_kernel
attribute of a kernel_build
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | A list of additional labels that participates in implementing the providers. This usually contains a list of prebuilts. Unlike srcs, these labels are NOT added to the DefaultInfo | List of labels | optional | [] |
srcs | The list of labels that are members of this file group. This usually contains a list of prebuilts, e.g. vmlinux , Image.lz4 , kernel-headers.tar.gz , etc.Not to be confused with kernel_srcs . | List of labels | optional | [] |
outs | Keys: from _kernel_build.outs . Values: path under $OUT_DIR . | Dictionary: Label -> String | optional | {} |
all_module_names | module_outs and module_implicit_outs of the original kernel_build target. | List of strings | optional | [] |
collect_unstripped_modules | See kernel_build.collect_unstripped_modules .Unlike kernel_build , this has default value True because kernel_abi sets define_abi_targets to True by default, which in turn sets collect_unstripped_modules to True by default. | Boolean | optional | True |
config_out_dir | Directory to support kernel_config | Label | optional | None |
config_out_dir_files | Files in config_out_dir | List of labels | optional | [] |
ddk_module_defconfig_fragments | Additional defconfig fragments for dependant DDK modules. | List of labels | optional | [] |
ddk_module_headers | Additional ddk_headers for dependant DDK modules. | List of labels | optional | [] |
env_setup_script | Setup script from kernel_env | Label | optional | None |
exec_platform | Execution platform, where the build is executed. See https://bazel.build/extending/platforms. | Label | required | |
gki_artifacts | A list of files that were built from the gki_artifacts target. The gki-info.txt file should be part of that list.If kernel_release is set, this attribute has no effect. | Label | optional | None |
images | A label providing files similar to a kernel_images target. | Label | optional | None |
internal_outs | Keys: from _kernel_build.internal_outs . Values: path under $OUT_DIR . | Dictionary: Label -> String | optional | {} |
kernel_release | A file providing the kernel release string. This is preferred over gki_artifacts . | Label | optional | None |
kernel_uapi_headers | The label pointing to kernel-uapi-headers.tar.gz .This attribute should be set to the kernel-uapi-headers.tar.gz artifact built by the kernel_build macro if the kernel_filegroup rule were a kernel_build .Setting this attribute allows merged_kernel_uapi_headers to work properly when this kernel_filegroup is set to the base_kernel .For example: kernel_filegroup( name = “kernel_aarch64_prebuilts”, srcs = [ “vmlinux”, # ... ], kernel_uapi_headers = “kernel-uapi-headers.tar.gz”, ) kernel_build( name = “tuna”, base_kernel = “:kernel_aarch64_prebuilts”, # ... ) merged_kernel_uapi_headers( name = “tuna_merged_kernel_uapi_headers”, kernel_build = “tuna”, # ... ) | Label | optional | None |
module_env_archive | Archive from kernel_build.pack_module_env that contains necessary files to build external modules. | Label | optional | None |
modules_prepare_archive | Archive from modules_prepare | Label | optional | None |
protected_modules_list | - | Label | optional | None |
strip_modules | See kernel_build.strip_modules . | Boolean | optional | False |
target_platform | Target platform that describes characteristics of the target device. See https://bazel.build/extending/platforms. | Label | required |
Extract Kythe source code index (kzip file) from a kernel_build
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
corpus | A flag containing value of KYTHE_CORPUS . See kythe.io/examples. | Label | required | |
kernel_build | The kernel_build target to extract from. | Label | required |
Like filegroup but for kernel_module
s or ddk_module
s.
Unlike filegroup, srcs
must not be empty.
Example:
# //package/my_subsystem # Hide a.ko and b.ko because they are implementation details of my_subsystem ddk_module( name = "a", visibility = ["//visibility:private"], ... ) ddk_module( name = "b", visibility = ["//visibility:private"], ... ) # my_subsystem is the public target that the device should depend on. kernel_module_group( name = "my_subsystem", srcs = [":a", ":b"], visibility = ["//package/my_device:__subpackages__"], ) # //package/my_device kernel_modules_install( name = "my_device_modules_install", kernel_modules = [ "//package/my_subsystem:my_subsystem", # This is equivalent to specifying a and b. ], )
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | List of kernel_module s or ddk_module s. | List of labels | required |
Generates a rule that runs depmod in the module installation directory.
When including this rule to the srcs
attribute of a pkg_files
rule that is included in a pkg_install
rule, all external kernel modules specified in kernel_modules
are included in distribution. This excludes module_outs
in kernel_build
to avoid conflicts.
Example:
kernel_modules_install( name = "foo_modules_install", kernel_modules = [ # kernel_module rules "//path/to/nfc:nfc_module", ], ) kernel_build( name = "foo", outs = ["vmlinux"], module_outs = ["core_module.ko"], ) pkg_files( name = "foo_dist_files", srcs = [ ":foo", # Includes core_module.ko and vmlinux ":foo_modules_install", # Includes nfc_module ], ) pkg_install( name = "foo_dist", srcs = [":foo_dist_files"], )
In foo_dist
, specifying foo_modules_install
in data
won't include core_module.ko
, because it is already included in foo
in data
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
outs | A list of additional outputs from make modules_install .Since external modules are returned by default, it can be used to obtain modules.* related files (results of depmod). Only files with allowed names can be added to outs. ( _OUT_ALLOWLIST ) _OUT_ALLOWLIST = [“modules.dep”, “modules.alias”, “modules.builtin”, “modules.symbols”, “modules.softdep”] Example: kernel_modules_install(
name = “foo_modules_install”,
kernel_modules = [“:foo_module_list”],
outs = [
“modules.dep”,
“modules.alias”,
],
) | List of strings | optional | [] |
kernel_build | Label referring to the kernel_build module. Otherwise, it is inferred from kernel_modules . | Label | optional | None |
kernel_modules | A list of labels referring to kernel_module s to install. | List of labels | optional | [] |
Compress the unstripped modules into a tarball.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
kernel_build | A kernel_build to retrieve unstripped in-tree modules from.It requires collect_unstripped_modules = True . If the kernel_build has a base_kernel , the rule also retrieves unstripped in-tree modules from the base_kernel , and requires the base_kernel has collect_unstripped_modules = True . | Label | optional | None |
kernel_modules | A list of external kernel_module s to retrieve unstripped external modules from.It requires that the base kernel_build has collect_unstripped_modules = True . | List of labels | optional | [] |
Merge .kzip files
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | kzip files | List of labels | optional | [] |
Merge Module.symvers files
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | It accepts targets from any of the following rules: - ddk_module - kernel_module_group - kernel_build (it requires keep_module_symvers = True to be set). | List of labels | optional | [] |
Merge kernel-uapi-headers.tar.gz
.
On certain devices, kernel modules install additional UAPI headers. Use this rule to add these module UAPI headers to the final kernel-uapi-headers.tar.gz
.
If there are conflicts of file names in the source tarballs, files higher in the list have higher priority:
base_kernel
of the kernel_build
(ususally the GKI build)kernel_build
(usually the device build)ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
kernel_build | The kernel_build | Label | required | |
kernel_modules | A list of external kernel_module s to merge kernel-uapi-headers.tar.gz | List of labels | optional | [] |
Generate a report from kernel modules of the given kernel build.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | - | List of labels | optional | [] |
Build super image.
Optionally takes in a “system_dlkm” and “vendor_dlkm”.
When included in a pkg_files
target included by pkg_install
, this rule copies super.img
to destdir
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
out | Image file name | String | optional | "super.img" |
super_img_size | Size of super.img | Integer | optional | 268435456 |
system_dlkm_image | system_dlkm_image to include in super.img | Label | optional | None |
vendor_dlkm_image | vendor_dlkm_image to include in super.img | Label | optional | None |
Build system_dlkm partition image with signed GKI modules.
When included in a pkg_files
target included by pkg_install
, this rule copies the following to destdir
:
system_dlkm.[erofs|ext4].img
if fs_types
is specifiedsystem_dlkm.flatten.[erofs|ext4].img
if build_flatten
is Truesystem_dlkm.modules.load
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | A list of additional dependencies to build system_dlkm image. | List of labels | optional | [] |
base | The system_dlkm_image() corresponding to the base_kernel of the kernel_build . This is required for building a device-specific system_dlkm image. For example, if base_kernel of kernel_build() is //common:kernel_aarch64 , then base is //common:kernel_aarch64_system_dlkm_image . | Label | optional | None |
build_flatten | When True it builds system_dlkm image with no uname -r in the path. | Boolean | optional | False |
fs_types | List of file systems type for system_dlkm images.Supported filesystems for system_dlkm image are ext4 and erofs . If not specified, build system_dlkm.img with ext4. Otherwise, build system_dlkm.<fs>.img for each file system type in the list. | List of strings | optional | ["ext4"] |
internal_extra_archive_files | Internal only; subject to change without notice. Extra files to be placed at the root of the archive. | List of labels | optional | [] |
kernel_modules_install | The kernel_modules_install . | Label | required | |
modules_blocklist | An optional file containing a list of modules which are blocked from being loaded. This file is copied directly to the staging directory and should be in the format: blocklist module_name | Label | optional | None |
modules_list | An optional file containing the list of kernel modules which shall be copied into a system_dlkm partition image. | Label | optional | None |
props | A text file containing the properties to be used for creation of a system_dlkm image (filesystem, partition size, etc). If this is not set (and build_system_dlkm is), a default set of properties will be used which assumes an ext4 filesystem and a dynamic partition. | Label | optional | None |
Build an unsparsed image.
Takes in a .img file and unsparses it.
When included in a pkg_files
/pkg_install
rule, this rule copies a super_unsparsed.img
to destdir
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
src | image to unsparse | Label | optional | None |
out | - | String | required |
Build vendor_boot
or vendor_kernel_boot
image.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | Additional dependencies to build boot images. | List of labels | optional | [] |
outs | A list of output files that will be installed to DIST_DIR when build_boot_images in build/kernel/build_utils.sh is executed.Unlike kernel_images , you must specify the list explicitly. | List of strings | optional | [] |
dtb_image | A dtb.img to packaged. If this is set, then *.dtb from kernel_build are ignored.See dtb_image . | Label | optional | None |
initramfs | The initramfs . | Label | optional | None |
kernel_build | The kernel_build . | Label | required | |
mkbootimg | mkbootimg.py script which builds boot.img. Only used if build_boot . If None , default to //tools/mkbootimg:mkbootimg.py . NOTE: This overrides MKBOOTIMG_PATH . | Label | optional | "@kleaf//tools/mkbootimg:mkbootimg.py" |
ramdisk_compression | If provided it specfies the format used for any ramdisks generated.If not provided a fallback value from build.config is used. | String | optional | "" |
ramdisk_compression_args | Command line arguments passed only to lz4 command to control compression level. | String | optional | "" |
unpack_ramdisk | When false it skips unpacking the vendor ramdisk and copy it as is, without modifications, into the boot image. Also skip the mkbootfs step. Unlike kernel_images() , unpack_ramdisk must be specified explicitly to clarify the intent. | Boolean | required | |
vendor_boot_name | Name of vendor_boot image.* If "vendor_boot" , build vendor_boot.img * If "vendor_kernel_boot" , build vendor_kernel_boot.img | String | optional | "vendor_boot" |
vendor_ramdisk_binaries | List of vendor ramdisk binaries which includes the device-specific components of ramdisk like the fstab file and the device-specific rc files. If specifying multiple vendor ramdisks and identical file paths exist in the ramdisks, the file from last ramdisk is used. Note: order matters. To prevent buildifier from sorting the list, add the following: # do not sort | List of labels | optional | [] |
vendor_ramdisk_dev_nodes | List of dev nodes description files which describes special device files to be added to the vendor ramdisk. File format is as accepted by mkbootfs. | List of labels | optional | [] |
Build vendor_dlkm image.
Execute build_vendor_dlkm
in build_utils.sh
.
When included in a pkg_files
target included by pkg_install
, this rule copies the following to destdir
:
vendor_dlkm.img
vendor_dlkm_flatten.img
if build_vendor_dlkm_flatten is TrueATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | A list of additional dependencies to build system_dlkm image. This must include the following: - The file specified by selinux_fc in props , if set | List of labels | optional | [] |
archive | Whether to archive the vendor_dlkm modules | Boolean | optional | False |
base_system_dlkm_image | The system_dlkm_image() corresponding to the base_kernel of the kernel_build . This is required if dedup_dlkm_modules and not system_dlkm_image . For example, if base_kernel of kernel_build() is //common:kernel_aarch64 , then base_system_dlkm_image is //common:kernel_aarch64_system_dlkm_image . | Label | optional | None |
build_flatten | When True it builds vendor_dlkm image with no uname -r in the path | Boolean | optional | False |
create_modules_order | Whether to create and keep a modules.order file generated by a postorder traversal of the kernel_modules_install sources. It defaults to True . | Boolean | optional | True |
dedup_dlkm_modules | Whether to exclude system_dlkm modules | Boolean | optional | False |
etc_files | Files that need to be copied to vendor_dlkm.img etc/ directory. | List of labels | optional | [] |
fs_type | Filesystem for vendor_dlkm.img . | String | optional | "ext4" |
kernel_modules_install | The kernel_modules_install . | Label | required | |
modules_blocklist | An optional file containing a list of modules which are blocked from being loaded. This file is copied directly to the staging directory and should be in the format: blocklist module_name | Label | optional | None |
modules_list | An optional file containing the list of kernel modules which shall be copied into a vendor_dlkm partition image. Any modules passed into MODULES_LIST which become part of the vendor_boot.modules.load will be trimmed from the vendor_dlkm.modules.load . | Label | optional | None |
props | A text file containing the properties to be used for creation of a vendor_dlkm image (filesystem, partition size, etc). If this is not set (and build_vendor_dlkm is), a default set of properties will be used which assumes an ext4 filesystem and a dynamic partition. | Label | optional | None |
system_dlkm_image | - | Label | optional | None |
vendor_boot_modules_load | File to vendor_boot.modules.load .Modules listed in this file is stripped away from the vendor_dlkm image.As a special case, you may also provide a initramfs target here, in which case the vendor_boot.modules.load of the initramfs is used. | Label | optional | None |
EXPERIMENTAL. A library that may be used by a DDK module.
The library has its own list of dependencies, flags that are usually local, and not exported to the ddk_module
using it. However, hdrs
, includes
, kconfig and defconfig are exported.
Known issues: - (b/392186874) The generated .o.cmd files contain absolute paths and are not reproducible. - (b/394411899) kernel_compile_commands() doesn't work on ddk_library yet. - (b/395014894) All ddk_module() dependency in ddk_library.deps must be duplicated in the ddk_module() that depends on this ddk_library.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of module | none |
kernel_build | kernel_build | none |
srcs | see ddk_module.srcs | None |
deps | see ddk_module.deps . ddk_submodule s are not allowed. | None |
hdrs | see ddk_module.hdrs | None |
includes | see ddk_module.includes | None |
linux_includes | see ddk_module.linux_includes | None |
local_defines | see ddk_module.local_defines | None |
copts | see ddk_module.copts | None |
removed_copts | see ddk_module.removed_copts | None |
asopts | see ddk_module.asopts | None |
config | see ddk_module.config | None |
kconfig | see ddk_module.kconfig | None |
defconfig | see ddk_module.defconfig | None |
autofdo_profile | see ddk_module.autofdo_profile | None |
debug_info_for_profiling | see ddk_module.debug_info_for_profiling | None |
pkvm_el2 | EXPERIMENTAL. If True, builds EL2 hypervisor code. If True: - The output list is the fixed ["kvm_nvhe.o"] , plus relevant .o.cmd files - The generated Makefile is modified to build EL2 hypervisor code.Note: This is only supported in selected branches. | None |
kwargs | Additional attributes to the internal rule. See complete list here. | none |
Defines a DDK (Driver Development Kit) module.
Example:
ddk_module( name = "my_module", srcs = ["my_module.c", "private_header.h"], out = "my_module.ko", # Exported headers hdrs = ["include/my_module_exported.h"], textual_hdrs = ["my_template.c"], includes = ["include"], )
Note: Local headers should be specified in one of the following ways:
ddk_headers
target in the same package, if you need to auto-generate -I
ccflags. In that case, specify the ddk_headers
target in deps
.srcs
if you don't need the -I
ccflags.Exported headers should be specified in one of the following ways:
ddk_headers
target in the same package. Then specify the target in hdrs
. This is recommended if there are multiple ddk_module
s depending on a glob
of headers or a large list of headers.hdrs
, textual_hdrs
and includes
of this target.For details, see build/kernel/kleaf/tests/ddk_examples/README.md
.
hdrs
, textual_hdrs
and includes
have the same semantics as ddk_headers
. That is, this target effectively acts as a ddk_headers
target when specified in the deps
attribute of another ddk_module
. In other words, the following code snippet:
ddk_module(name = "module_A", hdrs = [...], includes = [...], ...) ddk_module(name = "module_B", deps = ["module_A"], ...)
... is effectively equivalent to the following:
ddk_headers(name = "module_A_hdrs, hdrs = [...], includes = [...], ...) ddk_module(name = "module_A", ...) ddk_module(name = "module_B", deps = ["module_A", "module_A_hdrs"], ...)
Submodules
See ddk_submodule.
If deps
contains a ddk_submodule
target, the ddk_module
target must not specify anything except:
kernel_build
linux_includes
It is not recommended that a ddk_submodule
depends on a ddk_headers
target that specifies linux_includes
. If a ddk_submodule
does depend on a ddk_headers
target that specifies linux_includes
, all submodules below the same directory (i.e. sharing the same Kbuild
file) gets these linux_includes
. This is because LINUXINCLUDE
is set for the whole Kbuild
file, not per compilation unit.
In particular, a ddk_submodule
should not depend on //common:all_headers
. Instead, the dependency should come from the kernel_build
; that is, the kernel_build
of the ddk_module
, or the base_kernel
, should specify ddk_module_headers = "//common:all_headers"
.
To avoid confusion, the dependency on this ddk_headers
target with linux_includes
should be moved to the top-level ddk_module
. In this case, all submodules of this ddk_module
receives the said LINUXINCLUDE
from the ddk_headers
target.
Example:
# //common kernel_build(name = "kernel_aarch64", ddk_module_headers = ":all_headers_aarch64") ddk_headers( name = "all_headers_aarch64", linux_includes = [ "arch/arm64/include", "arch/arm64/include/uapi", "include", "include/uapi", ], )
# //device kernel_build(name = "tuna", base_kernel = "//common:kernel_aarch64") ddk_headers(name = "uapi", linux_includes = ["uapi/include"]) ddk_module( name = "mymodule", kernel_build = ":tuna", deps = [ ":mysubmodule" # Specify dependency on :uapi in the top level ddk_module ":uapi", ], ) ddk_submodule( name = "mysubmodule", deps = [ # Not recommended to specify dependency on :uapi since it contains # linux_includes # No need tp specify dependency on //common:all_headers_aarch64 # since it comes from :tuna -> //common:kernel_aarch64 ] )
Ordering of includes
The best practice is to not have conflicting header names and search paths. But if you do, see below for ordering of include directories to be searched for header files.
A ddk_module
is compiled with the following order of include directories (-I
options):
linux_includes
:linux_includes
of this target, in the specified orderlinux_includes
of deps
, in the specified order (recursively apply #1.3 on each target)linux_includes
of hdrs
, in the specified order (recursively apply #1.3 on each target)linux_includes
from kernel_build:linux_includes
from ddk_module_headers
of the base_kernel
of the kernel_build
of this ddk_module
;linux_includes
from ddk_module_headers
of the kernel_build
of this ddk_module
;LINUXINCLUDE
(See ${KERNEL_DIR}/Makefile
)includes
:includes
of this target, in the specified orderincludes
of deps
, in the specified order (recursively apply #3.1 and #3.3 on each target)includes
of hdrs
, in the specified order (recursively apply #3.1 and #3.3 on each target)includes
from kernel_build:includes
from ddk_module_headers
of the base_kernel
of the kernel_build
of this ddk_module
;includes
from ddk_module_headers
of the kernel_build
of this ddk_module
;In other words, #1 and #3 uses the preorder
of depset.
“In the specified order” means that order matters within these lists. To prevent buildifier from sorting these lists, use the # do not sort
magic line.
To export a target :x
in hdrs
before other targets in deps
(that is, if you need #3.3 before #3.2, or #1.2 before #1.1), specify :x
in the deps
list in the position you want. See example below.
To export an include directory in includes
that needs to be included after other targets in hdrs
or deps
(that is, if you need #3.1 after #3.2 or #3.3), specify the include directory in a separate ddk_headers
target, then specify this ddk_headers
target in hdrs
and/or deps
based on your needs.
For example:
ddk_headers(name = "base_ddk_headers", includes = ["base"], linux_includes = ["uapi/base"]) ddk_headers(name = "device_ddk_headers", includes = ["device"], linux_includes = ["uapi/device"]) kernel_build( name = "kernel_aarch64", ddk_module_headers = [":base_ddk_headers"], ) kernel_build( name = "device", base_kernel = ":kernel_aarch64", ddk_module_headers = [":device_ddk_headers"], ) ddk_headers(name = "dep_a", includes = ["dep_a"], linux_includes = ["uapi/dep_a"]) ddk_headers(name = "dep_b", includes = ["dep_b"]) ddk_headers(name = "dep_c", includes = ["dep_c"], hdrs = ["dep_a"]) ddk_headers(name = "hdrs_a", includes = ["hdrs_a"], linux_includes = ["uapi/hdrs_a"]) ddk_headers(name = "hdrs_b", includes = ["hdrs_b"]) ddk_headers(name = "x", includes = ["x"]) ddk_module( name = "module", kernel_build = ":device", deps = [":dep_b", ":x", ":dep_c"], hdrs = [":hdrs_a", ":x", ":hdrs_b"], linux_includes = ["uapi/module"], includes = ["self_1", "self_2"], )
Then ":module"
is compiled with these flags, in this order:
# 1.1 linux_includes -Iuapi/module # 1.2 deps, linux_includes, recursively -Iuapi/dep_a # 1.3 hdrs, linux_includes, recursively -Iuapi/hdrs_a # 1.4 linux_includes from kernel_build and base_kernel -Iuapi/device -Iuapi/base # 2. $(LINUXINCLUDE) # 3.1 includes -Iself_1 -Iself_2 # 3.2. deps, recursively -Idep_b -Ix -Idep_a # :dep_c depends on :dep_a, so include dep_a/ first -Idep_c # 3.3. hdrs, recursively -Ihdrs_a # x is already included, skip -Ihdrs_b # 3.4. includes from kernel_build and base_kernel -Idevice -Ibase
A dependent module automatically gets #1.1, #1.3, #3.1, #3.3, in this order. For example:
ddk_module( name = "child", kernel_build = ":device", deps = [":module"], # ... )
Then ":child"
is compiled with these flags, in this order:
# 1.2. linux_includes of deps, recursively -Iuapi/module -Iuapi/hdrs_a # 1.4 linux_includes from kernel_build and base_kernel -Iuapi/device -Iuapi/base # 2. $(LINUXINCLUDE) # 3.2. includes of deps, recursively -Iself_1 -Iself_2 -Ihdrs_a -Ix -Ihdrs_b # 3.4. includes from kernel_build and base_kernel -Idevice -Ibase
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name of target. This should usually be name of the output .ko file without the suffix. | none |
kernel_build | kernel_build | none |
srcs | sources or local headers. Source files ( .c , .S , .rs ) must be in the package of this ddk_module target, or in subpackages.Generated source files ( .c , .S , .rs ) are accepted as long as they are in the package of this ddk_module target, or in subpackages.Header files specified here are only visible to this ddk_module target, but not dependencies. To export a header so dependencies can use it, put it in hdrs and set includes accordingly.Generated header files are accepted. | None |
deps | A list of dependent targets. Each of them must be one of the following: - kernel_module - ddk_module - ddk_headers . - ddk_prebuilt_object - ddk_library If config is set, if some deps of this target have kconfig / defconfig set (including transitive dependencies), you may need to duplicate these targets in ddk_config.deps . Inconsistent configs are disallowed; if the resulting .config is not the same as the one from config , you get a build error. | None |
hdrs | See ddk_headers.hdrs If config is set, if some hdrs of this target have kconfig / defconfig set (including transitive dependencies), you may need to duplicate these targets in ddk_config.deps . Inconsistent configs are disallowed; if the resulting .config is not the same as the one from config , you get a build error. | None |
textual_hdrs | See ddk_headers.textual_hdrs . DEPRECATED. Use hdrs . | None |
includes | See ddk_headers.includes | None |
conditional_srcs | A dictionary that specifies sources conditionally compiled based on configs. Example: conditional_srcs = { “CONFIG_FOO”: { True: [“foo.c”], False: [“notfoo.c”] } } In the above example, if CONFIG_FOO is y or m , foo.c is compiled. Otherwise, notfoo.c is compiled instead. | None |
crate_root | For Rust modules, the file that will be passed to rustc to be used for building this module. Currently, each .ko may only contain a single Rust crate. Modules with multiple crates are not yet supported. Hence, only a single file may be passed into crate_root.Unlike rust_binary , this must always be set for Rust modules. No defaults are assumed. | None |
linux_includes | See ddk_headers.linux_includes Unlike ddk_headers.linux_includes , ddk_module.linux_includes is NOT applied to dependent ddk_module s. | None |
out | The output module file. This should usually be "{name}.ko" .This is required if this target does not contain submodules. | None |
local_defines | List of defines to add to the compile and assemble command line. Order matters. To prevent buildifier from sorting the list, use the # do not sort magic line.Each string is prepended with -D and added to the compile/assemble command line for this target, but not to its dependents.Unlike cc_library.local_defines , this is not subject to “Make” variable substitution or $(location) substitution.Each string is treated as a single Bourne shell token. Unlike cc_library.local_defines , this is not subject to Bourne shell tokenization. The behavior is similar to cc_library with the no_copts_tokenization feature. For details about no_copts_tokenization , see cc_library.copts . | None |
copts | Add these options to the compilation command. Order matters. To prevent buildifier from sorting the list, use the # do not sort magic line.Subject to $(location) substitution.The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All host paths should be provided via $(location) substitution. See “Implementation detail” section below.Each $(location) expression should occupy its own token; optional argument key is allowed as a prefix. For example:# Good copts = [“-include”, “$(location //other:header.h)”] copts = [“-include=$(location //other:header.h)”] # BAD - Don‘t do this! Split into two tokens. copts = [“-include $(location //other:header.h)”] # BAD - Don’t do this! Split into two tokens. copts = [“$(location //other:header.h) -Werror”] # BAD - Don't do this! Split into two tokens. copts = [“$(location //other:header.h) $(location //other:header2.h)”] Unlike cc_library.local_defines , this is not subject to “Make” variable substitution.Each string is treated as a single Bourne shell token. Unlike cc_library.copts this is not subject to Bourne shell tokenization. The behavior is similar to cc_library with the no_copts_tokenization feature. For details about no_copts_tokenization , see cc_library.copts .Because each string is treated as a single Bourne shell token, if a plural $(locations) expression expands to multiple paths, they are treated as a single Bourne shell token, which is likely an undesirable behavior. To avoid surprising behaviors, use singular $(location) expressions to ensure that the label only expands to one path. For differences between the $(locations) and $(location) , see $(location) substitution.Implementation detail: Unlike usual $(location) expansion, $(location) in copts is expanded to a path relative to the current package before sending to the compiler.For example: # package: //package ddk_module( name = “my_module”, copts = [“-include”, “$(location //other:header.h)”], srcs = [“//other:header.h”, “my_module.c”], ) Then the content of generated Makefile is semantically equivalent to: CFLAGS_my_module.o += -include ../other/header.h The behavior is such because the generated Makefile is located in package/Makefile , and make is executed under package/ . In order to find other/header.h , its path relative to package/ is given. | None |
removed_copts | Similar to copts but for flags removed from the compilation command.For example: ddk_module( name = “my_module”, removed_copts = [“-Werror”], srcs = [“my_module.c”], ) Then the content of generated Makefile is semantically equivalent to: CFLAGS_REMOVE_my_module.o += -Werror Note: Due to implementation details of Kleaf flags in copts are written to a file and provided to the compiler with the @<arg_file> syntax, so they are not affected by removed_copts implemented by CFLAGS_REMOVE_ . To remove flags from the Bazel copts list, do so directly. | None |
asopts | Similar to copts but for assembly.For example: ddk_module( name = “my_module”, asopts = [“-ansi”], srcs = [“my_module.S”], ) Then the content of generated Makefile is semantically equivalent to: AFLAGS_my_module.o += -ansi | None |
linkopts | Similar to copts but for linking the module.For example: ddk_module( name = “my_module”, linkopts = [“-lc”], out = “my_module.ko”, # ... ) Then the content of generated Makefile is semantically equivalent to: LDFLAGS_my_module.ko += -lc | None |
config | EXPERIMENTAL. The parent ddk_config that encapsulates Kconfig/defconfig. | None |
kconfig | The Kconfig files for this external module. See Documentation/kbuild/kconfig-language.rst for its format.Kconfig is optional for a ddk_module . The final Kconfig known by this module consists of the following:- Kconfig from kernel_build - Kconfig from dependent modules, if any - Kconfig of this module, if anyFor legacy reasons, this is singular and accepts a single target. If multiple Kconfig files should be added, use a filegroup to wrap the files. | None |
defconfig | The defconfig file.Items must already be declared in kconfig . An item not declared in Kconfig and inherited Kconfig files is silently dropped.An item declared in kconfig without a specific value in defconfig uses default value specified in kconfig . | None |
generate_btf | Allows generation of BTF type information for the module. See kernel_module.generate_btf | None |
autofdo_profile | Label to an AutoFDO profile. | None |
debug_info_for_profiling | If true, enables extra debug information to be emitted to make profile matching during AutoFDO more accurate. | None |
kwargs | Additional attributes to the internal rule. See complete list here. | none |
Declares a DDK (Driver Development Kit) submodule.
Symbol dependencies between submodules in the same ddk_module
are not specified explicitly. This is convenient when you have multiple module files for a subsystem.
See Building External Modules or Documentation/kbuild/modules.rst
, section “6.3 Symbols From Another External Module”, “Use a top-level kbuild file”.
Example:
ddk_submodule( name = "a", out = "a.ko", srcs = ["a.c"], ) ddk_submodule( name = "b", out = "b.ko", srcs = ["b_1.c", "b_2.c"], ) ddk_module( name = "mymodule", kernel_build = ":tuna", deps = [":a", ":b"], )
linux_includes
must be specified in the top-level ddk_module
; see ddk_module.linux_includes
.
ddk_submodule
should avoid depending on ddk_headers
that has linux_includes
. See the Submodules section in ddk_module
for best practices.
Ordering of includes
See ddk_module
.
Caveats
As an implementation detail, ddk_submodule
alone does not build any modules. The ddk_module
target is the one responsible for building all .ko
files.
A side effect is that for incremental builds, modules may be rebuilt unexpectedly. In the above example, if a.c
is modified, the whole mymodule
is rebuilt, causing both a.ko
and b.ko
to be rebuilt. Because ddk_module
is always built in a sandbox, the object files (*.o
) for b.ko
is not cached.
Hence, it is always recommended to use one ddk_module
per module (.ko
file). You may use build/kernel/kleaf/build_cleaner.py
to resolve dependencies; see build/kernel/kleaf/docs/build_cleaner.md
.
The ddk_submodule
rule should only be used when the dependencies among modules are too complicated to be presented in BUILD.bazel
, and are frequently updated. When the dependencies are stable, it is recommended to:
ddk_submodule
with ddk_module
;deps
attribute explicitly.PARAMETERS
Name | Description | Default Value |
---|---|---|
name | See ddk_module.name . | none |
out | See ddk_module.out . | none |
srcs | See ddk_module.srcs . | None |
deps | See ddk_module.deps .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are not exported to downstream targets that depends on the ddk_module that includes the current target. | None |
hdrs | See ddk_module.hdrs .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are exported to downstream targets that depends on the ddk_module that includes the current target. Example:ddk_submodule(name = “module_parent_a”, hdrs = [...]) ddk_module(name = “module_parent”, deps = [“:module_parent_a”]) ddk_module(name = “module_child”, deps = [“:module_parent”]) module_child automatically gets hdrs of module_parent_a . | None |
includes | See ddk_module.includes .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are exported to downstream targets that depends on the ddk_module that includes the current target. Example:ddk_submodule(name = “module_parent_a”, includes = [...]) ddk_module(name = “module_parent”, deps = [“:module_parent_a”]) ddk_module(name = “module_child”, deps = [“:module_parent”]) module_child automatically gets includes of module_parent_a . | None |
local_defines | See ddk_module.local_defines .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are not exported to downstream targets that depends on the ddk_module that includes the current target. | None |
copts | See ddk_module.copts .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are not exported to downstream targets that depends on the ddk_module that includes the current target. | None |
removed_copts | See ddk_module.removed_copts .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are not exported to downstream targets that depends on the ddk_module that includes the current target. | None |
asopts | See ddk_module.asopts .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are not exported to downstream targets that depends on the ddk_module that includes the current target. | None |
linkopts | See ddk_module.linkopts .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps .These are not exported to downstream targets that depends on the ddk_module that includes the current target. | None |
conditional_srcs | See ddk_module.conditional_srcs . | None |
crate_root | See ddk_module.crate_root . | None |
autofdo_profile | See ddk_module.autofdo_profile .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps . | None |
debug_info_for_profiling | See ddk_module.debug_info_for_profiling .These are only effective in the current submodule, not other submodules declared in the same ddk_module.deps . | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Declare targets for dependency graph visualization.
Output: File with a diagram representing a graph in DOT language.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name of this target. | none |
kernel_build | The kernel_build . | none |
kernel_modules | A list of external kernel_module() s. | none |
colorful | When set to True, outgoing edges from every node are colored differently. | None |
exclude_base_kernel_modules | Whether the analysis should made for only external modules. | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Tests that the initramfs has modules.load* files with the given content.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of the test | none |
kernel_images | name of the kernel_images target. It must build initramfs. | none |
expected_modules_list | file with the expected content for modules.load | None |
expected_modules_recovery_list | file with the expected content for modules.load.recovery | None |
expected_modules_charger_list | file with the expected content for modules.load.charger | None |
build_vendor_boot | If the kernel_images target builds vendor_boot.img | None |
build_vendor_kernel_boot | If the kernel_images target builds vendor_kernel_boot.img | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Declare multiple targets to support ABI monitoring.
This macro is meant to be used alongside kernel_build
macro.
For example, you may have the following declaration. (For actual definition of kernel_aarch64
, see define_common_kernels()
.
kernel_build(name = "kernel_aarch64", ...) kernel_abi( name = "kernel_aarch64_abi", kernel_build = ":kernel_aarch64", ... )
The kernel_abi
invocation above defines the following targets:
kernel_aarch64_abi_dump
kernel_abi_dist
target to copy ABI dump to --dist-dir
.kernel_aarch64_abi
kernel_aarch64_abi_dump
. It also contains other targets if define_abi_targets = True
; see below.In addition, the following targets are defined if define_abi_targets = True
:
kernel_aarch64_abi_update_symbol_list
kmi_symbol_list
.kernel_aarch64_abi_update_protected_exports
protected_exports_list
.kernel_aarch64_abi_update
abi_definition
.kernel_aarch64_abi_dump
kernel_abi_dist
target to copy ABI dump to --dist-dir
.To create a distribution, see kernel_abi_wrapped_dist
.
See build/kernel/kleaf/abi.md for a conversion chart from build_abi.sh
commands to Bazel commands.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name of this target. | none |
kernel_build | The kernel_build . | none |
define_abi_targets | Whether the target contains other files to support ABI monitoring. If None , defaults to True .If False , this macro is equivalent to just calling kernel_build(name = name, **kwargs)
filegroup(name = name + “_abi”, data = [name, abi_dump_target])If True , implies collect_unstripped_modules = True . See kernel_build.collect_unstripped_modules . | None |
kernel_modules | A list of external kernel_module() s to extract symbols from. | None |
module_grouping | If unspecified or None , it is True by default. If True , then the symbol list will group symbols based on the kernel modules that reference the symbol. Otherwise the symbol list will simply be a sorted list of symbols used by all the kernel modules. | None |
abi_definition_stg | Location of the ABI definition in STG format. | None |
kmi_enforced | This is an indicative option to signal that KMI is enforced. If set to True , KMI checking tools respects it and reacts to it by failing if KMI differences are detected. | None |
unstripped_modules_archive | A kernel_unstripped_modules_archive which name is specified in abi.prop . DEPRECATED. | None |
kmi_symbol_list_add_only | If unspecified or None , it is False by default. If True , then any symbols in the symbol list that would have been removed are preserved (at the end of the file). Symbol list update will fail if there is no pre-existing symbol list file to read from. This property is intended to prevent unintentional shrinkage of a stable ABI.This should be set to True if KMI_SYMBOL_LIST_ADD_ONLY=1 . | None |
kernel_modules_exclude_list | List of base names for in-tree kernel modules to exclude from. i.e. This is the modules built in kernel_build , not the kernel_modules mentioned above. | None |
enable_add_vmlinux | If unspecified or None , it is True by default. If True , enable the kernel_build_add_vmlinux transition from all targets instantiated by this macro (e.g. produced by abi_dump, extracted_symbols, etc). | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
This macro is no longer supported. Invoking this macro triggers an error.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | ignored | none |
kernel_abi | ignored | none |
kernel_build_add_vmlinux | ignored | None |
ignore_diff | ignored | None |
no_ignore_diff_target | ignored | None |
kwargs | ignored | none |
DEPRECATED
Use kernel_abi_wrapped_dist
instead.
A wrapper over dist
for kernel_abi
.
After calling the dist
, return the exit code from diff_abi
.
Example:
kernel_build( name = "tuna", base_kernel = "//common:kernel_aarch64", ... ) kernel_abi(name = "tuna_abi", ...) pkg_files( name = "tuna_abi_dist_internal_files", srcs = [ ":tuna", # "//common:kernel_aarch64", # remove GKI ":tuna_abi", ... # Add kernel_abi to pkg_files ], strip_prefix = strip_prefix.files_only(), visibility = ["//visibility:private"], ) pkg_install( name = "tuna_abi_dist_internal", srcs = [":tuna_abi_dist_internal_files"], visibility = ["//visibility:private"], ) kernel_abi_wrapped_dist( name = "tuna_abi_dist", dist = ":tuna_abi_dist_internal", kernel_abi = ":tuna_abi", )
Implementation notes:
with_vmlinux_transition
is applied on all targets by default. In particular, the kernel_build
targets in data
automatically builds vmlinux
regardless of whether vmlinux
is specified in outs
.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of the ABI dist target | none |
dist | The actual dist target (usually a pkg_install ).Note: This dist target should include kernel_abi in pkg_files that the pkg_install installs, e.g.kernel_abi(name = “tuna_abi”, ...) pkg_files( name = “tuna_abi_dist_files”, srcs = [“:tuna_abi”, ...], # Add kernel_abi to pkg_files() # ... ) pkg_install( name = “tuna_abi_dist_internal”, srcs = [“:tuna_abi_dist_files”], # ... ) kernel_abi_wrapped_dist( name = “tuna_abi_dist”, dist = “:tuna_abi_dist_internal”, # ... ) | none |
kernel_abi | Nonconfigurable. name of the kernel_abi invocation. | none |
ignore_diff | Nonconfigurable. If True and the return code of stgdiff signals the ABI difference, then the result is ignored. | None |
no_ignore_diff_target | Nonconfigurable. If ignore_diff is True , this need to be set to a name of the target that doesn't have ignore_diff . This target will be recommended as an alternative to a user. If no_ignore_diff_target is None, there will be no alternative recommended. | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Defines a kernel build target with all dependent targets.
It uses a build_config
to construct a deterministic build environment (e.g. common/build.config.gki.aarch64
). The kernel sources need to be declared via srcs (using a glob()
). outs declares the output files that are surviving the build. The effective output file names will be $(name)/$(output_file)
. Any other artifact is not guaranteed to be accessible after the rule has run.
A few additional labels are generated. For example, if name is "kernel_aarch64"
:
kernel_aarch64_uapi_headers
provides the UAPI kernel headers.kernel_aarch64_headers
provides the kernel headers.PARAMETERS
Name | Description | Default Value |
---|---|---|
name | The final kernel target name, e.g. "kernel_aarch64" . | none |
outs | The expected output files. Note: in-tree modules should be specified in module_outs instead.This attribute must be either a dict or a list . If it is a list , for each item in out :- If out does not contain a slash, the build rule automatically finds a file with name out in the kernel build output directory ${OUT_DIR} . find ${OUT_DIR} -name {out} There must be exactly one match. The file is copied to the following in the output directory {name}/{out} Example: kernel_build(name = “kernel_aarch64”, outs = [“vmlinux”]) The bulid system copies ${OUT_DIR}/[<optional subdirectory>/]vmlinux to kernel_aarch64/vmlinux . kernel_aarch64/vmlinux is the label to the file.- If out contains a slash, the build rule locates the file in the kernel build output directory ${OUT_DIR} with path out The file is copied to the following in the output directory 1. {name}/{out} 2. {name}/$(basename {out}) Example: kernel_build( name = “kernel_aarch64”, outs = [“arch/arm64/boot/vmlinux”]) The bulid system copies ${OUT_DIR}/arch/arm64/boot/vmlinux to: - kernel_aarch64/arch/arm64/boot/vmlinux - kernel_aarch64/vmlinux They are also the labels to the output files, respectively.See search_and_cp_output.py for details.Files in outs are part of the DefaultInfo that this kernel_build returns. For example: kernel_build(name = “kernel”, outs = [“vmlinux”], ...)
pkg_files(name = “kernel_files”, srcs = [“kernel”], ...)
pkg_install(name = “kernel_dist”, srcs = [“:kernel_files”]) vmlinux will be included in the distribution.If it is a dict , it is wrapped in select() .Example: kernel_build( name = “kernel_aarch64”, outs = {“config_foo”: [“vmlinux”]}) If conditions in config_foo is met, the rule is equivalent to kernel_build(
name = “kernel_aarch64”,
outs = [“vmlinux”]) As explained above, the bulid system copies ${OUT_DIR}/[<optional subdirectory>/]vmlinux to kernel_aarch64/vmlinux . kernel_aarch64/vmlinux is the label to the file.Note that a select() may not be passed into kernel_build() because select() cannot be evaluated in macros. Hence: - combining select() s is not allowed. Instead, expand the cartesian product. - To use AND chaining or OR chaining, use selects.config_setting_group() . | none |
build_config | Label of the build.config file, e.g. "build.config.gki.aarch64" .If it contains no files, the list of constants in @kernel_toolchain_info is used. This is //common:build.config.constants by default, unless otherwise specified.If it contains no files, makefile must be set as the anchor to the directory to run make . | None |
makefile | Makefile governing the kernel tree sources (see srcs ). Example values:* None (default): Falls back to the value of KERNEL_DIR from build_config . kernel_build() executes make in KERNEL_DIR .Note: The usage of specifying KERNEL_DIR in build_config is deprecated and will trigger a warning/error in the future.* "//common:Makefile" (most common): the kernel sources are located in //common . This means kernel_build() executes make to build the kernel image and in-tree drivers in common .This usually replaces //common:set_kernel_dir_build_config in your build_config ; that is, if you set kernel_build.makefile , it is likely that you may drop //common:set_kernel_dir_build_config from components of kernel_build.build_config .This replaces KERNEL_DIR=common in your build_config .* "@kleaf//common:Makefile" : If you set up a DDK workspace such that Kleaf tooling and your kernel source tree are located in the @kleaf submodule, you should specify the full label in the package. * the Makefile next to the build config:For example: kernel_build( name = "tuna", build_config = "//package:build.config.tuna", # the build.config.tuna is in //package makefile = "//package:Makefile", # so set KERNEL_DIR to "package" ) In this example, build.config.tuna is in //package . Hence, setting makefile = "Makefile" is equivalent to the legacy behavior of not setting KERNEL_DIR in build.config , and allowing _setup_env.sh to decide the value by inferring from the directory containing the build config, which is the //package .* Makefile in the current package: the kernel sources are in the current package where kernel_build() is called.For example: kernel_build( name = "tuna", build_config = "build.config.tuna", # the build.config.tuna is in this package makefile = "Makefile", # so set KERNEL_DIR to this package ) | None |
keep_module_symvers | If set to True, a copy of the default output Module.symvers is kept. * To avoid collisions in mixed build distribution packages, the file is renamed as $(name)_Module.symvers . * Default is False. | None |
keep_dot_config | If set to True, a copy of the default output .config is kept. * To avoid collisions in mixed build distribution packages, the file is renamed as $(name)_dot_config . * Default is False. | None |
srcs | The kernel sources (a glob() ). If unspecified or None , it is the following: glob(
[“**”],
exclude = [
“**/.*”, # Hidden files
“/.*/”, # Files in hidden directories
“**/BUILD.bazel”, # build files
“**/*.bzl”, # build files
],
) | None |
module_outs | A list of in-tree drivers. Similar to outs , but for *.ko files.If a *.ko kernel module should not be copied to ${DIST_DIR} , it must be included implicit_outs instead of module_outs . The list implicit_outs + module_outs must include all *.ko files in ${OUT_DIR} . If not, a build error is raised.Like outs , module_outs are part of the DefaultInfo that this kernel_build returns. For example: kernel_build(name = “kernel”, module_outs = [“foo.ko”], ...)
pkg_files(name = “kernel_files”, srcs = [“kernel”], ...)
pkg_install(name = “kernel_dist”, srcs = [“:kernel_files”]) foo.ko will be included in the distribution.Like outs , this may be a dict . If so, it is wrapped in select() . See documentation for outs for more details. | None |
implicit_outs | Like outs , but not copied to the distribution directory.Labels are created for each item in implicit_outs as in outs . | None |
module_implicit_outs | like module_outs , but not copied to the distribution directory.Labels are created for each item in module_implicit_outs as in outs . | None |
generate_vmlinux_btf | If True , generates vmlinux.btf that is stripped of any debug symbols, but contains type and symbol information within a .BTF section. This is suitable for ABI analysis through BTF.Requires that "vmlinux" is in outs . | None |
deps | Additional dependencies to build this kernel. | None |
arch | Nonconfigurable. Target architecture. Default is arm64 .Value should be one of: * arm64 * x86_64 * riscv64 * arm (for 32-bit, uncommon) * i386 (for 32-bit, uncommon)This must be consistent to ARCH in build configs if the latter is specified. Otherwise, a warning / error may be raised. | None |
base_kernel | A label referring the base kernel build. If set, the list of files specified in the DefaultInfo of the rule specified in base_kernel is copied to a directory, and KBUILD_MIXED_TREE is set to the directory. Setting KBUILD_MIXED_TREE effectively enables mixed build.To set additional flags for mixed build, change build_config to a kernel_build_config rule, with a build config fragment that contains the additional flags.The label specified by base_kernel must produce a list of files similar to what a kernel_build rule does. Usually, this points to one of the following: - //common:kernel_{arch} - A kernel_filegroup rule, e.g. load("//build/kernel/kleaf:constants.bzl, “DEFAULT_GKI_OUTS”)
kernel_filegroup(
name = “my_kernel_filegroup”,
srcs = DEFAULT_GKI_OUTS,
) | None |
make_goals | A list of strings defining targets for the kernel build. This overrides MAKE_GOALS from build config if provided. | None |
kconfig_ext | Label of an external Kconfig.ext file sourced by the GKI kernel. | None |
dtstree | Device tree support. | None |
kmi_symbol_list | A label referring to the main KMI symbol list file. See additional_kmi_symbol_lists .This is the Bazel equivalent of ADDITIONAL_KMI_SYMBOL_LISTS . | None |
protected_exports_list | A file containing list of protected exports. For example: protected_exports_list = “//common:android/abi_gki_protected_exports” | None |
protected_modules_list | A file containing list of protected modules, For example: protected_modules_list = “//common:android/gki_protected_modules” | None |
additional_kmi_symbol_lists | A list of labels referring to additional KMI symbol list files. This is the Bazel equivalent of ADDITIONAL_KMI_SYMBOL_LISTS .Let all_kmi_symbol_lists = [kmi_symbol_list] + additional_kmi_symbol_list If all_kmi_symbol_lists is a non-empty list, abi_symbollist and abi_symbollist.report are created and added to the DefaultInfo , and copied to DIST_DIR during distribution.If all_kmi_symbol_lists is None or an empty list, abi_symbollist and abi_symbollist.report are not created.It is possible to use a glob() to determine whether abi_symbollist and abi_symbollist.report should be generated at build time. For example: kmi_symbol_list = “android/abi_gki_aarch64”,
additional_kmi_symbol_lists = glob([“android/abi_gki_aarch64*”], exclude = [“android/abi_gki_aarch64”]), | None |
trim_nonlisted_kmi | If True , trim symbols not listed in kmi_symbol_list and additional_kmi_symbol_lists . This is the Bazel equivalent of TRIM_NONLISTED_KMI .Requires all_kmi_symbol_lists to be non-empty. If kmi_symbol_list or additional_kmi_symbol_lists is a glob() , it is possible to set trim_nonlisted_kmi to be a value based on that glob() . For example: trim_nonlisted_kmi = len(glob([“android/abi_gki_aarch64*”])) > 0 | None |
kmi_symbol_list_strict_mode | If True , add a build-time check between [kmi_symbol_list] + additional_kmi_symbol_lists and the KMI resulting from the build, to ensure they match 1-1. | None |
collect_unstripped_modules | If True , provide all unstripped in-tree. | None |
kbuild_symtypes | The value of KBUILD_SYMTYPES .This can be set to one of the following: - "true" - "false" - "auto" - None , which defaults to "auto" If the value is "auto" , it is determined by the --kbuild_symtypes flag.If the value is "true" ; or the value is "auto" and --kbuild_symtypes is specified, then KBUILD_SYMTYPES=1 . Note: kernel build time can be significantly longer.If the value is "false" ; or the value is "auto" and --kbuild_symtypes is not specified, then KBUILD_SYMTYPES= . | None |
strip_modules | If None or not specified, default is False . If set to True , debug information for distributed modules is stripped.This corresponds to negated value of DO_NOT_STRIP_MODULES in build.config . | None |
module_signing_key | A label referring to a module signing key. This is to allow for dynamic setting of CONFIG_MODULE_SIG_KEY from Bazel. | None |
system_trusted_key | A label referring to a trusted system key. This is to allow for dynamic setting of CONFIG_SYSTEM_TRUSTED_KEY from Bazel. | None |
modules_prepare_force_generate_headers | If True it forces generation of additional headers as part of modules_prepare. | None |
defconfig | Label to the base defconfig. As a convention, files should usually be named <device>_defconfig (e.g. tuna_defconfig ) to provide human-readable hints during the build. The prefix should be the name of the kernel_build . However, this is not a requirement. These configs are also applied to external modules, including kernel_module s and ddk_module s.For mixed builds ( base_kernel is set), this is usually set to the defconfig of the base_kernel , e.g. //common:arch/arm64/configs/gki_defconfig .If check_defconfig is not disabled , Items must be present in the intermediate .config before post_defconfig_fragments are applied. See build/kernel/kleaf/docs/kernel_config.md for details.As a special case, if this is evaluated to //build/kernel/kleaf:allmodconfig , Kleaf builds all modules except those exluded in post_defconfig_fragments . In this case, pre_defconfig_fragments must not be set.See build/kernel/kleaf/docs/kernel_config.md for details. | None |
pre_defconfig_fragments | A list of fragments that are applied to the defconfig before make defconfig .Even though this is a list, it is highly recommended that the list contains at most one item. This is so that tools/bazel run <name>_config applies to the single pre defconfig fragment correctly.As a convention, files should usually be named <prop>_defconfig (e.g. 16k_defconfig ) or <prop>_<value>_defconfig (e.g. page_size_16k_defconfig ) to provide human-readable hints during the build. The prefix should describe what the defconfig does. However, this is not a requirement. These configs are also applied to external modules, including kernel_module s and ddk_module s.For mixed builds ( base_kernel is set), the file usually contains additional in-tree modules to build on top of gki_defconfig , e.g. CONFIG_FOO=m .NOTE: pre_defconfig_fragments are applied before make defconfig , similar to PRE_DEFCONFIG_CMDS . If you had POST_DEFCONFIG_CMDS applying fragments in your build configs, consider using post_defconfig_fragments instead.NOTE: Order matters, unlike post_defconfig_fragments . If there are conflicting items, later items overrides earlier items.If check_defconfig is not disabled , Items must be present in the intermediate .config before post_defconfig_fragments are applied. See build/kernel/kleaf/docs/kernel_config.md for details. | None |
post_defconfig_fragments | A list of fragments that are applied to the defconfig after make defconfig .As a convention, files should usually be named <prop>_defconfig (e.g. kasan_defconfig ) or <prop>_<value>_defconfig (e.g. lto_none_defconfig ) to provide human-readable hints during the build. The prefix should describe what the defconfig does. However, this is not a requirement. These configs are also applied to external modules, including kernel_module s and ddk_module s.Files usually contain debug options. If you want to build in-tree modules, adding them to pre_defconfig_fragments may be a better choice.NOTE: post_defconfig_fragments are applied after make defconfig , similar to POST_DEFCONFIG_CMDS . If you had PRE_DEFCONFIG_CMDS applying fragments in your build configs, consider using pre_defconfig_fragments instead.If check_defconfig is not disabled , Items must be present in the final .config . See build/kernel/kleaf/docs/kernel_config.md for details. | None |
defconfig_fragments | Deprecated. Same as post_defconfig_fragments . | None |
check_defconfig | Default is match .If disabled , no check is performed.If match , checks .config against the defconfig , pre_defconfig_fragments and post_defconfig_fragments .If minimized , checks .config against the result of make savedefconfig right after make defconfig , but before post_defconfig_fragments are applied. This can be set to minimized only if defconfig is set and pre_defconfig_fragments is not set. | None |
page_size | Default is "default" . Page size of the kernel build.Value may be one of "default" , "4k" , "16k" or "64k" . If "default" , the defconfig is left as-is.16k / 64k page size is only supported on arch = "arm64" . | None |
pack_module_env | If True , create {name}_module_env.tar.gz and other archives as part of the default output of this target.These archives contains necessary files to build external modules. | None |
sanitizers | non-configurable. A list of sanitizer configurations. By default, no sanitizers are explicity configured; values in defconfig are respected. Possible values are: - ["kasan_any_mode"] - ["kasan_sw_tags"] - ["kasan_generic"] - ["kcsan"] | None |
ddk_module_defconfig_fragments | A list of additional defconfigs, to be used in ddk_module s building against this kernel. Unlike post_defconfig_fragments , ddk_module_defconfig_fragments is not applied to this kernel_build target, nor dependent legacy kernel_module s. | None |
ddk_module_headers | A list of ddk_headers , to be used in ddk_module s building against this kernel.Inherits ddk_module_headers from base_kernel , with a lower priority than ddk_module_headers of this kernel_build.These headers are not applied to this kernel_build target. | None |
kcflags | Extra KCFLAGS . Empty by default.To add common KCFLAGS, you must explicitly set it to COMMON_KCFLAGS (see //build/kernel/kleaf:constants.bzl ). | None |
clang_autofdo_profile | Path to an AutoFDO profile, For example: clang_autofdo_profile = “//toolchain/pgo-profiles/kernel:aarch64/android16-6.12/kernel.afdo” | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Specify a kernel DTS tree.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of the module | none |
srcs | sources of the DTS tree. Default is glob([“**”], exclude = [ “**/.*”, “/.*/”, “**/BUILD.bazel”, “**/*.bzl”, ]) | None |
makefile | Makefile of the DTS tree. Default is :Makefile , i.e. the Makefile at the root of the package. | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Build multiple kernel images.
You may use filegroup.output_group
to request certain files. Example:
kernel_images( name = "my_images", build_vendor_dlkm = True, ) filegroup( name = "my_vendor_dlkm", srcs = [":my_images"], output_group = "vendor_dlkm.img", )
Allowed strings in filegroup.output_group
:
vendor_dlkm.img
, if build_vendor_dlkm
is setvendor_dlkm_flatten.img
if build_vendor_dlkm_flatten
is not emptysystem_dlkm.img
, if build_system_dlkm
and system_dlkm_fs_type
is setsystem_dlkm.<type>.img
for each of system_dlkm_fs_types
, if build_system_dlkm
is set and system_dlkm_fs_types
is not empty.system_dlkm.flatten.<type>.img
for each of sytem_dlkm_fs_types, if
build_system_dlkm_flattenis set and
system_dlkm_fs_types` is not empty.If no output files are found, the filegroup resolves to an empty one. You may also read OutputGroupInfo
on the kernel_images
rule directly in your rule implementation.
For details, see Requesting output files.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of this rule, e.g. kernel_images , | none |
kernel_modules_install | A kernel_modules_install rule.The main kernel build is inferred from the kernel_build attribute of the specified kernel_modules_install rule. The main kernel build must contain System.map in outs (which is included if you use DEFAULT_GKI_OUTS or X86_64_OUTS from common_kernels.bzl ). | none |
kernel_build | A kernel_build rule. Must specify if build_boot . | None |
base_kernel_images | The kernel_images() corresponding to the base_kernel of the kernel_build . This is required for building a device-specific system_dlkm image. For example, if base_kernel of kernel_build() is //common:kernel_aarch64 , then base_kernel_images is //common:kernel_aarch64_images .This is also required if dedup_dlkm_modules and not build_system_dlkm . | None |
build_initramfs | Whether to build initramfs. Keep in sync with BUILD_INITRAMFS . | None |
build_vendor_dlkm | Whether to build vendor_dlkm image. It must be set if vendor_dlkm_modules_list is set. | None |
build_vendor_dlkm_flatten | Whether to build vendor_dlkm_flatten image. The image have directory structure as /lib/modules/*.ko i.e. no uname -r in the pathNote: at the time of writing (Jan 2022), vendor_dlkm.modules.blocklist is always created regardless of the value of VENDOR_DLKM_MODULES_BLOCKLIST . If build_vendor_dlkm() in build_utils.sh does not generate vendor_dlkm.modules.blocklist , an empty file is created. | None |
build_boot | Whether to build boot image. It must be set if either BUILD_BOOT_IMG or BUILD_VENDOR_BOOT_IMG is set.This depends on kernel_build . Hence, if this is set to True , kernel_build must be set.If True , adds boot.img to boot_image_outs if not already in the list. | None |
build_vendor_boot | Whether to build vendor_boot.img . It must be set if either BUILD_BOOT_IMG or BUILD_VENDOR_BOOT_IMG is set, and SKIP_VENDOR_BOOT is not set, and BUILD_VENDOR_KERNEL_BOOT is not set.At most one of build_vendor_boot and build_vendor_kernel_boot may be set to True .If True , adds vendor_boot.img to boot_image_outs if not already in the list. | None |
build_vendor_kernel_boot | Whether to build vendor_kernel_boot.img . It must be set if either BUILD_BOOT_IMG or BUILD_VENDOR_BOOT_IMG is set, and SKIP_VENDOR_BOOT is not set, and BUILD_VENDOR_KERNEL_BOOT is set.At most one of build_vendor_boot and build_vendor_kernel_boot may be set to True .If True , adds vendor_kernel_boot.img to boot_image_outs if not already in the list. | None |
build_system_dlkm | Whether to build system_dlkm.img an image with GKI modules. | None |
build_system_dlkm_flatten | Whether to build system_dlkm.flatten..img. This image have directory structure as /lib/modules/*.ko i.e. no uname -r in the path. | None |
build_dtbo | Whether to build dtbo image. Keep this in sync with BUILD_DTBO_IMG .If dtbo_srcs is non-empty, build_dtbo is True by default. Otherwise it is False by default. | None |
dtbo_srcs | list of *.dtbo files used to package the dtbo.img . Keep this in sync with MKDTIMG_DTBOS ; see example below.If dtbo_srcs is non-empty, build_dtbo must not be explicitly set to False .Example: kernel_build( name = “tuna_kernel”, outs = [ “path/to/foo.dtbo”, “path/to/bar.dtbo”, ], ) kernel_images( name = “tuna_images”, kernel_build = “:tuna_kernel”, dtbo_srcs = [ “:tuna_kernel/path/to/foo.dtbo”, “:tuna_kernel/path/to/bar.dtbo”, ] ) | None |
dtbo_config | a config file to create dtbo image by cfg_create command. | None |
mkbootimg | Path to the mkbootimg.py script which builds boot.img. Only used if build_boot . If None , default to //tools/mkbootimg:mkbootimg.py . NOTE: This overrides MKBOOTIMG_PATH . | None |
deps | Additional dependencies to build images. This must include the following: - For initramfs : - The file specified by MODULES_LIST - The file specified by MODULES_BLOCKLIST , if MODULES_BLOCKLIST is set - The file containing the list of modules needed for booting into recovery. - The file containing the list of modules needed for booting into charger mode. - For vendor_dlkm image: - The file specified by VENDOR_DLKM_MODULES_LIST - The file specified by VENDOR_DLKM_MODULES_BLOCKLIST , if set - The file specified by VENDOR_DLKM_PROPS , if set - The file specified by selinux_fc in VENDOR_DLKM_PROPS , if set | None |
boot_image_outs | A list of output files that will be installed to DIST_DIR when build_boot_images in build/kernel/build_utils.sh is executed.You may leave out vendor_boot.img from the list. It is automatically added when build_vendor_boot = True .If build_boot is equal to False , the default is empty.If build_boot is equal to True , the default list assumes the following: - BOOT_IMAGE_FILENAME is not set (which takes default value boot.img ), or is set to "boot.img" - vendor_boot.img if build_vendor_boot - RAMDISK_EXT=lz4 . Is used when ramdisk_compression (see below) is not specified. - The list contains ramdisk.<ramdisk_ext> which means it assumes build_boot_images generates this file. See build_utils.sh on conditions for when it is actually generated. - if build_vendor_boot , it assumes VENDOR_BOOTCONFIG is set and BOOT_IMAGE_HEADER_VERSION >= 4 , which creates vendor-bootconfig.img to contain VENDOR_BOOTCONFIG . - The list contains dtb.img | None |
modules_list | A file containing list of modules to use for vendor_boot.modules.load . | None |
modules_recovery_list | A file containing a list of modules to load when booting into recovery. | None |
modules_charger_list | A file containing a list of modules to load when booting into charger mode. | None |
modules_blocklist | A file containing a list of modules which are blocked from being loaded. This file is copied directly to staging directory, and should be in the format: blocklist module_name | None |
modules_options | Label to a file copied to /lib/modules/<kernel_version>/modules.options on the ramdisk.Lines in the file should be of the form: options <modulename> <param1>=<val> <param2>=<val> ... | None |
vendor_ramdisk_binaries | List of vendor ramdisk binaries which includes the device-specific components of ramdisk like the fstab file and the device-specific rc files. If specifying multiple vendor ramdisks and identical file paths exist in the ramdisks, the file from last ramdisk is used. Note: order matters. To prevent buildifier from sorting the list, add the following: # do not sort | None |
vendor_ramdisk_dev_nodes | List of dev nodes description files which describes special device files to be added to the vendor ramdisk. File format is as accepted by mkbootfs. | None |
system_dlkm_fs_type | Deprecated. Use system_dlkm_fs_types instead.Supported filesystems for system_dlkm image are ext4 and erofs . Defaults to ext4 if not specified. | None |
system_dlkm_fs_types | List of file systems type for system_dlkm images.Supported filesystems for system_dlkm image are ext4 and erofs . If not specified, builds system_dlkm.img with ext4 else builds system_dlkm.<fs>.img for each file system type in the list. | None |
system_dlkm_modules_list | location of an optional file containing the list of kernel modules which shall be copied into a system_dlkm partition image. | None |
system_dlkm_modules_blocklist | location of an optional file containing a list of modules which are blocked from being loaded. This file is copied directly to the staging directory and should be in the format: blocklist module_name | None |
system_dlkm_props | location of a text file containing the properties to be used for creation of a system_dlkm image (filesystem, partition size, etc). If this is not set (and build_system_dlkm is), a default set of properties will be used which assumes an ext4 filesystem and a dynamic partition. | None |
vendor_dlkm_archive | If set, enable archiving the vendor_dlkm staging directory. | None |
vendor_dlkm_etc_files | Files that need to be copied to vendor_dlkm.img etc/ directory. | None |
vendor_dlkm_fs_type | Supported filesystems for vendor_dlkm.img are ext4 and erofs . Defaults to ext4 if not specified. | None |
vendor_dlkm_modules_list | location of an optional file containing the list of kernel modules which shall be copied into a vendor_dlkm partition image. Any modules passed into MODULES_LIST which become part of the vendor_boot.modules.load will be trimmed from the vendor_dlkm.modules.load . | None |
vendor_dlkm_modules_blocklist | location of an optional file containing a list of modules which are blocked from being loaded. This file is copied directly to the staging directory and should be in the format: blocklist module_name | None |
vendor_dlkm_props | location of a text file containing the properties to be used for creation of a vendor_dlkm image (filesystem, partition size, etc). If this is not set (and build_vendor_dlkm is), a default set of properties will be used which assumes an ext4 filesystem and a dynamic partition. | None |
ramdisk_compression | If provided it specfies the format used for any ramdisks generated. If not provided a fallback value from build.config is used. Possible values are lz4 , gzip , None. | None |
ramdisk_compression_args | Command line arguments passed only to lz4 command to control compression level. It only has effect when used with ramdisk_compression equal to “lz4”. | None |
unpack_ramdisk | When set to False , skips unpacking the vendor ramdisk and copy it as is, without modifications, into the boot image. Also skips the mkbootfs step. | None |
avb_sign_boot_img | If set to True signs the boot image using the avb_boot_key. The kernel prebuilt tool avbtool is used for signing. | None |
avb_boot_partition_size | Size of the boot partition in bytes. Used when avb_sign_boot_img is True. | None |
avb_boot_key | Path to the key used for signing. Used when avb_sign_boot_img is True. | None |
avb_boot_algorithm | avb_boot_key algorithm used e.g. SHA256_RSA2048. Used when avb_sign_boot_img is True. | None |
avb_boot_partition_name | = Name of the boot partition. Used when avb_sign_boot_img is True. | None |
dedup_dlkm_modules | If set, modules already in system_dlkm is excluded in vendor_dlkm.modules.load . Modules in vendor_dlkm is allowed to link to modules in system_dlkm .The system_dlkm image is defined by the following:- If build_system_dlkm is set, the system_dlkm image built by this rule. - If build_system_dlkm is not set, the system_dlkm image in base_kernel_images . If base_kernel_images is not set, build fails.If set, additional changes in the userspace is required so that system_dlkm modules are loaded before vendor_dlkm modules. | None |
create_modules_order | Whether to create and keep a modules.order file generated by a postorder traversal of the kernel_modules_install sources. It applies to building initramfs and vendor_dlkm . | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Generates a rule that builds an external kernel module.
Example:
kernel_module( name = "nfc", srcs = glob([ "**/*.c", "**/*.h", # If there are Kbuild files, add them "**/Kbuild", # If there are additional makefiles in subdirectories, add them "**/Makefile", ]), outs = ["nfc.ko"], kernel_build = "//common:kernel_aarch64", )
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name of this kernel module. | none |
kernel_build | Label referring to the kernel_build module. | none |
outs | The expected output files. If unspecified or value is None , it is ["{name}.ko"] by default.For each token out , the build rule automatically finds a file named out in the legacy kernel modules staging directory. The file is copied to the output directory of this package, with the label name/out .- If out doesn't contain a slash, subdirectories are searched.Example: kernel_module(name = “nfc”, outs = [“nfc.ko”]) The build system copies <legacy modules staging dir>/lib/modules//extra/<some subdir>/nfc.ko to <package output dir>/nfc.ko nfc/nfc.ko is the label to the file.- If out contains slashes, its value is used. The file is also copied to the top of package output directory.For example: kernel_module(name = “nfc”, outs = [“foo/nfc.ko”]) The build system copies <legacy modules staging dir>/lib/modules//extra/foo/nfc.ko to foo/nfc.ko nfc/foo/nfc.ko is the label to the file.The file is also copied to <package output dir>/nfc.ko .nfc/nfc.ko is the label to the file.See search_and_cp_output.py for details. | None |
srcs | Source files to build this kernel module. If unspecified or value is None , it is by default the list in the above example: glob([
“**/*.c”,
“**/*.h”,
“**/Kbuild”,
“**/Makefile”,
]) | None |
deps | A list of other kernel_module or ddk_module dependencies.Before building this target, Modules.symvers from the targets in deps are restored, so this target can be built against them.It is an undefined behavior to put targets of other types to this list (e.g. ddk_headers ). | None |
makefile | Makefile for the module. By default, this is Makefile in the current package.This file determines where make modules is executed.This is useful when the Makefile is located in a different package or in a subdirectory. | None |
generate_btf | Allows generation of BTF type information for the module. If enabled, passes vmlinux image to module build, which is required by BTF generator makefile scripts.Disabled by default. Requires CONFIG_DEBUG_INFO_BTF enabled in base kernel.Requires rebuild of module if vmlinux changed, which may lead to an increase of incremental build time.BTF type information increases size of module binary. | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
A test on artifacts produced by kernel_module.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of test | none |
modules | The list of *.ko kernel modules, or targets that produces *.ko kernel modules (e.g. kernel_module). | None |
kwargs | Additional attributes to the internal rule, e.g. visibility . See complete list here. | none |
Defines a native cc_library based on a kernel's UAPI headers.
Example:
kernel_uapi_headers_cc_library( name = "uapi_header_lib", kernel_build = "//common:kernel_aarch64", ) cc_binary( name = "foo", srcs = ["foo.c"], deps = [":uapi_header_lib"], )
Internally, the kernel_build
‘s UAPI header output tarball is unpacked. Then, a header-only cc_library
is generated. This allows other native Bazel C/C++ rules to add the kernel’s UAPI headers as a dependency.
The library will automatically include the header directory in the dependent build, so source files are free to simply include the UAPI headers they need.
Note: the kernel_build
's output UAPI header tarball includes the usr/include
prefix. The prefix is stripped while creating this library. To include the file usr/include/linux/time.h
from the tarball, a source file would #include <linux/time.h>
.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name of target. | none |
kernel_build | kernel_build | none |
A kunit test.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | name of the test | none |
test_name | name of the kunit test suite | none |
modules | list of modules to be installed for kunit test | none |
deps | dependencies for kunit test runner | none |
kwargs | additional arguments for py_test | none |