blob: ebde8b272540464bff359ff16173a5e1b0e9b626 [file] [log] [blame]
# Copyright 2017 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.
declare_args() {
# This is the directory where host tools intended for manual use by
# developers get installed. It's something a developer might put
# into their shell's $PATH. Host tools that are just needed as part
# of the build do not get copied here. This directory is only for
# things that are generally useful for testing or debugging or
# whatnot outside of the GN build itself. These are only installed
# by an explicit install_host_tools() rule (see //build/host.gni).
host_tools_dir = "$root_build_dir/tools"
}
# This declares that a host tool (a target built in host_toolchain)
# should be installed in host_tools_dir. This target can be used in
# any toolchain, and it will forward to host_toolchain.
#
# Parameters
#
# outputs (required)
# [files list] Simple file name of each tool, should be the
# same as the output_name in the executable() or similar rule
# (which is usually just that target's name).
#
# deps (recommended)
# [label list] Should list each target that actually builds each output.
# It does not need to use explicit toolchain suffixes; the only target
# using the deps will be instantiated only in host_toolchain.
#
# testonly (optional)
# visibility (optional)
# Standard GN meaning.
#
# Example of usage:
#
# executable("frob") { ... }
# install_host_tools("fiddlers") {
# deps = [ ":frob", "//some/other/dir:twiddle" ]
# outputs = [ "frob", "twiddle" ]
# }
template("install_host_tools") {
assert(defined(invoker.outputs), "install_host_tools() must define outputs")
copy(target_name) {
forward_variables_from(invoker,
[
"deps",
"testonly",
"visibility",
])
if (defined(visibility)) {
visibility += [ ":$target_name" ]
}
outputs = [
"$host_tools_dir/{{source_file_part}}",
]
sources = []
foreach(output_name, invoker.outputs) {
sources += [ "$root_out_dir/$output_name" ]
}
}
}