| # Copyright 2018 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/sdk/sdk_atom.gni") |
| |
| # An executable which can be bundled in an SDK. |
| # |
| # An equivalent to the built-in executable which adds an SDK atom declaration to |
| # allow the resulting binary to be included in an SDK. |
| # |
| # category (required) |
| # Publication level of the executable in SDKs. |
| # See //build/sdk/sdk_atom.gni. |
| # |
| # sdk_deps (optional) |
| # List of labels representing elements that should be added to SDKs |
| # alongside the present binary. |
| # Labels in the list must represent SDK-ready targets. |
| |
| template("sdk_executable") { |
| assert(defined(invoker.category), "Must define an SDK category") |
| |
| main_target_name = target_name |
| |
| executable(main_target_name) { |
| forward_variables_from(invoker, "*", [ "category" ]) |
| } |
| |
| output_name = target_name |
| if (defined(invoker.output_name)) { |
| output_name = invoker.output_name |
| } |
| |
| if (!is_fuchsia) { |
| file_base = "tools/$output_name" |
| |
| sdk_atom("${target_name}_sdk") { |
| id = "sdk://tools/$output_name" |
| |
| category = invoker.category |
| |
| meta = { |
| dest = "$file_base-meta.json" |
| schema = "host_tool" |
| value = { |
| type = "host_tool" |
| name = output_name |
| root = "tools" |
| files = [ file_base ] |
| } |
| } |
| |
| files = [ |
| { |
| source = "$root_out_dir/$output_name" |
| dest = file_base |
| }, |
| ] |
| |
| if (defined(invoker.sdk_deps)) { |
| deps = invoker.sdk_deps |
| } |
| |
| non_sdk_deps = [ ":$main_target_name" ] |
| } |
| } |
| } |