blob: 70d40ac26b3d29862739fd2ffe5b4e427f2b3c53 [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")
declare_args() {
# Where to find Zircon's host-side tools that are run as part of the build.
zircon_tools_dir = "//out/build-zircon/tools"
# Zircon build directory for `target_cpu`, containing `.manifest` and
# `.bin` files for Zircon's BOOTFS, BOOTDATA, and kernel image.
zircon_build_dir = "//out/build-zircon/build-${target_cpu}"
}
# 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
}
}