blob: 8c68856e96f368f7903721f690721a84c1f4f07b [file] [edit]
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//src/developer/ffx/build/ffx_action.gni")
import("//zircon/kernel/phys/efi/toolchain.gni")
# Build an "EFI System Partition" target for EFI targets.
#
# Parameters
#
# deps (optional)
# [list of labels] Targets that generate the other inputs.
#
# output_name (optional, default: `target_name`)
# output_extension (optional, default: `".esp.blk"`)
# [string] Determines the file name, in `root_out_dir`.
#
# bootdata_bin (optional)
# [path] Must be a ramdisk that compliments zircon_bin.
#
# zircon_bin (optional)
# [path] A zircon kernel.
#
# zedboot (optional)
# [label] A Zedboot `zbi()` target.
#
# cmdline (optional)
# [path] A bootloader (Gigaboot) cmdline file to include in the EFI root.
#
# gigaboot_bin(optional)
# [path] Path to the gigaboot binary. Defaults to the binary generated by
# src/firmware/gigaboot.
#
# gigaboot_target(optional)
# [label] The dependency target required for having `gigaboot_bin`, Defaults
# to src/firmware/gigaboot.
template("esp") {
if (defined(invoker.output_name)) {
output_file = invoker.output_name
} else {
output_file = target_name
}
if (defined(invoker.output_extension)) {
if (invoker.output_extension != "") {
output_file += ".${invoker.output_extension}"
}
} else {
output_file += ".esp.blk"
}
output_file = "$root_out_dir/$output_file"
ffx_action(target_name) {
forward_variables_from(invoker,
[
"deps",
"metadata",
"testonly",
"visibility",
])
ffx_tool =
"//build/bazel/host:bazel_root_host_tools.ffx-efi_bazel_unversioned"
ffx_tool_output_name = "ffx-efi_bazel"
outputs = [ output_file ]
inputs = []
args = [
"efi",
"create",
"--output",
rebase_path(output_file, root_build_dir),
]
if (defined(invoker.zircon_bin)) {
args += [
"--zircon",
rebase_path(invoker.zircon_bin, root_build_dir),
]
inputs += [ invoker.zircon_bin ]
}
if (defined(invoker.bootdata_bin)) {
args += [
"--bootdata",
rebase_path(invoker.bootdata_bin, root_build_dir),
]
inputs += [ invoker.bootdata_bin ]
}
if (defined(invoker.zedboot)) {
args += [
"--zedboot",
rebase_path(invoker.zedboot, root_build_dir),
]
inputs += [ invoker.zedboot ]
}
if (defined(invoker.cmdline)) {
args += [
"--cmdline",
rebase_path(invoker.cmdline, root_build_dir),
]
inputs += [ invoker.cmdline ]
}
if (!defined(public_deps)) {
public_deps = []
}
gigaboot_target = "//src/firmware/gigaboot/cpp:fuchsia-efi($efi_toolchain)"
gigaboot_bin = get_label_info(gigaboot_target, "root_out_dir") + "/" +
"fuchsia-efi.efi"
if (defined(invoker.gigaboot_target)) {
gigaboot_target = invoker.gigaboot_target
}
if (defined(invoker.gigaboot_bin)) {
gigaboot_bin = invoker.gigaboot_bin
}
args += [
"--arch",
target_cpu,
"--efi-bootloader",
rebase_path(gigaboot_bin, root_build_dir),
]
inputs += [ gigaboot_bin ]
public_deps += [ gigaboot_target ]
}
}