| 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) |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 ] | 431 ] |
| 432 } | 432 } |
| 433 | 433 |
| 434 group(target_name) { | 434 group(target_name) { |
| 435 deps = [ | 435 deps = [ |
| 436 ":${target_name}__jar_toc", | 436 ":${target_name}__jar_toc", |
| 437 ] | 437 ] |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 | 440 |
| 441 template("finalize_apk") { |
| 442 action(target_name) { |
| 443 script = "//build/android/gyp/finalize_apk.py" |
| 444 depfile = "$target_gen_dir/$target_name.d" |
| 445 |
| 446 sources = [ |
| 447 invoker.input_apk_path, |
| 448 ] |
| 449 inputs = [ |
| 450 invoker.keystore_path, |
| 451 ] |
| 452 outputs = [ |
| 453 depfile, |
| 454 invoker.output_apk_path, |
| 455 ] |
| 456 |
| 457 args = [ |
| 458 "--depfile", |
| 459 rebase_path(depfile, root_build_dir), |
| 460 "--zipalign-path", |
| 461 rebase_path(zipalign_path, root_build_dir), |
| 462 "--unsigned-apk-path", |
| 463 rebase_path(invoker.input_apk_path, root_build_dir), |
| 464 "--final-apk-path", |
| 465 rebase_path(invoker.output_apk_path, root_build_dir), |
| 466 "--key-path", |
| 467 rebase_path(invoker.keystore_path, root_build_dir), |
| 468 "--key-name", |
| 469 invoker.keystore_name, |
| 470 "--key-passwd", |
| 471 invoker.keystore_password, |
| 472 ] |
| 473 if (defined(invoker.rezip_apk) && invoker.rezip_apk) { |
| 474 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar" |
| 475 inputs += [ _rezip_jar_path ] |
| 476 args += [ |
| 477 "--load-library-from-zip=1", |
| 478 "--rezip-apk-jar-path", |
| 479 rebase_path(_rezip_jar_path, root_build_dir), |
| 480 ] |
| 481 } |
| 482 } |
| 483 } |
| 484 |
| 441 # Packages resources, assets, dex, and native libraries into an apk. Signs and | 485 # Packages resources, assets, dex, and native libraries into an apk. Signs and |
| 442 # zipaligns the apk. | 486 # zipaligns the apk. |
| 443 template("create_apk") { | 487 template("create_apk") { |
| 444 set_sources_assignment_filter([]) | 488 set_sources_assignment_filter([]) |
| 445 if (defined(invoker.testonly)) { | 489 if (defined(invoker.testonly)) { |
| 446 testonly = invoker.testonly | 490 testonly = invoker.testonly |
| 447 } | 491 } |
| 448 | 492 |
| 449 _android_manifest = invoker.android_manifest | 493 _android_manifest = invoker.android_manifest |
| 450 _base_path = invoker.base_path | 494 _base_path = invoker.base_path |
| 451 _final_apk_path = invoker.apk_path | 495 _final_apk_path = invoker.apk_path |
| 452 | 496 |
| 453 if (defined(invoker.resources_zip)) { | 497 if (defined(invoker.resources_zip)) { |
| 454 _resources_zip = invoker.resources_zip | 498 _resources_zip = invoker.resources_zip |
| 455 } | 499 } |
| 456 if (defined(invoker.dex_path)) { | 500 if (defined(invoker.dex_path)) { |
| 457 _dex_path = invoker.dex_path | 501 _dex_path = invoker.dex_path |
| 458 } | 502 } |
| 459 _keystore_path = invoker.keystore_path | |
| 460 _keystore_name = invoker.keystore_name | |
| 461 _keystore_password = invoker.keystore_password | |
| 462 _load_library_from_apk = invoker.load_library_from_apk | 503 _load_library_from_apk = invoker.load_library_from_apk |
| 463 | 504 |
| 464 _deps = [] | 505 _package_deps = [] |
| 465 if (defined(invoker.deps)) { | 506 if (defined(invoker.deps)) { |
| 466 _deps = invoker.deps | 507 _package_deps = invoker.deps |
| 467 } | 508 } |
| 468 | 509 |
| 469 _native_libs_dir = "//build/android/empty/res" | 510 _native_libs_dir = "//build/android/empty/res" |
| 470 if (defined(invoker.native_libs_dir)) { | 511 if (defined(invoker.native_libs_dir)) { |
| 471 _native_libs_dir = invoker.native_libs_dir | 512 _native_libs_dir = invoker.native_libs_dir |
| 472 } | 513 } |
| 473 | 514 |
| 474 if (defined(invoker.asset_location)) { | 515 if (defined(invoker.asset_location)) { |
| 475 _asset_location = invoker.asset_location | 516 _asset_location = invoker.asset_location |
| 476 } | 517 } |
| 477 | 518 |
| 478 _version_code = invoker.version_code | 519 _version_code = invoker.version_code |
| 479 _version_name = invoker.version_name | 520 _version_name = invoker.version_name |
| 480 | 521 |
| 481 _base_apk_path = _base_path + ".apk_intermediates" | 522 _base_apk_path = _base_path + ".apk_intermediates" |
| 482 | 523 |
| 483 _resource_packaged_apk_path = _base_apk_path + ".ap_" | 524 _resource_packaged_apk_path = _base_apk_path + ".ap_" |
| 484 _packaged_apk_path = _base_apk_path + ".unfinished.apk" | 525 _packaged_apk_path = _base_apk_path + ".unfinished.apk" |
| 485 _shared_resources = | 526 _shared_resources = |
| 486 defined(invoker.shared_resources) && invoker.shared_resources | 527 defined(invoker.shared_resources) && invoker.shared_resources |
| 487 | 528 |
| 488 _configuration_name = "Release" | 529 _configuration_name = "Release" |
| 489 if (is_debug) { | 530 if (is_debug) { |
| 490 _configuration_name = "Debug" | 531 _configuration_name = "Debug" |
| 491 } | 532 } |
| 492 | 533 |
| 493 action("${target_name}__package_resources") { | 534 _create_density_splits = |
| 494 deps = _deps | 535 defined(invoker.create_density_splits) && invoker.create_density_splits |
| 536 if (_create_density_splits) { |
| 537 _split_densities = [ |
| 538 "hdpi", |
| 539 "xhdpi", |
| 540 "xxhdpi", |
| 541 "tvdpi", |
| 542 ] |
| 543 } |
| 544 |
| 545 _package_resources_target_name = "${target_name}__package_resources" |
| 546 action(_package_resources_target_name) { |
| 547 deps = _package_deps |
| 495 | 548 |
| 496 script = "//build/android/gyp/package_resources.py" | 549 script = "//build/android/gyp/package_resources.py" |
| 497 depfile = "${target_gen_dir}/${target_name}.d" | 550 depfile = "${target_gen_dir}/${target_name}.d" |
| 498 inputs = [ | 551 inputs = [ |
| 499 _android_manifest, | 552 _android_manifest, |
| 500 ] | 553 ] |
| 501 if (defined(_resources_zip)) { | 554 if (defined(_resources_zip)) { |
| 502 inputs += [ _resources_zip ] | 555 inputs += [ _resources_zip ] |
| 503 } | 556 } |
| 504 outputs = [ | 557 outputs = [ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 532 } | 585 } |
| 533 if (defined(_resources_zip)) { | 586 if (defined(_resources_zip)) { |
| 534 args += [ | 587 args += [ |
| 535 "--resource-zips", | 588 "--resource-zips", |
| 536 rebase_path(_resources_zip, root_build_dir), | 589 rebase_path(_resources_zip, root_build_dir), |
| 537 ] | 590 ] |
| 538 } | 591 } |
| 539 if (_shared_resources) { | 592 if (_shared_resources) { |
| 540 args += [ "--shared-resources" ] | 593 args += [ "--shared-resources" ] |
| 541 } | 594 } |
| 595 if (_create_density_splits) { |
| 596 args += [ "--create-density-splits" ] |
| 597 foreach(_density, _split_densities) { |
| 598 outputs += [ "${_resource_packaged_apk_path}-${_density}" ] |
| 599 } |
| 600 } |
| 542 } | 601 } |
| 543 | 602 |
| 544 action("${target_name}__package") { | 603 action("${target_name}__package") { |
| 545 script = "//build/android/gyp/ant.py" | 604 script = "//build/android/gyp/ant.py" |
| 546 _ant_script = "//build/android/ant/apk-package.xml" | 605 _ant_script = "//build/android/ant/apk-package.xml" |
| 547 | 606 |
| 607 deps = [ |
| 608 ":${_package_resources_target_name}", |
| 609 ] |
| 548 depfile = "$target_gen_dir/$target_name.d" | 610 depfile = "$target_gen_dir/$target_name.d" |
| 549 | 611 |
| 550 inputs = [ | 612 inputs = [ |
| 551 _resource_packaged_apk_path, | 613 _resource_packaged_apk_path, |
| 552 _ant_script, | 614 _ant_script, |
| 553 ] | 615 ] |
| 554 if (defined(_dex_path)) { | 616 if (defined(_dex_path)) { |
| 555 inputs += [ _dex_path ] | 617 inputs += [ _dex_path ] |
| 556 } | 618 } |
| 557 | 619 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 587 _rebased_dex_path = rebase_path(_dex_path, root_build_dir) | 649 _rebased_dex_path = rebase_path(_dex_path, root_build_dir) |
| 588 args += [ | 650 args += [ |
| 589 "-DDEX_FILE_PATH=$_rebased_dex_path", | 651 "-DDEX_FILE_PATH=$_rebased_dex_path", |
| 590 "-DHAS_CODE=true", | 652 "-DHAS_CODE=true", |
| 591 ] | 653 ] |
| 592 } else { | 654 } else { |
| 593 args += [ "-DHAS_CODE=false" ] | 655 args += [ "-DHAS_CODE=false" ] |
| 594 } | 656 } |
| 595 } | 657 } |
| 596 | 658 |
| 597 action("${target_name}__finalize") { | 659 _finalize_apk_rule_name = "${target_name}__finalize" |
| 598 script = "//build/android/gyp/finalize_apk.py" | 660 finalize_apk(_finalize_apk_rule_name) { |
| 599 depfile = "$target_gen_dir/$target_name.d" | 661 input_apk_path = _packaged_apk_path |
| 662 output_apk_path = _final_apk_path |
| 663 keystore_path = invoker.keystore_path |
| 664 keystore_name = invoker.keystore_name |
| 665 keystore_password = invoker.keystore_password |
| 666 rezip_apk = _load_library_from_apk |
| 667 } |
| 600 | 668 |
| 601 sources = [ | 669 _final_deps = [ ":${_finalize_apk_rule_name}" ] |
| 602 _packaged_apk_path, | |
| 603 ] | |
| 604 inputs = [ | |
| 605 _keystore_path, | |
| 606 ] | |
| 607 outputs = [ | |
| 608 depfile, | |
| 609 _final_apk_path, | |
| 610 ] | |
| 611 | 670 |
| 612 args = [ | 671 if (_create_density_splits) { |
| 613 "--depfile", | 672 foreach(_density, _split_densities) { |
| 614 rebase_path(depfile, root_build_dir), | 673 _finalize_split_rule_name = "${target_name}__finalize_${_density}_split" |
| 615 "--zipalign-path", | 674 finalize_apk(_finalize_split_rule_name) { |
| 616 rebase_path(zipalign_path, root_build_dir), | 675 input_apk_path = "${_resource_packaged_apk_path}-${_density}" |
| 617 "--unsigned-apk-path", | 676 _output_paths = process_file_template( |
| 618 rebase_path(_packaged_apk_path, root_build_dir), | 677 [ _final_apk_path ], |
| 619 "--final-apk-path", | 678 "{{source_dir}}/{{source_name_part}}-${_density}.apk") |
| 620 rebase_path(_final_apk_path, root_build_dir), | 679 output_apk_path = _output_paths[0] |
| 621 "--key-path", | 680 keystore_path = invoker.keystore_path |
| 622 rebase_path(_keystore_path, root_build_dir), | 681 keystore_name = invoker.keystore_name |
| 623 "--key-name", | 682 keystore_password = invoker.keystore_password |
| 624 _keystore_name, | 683 } |
| 625 "--key-passwd", | 684 _final_deps += [ ":${_finalize_split_rule_name}" ] |
| 626 _keystore_password, | |
| 627 ] | |
| 628 if (_load_library_from_apk) { | |
| 629 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar" | |
| 630 inputs += [ _rezip_jar_path ] | |
| 631 args += [ | |
| 632 "--load-library-from-zip=1", | |
| 633 "--rezip-apk-jar-path", | |
| 634 rebase_path(_rezip_jar_path, root_build_dir), | |
| 635 ] | |
| 636 } | 685 } |
| 637 } | 686 } |
| 638 | 687 |
| 639 group(target_name) { | 688 group(target_name) { |
| 640 deps = [ | 689 deps = _final_deps |
| 641 ":${target_name}__finalize", | |
| 642 ":${target_name}__package_resources", | |
| 643 ] | |
| 644 } | 690 } |
| 645 } | 691 } |
| 646 | 692 |
| 647 template("java_prebuilt_impl") { | 693 template("java_prebuilt_impl") { |
| 648 set_sources_assignment_filter([]) | 694 set_sources_assignment_filter([]) |
| 649 if (defined(invoker.testonly)) { | 695 if (defined(invoker.testonly)) { |
| 650 testonly = invoker.testonly | 696 testonly = invoker.testonly |
| 651 } | 697 } |
| 652 _supports_android = | 698 _supports_android = |
| 653 defined(invoker.supports_android) && invoker.supports_android | 699 defined(invoker.supports_android) && invoker.supports_android |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 script = "//build/android/gyp/generate_split_manifest.py" | 1290 script = "//build/android/gyp/generate_split_manifest.py" |
| 1245 outputs = [ | 1291 outputs = [ |
| 1246 depfile, | 1292 depfile, |
| 1247 invoker.out_manifest, | 1293 invoker.out_manifest, |
| 1248 ] | 1294 ] |
| 1249 inputs = [ | 1295 inputs = [ |
| 1250 invoker.main_manifest, | 1296 invoker.main_manifest, |
| 1251 ] | 1297 ] |
| 1252 } | 1298 } |
| 1253 } | 1299 } |
| OLD | NEW |