asar.gni 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import("node.gni")
  2. # TODO(MarshallOfSound): Move to electron/node, this is the only place it is used now
  3. # Run an action with a given working directory. Behaves identically to the
  4. # action() target type, with the exception that it changes directory before
  5. # running the script.
  6. #
  7. # Parameters:
  8. # cwd [required]: Directory to change to before running the script.
  9. template("chdir_action") {
  10. action(target_name) {
  11. forward_variables_from(invoker,
  12. "*",
  13. [
  14. "script",
  15. "args",
  16. ])
  17. assert(defined(cwd), "Need cwd in $target_name")
  18. script = "//electron/build/run-in-dir.py"
  19. if (defined(sources)) {
  20. sources += [ invoker.script ]
  21. } else {
  22. assert(defined(inputs))
  23. inputs += [ invoker.script ]
  24. }
  25. args = [
  26. rebase_path(cwd),
  27. rebase_path(invoker.script),
  28. ]
  29. args += invoker.args
  30. }
  31. }
  32. template("asar") {
  33. assert(defined(invoker.sources),
  34. "Need sources in $target_name listing the source files")
  35. assert(defined(invoker.outputs),
  36. "Need asar name (as 1-element array, e.g. \$root_out_dir/foo.asar)")
  37. assert(defined(invoker.root), "Need the base dir for generating the ASAR")
  38. node_action(target_name) {
  39. forward_variables_from(invoker,
  40. "*",
  41. [
  42. "script",
  43. "args",
  44. ])
  45. script = "//electron/script/gn-asar.js"
  46. args = [
  47. "--base",
  48. rebase_path(root),
  49. "--files",
  50. ] + rebase_path(sources) +
  51. [
  52. "--out",
  53. rebase_path(outputs[0]),
  54. ]
  55. }
  56. }