java_action.gni 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright 2015 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. jarrunner = "//build/util/java_action.py"
  5. # Declare a target that runs a java command a single time.
  6. #
  7. # This target type allows you to run a java command a single time to produce
  8. # one or more output files. If you want to run a java command for each of a
  9. # set of input files, see "java_action_foreach".
  10. #
  11. # See "gn help action" for more information on how to use this target. This
  12. # template is based on the "action" and supports the same variables.
  13. template("java_action") {
  14. assert(defined(invoker.script),
  15. "Need script in $target_name listing the .jar file to run.")
  16. assert(defined(invoker.outputs),
  17. "Need outputs in $target_name listing the generated outputs.")
  18. jarscript = invoker.script
  19. action(target_name) {
  20. script = jarrunner
  21. inputs = [ jarscript ]
  22. if (defined(invoker.inputs)) {
  23. inputs += invoker.inputs
  24. }
  25. args = [
  26. "-jar",
  27. rebase_path(jarscript, root_build_dir),
  28. ]
  29. if (defined(invoker.args)) {
  30. args += invoker.args
  31. }
  32. forward_variables_from(invoker,
  33. [
  34. "console",
  35. "data",
  36. "data_deps",
  37. "depfile",
  38. "deps",
  39. "outputs",
  40. "sources",
  41. "testonly",
  42. "visibility",
  43. ])
  44. }
  45. }
  46. # Declare a target that runs a java command over a set of files.
  47. #
  48. # This target type allows you to run a java command once-per-file over a set of
  49. # sources. If you want to run a java command once that takes many files as
  50. # input, see "java_action".
  51. #
  52. # See "gn help action_foreach" for more information on how to use this target.
  53. # This template is based on the "action_foreach" supports the same variables.
  54. template("java_action_foreach") {
  55. assert(defined(invoker.script),
  56. "Need script in $target_name listing the .jar file to run.")
  57. assert(defined(invoker.outputs),
  58. "Need outputs in $target_name listing the generated outputs.")
  59. assert(defined(invoker.sources),
  60. "Need sources in $target_name listing the target inputs.")
  61. jarscript = invoker.script
  62. action_foreach(target_name) {
  63. script = jarrunner
  64. inputs = [ jarscript ]
  65. if (defined(invoker.inputs)) {
  66. inputs += invoker.inputs
  67. }
  68. args = [
  69. "-jar",
  70. rebase_path(jarscript, root_build_dir),
  71. ]
  72. if (defined(invoker.args)) {
  73. args += invoker.args
  74. }
  75. forward_variables_from(invoker,
  76. [
  77. "console",
  78. "data",
  79. "data_deps",
  80. "depfile",
  81. "deps",
  82. "outputs",
  83. "sources",
  84. "testonly",
  85. "visibility",
  86. ])
  87. }
  88. }