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