构建内核

命令行选项 {#options}

内核命令行选项是定义在 kernel_cmdline 模版上:

  1. import("//build/zbi/kernel_cmdline.gni")
  2. kernel_cmdline("foobar") {
  3. args = [ "foobar=true" ]
  4. }

一个命令参数可以包含多个选项:

  1. import("//build/zbi/kernel_cmdline.gni")
  2. kernel_cmdline("debug") {
  3. args = [
  4. "debug.this=true",
  5. "debug.that=false",
  6. ]
  7. }

生成的GN标签应该通过GN参数插入到构建图中。注意,如果这些选项在由这样一个GN参数定义在依赖树中,那么它们将被考虑在内

指定版型(board)和产品(product)文件的选项

版型 或者 产品 文件中,将所需cmdline 选项的标签添加到 board_bootfs_babelsproduct_bootfs_labels

要改变 zedboot 或着 恢复版本的内核选项,请将标签添加到 board_zedboot_bootfs_labelsboard_recovery_bootfs_labels

在本地指定选项

Create a BUILD.gn file somewhere under //local to host the options targets. Note that this folder is not tracked by git and therefore might not exist yet in your checkout.

//local 下的某个地方创建一个 BUILD.gn 文件,以设置目标的选项。注意,这个文件夹不没有git 跟踪,因此可能当你检查的时候不存在。

使用dev_bootfs_labels 将选项注入到通过fx set 构建中,

  1. fx set ... --args='dev_bootfs_labels=["//local/path/to/my:options"]'

To locally alter kernel options for the zedboot or recovery build, follow the same procedure but use respectively dev_zedboot_bootfs_labels and dev_recovery_bootfs_labels to introduce the options into the build.

要在本地更改 zedboot 和 恢复版本的内核选项,请遵循相同的步骤,但分别使用 dev_zedboot_bootfs_labelsdev_recovery_bootfs_labels 将选项引入构建。