| # 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("plugins") { |
| output_name = target_name |
| if (defined(invoker.output_name)) { |
| output_name = invoker.output_name |
| } |
| includes_subcommands = false |
| if (defined(invoker.plugin_deps)) { |
| includes_subcommands = true |
| } |
| |
| includes_execution = false |
| if (defined(invoker.includes_execution)) { |
| includes_execution = invoker.includes_execution |
| } |
| |
| generated_file = "$target_gen_dir/" + output_name |
| |
| script_args = [ |
| "--out", |
| rebase_path(generated_file, root_build_dir), |
| "--args", |
| invoker.args, |
| "--execution_lib", |
| invoker.execution_lib, |
| ] |
| if (includes_execution) { |
| script_args += [ |
| "--includes_execution", |
| "true", |
| ] |
| } |
| if (includes_subcommands) { |
| script_args += [ |
| "--includes_subcommands", |
| "true", |
| ] |
| } |
| if (defined(invoker.plugin_deps)) { |
| libraries = [] |
| foreach(dep, invoker.plugin_deps) { |
| libraries += [ get_label_info(dep, "name") ] |
| } |
| |
| lib_str = string_join(",", libraries) |
| script_args += [ |
| "--deps", |
| lib_str, |
| ] |
| } |
| if (defined(invoker.sub_command)) { |
| script_args += [ |
| "--sub_command", |
| invoker.sub_command, |
| ] |
| } |
| |
| python_action(target_name) { |
| binary_label = "//src/developer/ffx/build:gn_generate_plugins" |
| template = "//src/developer/ffx/build/templates/plugins.rs.jinja" |
| args = script_args + [ |
| "--template", |
| rebase_path(template, root_build_dir), |
| ] |
| |
| # Rebuild if the template changes |
| inputs = [ template ] |
| outputs = [ generated_file ] |
| deps = [ "//src/developer/ffx/build:gn_generate_plugins" ] |
| } |
| } |