Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: build/config/android/internal_rules.gni

Issue 687633003: Greatly improve (non-android) java support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import("//build/config/android/config.gni") 5 import("//build/config/android/config.gni")
6 6
7 assert(is_android) 7 assert(is_android)
8 8
9 9
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 "--jar-path", rebase_path(jar_path, root_build_dir), 48 "--jar-path", rebase_path(jar_path, root_build_dir),
49 "--processed-config-path", rebase_path(config_path, root_build_dir), 49 "--processed-config-path", rebase_path(config_path, root_build_dir),
50 "--result-path", rebase_path(result_path, root_build_dir), 50 "--result-path", rebase_path(result_path, root_build_dir),
51 "--java-files=$rebased_java_files", 51 "--java-files=$rebased_java_files",
52 "--enable", 52 "--enable",
53 ] 53 ]
54 } 54 }
55 } 55 }
56 56
57 57
58 template("dex") {
59 if (defined(invoker.testonly)) { testonly = invoker.testonly }
60
61 assert(defined(invoker.sources))
62 assert(defined(invoker.output))
63 action(target_name) {
64 script = "//build/android/gyp/dex.py"
65 depfile = "$target_gen_dir/$target_name.d"
66 sources = invoker.sources
67 outputs = [depfile, invoker.output]
68 if (defined(invoker.inputs)) {
69 inputs = invoker.inputs
70 }
71
72 if (defined(invoker.deps)) {
73 deps = invoker.deps
74 }
75
76 rebased_output = rebase_path(invoker.output, root_build_dir)
77
78 args = [
79 "--depfile", rebase_path(depfile, root_build_dir),
80 "--android-sdk-tools", rebased_android_sdk_build_tools,
81 "--dex-path", rebased_output,
82 ]
83
84 if (defined(invoker.no_locals) && invoker.no_locals) {
85 args += [
86 "--no-locals=1"
87 ]
88 }
89
90 if (defined(invoker.args)) {
91 args += invoker.args
92 }
93
94 args += rebase_path(invoker.sources, root_build_dir)
95 }
96 }
97
98
99 # Creates a zip archive of the inputs.
100 # If base_dir is provided, the archive paths will be relative to it.
101 template("zip") {
102 if (defined(invoker.testonly)) { testonly = invoker.testonly }
103
104 assert(defined(invoker.inputs))
105 assert(defined(invoker.output))
106
107 rebase_inputs = rebase_path(invoker.inputs, root_build_dir)
108 rebase_output = rebase_path(invoker.output, root_build_dir)
109 action(target_name) {
110 script = "//build/android/gn/zip.py"
111 depfile = "$target_gen_dir/$target_name.d"
112 inputs = invoker.inputs
113 outputs = [
114 depfile,
115 invoker.output
116 ]
117 args = [
118 "--depfile", rebase_path(depfile, root_build_dir),
119 "--inputs=$rebase_inputs",
120 "--output=$rebase_output",
121 ]
122 if (defined(invoker.base_dir)) {
123 args += [
124 "--base-dir", rebase_path(invoker.base_dir, root_build_dir)
125 ]
126 }
127 }
128 }
129
130
58 # Write the target's .build_config file. This is a json file that contains a 131 # Write the target's .build_config file. This is a json file that contains a
59 # dictionary of information about how to build this target (things that 132 # dictionary of information about how to build this target (things that
60 # require knowledge about this target's dependencies and cannot be calculated 133 # require knowledge about this target's dependencies and cannot be calculated
61 # at gn-time). There is a special syntax to add a value in that dictionary to 134 # at gn-time). There is a special syntax to add a value in that dictionary to
62 # an action/action_foreachs args: 135 # an action/action_foreachs args:
63 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) 136 # --python-arg=@FileArg($rebased_build_config_path:key0:key1)
64 # At runtime, such an arg will be replaced by the value in the build_config. 137 # At runtime, such an arg will be replaced by the value in the build_config.
65 # See build/android/gyp/write_build_config.py and 138 # See build/android/gyp/write_build_config.py and
66 # build/android/gyp/util/build_utils.py:ExpandFileArgs 139 # build/android/gyp/util/build_utils.py:ExpandFileArgs
67 template("write_build_config") { 140 template("write_build_config") {
68 if (defined(invoker.testonly)) { testonly = invoker.testonly } 141 if (defined(invoker.testonly)) { testonly = invoker.testonly }
69 142
70 assert(defined(invoker.type)) 143 assert(defined(invoker.type))
71 assert(defined(invoker.build_config)) 144 assert(defined(invoker.build_config))
72 145
73 type = invoker.type 146 type = invoker.type
74 build_config = invoker.build_config 147 build_config = invoker.build_config
75 148
76 assert(type == "android_apk" || type == "android_library" || type == "android_ resources") 149 assert(type == "android_apk" || type == "java_library" || type == "android_res ources")
77 150
78 action(target_name) { 151 action(target_name) {
79 script = "//build/android/gyp/write_build_config.py" 152 script = "//build/android/gyp/write_build_config.py"
80 depfile = "$target_gen_dir/$target_name.d" 153 depfile = "$target_gen_dir/$target_name.d"
81 inputs = [] 154 inputs = []
82 155
83 deps = [] 156 deps = []
84 if (defined(invoker.deps)) { 157 if (defined(invoker.deps)) {
85 deps += invoker.deps 158 deps += invoker.deps
86 } 159 }
(...skipping 11 matching lines...) Expand all
98 build_config 171 build_config
99 ] 172 ]
100 173
101 args = [ 174 args = [
102 "--type", type, 175 "--type", type,
103 "--depfile", rebase_path(depfile, root_build_dir), 176 "--depfile", rebase_path(depfile, root_build_dir),
104 "--possible-deps-configs=$rebase_possible_deps_configs", 177 "--possible-deps-configs=$rebase_possible_deps_configs",
105 "--build-config", rebase_path(build_config, root_build_dir), 178 "--build-config", rebase_path(build_config, root_build_dir),
106 ] 179 ]
107 180
108 if (type == "android_library" || type == "android_apk") { 181 is_java_library = type == "java_library"
182 is_apk = type == "android_apk"
183 is_android_resources = type == "android_resources"
184
185 supports_android = (is_apk || is_android_resources ||
186 (is_java_library && defined(invoker.supports_android) &&
187 invoker.supports_android))
188 requires_android = (is_apk || is_android_resources ||
189 (is_java_library && defined(invoker.requires_android) &&
190 invoker.requires_android))
191
192 assert(!requires_android || supports_android, "requires_android requires" +
193 " supports_android")
194 # Mark these variables as used.
195 assert(is_java_library || true)
196 assert(is_apk || true)
197 assert(is_android_resources || true)
198
199 if (is_java_library || is_apk) {
109 args += [ 200 args += [
110 "--jar-path", rebase_path(invoker.jar_path, root_build_dir), 201 "--jar-path", rebase_path(invoker.jar_path, root_build_dir),
202 ]
203 }
204
205 if (is_apk || (is_java_library && supports_android)) {
206 args += [
111 "--dex-path", rebase_path(invoker.dex_path, root_build_dir), 207 "--dex-path", rebase_path(invoker.dex_path, root_build_dir),
112 ] 208 ]
113 } 209 }
210 if (supports_android) {
211 args += [ "--supports-android" ]
212 }
213 if (requires_android) {
214 args += [ "--requires-android" ]
215 }
114 216
115 if (type == "android_resources" || type == "android_apk") { 217 if (is_android_resources || is_apk) {
116 assert(defined(invoker.resources_zip)) 218 assert(defined(invoker.resources_zip))
117 args += [ 219 args += [
118 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), 220 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir),
119 ] 221 ]
120 if (defined(invoker.android_manifest)) { 222 if (defined(invoker.android_manifest)) {
121 inputs += [ 223 inputs += [
122 invoker.android_manifest 224 invoker.android_manifest
123 ] 225 ]
124 args += [ 226 args += [
125 "--android-manifest", rebase_path(invoker.android_manifest, root_build _dir), 227 "--android-manifest", rebase_path(invoker.android_manifest, root_build _dir),
126 ] 228 ]
127 } 229 }
128 if (defined(invoker.custom_package)) { 230 if (defined(invoker.custom_package)) {
129 args += [ 231 args += [
130 "--package-name", invoker.custom_package 232 "--package-name", invoker.custom_package
131 ] 233 ]
132 } 234 }
133 } 235 }
134 236
135 if (type == "android_apk") { 237 if (is_apk) {
136 if (defined(invoker.native_libs)) { 238 if (defined(invoker.native_libs)) {
137 rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir) 239 rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir)
138 rebased_android_readelf = rebase_path(android_readelf, root_build_dir) 240 rebased_android_readelf = rebase_path(android_readelf, root_build_dir)
139 args += [ 241 args += [
140 "--native-libs=$rebased_native_libs", 242 "--native-libs=$rebased_native_libs",
141 "--readelf-path=$rebased_android_readelf", 243 "--readelf-path=$rebased_android_readelf",
142 ] 244 ]
143 } 245 }
144 } 246 }
145 247
146 if (defined(invoker.srcjar)) { 248 if (defined(invoker.srcjar)) {
147 args += [ 249 args += [
148 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) 250 "--srcjar", rebase_path(invoker.srcjar, root_build_dir)
149 ] 251 ]
150 } 252 }
151 } 253 }
152 } 254 }
153 255
154 256
155 # Creates a zip archive of the inputs. 257 template("process_java_prebuilt") {
156 # If base_dir is provided, the archive paths will be relative to it.
157 template("zip") {
158 if (defined(invoker.testonly)) { testonly = invoker.testonly } 258 if (defined(invoker.testonly)) { testonly = invoker.testonly }
159 259
160 assert(defined(invoker.inputs)) 260 _input_jar_path = invoker.input_jar_path
161 assert(defined(invoker.output)) 261 _output_jar_path = invoker.output_jar_path
262 _jar_toc_path = _output_jar_path + ".TOC"
162 263
163 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) 264 assert(invoker.build_config != "")
164 rebase_output = rebase_path(invoker.output, root_build_dir) 265
165 action(target_name) { 266 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
166 script = "//build/android/gn/zip.py" 267 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar"
268 _proguard_config_path = invoker.proguard_config
269 _build_config = invoker.build_config
270 _rebased_build_config = rebase_path(_build_config, root_build_dir)
271 action("${target_name}__proguard_process") {
272 script = "//build/android/gyp/proguard.py"
273 inputs = [
274 android_sdk_jar,
275 _proguard_jar_path,
276 _build_config,
277 _input_jar_path,
278 _proguard_config_path,
279 ]
280 depfile = "${target_gen_dir}/${target_name}.d"
281 outputs = [
282 depfile,
283 _output_jar_path,
284 ]
285 args = [
286 "--depfile", rebase_path(depfile, root_build_dir),
287 "--proguard-path", rebase_path(_proguard_jar_path, root_build_dir),
288 "--input-path", rebase_path(_input_jar_path, root_build_dir),
289 "--output-path", rebase_path(_output_jar_path, root_build_dir),
290 "--proguard-config", rebase_path(_proguard_config_path, root_build_dir),
291 "--classpath", rebased_android_sdk_jar,
292 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
293 ]
294 }
295 } else {
296 copy("${target_name}__copy_jar") {
297 sources = [_input_jar_path]
298 outputs = [_output_jar_path]
299 }
300 }
301
302 action("${target_name}__jar_toc") {
303 script = "//build/android/gyp/jar_toc.py"
167 depfile = "$target_gen_dir/$target_name.d" 304 depfile = "$target_gen_dir/$target_name.d"
168 inputs = invoker.inputs
169 outputs = [ 305 outputs = [
170 depfile, 306 depfile,
171 invoker.output 307 _jar_toc_path,
308 _jar_toc_path + ".md5.stamp"
172 ] 309 ]
310 inputs = [ _output_jar_path ]
173 args = [ 311 args = [
174 "--depfile", rebase_path(depfile, root_build_dir), 312 "--depfile", rebase_path(depfile, root_build_dir),
175 "--inputs=$rebase_inputs", 313 "--jar-path", rebase_path(_output_jar_path, root_build_dir),
176 "--output=$rebase_output", 314 "--toc-path", rebase_path(_jar_toc_path, root_build_dir),
177 ] 315 ]
178 if (defined(invoker.base_dir)) { 316 }
179 args += [ 317
180 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) 318 group(target_name) {
181 ] 319 deps = [
182 } 320 ":${target_name}__jar_toc"
321 ]
183 } 322 }
184 } 323 }
185 324
186 template("dex") {
187 if (defined(invoker.testonly)) { testonly = invoker.testonly }
188
189 assert(defined(invoker.sources))
190 assert(defined(invoker.output))
191 action(target_name) {
192 script = "//build/android/gyp/dex.py"
193 depfile = "$target_gen_dir/$target_name.d"
194 sources = invoker.sources
195 outputs = [depfile, invoker.output]
196 if (defined(invoker.inputs)) {
197 inputs = invoker.inputs
198 }
199
200 if (defined(invoker.deps)) {
201 deps = invoker.deps
202 }
203
204 rebased_output = rebase_path(invoker.output, root_build_dir)
205
206 args = [
207 "--depfile", rebase_path(depfile, root_build_dir),
208 "--android-sdk-tools", rebased_android_sdk_build_tools,
209 "--dex-path", rebased_output,
210 ]
211
212 if (defined(invoker.no_locals) && invoker.no_locals) {
213 args += [
214 "--no-locals=1"
215 ]
216 }
217
218 if (defined(invoker.args)) {
219 args += invoker.args
220 }
221
222 args += rebase_path(invoker.sources, root_build_dir)
223 }
224 }
225 325
226 # Packages resources, assets, dex, and native libraries into an apk. Signs and 326 # Packages resources, assets, dex, and native libraries into an apk. Signs and
227 # zipaligns the apk. 327 # zipaligns the apk.
228 template("create_apk") { 328 template("create_apk") {
229 if (defined(invoker.testonly)) { testonly = invoker.testonly } 329 if (defined(invoker.testonly)) { testonly = invoker.testonly }
230 330
231 _android_manifest = invoker.android_manifest 331 _android_manifest = invoker.android_manifest
232 _base_path = invoker.base_path 332 _base_path = invoker.base_path
233 _final_apk_path = invoker.apk_path 333 _final_apk_path = invoker.apk_path
234 _resources_zip = invoker.resources_zip 334 _resources_zip = invoker.resources_zip
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 "--rezip-apk-jar-path", rebase_path(_rezip_jar_path, root_build_dir) 472 "--rezip-apk-jar-path", rebase_path(_rezip_jar_path, root_build_dir)
373 ] 473 ]
374 } 474 }
375 } 475 }
376 476
377 group(target_name) { 477 group(target_name) {
378 deps = [":${target_name}__finalize"] 478 deps = [":${target_name}__finalize"]
379 } 479 }
380 } 480 }
381 481
382 template("java_prebuilt") { 482 template("java_prebuilt_impl") {
383 if (defined(invoker.testonly)) { testonly = invoker.testonly } 483 if (defined(invoker.testonly)) { testonly = invoker.testonly }
484 _supports_android = (
485 defined(invoker.supports_android) && invoker.supports_android)
384 486
385 _input_jar_path = invoker.input_jar_path 487 assert(defined(invoker.jar_path))
386 _output_jar_path = invoker.output_jar_path 488 _base_path = "${target_gen_dir}/$target_name"
387 _jar_toc_path = _output_jar_path + ".TOC" 489 _jar_path = _base_path + ".jar"
490 _build_config = _base_path + ".build_config"
388 491
389 assert(invoker.build_config != "") 492 if (_supports_android) {
493 _dex_path = _base_path + ".dex.jar"
494 }
390 495
391 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { 496 _final_deps = []
392 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" 497 _template_name = target_name
393 _proguard_config_path = invoker.proguard_config 498
394 _build_config = invoker.build_config 499
395 _rebased_build_config = rebase_path(_build_config, root_build_dir) 500 _final_deps += [ ":${_template_name}__build_config" ]
396 action("${target_name}__proguard_process") { 501 write_build_config("${_template_name}__build_config") {
397 script = "//build/android/gyp/proguard.py" 502 type = "java_library"
398 inputs = [ 503 supports_android = _supports_android
399 android_sdk_jar, 504 requires_android = (defined(invoker.requires_android) &&
400 _proguard_jar_path, 505 invoker.requires_android)
401 _build_config, 506
402 _input_jar_path, 507 deps = []
403 _proguard_config_path, 508 if (defined(invoker.deps)) {
404 ] 509 deps += invoker.deps
405 depfile = "${target_gen_dir}/${target_name}.d"
406 outputs = [
407 depfile,
408 _output_jar_path,
409 ]
410 args = [
411 "--depfile", rebase_path(depfile, root_build_dir),
412 "--proguard-path", rebase_path(_proguard_jar_path, root_build_dir),
413 "--input-path", rebase_path(_input_jar_path, root_build_dir),
414 "--output-path", rebase_path(_output_jar_path, root_build_dir),
415 "--proguard-config", rebase_path(_proguard_config_path, root_build_dir),
416 "--classpath", rebased_android_sdk_jar,
417 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
418 ]
419 } 510 }
420 } else { 511 build_config = _build_config
421 copy("${target_name}__copy_jar") { 512 jar_path = _jar_path
422 sources = [_input_jar_path] 513 if (_supports_android) {
423 outputs = [_output_jar_path] 514 dex_path = _dex_path
424 } 515 }
425 } 516 }
426 517
427 action("${target_name}__jar_toc") { 518 _final_deps += [ ":${_template_name}__process_jar" ]
428 script = "//build/android/gyp/jar_toc.py" 519 process_java_prebuilt("${_template_name}__process_jar") {
429 depfile = "$target_gen_dir/$target_name.d" 520 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
430 outputs = [ 521 proguard_preprocess = true
431 depfile, 522 proguard_config = invoker.proguard_config
432 _jar_toc_path, 523 }
433 _jar_toc_path + ".md5.stamp" 524
434 ] 525 build_config = _build_config
435 inputs = [ _output_jar_path ] 526 input_jar_path = invoker.jar_path
436 args = [ 527 output_jar_path = _jar_path
437 "--depfile", rebase_path(depfile, root_build_dir), 528 }
438 "--jar-path", rebase_path(_output_jar_path, root_build_dir), 529
439 "--toc-path", rebase_path(_jar_toc_path, root_build_dir), 530 if (_supports_android) {
440 ] 531 _final_deps += [ ":${_template_name}__dex" ]
532 dex("${_template_name}__dex") {
533 sources = [_jar_path]
534 output = _dex_path
535 }
441 } 536 }
442 537
443 group(target_name) { 538 group(target_name) {
444 deps = [ 539 deps = _final_deps
445 ":${target_name}__jar_toc"
446 ]
447 } 540 }
448 } 541 }
449 542
543
450 # Compiles and jars a set of java files. 544 # Compiles and jars a set of java files.
451 # 545 #
452 # Outputs: 546 # Outputs:
453 # $jar_path.jar 547 # $jar_path.jar
454 # $jar_path.jar.TOC 548 # $jar_path.jar.TOC
455 # 549 #
456 # Variables 550 # Variables
457 # java_files: List of .java files to compile. 551 # java_files: List of .java files to compile.
458 # java_deps: List of java dependencies. These should all have a .jar output 552 # java_deps: List of java dependencies. These should all have a .jar output
459 # at "${target_gen_dir}/${target_name}.jar. 553 # at "${target_gen_dir}/${target_name}.jar.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 _java_srcjars = invoker.srcjars 589 _java_srcjars = invoker.srcjars
496 } 590 }
497 foreach(dep, _srcjar_deps) { 591 foreach(dep, _srcjar_deps) {
498 _dep_gen_dir = get_label_info(dep, "target_gen_dir") 592 _dep_gen_dir = get_label_info(dep, "target_gen_dir")
499 _dep_name = get_label_info(dep, "name") 593 _dep_name = get_label_info(dep, "name")
500 _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ] 594 _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
501 } 595 }
502 # Mark srcjar_deps as used. 596 # Mark srcjar_deps as used.
503 assert(_srcjar_deps == [] || true) 597 assert(_srcjar_deps == [] || true)
504 598
505 _system_jars = [ android_sdk_jar ] 599 _system_jars = []
506 action("${target_name}__javac") { 600 if (defined(invoker.android) && invoker.android) {
601 _system_jars += [ android_sdk_jar ]
602 }
603
604 _rebased_build_config = rebase_path(_build_config, root_build_dir)
605 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir)
606
607 _template_name = target_name
608 _final_deps = [ ":${_template_name}__javac" ]
609 action("${_template_name}__javac") {
507 script = "//build/android/gyp/javac.py" 610 script = "//build/android/gyp/javac.py"
508 depfile = "$target_gen_dir/$target_name.d" 611 depfile = "$target_gen_dir/$target_name.d"
612 deps = []
509 outputs = [ 613 outputs = [
510 depfile, 614 depfile,
511 _intermediate_jar_path, 615 _intermediate_jar_path,
512 _intermediate_jar_path + ".md5.stamp" 616 _intermediate_jar_path + ".md5.stamp"
513 ] 617 ]
514 sources = _java_files + _java_srcjars 618 sources = _java_files + _java_srcjars
515 inputs = _system_jars + [ _build_config ] 619 inputs = _system_jars + [ _build_config ]
516 620
517 _rebased_system_jars = rebase_path(_system_jars, root_build_dir) 621 _rebased_system_jars = rebase_path(_system_jars, root_build_dir)
518 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir) 622 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir)
519 _rebased_build_config = rebase_path(_build_config, root_build_dir)
520 _rebased_depfile = rebase_path(depfile, root_build_dir) 623 _rebased_depfile = rebase_path(depfile, root_build_dir)
521 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir)
522 args = [ 624 args = [
523 "--depfile=$_rebased_depfile", 625 "--depfile=$_rebased_depfile",
524 "--classpath=$_rebased_system_jars", 626 "--classpath=$_rebased_system_jars",
525 "--classpath=@FileArg($_rebased_build_config:javac:classpath)", 627 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
526 "--jar-path=$_rebased_jar_path", 628 "--jar-path=$_rebased_jar_path",
527 "--java-srcjars=$_rebased_java_srcjars", 629 "--java-srcjars=$_rebased_java_srcjars",
528 "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)", 630 "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
529 "--jar-excluded-classes=$_jar_excluded_patterns", 631 "--jar-excluded-classes=$_jar_excluded_patterns",
530 ] 632 ]
531 if (_chromium_code) { 633 if (_chromium_code) {
532 args += [ "--chromium-code" ] 634 args += [ "--chromium-code=1" ]
635 }
636
637 if (defined(invoker.main_class)) {
638 args += [
639 "--main-class", invoker.main_class
640 ]
533 } 641 }
534 642
535 args += rebase_path(_java_files, root_build_dir) 643 args += rebase_path(_java_files, root_build_dir)
536 } 644 }
537 645
538 java_prebuilt("${target_name}__finish") { 646 _final_deps += [ ":${_template_name}__finish" ]
647 process_java_prebuilt("${_template_name}__finish") {
539 build_config = _build_config 648 build_config = _build_config
540 input_jar_path = _intermediate_jar_path 649 input_jar_path = _intermediate_jar_path
541 output_jar_path = _final_jar_path 650 output_jar_path = _final_jar_path
542 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { 651 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
543 proguard_preprocess = invoker.proguard_preprocess 652 proguard_preprocess = invoker.proguard_preprocess
544 proguard_config = invoker.proguard_config 653 proguard_config = invoker.proguard_config
545 } 654 }
546 } 655 }
547 656
548 group(target_name) { 657 group(target_name) {
549 deps = [ 658 deps = _final_deps
550 ":${target_name}__javac",
551 ":${target_name}__finish",
552 ]
553 } 659 }
554 } 660 }
555 661
556 662
557 # This adds Android-specific parts to the java_library template. 663 template("java_library_impl") {
558 #
559 # Runs Android lint against the compiled java files.
560 # Dexes the output jar for inclusion in an APK.
561 template("android_java_library") {
562 if (defined(invoker.testonly)) { testonly = invoker.testonly } 664 if (defined(invoker.testonly)) { testonly = invoker.testonly }
563 665
564 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir) 666 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
565 || defined(invoker.srcjars) || defined(invoker.srcjar_deps)) 667 || defined(invoker.srcjars) || defined(invoker.srcjar_deps))
566 assert(defined(invoker.build_config)) 668 _base_path = "$target_gen_dir/$target_name"
567 assert(defined(invoker.jar_path)) 669 _jar_path = _base_path + ".jar"
568 assert(defined(invoker.dex_path)) 670 if (defined(invoker.jar_path)) {
671 _jar_path = invoker.jar_path
672 }
673 _template_name = target_name
674
675 _final_deps = []
676 _final_datadeps = []
677 if (defined(invoker.datadeps)) {
678 _final_datadeps = invoker.datadeps
679 }
680
681 _supports_android = (defined(invoker.supports_android) &&
682 invoker.supports_android)
683 _requires_android = (defined(invoker.requires_android) &&
684 invoker.requires_android)
685
686 if (_supports_android) {
687 _dex_path = _base_path + ".dex.jar"
688 if (defined(invoker.dex_path)) {
689 _dex_path = invoker.dex_path
690 }
691 }
692
693 if (defined(invoker.override_build_config)) {
694 _build_config = invoker.override_build_config
695 } else {
696 _build_config = _base_path + ".build_config"
697 _final_deps += [ ":${_template_name}__build_config" ]
698 write_build_config("${_template_name}__build_config") {
699 type = "java_library"
700 supports_android = _supports_android
701 requires_android = _requires_android
702
703 deps = []
704 if (defined(invoker.deps)) {
705 deps += invoker.deps
706 }
707
708 build_config = _build_config
709 jar_path = _jar_path
710 if (_supports_android) {
711 dex_path = _dex_path
712 }
713 }
714 }
715
716 _chromium_code = true
717 if (defined(invoker.chromium_code)) {
718 _chromium_code = invoker.chromium_code
719 }
569 720
570 _srcjar_deps = [] 721 _srcjar_deps = []
571 if (defined(invoker.srcjar_deps)) { 722 if (defined(invoker.srcjar_deps)) {
572 _srcjar_deps = invoker.srcjar_deps 723 _srcjar_deps = invoker.srcjar_deps
573 } 724 }
574 725
575 _srcjars = [] 726 _srcjars = []
576 if (defined(invoker.srcjars)) { 727 if (defined(invoker.srcjars)) {
577 _srcjars = invoker.srcjars 728 _srcjars = invoker.srcjars
578 } 729 }
(...skipping 16 matching lines...) Expand all
595 "--pattern", 746 "--pattern",
596 "*.java", 747 "*.java",
597 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir) 748 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
598 ], 749 ],
599 "list lines" 750 "list lines"
600 ) 751 )
601 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) 752 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
602 } 753 }
603 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != []) 754 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
604 755
605 _jar_path = invoker.jar_path 756 _final_deps += [ ":${_template_name}__compile_java" ]
606 _dex_path = invoker.dex_path 757 compile_java("${_template_name}__compile_java") {
607
608 _android_manifest = "//build/android/AndroidManifest.xml"
609 if (defined(invoker.android_manifest)) {
610 _android_manifest = invoker.android_manifest
611 }
612 assert(_android_manifest != "")
613
614 _final_deps = []
615 _final_datadeps = []
616
617 compile_java("${target_name}__compile_java") {
618 jar_path = _jar_path 758 jar_path = _jar_path
619 if (defined(invoker.jar_excluded_patterns)) { 759 build_config = _build_config
620 jar_excluded_patterns = invoker.jar_excluded_patterns
621 }
622 build_config = invoker.build_config
623 java_files = _java_files 760 java_files = _java_files
624 srcjar_deps = _srcjar_deps 761 srcjar_deps = _srcjar_deps
625 srcjars = _srcjars 762 srcjars = _srcjars
763 chromium_code = _chromium_code
764 android = _requires_android
626 765
627 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { 766 if (defined(invoker.jar_excluded_patterns)) { jar_excluded_patterns = invoke r.jar_excluded_patterns }
628 proguard_preprocess = invoker.proguard_preprocess 767 if (defined(invoker.main_class)) { main_class = invoker.main_class }
629 proguard_config = invoker.proguard_config 768 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess }
630 } 769 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig }
770 if (defined(invoker.dist_jar_path)) { dist_jar_path = invoker.dist_jar_path }
771 }
631 772
632 if (defined(invoker.dist_jar_path)) { 773 if (defined(invoker.main_class)) {
633 dist_jar_path = invoker.dist_jar_path 774 _final_deps += [ ":${_template_name}__binary_script" ]
775 action("${_template_name}__binary_script") {
776 script = "//build/android/gyp/create_java_binary_script.py"
777 depfile = "$target_gen_dir/$target_name.d"
778 java_script = "$root_build_dir/bin/$_template_name"
779 inputs = [ _build_config ]
780 outputs = [
781 depfile,
782 java_script,
783 ]
784 _rebased_build_config = rebase_path(_build_config, root_build_dir)
785 args = [
786 "--depfile", rebase_path(depfile, root_build_dir),
787 "--output", rebase_path(java_script, root_build_dir),
788 "--classpath=@FileArg($_rebased_build_config:java:full_classpath)",
789 "--jar-path", rebase_path(_jar_path, root_build_dir),
790 "--main-class", invoker.main_class,
791 ]
634 } 792 }
635 } 793 }
636 794
637 if (defined(invoker.chromium_code) && invoker.chromium_code) { 795 if (_supports_android) {
638 _final_datadeps += [ ":${target_name}__lint" ] 796 if (defined(invoker.chromium_code) && invoker.chromium_code) {
639 android_lint("${target_name}__lint") { 797 _android_manifest = "//build/android/AndroidManifest.xml"
640 android_manifest = _android_manifest 798 if (defined(invoker.android_manifest)) {
641 jar_path = _jar_path 799 _android_manifest = invoker.android_manifest
642 java_files = _java_files 800 }
801
802 _final_datadeps += [ ":${_template_name}__lint" ]
803 android_lint("${_template_name}__lint") {
804 android_manifest = _android_manifest
805 jar_path = _jar_path
806 java_files = _java_files
807 }
808 }
809
810 _final_deps += [ ":${_template_name}__dex" ]
811 dex("${_template_name}__dex") {
812 sources = [_jar_path]
813 output = _dex_path
643 } 814 }
644 } 815 }
645 816
646 dex("${target_name}__dex") {
647 sources = [_jar_path]
648 output = _dex_path
649 }
650
651 group(target_name) { 817 group(target_name) {
652 deps = [ 818 deps = _final_deps
653 ":${target_name}__compile_java", 819 datadeps = _final_datadeps
654 ":${target_name}__dex",
655 ] + _final_deps + _final_datadeps
656 } 820 }
657 } 821 }
658 822
823
659 # Runs process_resources.py 824 # Runs process_resources.py
660 template("process_resources") { 825 template("process_resources") {
661 if (defined(invoker.testonly)) { testonly = invoker.testonly } 826 if (defined(invoker.testonly)) { testonly = invoker.testonly }
662 827
663 zip_path = invoker.zip_path 828 zip_path = invoker.zip_path
664 srcjar_path = invoker.srcjar_path 829 srcjar_path = invoker.srcjar_path
665 build_config = invoker.build_config 830 build_config = invoker.build_config
666 resource_dirs = invoker.resource_dirs 831 resource_dirs = invoker.resource_dirs
667 android_manifest = invoker.android_manifest 832 android_manifest = invoker.android_manifest
668 833
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 939
775 if (defined(invoker.clear_dir) && invoker.clear_dir) { 940 if (defined(invoker.clear_dir) && invoker.clear_dir) {
776 args += ["--clear"] 941 args += ["--clear"]
777 } 942 }
778 943
779 if (defined(invoker.args)) { 944 if (defined(invoker.args)) {
780 args += invoker.args 945 args += invoker.args
781 } 946 }
782 } 947 }
783 } 948 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698