2019-02-05 20:10:15 +00:00
|
|
|
import("node.gni")
|
2018-05-03 22:44:29 +00:00
|
|
|
|
2019-02-05 20:10:15 +00:00
|
|
|
# TODO(MarshallOfSound): Move to electron/node, this is the only place it is used now
|
2018-07-25 00:48:26 +00:00
|
|
|
# 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"
|
2018-08-08 17:43:52 +00:00
|
|
|
if (defined(sources)) {
|
|
|
|
sources += [ invoker.script ]
|
|
|
|
} else {
|
|
|
|
assert(defined(inputs))
|
|
|
|
inputs += [ invoker.script ]
|
|
|
|
}
|
2018-07-25 00:48:26 +00:00
|
|
|
args = [
|
2018-08-08 17:43:52 +00:00
|
|
|
rebase_path(cwd),
|
2018-07-25 00:48:26 +00:00
|
|
|
rebase_path(invoker.script),
|
|
|
|
]
|
|
|
|
args += invoker.args
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-03 22:44:29 +00:00
|
|
|
template("asar") {
|
|
|
|
assert(defined(invoker.sources),
|
2019-02-05 20:10:15 +00:00
|
|
|
"Need sources in $target_name listing the source files")
|
2018-05-03 22:44:29 +00:00
|
|
|
assert(defined(invoker.outputs),
|
|
|
|
"Need asar name (as 1-element array, e.g. \$root_out_dir/foo.asar)")
|
2019-02-05 20:10:15 +00:00
|
|
|
assert(defined(invoker.root), "Need the base dir for generating the ASAR")
|
2018-07-25 00:48:26 +00:00
|
|
|
|
2019-02-05 20:10:15 +00:00
|
|
|
node_action(target_name) {
|
|
|
|
forward_variables_from(invoker,
|
|
|
|
"*",
|
|
|
|
[
|
|
|
|
"script",
|
|
|
|
"args",
|
|
|
|
])
|
|
|
|
|
|
|
|
script = "//electron/script/gn-asar.js"
|
|
|
|
args = [
|
|
|
|
"--base",
|
|
|
|
rebase_path(root),
|
|
|
|
"--files",
|
|
|
|
] + rebase_path(sources) +
|
|
|
|
[
|
|
|
|
"--out",
|
|
|
|
rebase_path(outputs[0]),
|
|
|
|
]
|
2018-05-03 22:44:29 +00:00
|
|
|
}
|
2021-09-09 21:49:01 +00:00
|
|
|
|
|
|
|
node_action(target_name + "_header_hash") {
|
|
|
|
invoker_out = invoker.outputs
|
|
|
|
|
|
|
|
deps = [ ":" + invoker.target_name ]
|
|
|
|
sources = invoker.outputs
|
|
|
|
|
|
|
|
script = "//electron/script/gn-asar-hash.js"
|
|
|
|
outputs = [ "$target_gen_dir/asar_hashes/$target_name.hash" ]
|
|
|
|
|
|
|
|
args = [
|
|
|
|
rebase_path(invoker_out[0]),
|
|
|
|
rebase_path(outputs[0]),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template("asar_hashed_info_plist") {
|
|
|
|
node_action(target_name) {
|
|
|
|
assert(defined(invoker.plist_file),
|
|
|
|
"Need plist_file to add hashed assets to")
|
|
|
|
assert(defined(invoker.keys), "Need keys to replace with asset hash")
|
|
|
|
assert(defined(invoker.hash_targets), "Need hash_targets to read hash from")
|
|
|
|
|
|
|
|
deps = invoker.hash_targets
|
|
|
|
|
|
|
|
script = "//electron/script/gn-plist-but-with-hashes.js"
|
|
|
|
inputs = [ invoker.plist_file ]
|
|
|
|
outputs = [ "$target_gen_dir/hashed_plists/$target_name.plist" ]
|
|
|
|
hash_files = []
|
|
|
|
foreach(hash_target, invoker.hash_targets) {
|
|
|
|
hash_files += get_target_outputs(hash_target)
|
|
|
|
}
|
|
|
|
args = [
|
|
|
|
rebase_path(invoker.plist_file),
|
|
|
|
rebase_path(outputs[0]),
|
|
|
|
] + invoker.keys + rebase_path(hash_files)
|
|
|
|
}
|
2018-05-03 22:44:29 +00:00
|
|
|
}
|