Re-enable blink_perf.canvas on Windows
[chromium-blink-merge.git] / build / java.gypi
blob716eb34beacc735d95e9fa43c756911a812433f8
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     'generated_src_dirs': ['>@(generated_R_dirs)'],
68     'generated_R_dirs': [],
69     'has_java_resources%': 0,
70     'res_extra_dirs': [],
71     'res_extra_files': [],
72     'res_v14_skip%': 0,
73     'res_v14_verify_only%': 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     'proguard_config%': '',
84     'proguard_preprocess%': '0',
85     'variables': {
86       'variables': {
87         'proguard_preprocess%': 0,
88         'emma_never_instrument%': 0,
89       },
90       'conditions': [
91         ['proguard_preprocess == 1', {
92           'javac_jar_path': '<(intermediate_dir)/<(_target_name).pre.jar'
93         }, {
94           'javac_jar_path': '<(jar_path)'
95         }],
96         ['chromium_code != 0 and emma_coverage != 0 and emma_never_instrument == 0', {
97           'emma_instrument': 1,
98         }, {
99           'emma_instrument': 0,
100         }],
101       ],
102     },
103     'emma_instrument': '<(emma_instrument)',
104     'javac_jar_path': '<(javac_jar_path)',
105   },
106   'conditions': [
107     ['add_to_dependents_classpaths == 1', {
108       # This all_dependent_settings is used for java targets only. This will add the
109       # jar path to the classpath of dependent java targets.
110       'all_dependent_settings': {
111         'variables': {
112           'input_jars_paths': ['<(jar_final_path)'],
113           'library_dexed_jars_paths': ['<(dex_path)'],
114         },
115       },
116     }],
117     ['has_java_resources == 1', {
118       'variables': {
119         'resource_dir': '<(java_in_dir)/res',
120         'res_input_dirs': ['<(resource_dir)', '<@(res_extra_dirs)'],
121         'resource_input_paths': ['<!@(find <(resource_dir) -type f)'],
123         'R_dir': '<(intermediate_dir)/java_R',
124         'R_text_file': '<(R_dir)/R.txt',
126         'generated_src_dirs': ['<(R_dir)'],
127         'additional_input_paths': ['<(resource_zip_path)', ],
129         'dependencies_res_zip_paths': [],
130         'resource_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
131       },
132       'all_dependent_settings': {
133         'variables': {
134           # Dependent libraries include this target's R.java file via
135           # generated_R_dirs.
136           'generated_R_dirs': ['<(R_dir)'],
138           # Dependent libraries and apks include this target's resources via
139           # dependencies_res_zip_paths.
140           'additional_input_paths': ['<(resource_zip_path)'],
141           'dependencies_res_zip_paths': ['<(resource_zip_path)'],
143           # additional_res_packages and additional_R_text_files are used to
144           # create this packages R.java files when building the APK.
145           'additional_res_packages': ['<(R_package)'],
146           'additional_R_text_files': ['<(R_text_file)'],
147         },
148       },
149       'actions': [
150         # Generate R.java and crunch image resources.
151         {
152           'action_name': 'process_resources',
153           'message': 'processing resources for <(_target_name)',
154           'variables': {
155             'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
156             # Write the inputs list to a file, so that its mtime is updated when
157             # the list of inputs changes.
158             'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths))',
159             'process_resources_options': [],
160             'conditions': [
161               ['res_v14_skip == 1', {
162                 'process_resources_options': ['--v14-skip']
163               }],
164               ['res_v14_verify_only == 1', {
165                 'process_resources_options': ['--v14-verify-only']
166               }],
167             ],
168           },
169           'inputs': [
170             '<(DEPTH)/build/android/gyp/util/build_utils.py',
171             '<(DEPTH)/build/android/gyp/process_resources.py',
172             '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py',
173             '>@(resource_input_paths)',
174             '>@(dependencies_res_zip_paths)',
175             '>(inputs_list_file)',
176           ],
177           'outputs': [
178             '<(resource_zip_path)',
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             '--non-constant-id',
186             '--android-manifest', '<(android_manifest)',
187             '--custom-package', '<(R_package)',
189             '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
190             '--resource-dirs', '<(res_input_dirs)',
192             '--R-dir', '<(R_dir)',
193             '--resource-zip-out', '<(resource_zip_path)',
195             '<@(process_resources_options)',
196           ],
197         },
198       ],
199     }],
200     ['proguard_preprocess == 1', {
201       'actions': [
202         {
203           'action_name': 'proguard_<(_target_name)',
204           'message': 'Proguard preprocessing <(_target_name) jar',
205           'inputs': [
206             '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
207             '<(DEPTH)/build/android/gyp/util/build_utils.py',
208             '<(DEPTH)/build/android/gyp/proguard.py',
209             '<(javac_jar_path)',
210             '<(proguard_config)',
211           ],
212           'outputs': [
213             '<(jar_path)',
214           ],
215           'action': [
216             'python', '<(DEPTH)/build/android/gyp/proguard.py',
217             '--proguard-path=<(android_sdk_root)/tools/proguard/lib/proguard.jar',
218             '--input-path=<(javac_jar_path)',
219             '--output-path=<(jar_path)',
220             '--proguard-config=<(proguard_config)',
221             '--classpath=<(android_sdk_jar) >(input_jars_paths)',
222           ]
223         },
224       ],
225     }],
226     ['run_findbugs == 1', {
227       'actions': [
228         {
229           'action_name': 'findbugs_<(_target_name)',
230           'message': 'Running findbugs on <(_target_name)',
231           'inputs': [
232             '<(DEPTH)/build/android/findbugs_diff.py',
233             '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml',
234             '<(DEPTH)/build/android/pylib/utils/findbugs.py',
235             '>@(input_jars_paths)',
236             '<(jar_final_path)',
237             '<(compile_stamp)',
238           ],
239           'outputs': [
240             '<(findbugs_stamp)',
241           ],
242           'action': [
243             'python', '<(DEPTH)/build/android/findbugs_diff.py',
244             '--auxclasspath-gyp', '>(input_jars_paths)',
245             '--stamp', '<(findbugs_stamp)',
246             '<(jar_final_path)',
247           ],
248         },
249       ],
250     }],
251   ],
252   'actions': [
253     {
254       'action_name': 'javac_<(_target_name)',
255       'message': 'Compiling <(_target_name) java sources',
256       'variables': {
257         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java")'],
258       },
259       'inputs': [
260         '<(DEPTH)/build/android/gyp/util/build_utils.py',
261         '<(DEPTH)/build/android/gyp/javac.py',
262         '>@(java_sources)',
263         '>@(input_jars_paths)',
264         '>@(additional_input_paths)',
265       ],
266       'outputs': [
267         '<(compile_stamp)',
268         '<(javac_jar_path)',
269       ],
270       'action': [
271         'python', '<(DEPTH)/build/android/gyp/javac.py',
272         '--classpath=>(input_jars_paths)',
273         '--src-gendirs=>(generated_src_dirs)',
274         '--javac-includes=<(javac_includes)',
275         '--chromium-code=<(chromium_code)',
276         '--jar-path=<(javac_jar_path)',
277         '--jar-excluded-classes=<(jar_excluded_classes)',
278         '--stamp=<(compile_stamp)',
279         '>@(java_sources)',
280       ]
281     },
282     {
283       'action_name': 'instr_jar_<(_target_name)',
284       'message': 'Instrumenting <(_target_name) jar',
285       'variables': {
286         'input_path': '<(jar_path)',
287         'output_path': '<(jar_final_path)',
288         'stamp_path': '<(instr_stamp)',
289         'instr_type': 'jar',
290       },
291       'outputs': [
292         '<(jar_final_path)',
293       ],
294       'inputs': [
295         '<(jar_path)',
296       ],
297       'includes': [ 'android/instr_action.gypi' ],
298     },
299     {
300       'variables': {
301         'src_dirs': [
302           '<(java_in_dir)/src',
303           '>@(additional_src_dirs)',
304         ],
305         'stamp_path': '<(lint_stamp)',
306         'result_path': '<(lint_result)',
307         'config_path': '<(lint_config)',
308         'lint_jar_path': '<(jar_final_path)',
309       },
310       'inputs': [
311         '<(jar_final_path)',
312         '<(compile_stamp)',
313       ],
314       'outputs': [
315         '<(lint_stamp)',
316       ],
317       'includes': [ 'android/lint_action.gypi' ],
318     },
319     {
320       'action_name': 'jar_toc_<(_target_name)',
321       'message': 'Creating <(_target_name) jar.TOC',
322       'inputs': [
323         '<(DEPTH)/build/android/gyp/util/build_utils.py',
324         '<(DEPTH)/build/android/gyp/util/md5_check.py',
325         '<(DEPTH)/build/android/gyp/jar_toc.py',
326         '<(jar_final_path)',
327       ],
328       'outputs': [
329         '<(jar_final_path).TOC',
330       ],
331       'action': [
332         'python', '<(DEPTH)/build/android/gyp/jar_toc.py',
333         '--jar-path=<(jar_final_path)',
334         '--toc-path=<(jar_final_path).TOC',
335       ]
336     },
337     {
338       'action_name': 'dex_<(_target_name)',
339       'variables': {
340         'conditions': [
341           ['emma_instrument != 0', {
342             'dex_no_locals': 1,
343           }],
344         ],
345         'dex_input_paths': [ '<(jar_final_path)' ],
346         'output_path': '<(dex_path)',
347       },
348       'includes': [ 'android/dex_action.gypi' ],
349     },
350   ],