| # Copyright 2023 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/images/args.gni") |
| import("//build/zircon/zircon_cpu.gni") |
| import("//zircon/kernel/phys/phys_executable.gni") |
| import("//zircon/kernel/phys/qemu.gni") |
| |
| # Defines a public target with the appropriate metadata to be used |
| # as a kernel for QEMU. |
| # |
| # Parameters |
| # |
| # * import |
| # - Optional: A .gni file to import(). This should define the $target_type |
| # template. A template not already in scope in shim_executable.gni |
| # itself cannot be used as $target_type without this, even if the |
| # template is already in scope in the file invoking shim_executable(). |
| # - Type: path |
| # |
| # * target_type |
| # - Optional: Target type (template) to define. |
| # - Type: string |
| # - Default: "phys_executable" |
| # |
| # See phys_executable() (or the passed $target_type() template) for other |
| # parameters and details. |
| template("shim_executable") { |
| if (defined(invoker.import)) { |
| import(invoker.import) |
| } |
| |
| if (defined(invoker.target_type)) { |
| target_type = invoker.target_type |
| } else { |
| target_type = "phys_executable" |
| } |
| |
| target(target_type, target_name) { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "image_metadata", |
| "import", |
| "target_type", |
| ]) |
| |
| if (qemu_boot_shim.name == target_name) { |
| # This marks it as the official default boot shim for using QEMU. |
| images_metadata = { |
| name = "qemu-kernel" |
| archive = add_qemu_to_build_archives |
| } |
| } |
| } |
| } |
| |
| _phys_import = { |
| import("//zircon/kernel/arch/$zircon_cpu/phys/phys.gni") |
| } |
| |
| set_defaults("shim_executable") { |
| configs = default_executable_configs + _phys_import.phys_zbi_configs |
| } |