blob: dc797dde706012df8db41a0776f62c6ade1aa85f [file] [log] [blame] [edit]
# 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/toolchain/default_tools.gni")
# Define a basic GN toolchain() instance that only has the "stamp" and "copy"
# tools. Use this for toolchains that will only have action() targets.
#
# Parameters:
# expected_label: Optional
# If provided, this template will assert that the full toolchain label
# matches this value. This is useful when the definition should match
# a global variable (e.g. go_toolchain or dart_toolchain).
# Type: GN label
#
# toolchain_args: Optional
# A scope of extra toolchain_args keys for this toolchain instance.
#
# NOTE: This also ensures this defines the global `toolchain_variant.base`
# variable, allowing BUILDCONFIG.gn to detect that this is not the default
# toolchain (see the definition of in_default_toolchain in that file for
# more details).
template("basic_toolchain") {
if (current_toolchain == default_toolchain) {
# This needs to be passed to basic toolchains because they can
# include configs() that depend on it.
_pass_through_clang_toolchain_info = clang_toolchain_info
# Basic toolchains should only be expanded once in the default toolchain.
toolchain(target_name) {
tool("stamp") {
command = stamp_command
description = stamp_description
}
tool("copy") {
command = copy_command
description = copy_description
}
toolchain_args = {
if (defined(invoker.toolchain_args)) {
forward_variables_from(invoker.toolchain_args, "*")
}
toolchain_variant = {
}
toolchain_variant = {
# This is a "basic" toolchain
is_basic = true
base = get_label_info(":$target_name", "label_no_toolchain")
if (defined(invoker.expected_label)) {
assert(
base == invoker.expected_label,
"Invalid toolchain label $base, expected ${invoker.expected_label}")
}
}
clang_toolchain_info = {
}
clang_toolchain_info = _pass_through_clang_toolchain_info
# LINT.IfChange(in_default_toolchain)
in_default_toolchain = false
# LINT.ThenChange(//build/config/BUILDCONFIG.gn:in_default_toolchain)
}
}
} else {
not_needed("*")
not_needed(invoker, "*")
}
}