| # 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. | |
| import("//build/images/shell_commands.gni") | |
| import("fuchsia_component.gni") | |
| import("fuchsia_package.gni") | |
| # Defines a package that contains shell commands. | |
| # See: https://fuchsia.dev/fuchsia-src/development/components/build | |
| # | |
| # Parameters | |
| # | |
| # package_name (optional) | |
| # The name of the package. | |
| # Type: string | |
| # Default: target_name | |
| # | |
| # manifest (optional) | |
| # If your shell program can also be launched as a component, | |
| # then specify the component manifest here. | |
| # Type: path | |
| # | |
| # data_deps | |
| # deps | |
| # testonly | |
| # visibility | |
| template("fuchsia_shell_package") { | |
| if (current_toolchain == default_toolchain) { | |
| package_name = target_name | |
| if (defined(invoker.package_name)) { | |
| package_name = invoker.package_name | |
| } | |
| shell_command_target = "${target_name}_shell_command" | |
| shell_command(shell_command_target) { | |
| forward_variables_from(invoker, | |
| [ | |
| "deps", | |
| "testonly", | |
| ]) | |
| visibility = [ ":*" ] | |
| package_name = package_name | |
| } | |
| if (defined(invoker.manifest)) { | |
| component_target = "${target_name}_component" | |
| fuchsia_component(component_target) { | |
| forward_variables_from(invoker, | |
| [ | |
| "data_deps", | |
| "deps", | |
| "manifest_deps", | |
| "testonly", | |
| ]) | |
| visibility = [ ":*" ] | |
| manifest = invoker.manifest | |
| component_name = package_name | |
| } | |
| } | |
| fuchsia_package(target_name) { | |
| forward_variables_from(invoker, | |
| [ | |
| "data_deps", | |
| "deps", | |
| "disable_elf_binaries_checks", | |
| "testonly", | |
| "visibility", | |
| ]) | |
| package_name = package_name | |
| if (!defined(deps)) { | |
| deps = [] | |
| } | |
| deps += [ ":$shell_command_target" ] | |
| if (defined(component_target)) { | |
| deps += [ ":$component_target" ] | |
| } | |
| # The shell environment is not intended for production use. | |
| deps += [ "//build/validate:non_production_tag" ] | |
| } | |
| } else { | |
| group(target_name) { | |
| forward_variables_from(invoker, | |
| [ | |
| "testonly", | |
| "visibility", | |
| ]) | |
| deps = [ ":$target_name($default_toolchain)" ] | |
| } | |
| not_needed(invoker, "*") | |
| } | |
| } |