| # Copyright 2026 The Fuchsia Authors | |
| # | |
| # Use of this source code is governed by a MIT-style | |
| # license that can be found in the LICENSE file or at | |
| # https://opensource.org/licenses/MIT | |
| import("//build/zbi/zbi.gni") | |
| # Defines a kernel image, i.e., a (bootable) ZBI containing a KERNEL item. | |
| # | |
| # Parameters | |
| # | |
| # * deps | |
| # - Required: Dependencies reaching `zbi_input()` targets, comprising the | |
| # image contents. | |
| # - Type: list(label) | |
| # | |
| # * output_name, testonly, visibility | |
| # - Optional: The usual GN meanings. | |
| # | |
| template("kernel_image") { | |
| assert( | |
| current_toolchain == default_toolchain, | |
| "kernel_image($target_name) should only be evaluated in the default toolchain, not $current_toolchain") | |
| zbi(target_name) { | |
| forward_variables_from(invoker, | |
| [ | |
| "testonly", | |
| "visibility", | |
| "output_name", | |
| "deps", | |
| ]) | |
| if (!defined(output_name)) { | |
| output_name = target_name | |
| } | |
| compress = "zstd.max" | |
| output_dir = root_out_dir | |
| output_extension = "zbi" | |
| output_path = rebase_path("$output_dir/$output_name.$output_extension", | |
| root_build_dir) | |
| metadata = { | |
| # For the //:images build_api_module(). | |
| images = [ | |
| { | |
| label = get_label_info(":$target_name", "label_with_toolchain") | |
| name = "kernel" | |
| tags = [ "incomplete" ] | |
| type = "zbi" | |
| path = output_path | |
| cpu = current_cpu | |
| }, | |
| ] | |
| } | |
| } | |
| } |