Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / build / java.gypi
blobbc489a78946a49e37dcc5b0765bf14329a88f1c2
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 #  add_to_dependents_classpaths - Set to 0 if the resulting jar file should not
23 #    be added to its dependents' classpaths.
24 #  additional_input_paths - These paths will be included in the 'inputs' list to
25 #    ensure that this target is rebuilt when one of these paths changes.
26 #  additional_src_dirs - Additional directories with .java files to be compiled
27 #    and included in the output of this target.
28 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
29 #    that are generated at build time. This should be set automatically by a
30 #    target's dependencies. The .java files in these directories are not
31 #    included in the 'inputs' list (unlike additional_src_dirs).
32 #  input_jars_paths - The path to jars to be included in the classpath. This
33 #    should be filled automatically by depending on the appropriate targets.
34 #  javac_includes - A list of specific files to include. This is by default
35 #    empty, which leads to inclusion of all files specified. May include
36 #    wildcard, and supports '**/' for recursive path wildcards, ie.:
37 #    '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'.
38 #  has_java_resources - Set to 1 if the java target contains an
39 #    Android-compatible resources folder named res.  If 1, R_package and
40 #    R_package_relpath must also be set.
41 #  R_package - The java package in which the R class (which maps resources to
42 #    integer IDs) should be generated, e.g. org.chromium.content.
43 #  R_package_relpath - Same as R_package, but replace each '.' with '/'.
44 #  res_extra_dirs - A list of extra directories containing Android resources.
45 #    These directories may be generated at build time.
46 #  res_extra_files - A list of the files in res_extra_dirs.
47 #  never_lint - Set to 1 to not run lint on this target.
50   'dependencies': [
51     '<(DEPTH)/build/android/setup.gyp:build_output_dirs'
52   ],
53   'variables': {
54     'add_to_dependents_classpaths%': 1,
55     'android_jar': '<(android_sdk)/android.jar',
56     'input_jars_paths': [ '<(android_jar)' ],
57     'additional_src_dirs': [],
58     'javac_includes': [],
59     'jar_name': '<(_target_name).jar',
60     'jar_dir': '<(PRODUCT_DIR)/lib.java',
61     'jar_path': '<(intermediate_dir)/<(jar_name)',
62     'jar_final_path': '<(jar_dir)/<(jar_name)',
63     'jar_excluded_classes': [ '*/R.class', '*/R##*.class' ],
64     'instr_stamp': '<(intermediate_dir)/instr.stamp',
65     'additional_input_paths': [],
66     'dex_path': '<(PRODUCT_DIR)/lib.java/<(_target_name).dex.jar',
67     'main_dex_list_path': '<(intermediate_dir)/main_dex_list.txt',
68     'generated_src_dirs': ['>@(generated_R_dirs)'],
69     'generated_R_dirs': [],
70     'has_java_resources%': 0,
71     'res_extra_dirs': [],
72     'res_extra_files': [],
73     'res_v14_skip%': 0,
74     'resource_input_paths': ['>@(res_extra_files)'],
75     'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)',
76     'compile_stamp': '<(intermediate_dir)/compile.stamp',
77     'lint_stamp': '<(intermediate_dir)/lint.stamp',
78     'lint_result': '<(intermediate_dir)/lint_result.xml',
79     'lint_config': '<(intermediate_dir)/lint_config.xml',
80     'never_lint%': 0,
81     'findbugs_stamp': '<(intermediate_dir)/findbugs.stamp',
82     'run_findbugs%': 0,
83     'java_in_dir_suffix%': '/src',
84     'proguard_config%': '',
85     'proguard_preprocess%': '0',
86     'enable_errorprone%': '0',
87     'errorprone_exe_path': '<(PRODUCT_DIR)/bin.java/chromium_errorprone',
88     'variables': {
89       'variables': {
90         'proguard_preprocess%': 0,
91         'emma_never_instrument%': 0,
92       },
93       'conditions': [
94         ['proguard_preprocess == 1', {
95           'javac_jar_path': '<(intermediate_dir)/<(_target_name).pre.jar'
96         }, {
97           'javac_jar_path': '<(jar_path)'
98         }],
99         ['chromium_code != 0 and emma_coverage != 0 and emma_never_instrument == 0', {
100           'emma_instrument': 1,
101         }, {
102           'emma_instrument': 0,
103         }],
104       ],
105     },
106     'emma_instrument': '<(emma_instrument)',
107     'javac_jar_path': '<(javac_jar_path)',
108   },
109   'conditions': [
110     ['add_to_dependents_classpaths == 1', {
111       # This all_dependent_settings is used for java targets only. This will add the
112       # jar path to the classpath of dependent java targets.
113       'all_dependent_settings': {
114         'variables': {
115           'input_jars_paths': ['<(jar_final_path)'],
116           'library_dexed_jars_paths': ['<(dex_path)'],
117           'main_dex_list_paths': ['<(main_dex_list_path)'],
118         },
119       },
120     }],
121     ['has_java_resources == 1', {
122       'variables': {
123         'resource_dir': '<(java_in_dir)/res',
124         'res_input_dirs': ['<(resource_dir)', '<@(res_extra_dirs)'],
125         'resource_input_paths': ['<!@(find <(resource_dir) -type f)'],
127         'R_dir': '<(intermediate_dir)/java_R',
128         'R_text_file': '<(R_dir)/R.txt',
130         'generated_src_dirs': ['<(R_dir)'],
131         'additional_input_paths': ['<(resource_zip_path)', ],
133         'dependencies_res_zip_paths': [],
134         'resource_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
135       },
136       'all_dependent_settings': {
137         'variables': {
138           # Dependent libraries include this target's R.java file via
139           # generated_R_dirs.
140           'generated_R_dirs': ['<(R_dir)'],
142           # Dependent libraries and apks include this target's resources via
143           # dependencies_res_zip_paths.
144           'additional_input_paths': ['<(resource_zip_path)'],
145           'dependencies_res_zip_paths': ['<(resource_zip_path)'],
147           # additional_res_packages and additional_R_text_files are used to
148           # create this packages R.java files when building the APK.
149           'additional_res_packages': ['<(R_package)'],
150           'additional_R_text_files': ['<(R_text_file)'],
151         },
152       },
153       'actions': [
154         # Generate R.java and crunch image resources.
155         {
156           'action_name': 'process_resources',
157           'message': 'processing resources for <(_target_name)',
158           'variables': {
159             'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
160             # Write the inputs list to a file, so that its mtime is updated when
161             # the list of inputs changes.
162             'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths))',
163             'process_resources_options': [],
164             'conditions': [
165               ['res_v14_skip == 1', {
166                 'process_resources_options': ['--v14-skip']
167               }],
168             ],
169           },
170           'inputs': [
171             '<(DEPTH)/build/android/gyp/util/build_utils.py',
172             '<(DEPTH)/build/android/gyp/process_resources.py',
173             '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py',
174             '>@(resource_input_paths)',
175             '>@(dependencies_res_zip_paths)',
176             '>(inputs_list_file)',
177           ],
178           'outputs': [
179             '<(resource_zip_path)',
180           ],
181           'action': [
182             'python', '<(DEPTH)/build/android/gyp/process_resources.py',
183             '--android-sdk', '<(android_sdk)',
184             '--aapt-path', '<(android_aapt_path)',
185             '--non-constant-id',
187             '--android-manifest', '<(android_manifest)',
188             '--custom-package', '<(R_package)',
190             '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
191             '--resource-dirs', '<(res_input_dirs)',
193             '--R-dir', '<(R_dir)',
194             '--resource-zip-out', '<(resource_zip_path)',
196             '<@(process_resources_options)',
197           ],
198         },
199       ],
200     }],
201     ['proguard_preprocess == 1', {
202       'actions': [
203         {
204           'action_name': 'proguard_<(_target_name)',
205           'message': 'Proguard preprocessing <(_target_name) jar',
206           'inputs': [
207             '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
208             '<(DEPTH)/build/android/gyp/util/build_utils.py',
209             '<(DEPTH)/build/android/gyp/proguard.py',
210             '<(javac_jar_path)',
211             '<(proguard_config)',
212           ],
213           'outputs': [
214             '<(jar_path)',
215           ],
216           'action': [
217             'python', '<(DEPTH)/build/android/gyp/proguard.py',
218             '--proguard-path=<(android_sdk_root)/tools/proguard/lib/proguard.jar',
219             '--input-path=<(javac_jar_path)',
220             '--output-path=<(jar_path)',
221             '--proguard-config=<(proguard_config)',
222             '--classpath=<(android_sdk_jar) >(input_jars_paths)',
223           ]
224         },
225       ],
226     }],
227     ['run_findbugs == 1', {
228       'actions': [
229         {
230           'action_name': 'findbugs_<(_target_name)',
231           'message': 'Running findbugs on <(_target_name)',
232           'variables': {
233             'additional_findbugs_args': [],
234             'findbugs_verbose%': 0,
235           },
236           'conditions': [
237             ['findbugs_verbose == 1', {
238               'variables': {
239                 'additional_findbugs_args+': ['-vv'],
240               },
241             }],
242           ],
243           'inputs': [
244             '<(DEPTH)/build/android/findbugs_diff.py',
245             '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml',
246             '<(DEPTH)/build/android/pylib/utils/findbugs.py',
247             '>@(input_jars_paths)',
248             '<(jar_final_path)',
249             '<(compile_stamp)',
250           ],
251           'outputs': [
252             '<(findbugs_stamp)',
253           ],
254           'action': [
255             'python', '<(DEPTH)/build/android/findbugs_diff.py',
256             '--auxclasspath-gyp', '>(input_jars_paths)',
257             '--stamp', '<(findbugs_stamp)',
258             '<@(additional_findbugs_args)',
259             '<(jar_final_path)',
260           ],
261         },
262       ],
263     }],
264     ['enable_errorprone == 1', {
265       'dependencies': [
266         '<(DEPTH)/third_party/errorprone/errorprone.gyp:require_errorprone',
267       ],
268     }],
269   ],
270   'actions': [
271     {
272       'action_name': 'javac_<(_target_name)',
273       'message': 'Compiling <(_target_name) java sources',
274       'variables': {
275         'extra_args': [],
276         'extra_inputs': [],
277         'java_sources': ['>!@(find >(java_in_dir)>(java_in_dir_suffix) >(additional_src_dirs) -name "*.java")'],
278         'conditions': [
279           ['enable_errorprone == 1', {
280             'extra_inputs': [
281               '<(errorprone_exe_path)',
282             ],
283             'extra_args': [ '--use-errorprone-path=<(errorprone_exe_path)' ],
284           }],
285         ],
286       },
287       'inputs': [
288         '<(DEPTH)/build/android/gyp/util/build_utils.py',
289         '<(DEPTH)/build/android/gyp/javac.py',
290         '>@(java_sources)',
291         '>@(input_jars_paths)',
292         '>@(additional_input_paths)',
293         '<@(extra_inputs)',
294       ],
295       'outputs': [
296         '<(compile_stamp)',
297         '<(javac_jar_path)',
298       ],
299       'action': [
300         'python', '<(DEPTH)/build/android/gyp/javac.py',
301         '--bootclasspath=<(android_sdk_jar)',
302         '--classpath=>(input_jars_paths)',
303         '--src-gendirs=>(generated_src_dirs)',
304         '--javac-includes=<(javac_includes)',
305         '--chromium-code=<(chromium_code)',
306         '--jar-path=<(javac_jar_path)',
307         '--jar-excluded-classes=<(jar_excluded_classes)',
308         '--stamp=<(compile_stamp)',
309         '>@(java_sources)',
310         '<@(extra_args)',
311       ]
312     },
313     {
314       'action_name': 'main_dex_list_for_<(_target_name)',
315       'variables': {
316         'jar_path': '<(javac_jar_path)',
317         'output_path': '<(main_dex_list_path)',
318       },
319       'includes': [ 'android/main_dex_action.gypi' ],
320     },
321     {
322       'action_name': 'instr_jar_<(_target_name)',
323       'message': 'Instrumenting <(_target_name) jar',
324       'variables': {
325         'input_path': '<(jar_path)',
326         'output_path': '<(jar_final_path)',
327         'stamp_path': '<(instr_stamp)',
328         'instr_type': 'jar',
329       },
330       'outputs': [
331         '<(jar_final_path)',
332       ],
333       'inputs': [
334         '<(jar_path)',
335       ],
336       'includes': [ 'android/instr_action.gypi' ],
337     },
338     {
339       'variables': {
340         'src_dirs': [
341           '<(java_in_dir)<(java_in_dir_suffix)',
342           '>@(additional_src_dirs)',
343         ],
344         'stamp_path': '<(lint_stamp)',
345         'result_path': '<(lint_result)',
346         'config_path': '<(lint_config)',
347         'lint_jar_path': '<(jar_final_path)',
348       },
349       'inputs': [
350         '<(jar_final_path)',
351         '<(compile_stamp)',
352       ],
353       'outputs': [
354         '<(lint_stamp)',
355       ],
356       'includes': [ 'android/lint_action.gypi' ],
357     },
358     {
359       'action_name': 'jar_toc_<(_target_name)',
360       'message': 'Creating <(_target_name) jar.TOC',
361       'inputs': [
362         '<(DEPTH)/build/android/gyp/util/build_utils.py',
363         '<(DEPTH)/build/android/gyp/util/md5_check.py',
364         '<(DEPTH)/build/android/gyp/jar_toc.py',
365         '<(jar_final_path)',
366       ],
367       'outputs': [
368         '<(jar_final_path).TOC',
369       ],
370       'action': [
371         'python', '<(DEPTH)/build/android/gyp/jar_toc.py',
372         '--jar-path=<(jar_final_path)',
373         '--toc-path=<(jar_final_path).TOC',
374       ]
375     },
376     {
377       'action_name': 'dex_<(_target_name)',
378       'variables': {
379         'conditions': [
380           ['emma_instrument != 0', {
381             'dex_no_locals': 1,
382           }],
383         ],
384         'dex_input_paths': [ '<(jar_final_path)' ],
385         'output_path': '<(dex_path)',
386       },
387       'includes': [ 'android/dex_action.gypi' ],
388     },
389   ],