blob: 7628dc178e36cb2640ab3a6348776b1d2570b249 [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/python/python.gni")
# Declares an action that executes a python script.
#
# Has the exact same API as the built-in `action` template, but under the hood
# ensures the use of the in-tree python interpreter so that the script doesn't
# rely on which python happens to be in the PATH.
template("python_action") {
assert(defined(invoker.script), "script is required")
_without_dot_py = string_replace(invoker.script, ".py", "")
assert(_without_dot_py + ".py" == invoker.script,
"script must be a python file, got " + invoker.script)
action(target_name) {
forward_variables_from(invoker,
"*",
[
"args",
"script",
])
script = python_exe_src
args = [ rebase_path(invoker.script, root_build_dir) ]
if (defined(invoker.args)) {
args += invoker.args
}
}
}