Check build status by parsing tryserver buildbot JSON.
[chromium-blink-merge.git] / build / java.gypi
blobd392206090900f2de008e00d3407ab1e3dceb6cd
1 # Copyright (c) 2012 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.
5 # This file is meant to be included into a target to provide a rule
6 # to build Java in a consistent manner.
8 # To use this, create a gyp target with the following form:
9 # {
10 #   'target_name': 'my-package_java',
11 #   'type': 'none',
12 #   'variables': {
13 #     'java_in_dir': 'path/to/package/root',
14 #   },
15 #   'includes': ['path/to/this/gypi/file'],
16 # }
18 # Required variables:
19 #  java_in_dir - The top-level java directory. The src should be in
20 #    <java_in_dir>/src.
21 # Optional/automatic variables:
22 #  additional_input_paths - These paths will be included in the 'inputs' list to
23 #    ensure that this target is rebuilt when one of these paths changes.
24 #  additional_src_dirs - Additional directories with .java files to be compiled
25 #    and included in the output of this target.
26 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
27 #    that are generated at build time. This should be set automatically by a
28 #    target's dependencies. The .java files in these directories are not
29 #    included in the 'inputs' list (unlike additional_src_dirs).
30 #  input_jars_paths - The path to jars to be included in the classpath. This
31 #    should be filled automatically by depending on the appropriate targets.
32 #  javac_includes - A list of specific files to include. This is by default
33 #    empty, which leads to inclusion of all files specified. May include
34 #    wildcard, and supports '**/' for recursive path wildcards, ie.:
35 #    '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'.
36 #  has_java_resources - Set to 1 if the java target contains an
37 #    Android-compatible resources folder named res.  If 1, R_package and
38 #    R_package_relpath must also be set.
39 #  R_package - The java package in which the R class (which maps resources to
40 #    integer IDs) should be generated, e.g. org.chromium.content.
41 #  R_package_relpath - Same as R_package, but replace each '.' with '/'.
42 #  res_extra_dirs - A list of extra directories containing Android resources.
43 #    These directories may be generated at build time.
44 #  res_extra_files - A list of the files in res_extra_dirs.
45 #  never_lint - Set to 1 to not run lint on this target.
48   'dependencies': [
49     '<(DEPTH)/build/android/setup.gyp:build_output_dirs'
50   ],
51   'variables': {
52     'android_jar': '<(android_sdk)/android.jar',
53     'input_jars_paths': [ '<(android_jar)' ],
54     'additional_src_dirs': [],
55     'javac_includes': [],
56     'jar_name': '<(_target_name).jar',
57     'jar_dir': '<(PRODUCT_DIR)/lib.java',
58     'jar_path': '<(intermediate_dir)/<(jar_name)',
59     'jar_final_path': '<(jar_dir)/<(jar_name)',
60     'jar_excluded_classes': [ '*/R.class', '*/R##*.class' ],
61     'instr_stamp': '<(intermediate_dir)/instr.stamp',
62     'additional_input_paths': [],
63     'dex_path': '<(PRODUCT_DIR)/lib.java/<(_target_name).dex.jar',
64     'generated_src_dirs': ['>@(generated_R_dirs)'],
65     'generated_R_dirs': [],
66     'has_java_resources%': 0,
67     'res_extra_dirs': [],
68     'res_extra_files': [],
69     'res_v14_verify_only%': 0,
70     'resource_input_paths': ['>@(res_extra_files)'],
71     'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)',
72     'classes_dir': '<(intermediate_dir)/classes',
73     'compile_stamp': '<(intermediate_dir)/compile.stamp',
74     'lint_stamp': '<(intermediate_dir)/lint.stamp',
75     'lint_result': '<(intermediate_dir)/lint_result.xml',
76     'lint_config': '<(intermediate_dir)/lint_config.xml',
77     'never_lint%': 0,
78     'proguard_config%': '',
79     'proguard_preprocess%': '0',
80     'variables': {
81       'variables': {
82         'proguard_preprocess%': 0,
83         'emma_never_instrument%': 0,
84       },
85       'conditions': [
86         ['proguard_preprocess == 1', {
87           'javac_jar_path': '<(intermediate_dir)/<(_target_name).pre.jar'
88         }, {
89           'javac_jar_path': '<(jar_path)'
90         }],
91         ['chromium_code != 0 and emma_coverage != 0 and emma_never_instrument == 0', {
92           'emma_instrument': 1,
93         }, {
94           'emma_instrument': 0,
95         }],
96       ],
97     },
98     'emma_instrument': '<(emma_instrument)',
99     'javac_jar_path': '<(javac_jar_path)',
100   },
101   # This all_dependent_settings is used for java targets only. This will add the
102   # jar path to the classpath of dependent java targets.
103   'all_dependent_settings': {
104     'variables': {
105       'input_jars_paths': ['<(jar_final_path)'],
106       'library_dexed_jars_paths': ['<(dex_path)'],
107     },
108   },
109   'conditions': [
110     ['has_java_resources == 1', {
111       'variables': {
112         'res_dir': '<(java_in_dir)/res',
113         'res_crunched_dir': '<(intermediate_dir)/res_crunched',
114         'res_v14_compatibility_stamp': '<(intermediate_dir)/res_v14_compatibility.stamp',
115         'res_v14_compatibility_dir': '<(intermediate_dir)/res_v14_compatibility',
116         'res_input_dirs': ['<(res_dir)', '<@(res_extra_dirs)'],
117         'resource_input_paths': ['<!@(find <(res_dir) -type f)'],
118         'R_dir': '<(intermediate_dir)/java_R',
119         'R_text_file': '<(R_dir)/R.txt',
120         'R_stamp': '<(intermediate_dir)/resources.stamp',
121         'generated_src_dirs': ['<(R_dir)'],
122         'additional_input_paths': ['<(R_stamp)',
123                                    '<(res_v14_compatibility_stamp)',],
124         'additional_res_dirs': [],
125         'dependencies_res_input_dirs': [],
126         'dependencies_res_files': [],
127       },
128       'all_dependent_settings': {
129         'variables': {
130           # Dependent jars include this target's R.java file via
131           # generated_R_dirs and include its resources via
132           # dependencies_res_files.
133           'generated_R_dirs': ['<(R_dir)'],
134           'additional_input_paths': ['<(R_stamp)',
135                                      '<(res_v14_compatibility_stamp)',],
136           'dependencies_res_files': ['<@(resource_input_paths)'],
138           'dependencies_res_input_dirs': ['<@(res_input_dirs)'],
140           # Dependent APKs include this target's resources via
141           # additional_res_dirs, additional_res_packages, and
142           # additional_R_text_files.
143           'additional_res_dirs': [
144               # The order of these is important to ensure that the proper
145               # version (i.e. the crunched version) of resources takes
146               # precedence.
147               '<(res_crunched_dir)',
148               '<(res_v14_compatibility_dir)',
149               '<@(res_input_dirs)'
150               ],
151           'additional_res_packages': ['<(R_package)'],
152           'additional_R_text_files': ['<(R_text_file)'],
153         },
154       },
155       'actions': [
156         # Generate R.java and crunch image resources.
157         {
158           'action_name': 'process_resources',
159           'message': 'processing resources for <(_target_name)',
160           'variables': {
161             'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
162             # Include the dependencies' res dirs so that references to
163             # resources in dependencies can be resolved.
164             'dependencies_res_dirs': ['<@(res_extra_dirs)',
165                                       '>@(dependencies_res_input_dirs)',],
166             # Write the inputs list to a file, so that its mtime is updated when
167             # the list of inputs changes.
168             'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths) >@(dependencies_res_files))'
169           },
170           'inputs': [
171             '<(DEPTH)/build/android/gyp/util/build_utils.py',
172             '<(DEPTH)/build/android/gyp/process_resources.py',
173             '>@(resource_input_paths)',
174             '>@(dependencies_res_files)',
175             '>(inputs_list_file)',
176           ],
177           'outputs': [
178             '<(R_stamp)',
179           ],
180           'action': [
181             'python', '<(DEPTH)/build/android/gyp/process_resources.py',
182             '--android-sdk', '<(android_sdk)',
183             '--android-sdk-tools', '<(android_sdk_tools)',
184             '--R-dir', '<(R_dir)',
185             '--dependencies-res-dirs', '>(dependencies_res_dirs)',
186             '--resource-dir', '<(res_dir)',
187             '--crunch-output-dir', '<(res_crunched_dir)',
188             '--android-manifest', '<(android_manifest)',
189             '--non-constant-id',
190             '--custom-package', '<(R_package)',
191             '--stamp', '<(R_stamp)',
192           ],
193         },
194         # Generate API 14 resources.
195         {
196           'action_name': 'generate_api_14_resources_<(_target_name)',
197           'message': 'Generating Android API 14 resources <(_target_name)',
198           'variables' : {
199             'res_v14_additional_options': [],
200           },
201           'conditions': [
202             ['res_v14_verify_only == 1', {
203               'variables': {
204                 'res_v14_additional_options': ['--verify-only']
205               },
206             }],
207           ],
208           'inputs': [
209             '<(DEPTH)/build/android/gyp/util/build_utils.py',
210             '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py',
211             '>@(resource_input_paths)',
212           ],
213           'outputs': [
214             '<(res_v14_compatibility_stamp)',
215           ],
216           'action': [
217             'python', '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py',
218             '--res-dir=<(res_dir)',
219             '--res-v14-compatibility-dir=<(res_v14_compatibility_dir)',
220             '--stamp', '<(res_v14_compatibility_stamp)',
221             '<@(res_v14_additional_options)',
222           ]
223         },
224       ],
225     }],
226     ['proguard_preprocess == 1', {
227       'actions': [
228         {
229           'action_name': 'proguard_<(_target_name)',
230           'message': 'Proguard preprocessing <(_target_name) jar',
231           'inputs': [
232             '<(android_sdk_root)/tools/proguard/bin/proguard.sh',
233             '<(DEPTH)/build/android/gyp/util/build_utils.py',
234             '<(DEPTH)/build/android/gyp/proguard.py',
235             '<(javac_jar_path)',
236             '<(proguard_config)',
237           ],
238           'outputs': [
239             '<(jar_path)',
240           ],
241           'action': [
242             'python', '<(DEPTH)/build/android/gyp/proguard.py',
243             '--proguard-path=<(android_sdk_root)/tools/proguard/bin/proguard.sh',
244             '--input-path=<(javac_jar_path)',
245             '--output-path=<(jar_path)',
246             '--proguard-config=<(proguard_config)',
247             '--classpath=<(android_sdk_jar) >(input_jars_paths)',
248           ]
249         },
250       ],
251     }],
252   ],
253   'actions': [
254     {
255       'action_name': 'javac_<(_target_name)',
256       'message': 'Compiling <(_target_name) java sources',
257       'variables': {
258         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java")'],
259       },
260       'inputs': [
261         '<(DEPTH)/build/android/gyp/util/build_utils.py',
262         '<(DEPTH)/build/android/gyp/javac.py',
263         '>@(java_sources)',
264         '>@(input_jars_paths)',
265         '>@(additional_input_paths)',
266       ],
267       'outputs': [
268         '<(compile_stamp)',
269       ],
270       'action': [
271         'python', '<(DEPTH)/build/android/gyp/javac.py',
272         '--output-dir=<(classes_dir)',
273         '--classpath=>(input_jars_paths)',
274         '--src-gendirs=>(generated_src_dirs)',
275         '--javac-includes=<(javac_includes)',
276         '--chromium-code=<(chromium_code)',
277         '--stamp=<(compile_stamp)',
278         '>@(java_sources)',
279       ]
280     },
281     {
282       'variables': {
283         'src_dirs': [
284           '<(java_in_dir)/src',
285           '>@(additional_src_dirs)',
286         ],
287         'stamp_path': '<(lint_stamp)',
288         'result_path': '<(lint_result)',
289         'config_path': '<(lint_config)',
290       },
291       'inputs': [
292         '<(compile_stamp)',
293       ],
294       'outputs': [
295         '<(lint_stamp)',
296       ],
297       'includes': [ 'android/lint_action.gypi' ],
298     },
299     {
300       'action_name': 'jar_<(_target_name)',
301       'message': 'Creating <(_target_name) jar',
302       'inputs': [
303         '<(DEPTH)/build/android/gyp/util/build_utils.py',
304         '<(DEPTH)/build/android/gyp/util/md5_check.py',
305         '<(DEPTH)/build/android/gyp/jar.py',
306         '<(compile_stamp)',
307       ],
308       'outputs': [
309         '<(javac_jar_path)',
310       ],
311       'action': [
312         'python', '<(DEPTH)/build/android/gyp/jar.py',
313         '--classes-dir=<(classes_dir)',
314         '--jar-path=<(javac_jar_path)',
315         '--excluded-classes=<(jar_excluded_classes)',
316       ]
317     },
318     {
319       'action_name': 'instr_jar_<(_target_name)',
320       'message': 'Instrumenting <(_target_name) jar',
321       'variables': {
322         'input_path': '<(jar_path)',
323         'output_path': '<(jar_final_path)',
324         'stamp_path': '<(instr_stamp)',
325         'instr_type': 'jar',
326       },
327       'outputs': [
328         '<(jar_final_path)',
329       ],
330       'inputs': [
331         '<(jar_path)',
332       ],
333       'includes': [ 'android/instr_action.gypi' ],
334     },
335     {
336       'action_name': 'jar_toc_<(_target_name)',
337       'message': 'Creating <(_target_name) jar.TOC',
338       'inputs': [
339         '<(DEPTH)/build/android/gyp/util/build_utils.py',
340         '<(DEPTH)/build/android/gyp/util/md5_check.py',
341         '<(DEPTH)/build/android/gyp/jar_toc.py',
342         '<(jar_final_path)',
343       ],
344       'outputs': [
345         '<(jar_final_path).TOC',
346       ],
347       'action': [
348         'python', '<(DEPTH)/build/android/gyp/jar_toc.py',
349         '--jar-path=<(jar_final_path)',
350         '--toc-path=<(jar_final_path).TOC',
351       ]
352     },
353     {
354       'action_name': 'dex_<(_target_name)',
355       'variables': {
356         'conditions': [
357           ['emma_instrument != 0', {
358             'dex_no_locals': 1,
359           }],
360         ],
361         'dex_input_paths': [ '<(jar_final_path)' ],
362         'output_path': '<(dex_path)',
363       },
364       'includes': [ 'android/dex_action.gypi' ],
365     },
366   ],