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