2018-05-04 01:44:29 +03:00
|
|
|
import("npm.gni")
|
|
|
|
|
2018-07-25 03:48:26 +03: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 20:43:52 +03:00
|
|
|
if (defined(sources)) {
|
|
|
|
sources += [ invoker.script ]
|
|
|
|
} else {
|
|
|
|
assert(defined(inputs))
|
|
|
|
inputs += [ invoker.script ]
|
|
|
|
}
|
2018-07-25 03:48:26 +03:00
|
|
|
args = [
|
2018-08-08 20:43:52 +03:00
|
|
|
rebase_path(cwd),
|
2018-07-25 03:48:26 +03:00
|
|
|
rebase_path(invoker.script),
|
|
|
|
]
|
|
|
|
args += invoker.args
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-04 01:44:29 +03:00
|
|
|
template("asar") {
|
|
|
|
assert(defined(invoker.sources),
|
|
|
|
"Need sources in $target_name listing the JS files.")
|
|
|
|
assert(defined(invoker.outputs),
|
|
|
|
"Need asar name (as 1-element array, e.g. \$root_out_dir/foo.asar)")
|
2018-07-25 03:48:26 +03:00
|
|
|
assert(defined(invoker.root), "Need asar root directory")
|
2018-05-04 01:44:29 +03:00
|
|
|
asar_root = invoker.root
|
2018-07-25 03:48:26 +03:00
|
|
|
|
|
|
|
# js2asar.py expects relative paths to its inputs, so we must run it in a
|
|
|
|
# working directory in which those relative paths make sense.
|
|
|
|
chdir_action(target_name) {
|
2018-05-04 01:44:29 +03:00
|
|
|
sources = invoker.sources
|
|
|
|
outputs = invoker.outputs
|
2018-07-25 03:48:26 +03:00
|
|
|
script = "//electron/tools/js2asar.py"
|
|
|
|
cwd = rebase_path(get_path_info(".", "abspath"))
|
|
|
|
args = rebase_path(outputs, cwd) + [ asar_root ] + rebase_path(sources, ".")
|
2018-05-04 01:44:29 +03:00
|
|
|
}
|
|
|
|
}
|