blob: 7d1f09e891a20db4b12e2c63c14334a72b918762 [file] [log] [blame]
# Copyright 2022 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("toolchain.gni")
# Build an executable for the kernel.efi environment.
#
# This just defines an executable() target, but it's always in the toolchain
# for the kernel.efi environment for $current_cpu.
#
# Parameters
#
# * install_path
# - Optional: If set, this specifies in the destination in FAT filesystem
# when aggregated as a dependency of `fat_filesystem()` - at which this
# executable should be installed
# - Type: relative path
#
# * output_extension
# - Optional: See executable(), but defaults to "efi".
# - Type: string
# - Default: "efi"
#
# See executable() for other parameters.
template("efi_executable") {
if (!is_efi) {
group(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
public_deps = [ ":$target_name($efi_toolchain)" ]
}
not_needed(invoker, "*")
} else {
executable(target_name) {
forward_variables_from(invoker,
"*",
[
"install_path",
"metadata",
])
if (defined(visibility)) {
# Make sure it's visible to the redirector group above.
visibility += [ ":$target_name" ]
}
if (!defined(output_extension)) {
output_extension = "efi"
}
if (!defined(output_name)) {
output_name = target_name
}
metadata = {
if (defined(invoker.metadata)) {
forward_variables_from(invoker.metadata, "*")
}
if (defined(invoker.install_path)) {
if (!defined(distribution_entries)) {
distribution_entries = []
}
distribution_entries += [
{
source = rebase_path(
"${root_out_dir}/${output_name}.${output_extension}",
root_build_dir)
destination = invoker.install_path
label = get_label_info(":$target_name", "label_with_toolchain")
},
]
}
}
}
}
}
if (is_efi) {
set_defaults("efi_executable") {
configs = default_executable_configs
}
}
# TODO(mcgrathr): EFI compilation not there yet on RISC-V
have_efi = current_cpu != "riscv64"