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