blob: d2afc2bfbdcd8a911454c38f30c5e8f243944fd4 [file] [log] [blame]
# Copyright 2020 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/zircon/zircon_cpu.gni")
import("//zircon/kernel/phys/phys_executable.gni")
# Build a standalone ZBI kernel in the phys environment.
#
# This defines one public target that acts as a zbi_input() target. The
# target is used like executable(), but deps on this target from other
# environments transparently redirect to the phys environment. There
# are also implicit deps to supply the ZBI headers and phys entry point
# code that calls the C++ `ZbiMain` via the "main.h" API.
#
# Parameters
#
# * output_extension
# - Optional: See executable(), but defaults to "zbi".
# - Type: string
# - Default: "zbi"
#
# See executable() for other parameters.
#
template("zbi_executable") {
phys_executable(target_name) {
deps = []
ldflags = []
forward_variables_from(invoker,
"*",
[
"metadata",
"visibility",
])
forward_variables_from(invoker, [ "visibility" ])
# zbi-header.S needs this linker script. Note it must go before the main
# phys.ld (at least for BFD ld); phys_executable will append it to ldflags.
ldflags += [ "-Wl,-T," + rebase_path("//zircon/kernel/phys/zbi-header.ld",
root_build_dir) ]
deps += [ "//zircon/kernel/phys:zbi_executable.deps" ]
if (!defined(output_dir)) {
output_dir = target_out_dir
}
if (!defined(output_name)) {
output_name = target_name
}
if (!defined(output_extension)) {
output_extension = "zbi"
}
output_file = "$output_dir/$output_name"
if (output_extension != "") {
output_file += ".$output_extension"
}
metadata = {
zbi_input_args = []
if (defined(invoker.metadata)) {
forward_variables_from(invoker.metadata, "*")
}
# Used by zbi() template. This metadata makes the kernel act as a
# zbi_input() target so it can be a dependency of a zbi() target to get
# into the image.
zbi_input_args += [
"--type=container",
rebase_path(output_file, root_build_dir),
]
}
}
}
_phys_import = {
import("//zircon/kernel/arch/$zircon_cpu/phys/phys.gni")
}
set_defaults("zbi_executable") {
configs = default_executable_configs + _phys_import.phys_zbi_configs
}