| # Copyright 2020 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. |
| |
| # Generates FFX subcommand with a plugin commands |
| # |
| |
| import("//build/python/python_action.gni") |
| |
| template("command") { |
| output_name = target_name |
| if (defined(invoker.output_name)) { |
| output_name = invoker.output_name |
| } |
| plugin_deps = [] |
| if (defined(invoker.plugin_deps)) { |
| plugin_deps += invoker.plugin_deps |
| } |
| |
| libraries = [] |
| foreach(dep, plugin_deps) { |
| libraries += [ get_label_info(dep, "name") ] |
| } |
| |
| generated_file = "$target_gen_dir/" + output_name |
| |
| python_action(target_name) { |
| binary_label = "//src/developer/ffx/build:gn_generate_cmd" |
| template = "//src/developer/ffx/build/templates/command.rs.jinja" |
| args = [ |
| "--out", |
| rebase_path(generated_file, root_build_dir), |
| "--deps", |
| string_join(",", libraries), |
| "--template", |
| rebase_path(template, root_build_dir), |
| ] |
| |
| # Rebuild if the template changes |
| inputs = [ template ] |
| outputs = [ generated_file ] |
| deps = [ "//src/developer/ffx/build:gn_generate_cmd" ] |
| } |
| } |