| # Copyright 2021 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_input.gni") | |
| # Defines a kernel package, a directory namespace within a STORAGE_KERNEL ZBI | |
| # item in the BOOTFS format, for a dependent zbi() target. This namespace - | |
| # given by $target_name - is comprised of the resource() targets - or those | |
| # that contribute resource()-like metadata - within the dependency graph. | |
| # | |
| # Parameters | |
| # | |
| # * deps | |
| # - Required: Dependencies to reach all `resource()` targets and the like. | |
| # Note that this should *not* reach another kernel_package() target (or, | |
| # equivalently, a zbi_input() with $prefix set) as the $target_name | |
| # prefix would *not* compound the prefix on a target in this $deps list. | |
| # Instead, distribution_manifest() targets with $prefix set can be used | |
| # to "layer" the kernel-package prefix on a prefixed collection inside. | |
| # - Type: list(label) | |
| # | |
| # * data_deps | |
| # - Optional: The usual GN meaning, though in this case no resource() | |
| # targets in its graph will contribute to the dependent ZBI. | |
| # - Type: list(label) | |
| # | |
| # * prefix | |
| # - Optional: The directory prefix for files reached by `deps`. | |
| # This should be left to the default for actual kernel packages, | |
| # and used only for special cases that go outside package selection. | |
| # - Type: string | |
| # - Default: "$target_name" | |
| # | |
| # * metadata, testonly, visibility | |
| # - Optional: The usual GN meanings. | |
| # | |
| template("kernel_package") { | |
| zbi_input(target_name) { | |
| forward_variables_from(invoker, | |
| [ | |
| "data_deps", | |
| "deps", | |
| "prefix", | |
| "testonly", | |
| "visibility", | |
| ]) | |
| args = [ | |
| # Package entries are relatively small and should compress quickly | |
| # enough. | |
| "--compressed=max", | |
| "--files-type=kernel", | |
| ] | |
| # This prefix will apply in the zbi command line to the zbi_input_args | |
| # elements that come directly from this zbi_input() target, i.e. via the | |
| # implicit distribution_manifest() collection done here. But it won't | |
| # apply to the zbi_input_args metadata found in deps/data_deps, which | |
| # appear *before* this target's zbi_input_args in the zbi() collection. | |
| if (!defined(prefix)) { | |
| prefix = target_name | |
| } | |
| } | |
| } |