build: consolidate gn templates (#34918)

This commit is contained in:
Shelley Vohr 2022-07-20 11:14:54 +02:00 committed by GitHub
parent 3c7d446fad
commit 1b96a3aa1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 47 deletions

View file

@ -1,33 +1,22 @@
import("node.gni")
template("node_action") {
assert(defined(invoker.script), "Need script path to run")
assert(defined(invoker.args), "Need script arguments")
# TODO(MarshallOfSound): Move to electron/node, this is the only place it is used now
# Run an action with a given working directory. Behaves identically to the
# action() target type, with the exception that it changes directory before
# running the script.
#
# Parameters:
# cwd [required]: Directory to change to before running the script.
template("chdir_action") {
action(target_name) {
forward_variables_from(invoker,
"*",
[
"script",
"args",
"deps",
"public_deps",
"sources",
"inputs",
"outputs",
])
assert(defined(cwd), "Need cwd in $target_name")
script = "//electron/build/run-in-dir.py"
if (defined(sources)) {
sources += [ invoker.script ]
} else {
assert(defined(inputs))
inputs += [ invoker.script ]
if (!defined(inputs)) {
inputs = []
}
args = [
rebase_path(cwd),
rebase_path(invoker.script),
]
args += invoker.args
inputs += [ invoker.script ]
script = "//electron/build/run-node.py"
args = [ rebase_path(invoker.script) ] + invoker.args
}
}

View file

@ -1,21 +0,0 @@
template("node_action") {
assert(defined(invoker.script), "Need script path to run")
assert(defined(invoker.args), "Need script arguments")
action(target_name) {
forward_variables_from(invoker,
[
"deps",
"public_deps",
"sources",
"inputs",
"outputs",
])
if (!defined(inputs)) {
inputs = []
}
inputs += [ invoker.script ]
script = "//electron/build/run-node.py"
args = [ rebase_path(invoker.script) ] + invoker.args
}
}