blob: 221ca3e285bd858e3a365024b2f9dc5947010d23 [file] [log] [blame]
# Copyright 2021 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.
# Template used internally by python_action() and others below
# Uses the same parameters as their callers, with the addition of:
#
# Parameters:
# target_type: Inner target type to invoke (e.g. "action")
#
template("_python_action") {
assert(
defined(invoker.binary_label),
"The label of the python_binary() to use to perform the action must be specified.")
# force the binary_label into the host toolchain
binary_label_no_toolchain =
get_label_info(invoker.binary_label, "label_no_toolchain")
binary_label = "${binary_label_no_toolchain}(${host_toolchain})"
binary_label_name = get_label_info(binary_label, "name")
binary_tool_output_dir = get_label_info(binary_label, "target_out_dir")
binary_tool_output_name = "${binary_tool_output_dir}/${binary_label_name}.pyz"
target(invoker.target_type, target_name) {
forward_variables_from(invoker,
"*",
[
"deps",
"binary_label",
"script",
"target_type",
])
script = binary_tool_output_name
deps = [ binary_label ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
}
# Declares an action() that uses a python_binary for the script
#
# This sets up the python module search path using the GN paths specified, and
# otherwise is the same as an action(), forwarding all invoker vars to the
# action()
#
# Parameters:
#
# binary_label
# [label] Label (without host toolchain), to python binary that is to be
# executed by the action.
#
# all others are passed to action() as expected,
#
template("python_action") {
_python_action(target_name) {
forward_variables_from(invoker, "*")
target_type = "action"
}
}
# Declares an hermetic_inputs_action() that uses a python_binary for the script
#
# This is useful if the action's command is not hermetic, which is allowed
# for those that generate hermetic input files. See documentation for action()
# and hermetic_inputs_action() in //build/config/BUILDCONFIG.gn for more details.
#
# This sets up the python module search path using the GN paths specified, and
# otherwise is the same as an action(), forwarding all invoker vars to the
# action()
#
# Parameters:
#
# binary_label
# [label] Label (without host toolchain), to python binary that is to be
# executed by the action.
#
# all others are passed to hermetic_inputs_action() as expected,
#
template("python_hermetic_inputs_action") {
_python_action(target_name) {
forward_variables_from(invoker, "*")
target_type = "hermetic_inputs_action"
}
}