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