blob: 75064ab6117204cd3beb16a20f08bda77de239b5 [file] [log] [blame]
# 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("//build/config/clang/clang.gni")
# This is $root_build_dir in the Zircon GN build.
zircon_root_build_dir = "//out/build-zircon"
# The top-level `tools` Ninja target in Zircon puts the tool binaries here.
zircon_tools_dir = "$zircon_root_build_dir/tools"
# The `gn gen` stage of the Zircon GN build writes this file.
# It's a list of {name=... path=... type=...} scopes.
zircon_images = read_file("$zircon_root_build_dir/images.json", "json")
foreach(image, zircon_images) {
if (image.name == "kernel" && image.type == "zbi" && image.cpu == target_cpu) {
zircon_kernel_zbi = "$zircon_root_build_dir/${image.path}"
}
}
# Template for running a Zircon host tool as part of the build.
# This is a thin wrapper to define an `action()` target.
#
# Parameters
#
# tool (required)
# [string] The name of the tool, like "mkbootfs".
#
# args (required)
# [list of strings] The arguments to pass the tool.
# The tool runs with `root_build_dir` as its current directory,
# so any file names should be made either absolute or relative
# to `root_build_dir` using `rebase_path()`.
#
# All other parameters are exactly as for `action()`, except
# that `script` is replaced with `tool`.
#
template("zircon_tool_action") {
assert(defined(invoker.tool), "zircon_tool_action() requires `tool`")
assert(defined(invoker.args), "zircon_tool_action() requires `args`")
_tool = "$zircon_tools_dir/${invoker.tool}"
action(target_name) {
inputs = []
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
forward_variables_from(invoker,
"*",
[
"args",
"script",
"tool",
"testonly",
"visibility",
])
script = "//build/gn_run_binary.sh"
inputs += [ _tool ]
args = [
clang_prefix,
rebase_path(_tool, root_build_dir),
] + invoker.args
}
}