From 1b96a3aa1d81837fa08b018bbb97c5917d1d8f45 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 20 Jul 2022 11:14:54 +0200 Subject: [PATCH] build: consolidate gn templates (#34918) --- build/asar.gni | 37 +++++++------------ build/node.gni | 21 ----------- patches/node/build_add_gn_build_files.patch | 39 +++++++++++++++++++-- 3 files changed, 50 insertions(+), 47 deletions(-) delete mode 100644 build/node.gni diff --git a/build/asar.gni b/build/asar.gni index 3e11845bd5..b8b290da2c 100644 --- a/build/asar.gni +++ b/build/asar.gni @@ -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 } } diff --git a/build/node.gni b/build/node.gni deleted file mode 100644 index 6d7882d346..0000000000 --- a/build/node.gni +++ /dev/null @@ -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 - } -} diff --git a/patches/node/build_add_gn_build_files.patch b/patches/node/build_add_gn_build_files.patch index 69142b12e0..778d72eb5e 100644 --- a/patches/node/build_add_gn_build_files.patch +++ b/patches/node/build_add_gn_build_files.patch @@ -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