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