OLD | NEW |
| (Empty) |
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. | |
4 | |
5 # This file is meant to be included into a target to provide a rule | |
6 # to build Java in a consistent manner. | |
7 # | |
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 # } | |
17 # | |
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. | |
48 | |
49 { | |
50 'dependencies': [ | |
51 '<(DEPTH)/build/android/android_lint_cache.gyp:android_lint_cache', | |
52 '<(DEPTH)/build/android/setup.gyp:build_output_dirs', | |
53 ], | |
54 'variables': { | |
55 'add_to_dependents_classpaths%': 1, | |
56 'android_jar': '<(android_sdk)/android.jar', | |
57 'input_jars_paths': [ '<(android_jar)' ], | |
58 'additional_src_dirs': [], | |
59 'javac_includes': [], | |
60 'jar_name': '<(_target_name).jar', | |
61 'jar_dir': '<(PRODUCT_DIR)/lib.java', | |
62 'jar_path': '<(intermediate_dir)/<(jar_name)', | |
63 'jar_final_path': '<(jar_dir)/<(jar_name)', | |
64 'jar_excluded_classes': [ '*/R.class', '*/R##*.class' ], | |
65 'emma_instr_stamp': '<(intermediate_dir)/emma_instr.stamp', | |
66 'additional_input_paths': [], | |
67 'additional_locale_input_paths': [], | |
68 'dex_path': '<(PRODUCT_DIR)/lib.java/<(_target_name).dex.jar', | |
69 'generated_src_dirs': ['>@(generated_R_dirs)'], | |
70 'generated_R_dirs': [], | |
71 'has_java_resources%': 0, | |
72 'res_extra_dirs': [], | |
73 'res_extra_files': [], | |
74 'res_v14_skip%': 0, | |
75 'resource_input_paths': ['>@(res_extra_files)'], | |
76 'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)', | |
77 'compile_stamp': '<(intermediate_dir)/compile.stamp', | |
78 'lint_stamp': '<(intermediate_dir)/lint.stamp', | |
79 'lint_result': '<(intermediate_dir)/lint_result.xml', | |
80 'lint_config': '<(intermediate_dir)/lint_config.xml', | |
81 'never_lint%': 0, | |
82 'findbugs_stamp': '<(intermediate_dir)/findbugs.stamp', | |
83 'run_findbugs%': 0, | |
84 'java_in_dir_suffix%': '/src', | |
85 'proguard_config%': '', | |
86 'proguard_preprocess%': '0', | |
87 'variables': { | |
88 'variables': { | |
89 'proguard_preprocess%': 0, | |
90 'emma_never_instrument%': 0, | |
91 }, | |
92 'conditions': [ | |
93 ['proguard_preprocess == 1', { | |
94 'javac_jar_path': '<(intermediate_dir)/<(_target_name).pre.jar' | |
95 }, { | |
96 'javac_jar_path': '<(jar_path)' | |
97 }], | |
98 ['chromium_code != 0 and emma_coverage != 0 and emma_never_instrument ==
0', { | |
99 'emma_instrument': 1, | |
100 }, { | |
101 'emma_instrument': 0, | |
102 }], | |
103 ], | |
104 }, | |
105 'emma_instrument': '<(emma_instrument)', | |
106 'javac_jar_path': '<(javac_jar_path)', | |
107 'conditions': [ | |
108 ['chromium_code == 0', { | |
109 'enable_errorprone': 0, | |
110 }], | |
111 ], | |
112 'enable_errorprone%': 0, | |
113 'errorprone_exe_path': '<(PRODUCT_DIR)/bin.java/chromium_errorprone', | |
114 }, | |
115 'conditions': [ | |
116 ['add_to_dependents_classpaths == 1', { | |
117 # This all_dependent_settings is used for java targets only. This will add
the | |
118 # jar path to the classpath of dependent java targets. | |
119 'all_dependent_settings': { | |
120 'variables': { | |
121 'input_jars_paths': ['<(jar_final_path)'], | |
122 'library_dexed_jars_paths': ['<(dex_path)'], | |
123 }, | |
124 }, | |
125 }], | |
126 ['has_java_resources == 1', { | |
127 'variables': { | |
128 'resource_dir': '<(java_in_dir)/res', | |
129 'res_input_dirs': ['<(resource_dir)', '<@(res_extra_dirs)'], | |
130 'resource_input_paths': ['<!@(find <(resource_dir) -type f)'], | |
131 | |
132 'R_dir': '<(intermediate_dir)/java_R', | |
133 'R_text_file': '<(R_dir)/R.txt', | |
134 | |
135 'generated_src_dirs': ['<(R_dir)'], | |
136 'additional_input_paths': ['<(resource_zip_path)', ], | |
137 | |
138 'dependencies_locale_zip_paths': [], | |
139 'dependencies_res_zip_paths': [], | |
140 'resource_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip', | |
141 }, | |
142 'all_dependent_settings': { | |
143 'variables': { | |
144 # Dependent libraries include this target's R.java file via | |
145 # generated_R_dirs. | |
146 'generated_R_dirs': ['<(R_dir)'], | |
147 | |
148 # Dependent libraries and apks include this target's resources via | |
149 # dependencies_res_zip_paths. | |
150 'additional_input_paths': ['<(resource_zip_path)'], | |
151 'dependencies_res_zip_paths': ['<(resource_zip_path)'], | |
152 | |
153 # additional_res_packages and additional_R_text_files are used to | |
154 # create this packages R.java files when building the APK. | |
155 'additional_res_packages': ['<(R_package)'], | |
156 'additional_R_text_files': ['<(R_text_file)'], | |
157 }, | |
158 }, | |
159 'actions': [ | |
160 # Generate R.java and crunch image resources. | |
161 { | |
162 'action_name': 'process_resources', | |
163 'message': 'processing resources for <(_target_name)', | |
164 'variables': { | |
165 'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml', | |
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 >@(res
ource_input_paths))', | |
169 'process_resources_options': [], | |
170 'local_dependencies_res_zip_paths': [ | |
171 '>@(dependencies_res_zip_paths)', | |
172 '>@(dependencies_locale_zip_paths)' | |
173 ], | |
174 'conditions': [ | |
175 ['res_v14_skip == 1', { | |
176 'process_resources_options': ['--v14-skip'] | |
177 }], | |
178 ], | |
179 }, | |
180 'inputs': [ | |
181 '<(DEPTH)/build/android/gyp/util/build_utils.py', | |
182 '<(DEPTH)/build/android/gyp/process_resources.py', | |
183 '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py', | |
184 '>@(resource_input_paths)', | |
185 '>@(local_dependencies_res_zip_paths)', | |
186 '>(inputs_list_file)', | |
187 ], | |
188 'outputs': [ | |
189 '<(resource_zip_path)', | |
190 ], | |
191 'action': [ | |
192 'python', '<(DEPTH)/build/android/gyp/process_resources.py', | |
193 '--android-sdk-jar', '<(android_sdk_jar)', | |
194 '--aapt-path', '<(android_aapt_path)', | |
195 # Need to generate onResourcesLoaded() in R.java, so could be used i
n java lib. | |
196 '--shared-resources', | |
197 | |
198 '--android-manifest', '<(android_manifest)', | |
199 '--custom-package', '<(R_package)', | |
200 | |
201 '--dependencies-res-zips', '>(local_dependencies_res_zip_paths)', | |
202 '--resource-dirs', '<(res_input_dirs)', | |
203 | |
204 '--R-dir', '<(R_dir)', | |
205 '--resource-zip-out', '<(resource_zip_path)', | |
206 | |
207 '<@(process_resources_options)', | |
208 ], | |
209 }, | |
210 ], | |
211 }], | |
212 ['proguard_preprocess == 1', { | |
213 'actions': [ | |
214 { | |
215 'action_name': 'proguard_<(_target_name)', | |
216 'message': 'Proguard preprocessing <(_target_name) jar', | |
217 'inputs': [ | |
218 '<(DEPTH)/third_party/proguard/lib/proguard.jar', | |
219 '<(DEPTH)/build/android/gyp/util/build_utils.py', | |
220 '<(DEPTH)/build/android/gyp/proguard.py', | |
221 '<(javac_jar_path)', | |
222 '<(proguard_config)', | |
223 ], | |
224 'outputs': [ | |
225 '<(jar_path)', | |
226 ], | |
227 'action': [ | |
228 'python', '<(DEPTH)/build/android/gyp/proguard.py', | |
229 '--proguard-path=<(DEPTH)/third_party/proguard/lib/proguard.jar', | |
230 '--input-path=<(javac_jar_path)', | |
231 '--output-path=<(jar_path)', | |
232 '--proguard-config=<(proguard_config)', | |
233 '--classpath=<(android_sdk_jar) >(input_jars_paths)', | |
234 ] | |
235 }, | |
236 ], | |
237 }], | |
238 ['run_findbugs == 1', { | |
239 'actions': [ | |
240 { | |
241 'action_name': 'findbugs_<(_target_name)', | |
242 'message': 'Running findbugs on <(_target_name)', | |
243 'variables': { | |
244 'additional_findbugs_args': [], | |
245 'findbugs_verbose%': 0, | |
246 }, | |
247 'conditions': [ | |
248 ['findbugs_verbose == 1', { | |
249 'variables': { | |
250 'additional_findbugs_args+': ['-vv'], | |
251 }, | |
252 }], | |
253 ], | |
254 'inputs': [ | |
255 '<(DEPTH)/build/android/findbugs_diff.py', | |
256 '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml', | |
257 '<(DEPTH)/build/android/pylib/utils/findbugs.py', | |
258 '>@(input_jars_paths)', | |
259 '<(jar_final_path)', | |
260 '<(compile_stamp)', | |
261 ], | |
262 'outputs': [ | |
263 '<(findbugs_stamp)', | |
264 ], | |
265 'action': [ | |
266 'python', '<(DEPTH)/build/android/findbugs_diff.py', | |
267 '--auxclasspath-gyp', '>(input_jars_paths)', | |
268 '--stamp', '<(findbugs_stamp)', | |
269 '<@(additional_findbugs_args)', | |
270 '<(jar_final_path)', | |
271 ], | |
272 }, | |
273 ], | |
274 }], | |
275 ['enable_errorprone == 1', { | |
276 'dependencies': [ | |
277 '<(DEPTH)/third_party/errorprone/errorprone.gyp:require_errorprone', | |
278 ], | |
279 }], | |
280 ], | |
281 'actions': [ | |
282 { | |
283 'action_name': 'javac_<(_target_name)', | |
284 'message': 'Compiling <(_target_name) java sources', | |
285 'variables': { | |
286 'local_additional_input_paths': [ | |
287 '>@(additional_input_paths)', | |
288 '>@(additional_locale_input_paths)', | |
289 ], | |
290 'extra_args': [], | |
291 'extra_inputs': [], | |
292 'java_sources': ['>!@(find >(java_in_dir)>(java_in_dir_suffix) >(additio
nal_src_dirs) -name "*.java")'], | |
293 'conditions': [ | |
294 ['enable_errorprone == 1', { | |
295 'extra_inputs': [ | |
296 '<(errorprone_exe_path)', | |
297 ], | |
298 'extra_args': [ '--use-errorprone-path=<(errorprone_exe_path)' ], | |
299 }], | |
300 ], | |
301 }, | |
302 'inputs': [ | |
303 '<(DEPTH)/build/android/gyp/util/build_utils.py', | |
304 '<(DEPTH)/build/android/gyp/javac.py', | |
305 '>@(java_sources)', | |
306 '>@(input_jars_paths)', | |
307 '>@(local_additional_input_paths)', | |
308 '<@(extra_inputs)', | |
309 ], | |
310 'outputs': [ | |
311 '<(compile_stamp)', | |
312 '<(javac_jar_path)', | |
313 ], | |
314 'action': [ | |
315 'python', '<(DEPTH)/build/android/gyp/javac.py', | |
316 '--bootclasspath=<(android_sdk_jar)', | |
317 '--classpath=>(input_jars_paths)', | |
318 '--src-gendirs=>(generated_src_dirs)', | |
319 '--javac-includes=<(javac_includes)', | |
320 '--chromium-code=<(chromium_code)', | |
321 '--jar-path=<(javac_jar_path)', | |
322 '--jar-excluded-classes=<(jar_excluded_classes)', | |
323 '--stamp=<(compile_stamp)', | |
324 '>@(java_sources)', | |
325 '<@(extra_args)', | |
326 ] | |
327 }, | |
328 { | |
329 'action_name': 'emma_instr_jar_<(_target_name)', | |
330 'message': 'Instrumenting <(_target_name) jar', | |
331 'variables': { | |
332 'input_path': '<(jar_path)', | |
333 'output_path': '<(jar_final_path)', | |
334 'coverage_file': '<(jar_dir)/<(_target_name).em', | |
335 'sources_list_file': '<(jar_dir)/<(_target_name)_sources.txt', | |
336 'stamp_path': '<(emma_instr_stamp)', | |
337 }, | |
338 'outputs': [ | |
339 '<(jar_final_path)', | |
340 ], | |
341 'inputs': [ | |
342 '<(jar_path)', | |
343 ], | |
344 'includes': [ 'android/emma_instr_action.gypi' ], | |
345 }, | |
346 { | |
347 'variables': { | |
348 'src_dirs': [ | |
349 '<(java_in_dir)<(java_in_dir_suffix)', | |
350 '>@(additional_src_dirs)', | |
351 ], | |
352 'stamp_path': '<(lint_stamp)', | |
353 'result_path': '<(lint_result)', | |
354 'config_path': '<(lint_config)', | |
355 'lint_jar_path': '<(jar_final_path)', | |
356 }, | |
357 'inputs': [ | |
358 '<(jar_final_path)', | |
359 '<(compile_stamp)', | |
360 ], | |
361 'outputs': [ | |
362 '<(lint_stamp)', | |
363 ], | |
364 'includes': [ 'android/lint_action.gypi' ], | |
365 }, | |
366 { | |
367 'action_name': 'jar_toc_<(_target_name)', | |
368 'message': 'Creating <(_target_name) jar.TOC', | |
369 'inputs': [ | |
370 '<(DEPTH)/build/android/gyp/util/build_utils.py', | |
371 '<(DEPTH)/build/android/gyp/util/md5_check.py', | |
372 '<(DEPTH)/build/android/gyp/jar_toc.py', | |
373 '<(jar_final_path)', | |
374 ], | |
375 'outputs': [ | |
376 '<(jar_final_path).TOC', | |
377 ], | |
378 'action': [ | |
379 'python', '<(DEPTH)/build/android/gyp/jar_toc.py', | |
380 '--jar-path=<(jar_final_path)', | |
381 '--toc-path=<(jar_final_path).TOC', | |
382 ] | |
383 }, | |
384 { | |
385 'action_name': 'dex_<(_target_name)', | |
386 'variables': { | |
387 'conditions': [ | |
388 ['emma_instrument != 0', { | |
389 'dex_no_locals': 1, | |
390 }], | |
391 ], | |
392 'dex_input_paths': [ '<(jar_final_path)' ], | |
393 'output_path': '<(dex_path)', | |
394 }, | |
395 'includes': [ 'android/dex_action.gypi' ], | |
396 }, | |
397 ], | |
398 } | |
OLD | NEW |