blob: 700f3eaf26e1bbba8eb0ce1662afa5817d43c18a [file] [log] [blame]
# 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/sdk/sdk_atom.gni")
# Defines a host tool in the SDK.
#
# Parameters
# category (required)
# Publication level of the executable in SDKs.
# See //build/sdk/sdk_atom.gni.
#
# binary (optional)
# Path to the tool binary. Defaults to "$root_out_dir/$output_name".
#
# output_name (optional)
# The tool's name. Inferred from target_name by default.
#
# 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.
#
# deps, etc.
# Usual GN meaning.
template("sdk_host_tool") {
assert(defined(invoker.category), "Must define an SDK category")
output_name = target_name
if (defined(invoker.output_name)) {
output_name = invoker.output_name
}
binary = "$root_out_dir/$output_name"
if (defined(invoker.binary)) {
binary = invoker.binary
}
gn_deps = []
if (defined(invoker.deps)) {
gn_deps += invoker.deps
}
file_base = "tools/$output_name"
# TODO(fxb/42999): remove extra atom
if (current_cpu == host_cpu) {
sdk_atom("${target_name}_legacy") {
id = "sdk://$file_base"
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 = binary
dest = file_base
},
]
if (defined(invoker.sdk_deps)) {
deps = invoker.sdk_deps
}
non_sdk_deps = gn_deps
}
}
if (host_os == "linux" || host_os == "mac") {
file_base = "tools/$current_cpu/$output_name"
}
sdk_atom(target_name) {
id = "sdk://$file_base"
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 = binary
dest = file_base
},
]
if (defined(invoker.sdk_deps)) {
deps = invoker.sdk_deps
}
non_sdk_deps = invoker.deps
}
}