build: consolidate gn templates (#34918)

This commit is contained in:
Shelley Vohr 2022-07-20 11:14:54 +02:00 коммит произвёл GitHub
Родитель 3c7d446fad
Коммит 1b96a3aa1d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 50 добавлений и 47 удалений

Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -7,12 +7,12 @@ This adds GN build files for Node, so we don't have to build with GYP.
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..4afca42d22ee702af50da92aa08c1de897891424
index 0000000000000000000000000000000000000000..9e34a074cfa7dec61c4e11821ba5f1969f393dfb
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,403 @@
+import("//electron/build/asar.gni")
+import("//v8/gni/v8.gni")
+import("node.gni")
+
+declare_args() {
+ # Enable the V8 inspector protocol for use with node.
@ -1593,6 +1593,41 @@ index 0000000000000000000000000000000000000000..a2cfdffcd7308b73c5c302ebc4b946c6
+ "//v8/include/v8.h"
+ ]
+}
diff --git a/node.gni b/node.gni
new file mode 100644
index 0000000000000000000000000000000000000000..9b1a4048a4a64c36d88de0bbe1a548c906aaa22c
--- /dev/null
+++ b/node.gni
@@ -0,0 +1,29 @@
+# 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",
+ ])
+ 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 ]
+ }
+ args = [
+ rebase_path(cwd),
+ rebase_path(invoker.script),
+ ]
+ args += invoker.args
+ }
+}
diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..d1d6b51e8c0c5bc6a5d09e217eb3048361d9d591