OLD | NEW |
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 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) | 9 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) |
10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) | 10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) |
11 rebased_android_sdk_build_tools = | 11 rebased_android_sdk_build_tools = |
12 rebase_path(android_sdk_build_tools, root_build_dir) | 12 rebase_path(android_sdk_build_tools, root_build_dir) |
13 | 13 |
14 android_sdk_jar = "$android_sdk/android.jar" | 14 android_sdk_jar = "$android_sdk/android.jar" |
15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) | 15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) |
| 16 android_aapt_path = "$rebased_android_sdk_build_tools/aapt" |
16 | 17 |
17 template("android_lint") { | 18 template("android_lint") { |
18 set_sources_assignment_filter([]) | 19 set_sources_assignment_filter([]) |
19 if (defined(invoker.testonly)) { | 20 if (defined(invoker.testonly)) { |
20 testonly = invoker.testonly | 21 testonly = invoker.testonly |
21 } | 22 } |
22 | 23 |
23 jar_path = invoker.jar_path | 24 jar_path = invoker.jar_path |
24 android_manifest = invoker.android_manifest | 25 android_manifest = invoker.android_manifest |
25 java_files = invoker.java_files | 26 java_files = invoker.java_files |
(...skipping 26 matching lines...) Expand all Loading... |
52 "--product-dir=.", | 53 "--product-dir=.", |
53 "--jar-path", | 54 "--jar-path", |
54 rebase_path(jar_path, root_build_dir), | 55 rebase_path(jar_path, root_build_dir), |
55 "--processed-config-path", | 56 "--processed-config-path", |
56 rebase_path(config_path, root_build_dir), | 57 rebase_path(config_path, root_build_dir), |
57 "--result-path", | 58 "--result-path", |
58 rebase_path(result_path, root_build_dir), | 59 rebase_path(result_path, root_build_dir), |
59 "--java-files=$rebased_java_files", | 60 "--java-files=$rebased_java_files", |
60 "--enable", | 61 "--enable", |
61 ] | 62 ] |
| 63 |
| 64 if (defined(invoker.deps)) { |
| 65 deps = invoker.deps |
| 66 } |
| 67 if (defined(invoker.public_deps)) { |
| 68 public_deps = invoker.public_deps |
| 69 } |
| 70 if (defined(invoker.data_deps)) { |
| 71 data_deps = invoker.data_deps |
| 72 } |
62 } | 73 } |
63 } | 74 } |
64 | 75 |
65 template("findbugs") { | 76 template("findbugs") { |
66 jar_path = invoker.jar_path | 77 jar_path = invoker.jar_path |
67 | 78 |
68 build_config = invoker.build_config | 79 build_config = invoker.build_config |
69 | 80 |
70 action(target_name) { | 81 action(target_name) { |
71 script = "//build/android/findbugs_diff.py" | 82 script = "//build/android/findbugs_diff.py" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 rebase_path(depfile, root_build_dir), | 187 rebase_path(depfile, root_build_dir), |
177 "--inputs=$rebase_inputs", | 188 "--inputs=$rebase_inputs", |
178 "--output=$rebase_output", | 189 "--output=$rebase_output", |
179 ] | 190 ] |
180 if (defined(invoker.base_dir)) { | 191 if (defined(invoker.base_dir)) { |
181 args += [ | 192 args += [ |
182 "--base-dir", | 193 "--base-dir", |
183 rebase_path(invoker.base_dir, root_build_dir), | 194 rebase_path(invoker.base_dir, root_build_dir), |
184 ] | 195 ] |
185 } | 196 } |
| 197 |
| 198 if (defined(invoker.deps)) { |
| 199 deps = invoker.deps |
| 200 } |
| 201 if (defined(invoker.public_deps)) { |
| 202 public_deps = invoker.public_deps |
| 203 } |
| 204 if (defined(invoker.data_deps)) { |
| 205 data_deps = invoker.data_deps |
| 206 } |
| 207 |
| 208 if (defined(invoker.visibility)) { |
| 209 visibility = invoker.visibility |
| 210 } |
186 } | 211 } |
187 } | 212 } |
188 | 213 |
189 # Write the target's .build_config file. This is a json file that contains a | 214 # Write the target's .build_config file. This is a json file that contains a |
190 # dictionary of information about how to build this target (things that | 215 # dictionary of information about how to build this target (things that |
191 # require knowledge about this target's dependencies and cannot be calculated | 216 # require knowledge about this target's dependencies and cannot be calculated |
192 # at gn-time). There is a special syntax to add a value in that dictionary to | 217 # at gn-time). There is a special syntax to add a value in that dictionary to |
193 # an action/action_foreachs args: | 218 # an action/action_foreachs args: |
194 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) | 219 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) |
195 # At runtime, such an arg will be replaced by the value in the build_config. | 220 # At runtime, such an arg will be replaced by the value in the build_config. |
196 # See build/android/gyp/write_build_config.py and | 221 # See build/android/gyp/write_build_config.py and |
197 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 222 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
198 template("write_build_config") { | 223 template("write_build_config") { |
199 set_sources_assignment_filter([]) | 224 set_sources_assignment_filter([]) |
200 if (defined(invoker.testonly)) { | 225 if (defined(invoker.testonly)) { |
201 testonly = invoker.testonly | 226 testonly = invoker.testonly |
202 } | 227 } |
203 | 228 |
204 assert(defined(invoker.type)) | 229 assert(defined(invoker.type)) |
205 assert(defined(invoker.build_config)) | 230 assert(defined(invoker.build_config)) |
206 | 231 |
207 type = invoker.type | 232 type = invoker.type |
208 build_config = invoker.build_config | 233 build_config = invoker.build_config |
209 | 234 |
210 assert(type == "android_apk" || type == "java_library" || | 235 assert(type == "android_apk" || type == "java_library" || |
211 type == "android_resources" || type == "deps_dex") | 236 type == "android_resources" || type == "deps_dex") |
212 | 237 |
213 action(target_name) { | 238 action(target_name) { |
| 239 if (defined(invoker.visibility)) { |
| 240 visibility = invoker.visibility |
| 241 } |
| 242 |
214 script = "//build/android/gyp/write_build_config.py" | 243 script = "//build/android/gyp/write_build_config.py" |
215 depfile = "$target_gen_dir/$target_name.d" | 244 depfile = "$target_gen_dir/$target_name.d" |
216 inputs = [] | 245 inputs = [] |
217 | 246 |
218 deps = [] | 247 deps = [] |
219 if (defined(invoker.deps)) { | 248 if (defined(invoker.deps)) { |
220 deps += invoker.deps | 249 deps += invoker.deps |
221 } | 250 } |
222 | 251 |
223 possible_deps_configs = [] | 252 possible_deps_configs = [] |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 _output_jar_path = invoker.output_jar_path | 391 _output_jar_path = invoker.output_jar_path |
363 _jar_toc_path = _output_jar_path + ".TOC" | 392 _jar_toc_path = _output_jar_path + ".TOC" |
364 | 393 |
365 assert(invoker.build_config != "") | 394 assert(invoker.build_config != "") |
366 | 395 |
367 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { | 396 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
368 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" | 397 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" |
369 _proguard_config_path = invoker.proguard_config | 398 _proguard_config_path = invoker.proguard_config |
370 _build_config = invoker.build_config | 399 _build_config = invoker.build_config |
371 _rebased_build_config = rebase_path(_build_config, root_build_dir) | 400 _rebased_build_config = rebase_path(_build_config, root_build_dir) |
372 action("${target_name}__proguard_process") { | 401 _output_jar_target = "${target_name}__proguard_process" |
| 402 action(_output_jar_target) { |
373 script = "//build/android/gyp/proguard.py" | 403 script = "//build/android/gyp/proguard.py" |
374 inputs = [ | 404 inputs = [ |
375 android_sdk_jar, | 405 android_sdk_jar, |
376 _proguard_jar_path, | 406 _proguard_jar_path, |
377 _build_config, | 407 _build_config, |
378 _input_jar_path, | 408 _input_jar_path, |
379 _proguard_config_path, | 409 _proguard_config_path, |
380 ] | 410 ] |
381 depfile = "${target_gen_dir}/${target_name}.d" | 411 depfile = "${target_gen_dir}/${target_name}.d" |
382 outputs = [ | 412 outputs = [ |
383 depfile, | 413 depfile, |
384 _output_jar_path, | 414 _output_jar_path, |
385 ] | 415 ] |
386 args = [ | 416 args = [ |
387 "--depfile", | 417 "--depfile", |
388 rebase_path(depfile, root_build_dir), | 418 rebase_path(depfile, root_build_dir), |
389 "--proguard-path", | 419 "--proguard-path", |
390 rebase_path(_proguard_jar_path, root_build_dir), | 420 rebase_path(_proguard_jar_path, root_build_dir), |
391 "--input-path", | 421 "--input-path", |
392 rebase_path(_input_jar_path, root_build_dir), | 422 rebase_path(_input_jar_path, root_build_dir), |
393 "--output-path", | 423 "--output-path", |
394 rebase_path(_output_jar_path, root_build_dir), | 424 rebase_path(_output_jar_path, root_build_dir), |
395 "--proguard-config", | 425 "--proguard-config", |
396 rebase_path(_proguard_config_path, root_build_dir), | 426 rebase_path(_proguard_config_path, root_build_dir), |
397 "--classpath", | 427 "--classpath", |
398 rebased_android_sdk_jar, | 428 rebased_android_sdk_jar, |
399 "--classpath=@FileArg($_rebased_build_config:javac:classpath)", | 429 "--classpath=@FileArg($_rebased_build_config:javac:classpath)", |
400 ] | 430 ] |
| 431 |
| 432 if (defined(invoker.deps)) { |
| 433 deps = invoker.deps |
| 434 } |
| 435 if (defined(invoker.public_deps)) { |
| 436 public_deps = invoker.public_deps |
| 437 } |
| 438 if (defined(invoker.data_deps)) { |
| 439 data_deps = invoker.data_deps |
| 440 } |
401 } | 441 } |
402 } else { | 442 } else { |
403 copy("${target_name}__copy_jar") { | 443 _output_jar_target = "${target_name}__copy_jar" |
| 444 copy(_output_jar_target) { |
404 sources = [ | 445 sources = [ |
405 _input_jar_path, | 446 _input_jar_path, |
406 ] | 447 ] |
407 outputs = [ | 448 outputs = [ |
408 _output_jar_path, | 449 _output_jar_path, |
409 ] | 450 ] |
| 451 |
| 452 if (defined(invoker.deps)) { |
| 453 deps = invoker.deps |
| 454 } |
| 455 if (defined(invoker.public_deps)) { |
| 456 public_deps = invoker.public_deps |
| 457 } |
| 458 if (defined(invoker.data_deps)) { |
| 459 data_deps = invoker.data_deps |
| 460 } |
410 } | 461 } |
411 } | 462 } |
412 | 463 |
413 action("${target_name}__jar_toc") { | 464 action("${target_name}__jar_toc") { |
414 script = "//build/android/gyp/jar_toc.py" | 465 script = "//build/android/gyp/jar_toc.py" |
415 depfile = "$target_gen_dir/$target_name.d" | 466 depfile = "$target_gen_dir/$target_name.d" |
416 outputs = [ | 467 outputs = [ |
417 depfile, | 468 depfile, |
418 _jar_toc_path, | 469 _jar_toc_path, |
419 _jar_toc_path + ".md5.stamp", | 470 _jar_toc_path + ".md5.stamp", |
420 ] | 471 ] |
421 inputs = [ | 472 inputs = [ |
422 _output_jar_path, | 473 _output_jar_path, |
423 ] | 474 ] |
424 args = [ | 475 args = [ |
425 "--depfile", | 476 "--depfile", |
426 rebase_path(depfile, root_build_dir), | 477 rebase_path(depfile, root_build_dir), |
427 "--jar-path", | 478 "--jar-path", |
428 rebase_path(_output_jar_path, root_build_dir), | 479 rebase_path(_output_jar_path, root_build_dir), |
429 "--toc-path", | 480 "--toc-path", |
430 rebase_path(_jar_toc_path, root_build_dir), | 481 rebase_path(_jar_toc_path, root_build_dir), |
431 ] | 482 ] |
| 483 public_deps = [ |
| 484 ":$_output_jar_target", |
| 485 ] |
432 } | 486 } |
433 | 487 |
434 group(target_name) { | 488 group(target_name) { |
435 deps = [ | 489 if (defined(invoker.visibility)) { |
| 490 visibility = invoker.visibility |
| 491 } |
| 492 public_deps = [ |
436 ":${target_name}__jar_toc", | 493 ":${target_name}__jar_toc", |
| 494 ":$_output_jar_target", |
437 ] | 495 ] |
438 } | 496 } |
439 } | 497 } |
440 | 498 |
| 499 template("finalize_apk") { |
| 500 action(target_name) { |
| 501 script = "//build/android/gyp/finalize_apk.py" |
| 502 depfile = "$target_gen_dir/$target_name.d" |
| 503 |
| 504 if (defined(invoker.testonly)) { |
| 505 testonly = invoker.testonly |
| 506 } |
| 507 |
| 508 sources = [ |
| 509 invoker.input_apk_path, |
| 510 ] |
| 511 inputs = [ |
| 512 invoker.keystore_path, |
| 513 ] |
| 514 outputs = [ |
| 515 depfile, |
| 516 invoker.output_apk_path, |
| 517 ] |
| 518 |
| 519 args = [ |
| 520 "--depfile", |
| 521 rebase_path(depfile, root_build_dir), |
| 522 "--zipalign-path", |
| 523 rebase_path(zipalign_path, root_build_dir), |
| 524 "--unsigned-apk-path", |
| 525 rebase_path(invoker.input_apk_path, root_build_dir), |
| 526 "--final-apk-path", |
| 527 rebase_path(invoker.output_apk_path, root_build_dir), |
| 528 "--key-path", |
| 529 rebase_path(invoker.keystore_path, root_build_dir), |
| 530 "--key-name", |
| 531 invoker.keystore_name, |
| 532 "--key-passwd", |
| 533 invoker.keystore_password, |
| 534 ] |
| 535 if (defined(invoker.rezip_apk) && invoker.rezip_apk) { |
| 536 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar" |
| 537 inputs += [ _rezip_jar_path ] |
| 538 args += [ |
| 539 "--load-library-from-zip=1", |
| 540 "--rezip-apk-jar-path", |
| 541 rebase_path(_rezip_jar_path, root_build_dir), |
| 542 ] |
| 543 } |
| 544 |
| 545 if (defined(invoker.deps)) { |
| 546 deps = invoker.deps |
| 547 } |
| 548 if (defined(invoker.public_deps)) { |
| 549 public_deps = invoker.public_deps |
| 550 } |
| 551 if (defined(invoker.data_deps)) { |
| 552 data_deps = invoker.data_deps |
| 553 } |
| 554 } |
| 555 } |
| 556 |
441 # Packages resources, assets, dex, and native libraries into an apk. Signs and | 557 # Packages resources, assets, dex, and native libraries into an apk. Signs and |
442 # zipaligns the apk. | 558 # zipaligns the apk. |
443 template("create_apk") { | 559 template("create_apk") { |
444 set_sources_assignment_filter([]) | 560 set_sources_assignment_filter([]) |
445 if (defined(invoker.testonly)) { | 561 if (defined(invoker.testonly)) { |
446 testonly = invoker.testonly | 562 testonly = invoker.testonly |
447 } | 563 } |
448 | 564 |
449 _android_manifest = invoker.android_manifest | 565 _android_manifest = invoker.android_manifest |
450 _base_path = invoker.base_path | 566 _base_path = invoker.base_path |
451 _final_apk_path = invoker.apk_path | 567 _final_apk_path = invoker.apk_path |
452 _resources_zip = invoker.resources_zip | 568 |
453 _dex_path = invoker.dex_path | 569 if (defined(invoker.resources_zip)) { |
454 _keystore_path = invoker.keystore_path | 570 _resources_zip = invoker.resources_zip |
455 _keystore_name = invoker.keystore_name | 571 } |
456 _keystore_password = invoker.keystore_password | 572 if (defined(invoker.dex_path)) { |
| 573 _dex_path = invoker.dex_path |
| 574 } |
457 _load_library_from_apk = invoker.load_library_from_apk | 575 _load_library_from_apk = invoker.load_library_from_apk |
458 | 576 |
459 _deps = [] | 577 _package_deps = [] |
460 if (defined(invoker.deps)) { | 578 if (defined(invoker.deps)) { |
461 _deps = invoker.deps | 579 _package_deps = invoker.deps |
462 } | 580 } |
463 | 581 |
464 _native_libs_dir = "//build/android/empty/res" | 582 _native_libs_dir = "//build/android/empty/res" |
465 if (defined(invoker.native_libs_dir)) { | 583 if (defined(invoker.native_libs_dir)) { |
466 _native_libs_dir = invoker.native_libs_dir | 584 _native_libs_dir = invoker.native_libs_dir |
467 } | 585 } |
468 | 586 |
469 _asset_location = "//build/android/empty/res" | |
470 if (defined(invoker.asset_location)) { | 587 if (defined(invoker.asset_location)) { |
471 _asset_location = invoker.asset_location | 588 _asset_location = invoker.asset_location |
472 } | 589 } |
473 | 590 |
474 _version_code = invoker.version_code | 591 _version_code = invoker.version_code |
475 _version_name = invoker.version_name | 592 _version_name = invoker.version_name |
476 | 593 |
477 _base_apk_path = _base_path + ".apk_intermediates" | 594 _base_apk_path = _base_path + ".apk_intermediates" |
478 | 595 |
479 _resource_packaged_apk_path = _base_apk_path + ".ap_" | 596 _resource_packaged_apk_path = _base_apk_path + ".ap_" |
480 _packaged_apk_path = _base_apk_path + ".unfinished.apk" | 597 _packaged_apk_path = _base_apk_path + ".unfinished.apk" |
481 _shared_resources = | 598 _shared_resources = |
482 defined(invoker.shared_resources) && invoker.shared_resources | 599 defined(invoker.shared_resources) && invoker.shared_resources |
483 | 600 |
484 _configuration_name = "Release" | 601 _configuration_name = "Release" |
485 if (is_debug) { | 602 if (is_debug) { |
486 _configuration_name = "Debug" | 603 _configuration_name = "Debug" |
487 } | 604 } |
488 | 605 |
489 action("${target_name}__package_resources") { | 606 _create_density_splits = |
490 deps = _deps | 607 defined(invoker.create_density_splits) && invoker.create_density_splits |
| 608 if (_create_density_splits) { |
| 609 _split_densities = [ |
| 610 "hdpi", |
| 611 "xhdpi", |
| 612 "xxhdpi", |
| 613 "tvdpi", |
| 614 ] |
| 615 } |
| 616 |
| 617 _package_resources_target_name = "${target_name}__package_resources" |
| 618 action(_package_resources_target_name) { |
| 619 deps = _package_deps |
491 | 620 |
492 script = "//build/android/gyp/package_resources.py" | 621 script = "//build/android/gyp/package_resources.py" |
493 depfile = "${target_gen_dir}/${target_name}.d" | 622 depfile = "${target_gen_dir}/${target_name}.d" |
494 inputs = [ | 623 inputs = [ |
495 _android_manifest, | 624 _android_manifest, |
496 _resources_zip, | |
497 ] | 625 ] |
| 626 if (defined(_resources_zip)) { |
| 627 inputs += [ _resources_zip ] |
| 628 } |
498 outputs = [ | 629 outputs = [ |
499 depfile, | 630 depfile, |
500 _resource_packaged_apk_path, | 631 _resource_packaged_apk_path, |
501 ] | 632 ] |
502 | 633 |
503 _rebased_resources_zips = [ rebase_path(_resources_zip, root_build_dir) ] | |
504 args = [ | 634 args = [ |
505 "--depfile", | 635 "--depfile", |
506 rebase_path(depfile, root_build_dir), | 636 rebase_path(depfile, root_build_dir), |
507 "--android-sdk", | 637 "--android-sdk", |
508 rebased_android_sdk, | 638 rebased_android_sdk, |
509 "--android-sdk-tools", | 639 "--aapt-path", |
510 rebased_android_sdk_build_tools, | 640 android_aapt_path, |
511 "--configuration-name=$_configuration_name", | 641 "--configuration-name=$_configuration_name", |
512 "--android-manifest", | 642 "--android-manifest", |
513 rebase_path(_android_manifest, root_build_dir), | 643 rebase_path(_android_manifest, root_build_dir), |
514 "--version-code", | 644 "--version-code", |
515 _version_code, | 645 _version_code, |
516 "--version-name", | 646 "--version-name", |
517 _version_name, | 647 _version_name, |
518 "--asset-dir", | |
519 rebase_path(_asset_location, root_build_dir), | |
520 "--resource-zips=$_rebased_resources_zips", | |
521 "--apk-path", | 648 "--apk-path", |
522 rebase_path(_resource_packaged_apk_path, root_build_dir), | 649 rebase_path(_resource_packaged_apk_path, root_build_dir), |
523 ] | 650 ] |
524 | 651 |
| 652 if (defined(_asset_location)) { |
| 653 args += [ |
| 654 "--asset-dir", |
| 655 rebase_path(_asset_location, root_build_dir), |
| 656 ] |
| 657 } |
| 658 if (defined(_resources_zip)) { |
| 659 args += [ |
| 660 "--resource-zips", |
| 661 rebase_path(_resources_zip, root_build_dir), |
| 662 ] |
| 663 } |
525 if (_shared_resources) { | 664 if (_shared_resources) { |
526 args += [ "--shared-resources" ] | 665 args += [ "--shared-resources" ] |
527 } | 666 } |
| 667 if (_create_density_splits) { |
| 668 args += [ "--create-density-splits" ] |
| 669 foreach(_density, _split_densities) { |
| 670 outputs += [ "${_resource_packaged_apk_path}-${_density}" ] |
| 671 } |
| 672 } |
528 } | 673 } |
529 | 674 |
530 action("${target_name}__package") { | 675 package_target = "${target_name}__package" |
| 676 action(package_target) { |
531 script = "//build/android/gyp/ant.py" | 677 script = "//build/android/gyp/ant.py" |
532 _ant_script = "//build/android/ant/apk-package.xml" | 678 _ant_script = "//build/android/ant/apk-package.xml" |
533 | 679 |
| 680 deps = [ |
| 681 ":${_package_resources_target_name}", |
| 682 ] |
| 683 if (defined(invoker.deps)) { |
| 684 deps += invoker.deps |
| 685 } |
534 depfile = "$target_gen_dir/$target_name.d" | 686 depfile = "$target_gen_dir/$target_name.d" |
535 | 687 |
536 inputs = [ | 688 inputs = [ |
537 _dex_path, | |
538 _resource_packaged_apk_path, | 689 _resource_packaged_apk_path, |
539 _ant_script, | 690 _ant_script, |
540 ] | 691 ] |
| 692 if (defined(_dex_path)) { |
| 693 inputs += [ _dex_path ] |
| 694 } |
541 | 695 |
542 outputs = [ | 696 outputs = [ |
543 depfile, | 697 depfile, |
544 _packaged_apk_path, | 698 _packaged_apk_path, |
545 ] | 699 ] |
546 | 700 |
547 _rebased_emma_jar = "" | 701 _rebased_emma_jar = "" |
548 _rebased_resource_packaged_apk_path = | 702 _rebased_resource_packaged_apk_path = |
549 rebase_path(_resource_packaged_apk_path, root_build_dir) | 703 rebase_path(_resource_packaged_apk_path, root_build_dir) |
550 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) | 704 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) |
551 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir) | 705 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir) |
552 _rebased_dex_path = rebase_path(_dex_path, root_build_dir) | |
553 args = [ | 706 args = [ |
554 "--depfile", | 707 "--depfile", |
555 rebase_path(depfile, root_build_dir), | 708 rebase_path(depfile, root_build_dir), |
556 "--", | 709 "--", |
557 "-quiet", | 710 "-quiet", |
558 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root", | 711 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root", |
559 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools", | 712 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools", |
560 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path", | 713 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path", |
561 "-DCONFIGURATION_NAME=$_configuration_name", | 714 "-DCONFIGURATION_NAME=$_configuration_name", |
562 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir", | 715 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir", |
563 "-DOUT_DIR=", | 716 "-DOUT_DIR=", |
564 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", | 717 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", |
565 "-DEMMA_INSTRUMENT=0", | 718 "-DEMMA_INSTRUMENT=0", |
566 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar", | 719 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar", |
567 "-DDEX_FILE_PATH=$_rebased_dex_path", | |
568 "-Dbasedir=.", | 720 "-Dbasedir=.", |
569 "-buildfile", | 721 "-buildfile", |
570 rebase_path(_ant_script, root_build_dir), | 722 rebase_path(_ant_script, root_build_dir), |
571 ] | 723 ] |
| 724 if (defined(_dex_path)) { |
| 725 _rebased_dex_path = rebase_path(_dex_path, root_build_dir) |
| 726 args += [ |
| 727 "-DDEX_FILE_PATH=$_rebased_dex_path", |
| 728 "-DHAS_CODE=true", |
| 729 ] |
| 730 } else { |
| 731 args += [ "-DHAS_CODE=false" ] |
| 732 } |
572 } | 733 } |
573 | 734 |
574 action("${target_name}__finalize") { | 735 _finalize_apk_rule_name = "${target_name}__finalize" |
575 script = "//build/android/gyp/finalize_apk.py" | 736 finalize_apk(_finalize_apk_rule_name) { |
576 depfile = "$target_gen_dir/$target_name.d" | 737 input_apk_path = _packaged_apk_path |
| 738 output_apk_path = _final_apk_path |
| 739 keystore_path = invoker.keystore_path |
| 740 keystore_name = invoker.keystore_name |
| 741 keystore_password = invoker.keystore_password |
| 742 rezip_apk = _load_library_from_apk |
577 | 743 |
578 sources = [ | 744 public_deps = [ |
579 _packaged_apk_path, | 745 # Generator of the _packaged_apk_path this target takes as input. |
| 746 ":$package_target", |
580 ] | 747 ] |
581 inputs = [ | 748 } |
582 _keystore_path, | |
583 ] | |
584 outputs = [ | |
585 depfile, | |
586 _final_apk_path, | |
587 ] | |
588 | 749 |
589 args = [ | 750 _final_deps = [ ":${_finalize_apk_rule_name}" ] |
590 "--depfile", | 751 |
591 rebase_path(depfile, root_build_dir), | 752 if (_create_density_splits) { |
592 "--zipalign-path", | 753 foreach(_density, _split_densities) { |
593 rebase_path(zipalign_path, root_build_dir), | 754 _finalize_split_rule_name = "${target_name}__finalize_${_density}_split" |
594 "--unsigned-apk-path", | 755 finalize_apk(_finalize_split_rule_name) { |
595 rebase_path(_packaged_apk_path, root_build_dir), | 756 input_apk_path = "${_resource_packaged_apk_path}-${_density}" |
596 "--final-apk-path", | 757 _output_paths = process_file_template( |
597 rebase_path(_final_apk_path, root_build_dir), | 758 [ _final_apk_path ], |
598 "--key-path", | 759 "{{source_dir}}/{{source_name_part}}-${_density}.apk") |
599 rebase_path(_keystore_path, root_build_dir), | 760 output_apk_path = _output_paths[0] |
600 "--key-name", | 761 keystore_path = invoker.keystore_path |
601 _keystore_name, | 762 keystore_name = invoker.keystore_name |
602 "--key-passwd", | 763 keystore_password = invoker.keystore_password |
603 _keystore_password, | 764 } |
604 ] | 765 _final_deps += [ ":${_finalize_split_rule_name}" ] |
605 if (_load_library_from_apk) { | |
606 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar" | |
607 inputs += [ _rezip_jar_path ] | |
608 args += [ | |
609 "--load-library-from-zip-file=1", | |
610 "--rezip-apk-jar-path", | |
611 rebase_path(_rezip_jar_path, root_build_dir), | |
612 ] | |
613 } | 766 } |
614 } | 767 } |
615 | 768 |
616 group(target_name) { | 769 group(target_name) { |
617 deps = [ | 770 public_deps = _final_deps |
618 ":${target_name}__finalize", | |
619 ] | |
620 } | 771 } |
621 } | 772 } |
622 | 773 |
623 template("java_prebuilt_impl") { | 774 template("java_prebuilt_impl") { |
624 set_sources_assignment_filter([]) | 775 set_sources_assignment_filter([]) |
625 if (defined(invoker.testonly)) { | 776 if (defined(invoker.testonly)) { |
626 testonly = invoker.testonly | 777 testonly = invoker.testonly |
627 } | 778 } |
628 _supports_android = | 779 _supports_android = |
629 defined(invoker.supports_android) && invoker.supports_android | 780 defined(invoker.supports_android) && invoker.supports_android |
630 | 781 |
631 assert(defined(invoker.jar_path)) | 782 assert(defined(invoker.jar_path)) |
632 _base_path = "${target_gen_dir}/$target_name" | 783 _base_path = "${target_gen_dir}/$target_name" |
633 _jar_path = _base_path + ".jar" | 784 _jar_path = _base_path + ".jar" |
634 _build_config = _base_path + ".build_config" | 785 _build_config = _base_path + ".build_config" |
635 | 786 |
636 if (_supports_android) { | 787 if (_supports_android) { |
637 _dex_path = _base_path + ".dex.jar" | 788 _dex_path = _base_path + ".dex.jar" |
638 } | 789 } |
639 | 790 |
640 _final_deps = [] | |
641 _template_name = target_name | 791 _template_name = target_name |
642 | 792 |
643 _final_deps += [ ":${_template_name}__build_config" ] | 793 build_config_target_name = "${_template_name}__build_config" |
644 write_build_config("${_template_name}__build_config") { | 794 process_jar_target_name = "${_template_name}__process_jar" |
| 795 if (_supports_android) { |
| 796 dex_target_name = "${_template_name}__dex" |
| 797 } |
| 798 |
| 799 write_build_config(build_config_target_name) { |
645 type = "java_library" | 800 type = "java_library" |
646 supports_android = _supports_android | 801 supports_android = _supports_android |
647 requires_android = | 802 requires_android = |
648 defined(invoker.requires_android) && invoker.requires_android | 803 defined(invoker.requires_android) && invoker.requires_android |
649 | 804 |
650 deps = [] | 805 deps = [] |
651 if (defined(invoker.deps)) { | 806 if (defined(invoker.deps)) { |
652 deps += invoker.deps | 807 deps += invoker.deps |
653 } | 808 } |
654 build_config = _build_config | 809 build_config = _build_config |
655 jar_path = _jar_path | 810 jar_path = _jar_path |
656 if (_supports_android) { | 811 if (_supports_android) { |
657 dex_path = _dex_path | 812 dex_path = _dex_path |
658 } | 813 } |
659 } | 814 } |
660 | 815 |
661 _final_deps += [ ":${_template_name}__process_jar" ] | 816 process_java_prebuilt(process_jar_target_name) { |
662 process_java_prebuilt("${_template_name}__process_jar") { | 817 visibility = [ ":$_template_name" ] |
| 818 if (_supports_android) { |
| 819 visibility += [ ":$dex_target_name" ] |
| 820 } |
| 821 |
663 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { | 822 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
664 proguard_preprocess = true | 823 proguard_preprocess = true |
665 proguard_config = invoker.proguard_config | 824 proguard_config = invoker.proguard_config |
666 } | 825 } |
667 | 826 |
668 build_config = _build_config | 827 build_config = _build_config |
669 input_jar_path = invoker.jar_path | 828 input_jar_path = invoker.jar_path |
670 output_jar_path = _jar_path | 829 output_jar_path = _jar_path |
| 830 |
| 831 deps = [ |
| 832 ":$build_config_target_name", |
| 833 ] |
671 } | 834 } |
672 | 835 |
673 if (_supports_android) { | 836 if (_supports_android) { |
674 _final_deps += [ ":${_template_name}__dex" ] | 837 dex(dex_target_name) { |
675 dex("${_template_name}__dex") { | |
676 sources = [ | 838 sources = [ |
677 _jar_path, | 839 _jar_path, |
678 ] | 840 ] |
679 output = _dex_path | 841 output = _dex_path |
| 842 deps = [ |
| 843 ":$process_jar_target_name", |
| 844 ] |
680 } | 845 } |
681 } | 846 } |
682 | 847 |
683 group(target_name) { | 848 group(target_name) { |
684 deps = _final_deps | 849 deps = [ |
| 850 ":$process_jar_target_name", |
| 851 ] |
| 852 if (_supports_android) { |
| 853 deps += [ ":$dex_target_name" ] |
| 854 } |
685 } | 855 } |
686 } | 856 } |
687 | 857 |
688 # Compiles and jars a set of java files. | 858 # Compiles and jars a set of java files. |
689 # | 859 # |
690 # Outputs: | 860 # Outputs: |
691 # $jar_path.jar | 861 # $jar_path.jar |
692 # $jar_path.jar.TOC | 862 # $jar_path.jar.TOC |
693 # | 863 # |
694 # Variables | 864 # Variables |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 assert(_srcjar_deps == [] || true) | 919 assert(_srcjar_deps == [] || true) |
750 | 920 |
751 _system_jars = [] | 921 _system_jars = [] |
752 if (defined(invoker.android) && invoker.android) { | 922 if (defined(invoker.android) && invoker.android) { |
753 _system_jars += [ android_sdk_jar ] | 923 _system_jars += [ android_sdk_jar ] |
754 } | 924 } |
755 | 925 |
756 _rebased_build_config = rebase_path(_build_config, root_build_dir) | 926 _rebased_build_config = rebase_path(_build_config, root_build_dir) |
757 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir) | 927 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir) |
758 | 928 |
759 _template_name = target_name | 929 javac_target_name = "${target_name}__javac" |
760 _final_deps = [ ":${_template_name}__javac" ] | 930 finish_target_name = "${target_name}__finish" |
761 action("${_template_name}__javac") { | 931 final_target_name = target_name |
| 932 |
| 933 action(javac_target_name) { |
762 script = "//build/android/gyp/javac.py" | 934 script = "//build/android/gyp/javac.py" |
763 depfile = "$target_gen_dir/$target_name.d" | 935 depfile = "$target_gen_dir/$target_name.d" |
764 deps = [] | 936 deps = _srcjar_deps |
| 937 if (defined(invoker.deps)) { |
| 938 deps += invoker.deps |
| 939 } |
| 940 |
765 outputs = [ | 941 outputs = [ |
766 depfile, | 942 depfile, |
767 _intermediate_jar_path, | 943 _intermediate_jar_path, |
768 _intermediate_jar_path + ".md5.stamp", | 944 _intermediate_jar_path + ".md5.stamp", |
769 ] | 945 ] |
770 sources = _java_files + _java_srcjars | 946 sources = _java_files + _java_srcjars |
771 inputs = _system_jars + [ _build_config ] | 947 inputs = _system_jars + [ _build_config ] |
772 | 948 |
773 _rebased_system_jars = rebase_path(_system_jars, root_build_dir) | 949 _rebased_system_jars = rebase_path(_system_jars, root_build_dir) |
774 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir) | 950 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir) |
(...skipping 10 matching lines...) Expand all Loading... |
785 foreach(e, _manifest_entries) { | 961 foreach(e, _manifest_entries) { |
786 args += [ "--manifest-entry=" + e ] | 962 args += [ "--manifest-entry=" + e ] |
787 } | 963 } |
788 if (_chromium_code) { | 964 if (_chromium_code) { |
789 args += [ "--chromium-code=1" ] | 965 args += [ "--chromium-code=1" ] |
790 } | 966 } |
791 | 967 |
792 args += rebase_path(_java_files, root_build_dir) | 968 args += rebase_path(_java_files, root_build_dir) |
793 } | 969 } |
794 | 970 |
795 _final_deps += [ ":${_template_name}__finish" ] | 971 process_java_prebuilt(finish_target_name) { |
796 process_java_prebuilt("${_template_name}__finish") { | 972 visibility = [ ":$final_target_name" ] |
| 973 |
797 build_config = _build_config | 974 build_config = _build_config |
798 input_jar_path = _intermediate_jar_path | 975 input_jar_path = _intermediate_jar_path |
799 output_jar_path = _final_jar_path | 976 output_jar_path = _final_jar_path |
800 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { | 977 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
801 proguard_preprocess = invoker.proguard_preprocess | 978 proguard_preprocess = invoker.proguard_preprocess |
802 proguard_config = invoker.proguard_config | 979 proguard_config = invoker.proguard_config |
803 } | 980 } |
| 981 deps = [ |
| 982 ":$javac_target_name", |
| 983 ] |
804 } | 984 } |
805 | 985 |
806 group(target_name) { | 986 group(final_target_name) { |
807 deps = _final_deps | 987 if (defined(invoker.visibility)) { |
| 988 visibility = invoker.visibility |
| 989 } |
| 990 public_deps = [ |
| 991 ":$finish_target_name", |
| 992 ] |
808 } | 993 } |
809 } | 994 } |
810 | 995 |
811 template("java_library_impl") { | 996 template("java_library_impl") { |
812 set_sources_assignment_filter([]) | 997 set_sources_assignment_filter([]) |
813 if (defined(invoker.testonly)) { | 998 if (defined(invoker.testonly)) { |
814 testonly = invoker.testonly | 999 testonly = invoker.testonly |
815 } | 1000 } |
816 | 1001 |
817 assert( | 1002 assert( |
(...skipping 17 matching lines...) Expand all Loading... |
835 _requires_android = | 1020 _requires_android = |
836 defined(invoker.requires_android) && invoker.requires_android | 1021 defined(invoker.requires_android) && invoker.requires_android |
837 | 1022 |
838 if (_supports_android) { | 1023 if (_supports_android) { |
839 _dex_path = _base_path + ".dex.jar" | 1024 _dex_path = _base_path + ".dex.jar" |
840 if (defined(invoker.dex_path)) { | 1025 if (defined(invoker.dex_path)) { |
841 _dex_path = invoker.dex_path | 1026 _dex_path = invoker.dex_path |
842 } | 1027 } |
843 } | 1028 } |
844 | 1029 |
| 1030 # Define build_config_deps which will be a list of targets required to |
| 1031 # build the _build_config. |
845 if (defined(invoker.override_build_config)) { | 1032 if (defined(invoker.override_build_config)) { |
846 _build_config = invoker.override_build_config | 1033 _build_config = invoker.override_build_config |
| 1034 |
| 1035 # When a custom build config file is specified, we need to use the deps |
| 1036 # supplied by the invoker any time we reference the build config file. |
| 1037 assert(defined(invoker.deps), |
| 1038 "If you specify a build config file for " + |
| 1039 "java_library_impl($target_name), you should " + |
| 1040 "also specify the target that made it in the deps") |
| 1041 build_config_deps = invoker.deps |
847 } else { | 1042 } else { |
848 _build_config = _base_path + ".build_config" | 1043 _build_config = _base_path + ".build_config" |
849 _final_deps += [ ":${_template_name}__build_config" ] | 1044 build_config_target_name = "${_template_name}__build_config" |
850 write_build_config("${_template_name}__build_config") { | 1045 build_config_deps = [ ":$build_config_target_name" ] |
| 1046 |
| 1047 write_build_config(build_config_target_name) { |
851 type = "java_library" | 1048 type = "java_library" |
852 supports_android = _supports_android | 1049 supports_android = _supports_android |
853 requires_android = _requires_android | 1050 requires_android = _requires_android |
854 bypass_platform_checks = defined(invoker.bypass_platform_checks) && | 1051 bypass_platform_checks = defined(invoker.bypass_platform_checks) && |
855 invoker.bypass_platform_checks | 1052 invoker.bypass_platform_checks |
856 | 1053 |
857 deps = [] | 1054 deps = [] |
858 if (defined(invoker.deps)) { | 1055 if (defined(invoker.deps)) { |
859 deps += invoker.deps | 1056 deps += invoker.deps |
860 } | 1057 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 [ | 1096 [ |
900 "--pattern", | 1097 "--pattern", |
901 "*.java", | 1098 "*.java", |
902 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir), | 1099 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir), |
903 ], | 1100 ], |
904 "list lines") | 1101 "list lines") |
905 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) | 1102 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) |
906 } | 1103 } |
907 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != []) | 1104 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != []) |
908 | 1105 |
909 _final_deps += [ ":${_template_name}__compile_java" ] | 1106 _compile_java_target = "${_template_name}__compile_java" |
910 compile_java("${_template_name}__compile_java") { | 1107 _final_deps += [ ":$_compile_java_target" ] |
| 1108 compile_java(_compile_java_target) { |
911 jar_path = _jar_path | 1109 jar_path = _jar_path |
912 build_config = _build_config | 1110 build_config = _build_config |
913 java_files = _java_files | 1111 java_files = _java_files |
914 srcjar_deps = _srcjar_deps | 1112 srcjar_deps = _srcjar_deps |
915 srcjars = _srcjars | 1113 srcjars = _srcjars |
916 chromium_code = _chromium_code | 1114 chromium_code = _chromium_code |
917 android = _requires_android | 1115 android = _requires_android |
918 | 1116 |
919 if (defined(invoker.jar_excluded_patterns)) { | 1117 if (defined(invoker.jar_excluded_patterns)) { |
920 jar_excluded_patterns = invoker.jar_excluded_patterns | 1118 jar_excluded_patterns = invoker.jar_excluded_patterns |
921 } | 1119 } |
922 if (defined(invoker.proguard_preprocess)) { | 1120 if (defined(invoker.proguard_preprocess)) { |
923 proguard_preprocess = invoker.proguard_preprocess | 1121 proguard_preprocess = invoker.proguard_preprocess |
924 } | 1122 } |
925 if (defined(invoker.proguard_config)) { | 1123 if (defined(invoker.proguard_config)) { |
926 proguard_config = invoker.proguard_config | 1124 proguard_config = invoker.proguard_config |
927 } | 1125 } |
928 if (defined(invoker.dist_jar_path)) { | 1126 if (defined(invoker.dist_jar_path)) { |
929 dist_jar_path = invoker.dist_jar_path | 1127 dist_jar_path = invoker.dist_jar_path |
930 } | 1128 } |
931 if (defined(invoker.manifest_entries)) { | 1129 if (defined(invoker.manifest_entries)) { |
932 manifest_entries = invoker.manifest_entries | 1130 manifest_entries = invoker.manifest_entries |
933 } | 1131 } |
| 1132 |
| 1133 deps = build_config_deps |
934 } | 1134 } |
935 | 1135 |
936 if (defined(invoker.main_class)) { | 1136 if (defined(invoker.main_class)) { |
937 _final_deps += [ ":${_template_name}__binary_script" ] | 1137 _final_deps += [ ":${_template_name}__binary_script" ] |
938 action("${_template_name}__binary_script") { | 1138 action("${_template_name}__binary_script") { |
939 script = "//build/android/gyp/create_java_binary_script.py" | 1139 script = "//build/android/gyp/create_java_binary_script.py" |
940 depfile = "$target_gen_dir/$target_name.d" | 1140 depfile = "$target_gen_dir/$target_name.d" |
941 java_script = "$root_build_dir/bin/$_template_name" | 1141 java_script = "$root_build_dir/bin/$_template_name" |
942 inputs = [ | 1142 inputs = [ |
943 _build_config, | 1143 _build_config, |
944 ] | 1144 ] |
945 outputs = [ | 1145 outputs = [ |
946 depfile, | 1146 depfile, |
947 java_script, | 1147 java_script, |
948 ] | 1148 ] |
949 _rebased_build_config = rebase_path(_build_config, root_build_dir) | 1149 _rebased_build_config = rebase_path(_build_config, root_build_dir) |
950 args = [ | 1150 args = [ |
951 "--depfile", | 1151 "--depfile", |
952 rebase_path(depfile, root_build_dir), | 1152 rebase_path(depfile, root_build_dir), |
953 "--output", | 1153 "--output", |
954 rebase_path(java_script, root_build_dir), | 1154 rebase_path(java_script, root_build_dir), |
955 "--classpath=@FileArg($_rebased_build_config:java:full_classpath)", | 1155 "--classpath=@FileArg($_rebased_build_config:java:full_classpath)", |
956 "--jar-path", | 1156 "--jar-path", |
957 rebase_path(_jar_path, root_build_dir), | 1157 rebase_path(_jar_path, root_build_dir), |
958 "--main-class", | 1158 "--main-class", |
959 invoker.main_class, | 1159 invoker.main_class, |
960 ] | 1160 ] |
| 1161 |
| 1162 deps = build_config_deps |
961 } | 1163 } |
962 } | 1164 } |
963 | 1165 |
964 if (_supports_android) { | 1166 if (_supports_android) { |
965 if (defined(invoker.chromium_code) && invoker.chromium_code) { | 1167 if (defined(invoker.chromium_code) && invoker.chromium_code) { |
966 _android_manifest = "//build/android/AndroidManifest.xml" | 1168 _android_manifest = "//build/android/AndroidManifest.xml" |
967 if (defined(invoker.android_manifest)) { | 1169 if (defined(invoker.android_manifest)) { |
968 _android_manifest = invoker.android_manifest | 1170 _android_manifest = invoker.android_manifest |
969 } | 1171 } |
970 | 1172 |
971 _final_datadeps += [ ":${_template_name}__lint" ] | 1173 _final_datadeps += [ ":${_template_name}__lint" ] |
972 android_lint("${_template_name}__lint") { | 1174 android_lint("${_template_name}__lint") { |
973 android_manifest = _android_manifest | 1175 android_manifest = _android_manifest |
974 jar_path = _jar_path | 1176 jar_path = _jar_path |
975 java_files = _java_files | 1177 java_files = _java_files |
| 1178 deps = [ |
| 1179 ":$_compile_java_target", |
| 1180 ] |
| 1181 if (defined(invoker.deps)) { |
| 1182 deps += invoker.deps |
| 1183 } |
976 } | 1184 } |
977 | 1185 |
978 if (run_findbugs) { | 1186 if (run_findbugs) { |
979 _final_datadeps += [ ":${_template_name}__findbugs" ] | 1187 _final_datadeps += [ ":${_template_name}__findbugs" ] |
980 findbugs("${_template_name}__findbugs") { | 1188 findbugs("${_template_name}__findbugs") { |
981 build_config = _build_config | 1189 build_config = _build_config |
982 jar_path = _jar_path | 1190 jar_path = _jar_path |
| 1191 deps = build_config_deps |
983 } | 1192 } |
984 } | 1193 } |
985 } | 1194 } |
986 | 1195 |
987 _final_deps += [ ":${_template_name}__dex" ] | 1196 _final_deps += [ ":${_template_name}__dex" ] |
988 dex("${_template_name}__dex") { | 1197 dex("${_template_name}__dex") { |
989 sources = [ | 1198 sources = [ |
990 _jar_path, | 1199 _jar_path, |
991 ] | 1200 ] |
992 output = _dex_path | 1201 output = _dex_path |
| 1202 deps = [ |
| 1203 ":$_compile_java_target", |
| 1204 ] |
993 } | 1205 } |
994 } | 1206 } |
995 | 1207 |
996 group(target_name) { | 1208 group(target_name) { |
997 if (defined(invoker.visibility)) { | 1209 if (defined(invoker.visibility)) { |
998 visibility = invoker.visibility | 1210 visibility = invoker.visibility |
999 } | 1211 } |
1000 deps = _final_deps | 1212 public_deps = _final_deps |
1001 datadeps = _final_datadeps | 1213 data_deps = _final_datadeps |
1002 } | 1214 } |
1003 } | 1215 } |
1004 | 1216 |
1005 # Runs process_resources.py | 1217 # Runs process_resources.py |
1006 template("process_resources") { | 1218 template("process_resources") { |
1007 set_sources_assignment_filter([]) | 1219 set_sources_assignment_filter([]) |
1008 if (defined(invoker.testonly)) { | 1220 if (defined(invoker.testonly)) { |
1009 testonly = invoker.testonly | 1221 testonly = invoker.testonly |
1010 } | 1222 } |
1011 | 1223 |
1012 zip_path = invoker.zip_path | 1224 zip_path = invoker.zip_path |
1013 srcjar_path = invoker.srcjar_path | 1225 srcjar_path = invoker.srcjar_path |
1014 r_text_path = invoker.r_text_path | 1226 r_text_path = invoker.r_text_path |
1015 build_config = invoker.build_config | 1227 build_config = invoker.build_config |
1016 resource_dirs = invoker.resource_dirs | 1228 resource_dirs = invoker.resource_dirs |
1017 android_manifest = invoker.android_manifest | 1229 android_manifest = invoker.android_manifest |
1018 | 1230 |
1019 non_constant_id = true | 1231 non_constant_id = true |
1020 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { | 1232 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { |
1021 non_constant_id = false | 1233 non_constant_id = false |
1022 } | 1234 } |
1023 | 1235 |
1024 action(target_name) { | 1236 action(target_name) { |
| 1237 if (defined(invoker.visibility)) { |
| 1238 visibility = invoker.visibility |
| 1239 } |
| 1240 |
1025 script = "//build/android/gyp/process_resources.py" | 1241 script = "//build/android/gyp/process_resources.py" |
1026 | 1242 |
1027 depfile = "$target_gen_dir/$target_name.d" | 1243 depfile = "$target_gen_dir/$target_name.d" |
1028 outputs = [ | 1244 outputs = [ |
1029 depfile, | 1245 depfile, |
1030 zip_path, | 1246 zip_path, |
1031 srcjar_path, | 1247 srcjar_path, |
1032 r_text_path, | 1248 r_text_path, |
1033 ] | 1249 ] |
1034 | 1250 |
1035 sources_build_rel = exec_script("//build/android/gyp/find.py", | 1251 sources_build_rel = exec_script("//build/android/gyp/find.py", |
1036 rebase_path(resource_dirs, root_build_dir), | 1252 rebase_path(resource_dirs, root_build_dir), |
1037 "list lines") | 1253 "list lines") |
1038 sources = rebase_path(sources_build_rel, ".", root_build_dir) | 1254 sources = rebase_path(sources_build_rel, ".", root_build_dir) |
1039 | 1255 |
1040 inputs = [ | 1256 inputs = [ |
1041 build_config, | 1257 build_config, |
1042 android_manifest, | 1258 android_manifest, |
1043 ] | 1259 ] |
1044 | 1260 |
1045 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) | 1261 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) |
1046 rebase_build_config = rebase_path(build_config, root_build_dir) | 1262 rebase_build_config = rebase_path(build_config, root_build_dir) |
1047 args = [ | 1263 args = [ |
1048 "--depfile", | 1264 "--depfile", |
1049 rebase_path(depfile, root_build_dir), | 1265 rebase_path(depfile, root_build_dir), |
1050 "--android-sdk", | 1266 "--android-sdk", |
1051 rebase_path(android_sdk, root_build_dir), | 1267 rebase_path(android_sdk, root_build_dir), |
1052 "--android-sdk-tools", | 1268 "--aapt-path", |
1053 rebase_path(android_sdk_build_tools, root_build_dir), | 1269 android_aapt_path, |
1054 "--android-manifest", | 1270 "--android-manifest", |
1055 rebase_path(android_manifest, root_build_dir), | 1271 rebase_path(android_manifest, root_build_dir), |
1056 "--resource-dirs=$rebase_resource_dirs", | 1272 "--resource-dirs=$rebase_resource_dirs", |
1057 "--srcjar-out", | 1273 "--srcjar-out", |
1058 rebase_path(srcjar_path, root_build_dir), | 1274 rebase_path(srcjar_path, root_build_dir), |
1059 "--resource-zip-out", | 1275 "--resource-zip-out", |
1060 rebase_path(zip_path, root_build_dir), | 1276 rebase_path(zip_path, root_build_dir), |
1061 "--r-text-out", | 1277 "--r-text-out", |
1062 rebase_path(r_text_path, root_build_dir), | 1278 rebase_path(r_text_path, root_build_dir), |
1063 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc
y_zips)", | 1279 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc
y_zips)", |
1064 "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_packag
e_names)", | 1280 "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_packag
e_names)", |
1065 "--extra-r-text-files=@FileArg($rebase_build_config:resources:extra_r_text
_files)", | 1281 "--extra-r-text-files=@FileArg($rebase_build_config:resources:extra_r_text
_files)", |
1066 ] | 1282 ] |
1067 | 1283 |
1068 if (non_constant_id) { | 1284 if (non_constant_id) { |
1069 args += [ "--non-constant-id" ] | 1285 args += [ "--non-constant-id" ] |
1070 } | 1286 } |
1071 | 1287 |
1072 if (defined(invoker.custom_package)) { | 1288 if (defined(invoker.custom_package)) { |
1073 args += [ | 1289 args += [ |
1074 "--custom-package", | 1290 "--custom-package", |
1075 invoker.custom_package, | 1291 invoker.custom_package, |
1076 ] | 1292 ] |
1077 } | 1293 } |
1078 | 1294 |
1079 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) { | 1295 if (defined(invoker.v14_skip) && invoker.v14_skip) { |
1080 args += [ "--v14-verify-only" ] | 1296 args += [ "--v14-skip" ] |
1081 } | 1297 } |
1082 | 1298 |
1083 if (defined(invoker.shared_resources) && invoker.shared_resources) { | 1299 if (defined(invoker.shared_resources) && invoker.shared_resources) { |
1084 args += [ "--shared-resources" ] | 1300 args += [ "--shared-resources" ] |
1085 } | 1301 } |
1086 | 1302 |
1087 if (defined(invoker.include_all_resources) && | 1303 if (defined(invoker.include_all_resources) && |
1088 invoker.include_all_resources) { | 1304 invoker.include_all_resources) { |
1089 args += [ "--include-all-resources" ] | 1305 args += [ "--include-all-resources" ] |
1090 } | 1306 } |
1091 | 1307 |
1092 if (defined(invoker.all_resources_zip_path)) { | 1308 if (defined(invoker.all_resources_zip_path)) { |
1093 all_resources_zip = invoker.all_resources_zip_path | 1309 all_resources_zip = invoker.all_resources_zip_path |
1094 outputs += [ all_resources_zip ] | 1310 outputs += [ all_resources_zip ] |
1095 args += [ | 1311 args += [ |
1096 "--all-resources-zip-out", | 1312 "--all-resources-zip-out", |
1097 rebase_path(all_resources_zip, root_build_dir), | 1313 rebase_path(all_resources_zip, root_build_dir), |
1098 ] | 1314 ] |
1099 } | 1315 } |
1100 | 1316 |
1101 if (defined(invoker.args)) { | 1317 if (defined(invoker.args)) { |
1102 args += invoker.args | 1318 args += invoker.args |
1103 } | 1319 } |
| 1320 if (defined(invoker.deps)) { |
| 1321 deps = invoker.deps |
| 1322 } |
1104 } | 1323 } |
1105 } | 1324 } |
1106 | 1325 |
1107 template("copy_ex") { | 1326 template("copy_ex") { |
1108 set_sources_assignment_filter([]) | 1327 set_sources_assignment_filter([]) |
1109 if (defined(invoker.testonly)) { | 1328 if (defined(invoker.testonly)) { |
1110 testonly = invoker.testonly | 1329 testonly = invoker.testonly |
1111 } | 1330 } |
1112 | 1331 |
1113 action(target_name) { | 1332 action(target_name) { |
| 1333 if (defined(invoker.visibility)) { |
| 1334 visibility = invoker.visibility |
| 1335 } |
| 1336 |
1114 script = "//build/android/gyp/copy_ex.py" | 1337 script = "//build/android/gyp/copy_ex.py" |
1115 | 1338 |
1116 if (defined(invoker.deps)) { | 1339 if (defined(invoker.deps)) { |
1117 deps = invoker.deps | 1340 deps = invoker.deps |
1118 } | 1341 } |
1119 | 1342 |
1120 sources = [] | 1343 sources = [] |
1121 if (defined(invoker.sources)) { | 1344 if (defined(invoker.sources)) { |
1122 sources += invoker.sources | 1345 sources += invoker.sources |
1123 } | 1346 } |
(...skipping 24 matching lines...) Expand all Loading... |
1148 if (defined(invoker.args)) { | 1371 if (defined(invoker.args)) { |
1149 args += invoker.args | 1372 args += invoker.args |
1150 } | 1373 } |
1151 } | 1374 } |
1152 } | 1375 } |
1153 | 1376 |
1154 # Produces a single .dex.jar out of a set of Java dependencies. | 1377 # Produces a single .dex.jar out of a set of Java dependencies. |
1155 template("deps_dex") { | 1378 template("deps_dex") { |
1156 set_sources_assignment_filter([]) | 1379 set_sources_assignment_filter([]) |
1157 build_config = "$target_gen_dir/${target_name}.build_config" | 1380 build_config = "$target_gen_dir/${target_name}.build_config" |
1158 write_build_config("${target_name}__build_config") { | 1381 build_config_target_name = "${target_name}__build_config" |
| 1382 |
| 1383 write_build_config(build_config_target_name) { |
1159 type = "deps_dex" | 1384 type = "deps_dex" |
1160 deps = invoker.deps | 1385 deps = invoker.deps |
1161 | 1386 |
1162 build_config = build_config | 1387 build_config = build_config |
1163 dex_path = invoker.dex_path | 1388 dex_path = invoker.dex_path |
1164 } | 1389 } |
1165 | 1390 |
1166 rebased_build_config = rebase_path(build_config, root_build_dir) | 1391 rebased_build_config = rebase_path(build_config, root_build_dir) |
1167 dex(target_name) { | 1392 dex(target_name) { |
1168 inputs = [ | 1393 inputs = [ |
1169 build_config, | 1394 build_config, |
1170 ] | 1395 ] |
1171 output = invoker.dex_path | 1396 output = invoker.dex_path |
1172 dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files" | 1397 dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files" |
1173 args = [ "--inputs=@FileArg($dex_arg_key)" ] | 1398 args = [ "--inputs=@FileArg($dex_arg_key)" ] |
1174 if (defined(invoker.excluded_jars)) { | 1399 if (defined(invoker.excluded_jars)) { |
1175 excluded_jars = rebase_path(invoker.excluded_jars, root_build_dir) | 1400 excluded_jars = rebase_path(invoker.excluded_jars, root_build_dir) |
1176 args += [ "--excluded-paths=${excluded_jars}" ] | 1401 args += [ "--excluded-paths=${excluded_jars}" ] |
1177 } | 1402 } |
| 1403 deps = [ |
| 1404 ":$build_config_target_name", |
| 1405 ] |
1178 } | 1406 } |
1179 } | 1407 } |
1180 | 1408 |
1181 # Creates an AndroidManifest.xml for an APK split. | 1409 # Creates an AndroidManifest.xml for an APK split. |
1182 template("generate_split_manifest") { | 1410 template("generate_split_manifest") { |
1183 assert(defined(invoker.main_manifest)) | 1411 assert(defined(invoker.main_manifest)) |
1184 assert(defined(invoker.out_manifest)) | 1412 assert(defined(invoker.out_manifest)) |
1185 assert(defined(invoker.split_name)) | 1413 assert(defined(invoker.split_name)) |
1186 | 1414 |
1187 action(target_name) { | 1415 action(target_name) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 script = "//build/android/gyp/generate_split_manifest.py" | 1448 script = "//build/android/gyp/generate_split_manifest.py" |
1221 outputs = [ | 1449 outputs = [ |
1222 depfile, | 1450 depfile, |
1223 invoker.out_manifest, | 1451 invoker.out_manifest, |
1224 ] | 1452 ] |
1225 inputs = [ | 1453 inputs = [ |
1226 invoker.main_manifest, | 1454 invoker.main_manifest, |
1227 ] | 1455 ] |
1228 } | 1456 } |
1229 } | 1457 } |
| 1458 |
| 1459 # Generates a script in the output bin directory which runs the test |
| 1460 # target using the test runner script in build/android/test_runner.py. |
| 1461 template("test_runner_script") { |
| 1462 testonly = true |
| 1463 _test_name = invoker.test_name |
| 1464 _test_type = invoker.test_type |
| 1465 |
| 1466 action(target_name) { |
| 1467 script = "//build/android/gyp/create_test_runner_script.py" |
| 1468 depfile = "$target_gen_dir/$target_name.d" |
| 1469 |
| 1470 test_runner_args = [ |
| 1471 _test_type, |
| 1472 "--output-directory", |
| 1473 rebase_path(root_build_dir, root_build_dir), |
| 1474 ] |
| 1475 if (_test_type == "gtest") { |
| 1476 assert(defined(invoker.test_suite)) |
| 1477 test_runner_args += [ |
| 1478 "--suite", |
| 1479 invoker.test_suite, |
| 1480 ] |
| 1481 } else if (_test_type == "instrumentation") { |
| 1482 assert(defined(invoker.test_apk)) |
| 1483 test_runner_args += [ |
| 1484 "--test-apk", |
| 1485 invoker.test_apk, |
| 1486 ] |
| 1487 } else { |
| 1488 assert(false, "Invalid test type: $_test_type.") |
| 1489 } |
| 1490 |
| 1491 if (defined(invoker.isolate_file)) { |
| 1492 test_runner_args += [ |
| 1493 "--isolate-file-path", |
| 1494 rebase_path(invoker.isolate_file, root_build_dir), |
| 1495 ] |
| 1496 } |
| 1497 |
| 1498 generated_script = "$root_build_dir/bin/run_${_test_name}" |
| 1499 outputs = [ |
| 1500 depfile, |
| 1501 generated_script, |
| 1502 ] |
| 1503 args = [ |
| 1504 "--depfile", |
| 1505 rebase_path(depfile, root_build_dir), |
| 1506 "--script-output-path", |
| 1507 rebase_path(generated_script, root_build_dir), |
| 1508 ] |
| 1509 args += test_runner_args |
| 1510 } |
| 1511 } |
OLD | NEW |