| # Copyright 2019 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("prebuilt.gni") |
| |
| # Declare a prebuilt tool for use with host_tool_action(). |
| # |
| # Parameters |
| # |
| # script |
| # - Optional: Path of a prebuilt binary. (Required unless $args is defined. |
| # Omitted if not an explicit file path.) |
| # - Type: file |
| # args |
| # - Optional: Additional arguments to pass to the $script. When $script is |
| # omitted, this is the full command. |
| # - Type: list(string) |
| # inputs |
| # - Optional: Dependencies for the pre-built. All implicit dependencies to |
| # $args must be listed ($script is always a dependency). |
| # - Type: list(file) |
| |
| template("prebuilt_host_tool") { |
| assert(defined(invoker.args) || defined(invoker.script), |
| "A script or args must be defined for $target_name") |
| |
| # A no-op group that only propogates metadata. |
| group(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "inputs", |
| "testonly", |
| "visibility", |
| ]) |
| |
| if (!defined(inputs)) { |
| inputs = [] |
| } |
| |
| if (defined(invoker.script)) { |
| inputs += [ invoker.script ] |
| } |
| |
| metadata = { |
| # Dependencies come before the "--". |
| host_tool_rspfile = rebase_path(inputs, root_build_dir) |
| host_tool_rspfile += [ "--" ] |
| |
| # The command line to run comes after the "--". |
| if (defined(invoker.script)) { |
| host_tool_rspfile += [ rebase_path(invoker.script, root_build_dir) ] |
| } |
| if (defined(invoker.args)) { |
| host_tool_rspfile += invoker.args |
| } |
| } |
| } |
| } |