Chromium Code Reviews| 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 import("//build/config/android/internal_rules.gni") | 6 import("//build/config/android/internal_rules.gni") |
| 7 import("//build/toolchain/toolchain.gni") | 7 import("//build/toolchain/toolchain.gni") |
| 8 | 8 |
| 9 assert(is_android) | 9 assert(is_android) |
| 10 | 10 |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1419 # * dependencies of this .so are not automatically included | 1419 # * dependencies of this .so are not automatically included |
| 1420 # * ".cr.so" is never added | 1420 # * ".cr.so" is never added |
| 1421 # * they are not side-loaded for _incremental targets. | 1421 # * they are not side-loaded for _incremental targets. |
| 1422 # * load_library_from_apk, use_chromium_linker, | 1422 # * load_library_from_apk, use_chromium_linker, |
| 1423 # and enable_relocation_packing do not apply | 1423 # and enable_relocation_packing do not apply |
| 1424 # Use this instead of shared_libraries when you are going to load the libr ary | 1424 # Use this instead of shared_libraries when you are going to load the libr ary |
| 1425 # conditionally, and only when shared_libraries doesn't work for you. | 1425 # conditionally, and only when shared_libraries doesn't work for you. |
| 1426 # shared_libraries: List shared_library targets to bundle. If these | 1426 # shared_libraries: List shared_library targets to bundle. If these |
| 1427 # libraries depend on other shared_library targets, those dependencies wil l | 1427 # libraries depend on other shared_library targets, those dependencies wil l |
| 1428 # also be included in the apk (e.g. for is_component_build). | 1428 # also be included in the apk (e.g. for is_component_build). |
| 1429 # native_lib_placeholders: List of placeholder filenames to add to the apk | 1429 # native_lib_placeholders: List of placeholder filenames to add to the apk. |
| 1430 # (optional). | 1430 # These placeholders are necessary for some older devices - see |
| 1431 # http://crbug.com/395038. | |
| 1431 # apk_under_test: For an instrumentation test apk, this is the target of the | 1432 # apk_under_test: For an instrumentation test apk, this is the target of the |
| 1432 # tested apk. | 1433 # tested apk. |
| 1433 # include_all_resources - If true include all resource IDs in all generated | 1434 # include_all_resources - If true include all resource IDs in all generated |
| 1434 # R.java files. | 1435 # R.java files. |
| 1435 # testonly: Marks this target as "test-only". | 1436 # testonly: Marks this target as "test-only". |
| 1436 # write_asset_list: Adds an extra file to the assets, which contains a list of | 1437 # write_asset_list: Adds an extra file to the assets, which contains a list of |
| 1437 # all other asset files. | 1438 # all other asset files. |
| 1438 # alternative_locale_resource_dep: The locale resource target which override s | 1439 # alternative_locale_resource_dep: The locale resource target which override s |
| 1439 # any exsting locale resources in dep graph. | 1440 # any exsting locale resources in dep graph. |
| 1440 # requires_sdk_api_level_23: If defined and true, the apk is intended for | 1441 # requires_sdk_api_level_23: If defined and true, the apk is intended for |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1464 # ":my_shared_lib", | 1465 # ":my_shared_lib", |
| 1465 # ] | 1466 # ] |
| 1466 # } | 1467 # } |
| 1467 template("android_apk") { | 1468 template("android_apk") { |
| 1468 set_sources_assignment_filter([]) | 1469 set_sources_assignment_filter([]) |
| 1469 forward_variables_from(invoker, [ "testonly" ]) | 1470 forward_variables_from(invoker, [ "testonly" ]) |
| 1470 | 1471 |
| 1471 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) | 1472 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) |
| 1472 assert(defined(invoker.android_manifest)) | 1473 assert(defined(invoker.android_manifest)) |
| 1473 gen_dir = "$target_gen_dir/$target_name" | 1474 gen_dir = "$target_gen_dir/$target_name" |
| 1474 base_path = "$gen_dir/$target_name" | 1475 _base_path = "$gen_dir/$target_name" |
| 1475 _build_config = "$target_gen_dir/$target_name.build_config" | 1476 _build_config = "$target_gen_dir/$target_name.build_config" |
| 1476 resources_zip_path = "$base_path.resources.zip" | 1477 resources_zip_path = "$_base_path.resources.zip" |
| 1477 _all_resources_zip_path = "$base_path.resources.all.zip" | 1478 _all_resources_zip_path = "$_base_path.resources.all.zip" |
| 1478 _jar_path = "$base_path.jar" | 1479 _jar_path = "$_base_path.jar" |
| 1479 _lib_dex_path = "$base_path.dex.jar" | 1480 _lib_dex_path = "$_base_path.dex.jar" |
| 1480 _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir) | 1481 _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir) |
| 1481 _template_name = target_name | 1482 _template_name = target_name |
| 1482 | 1483 |
| 1483 enable_multidex = | 1484 enable_multidex = |
| 1484 defined(invoker.enable_multidex) && invoker.enable_multidex | 1485 defined(invoker.enable_multidex) && invoker.enable_multidex |
| 1485 if (enable_multidex) { | 1486 if (enable_multidex) { |
| 1486 final_dex_path = "$gen_dir/classes.dex.zip" | 1487 _final_dex_path = "$gen_dir/classes.dex.zip" |
| 1487 } else { | 1488 } else { |
| 1488 final_dex_path = "$gen_dir/classes.dex" | 1489 _final_dex_path = "$gen_dir/classes.dex" |
| 1489 } | 1490 } |
| 1490 final_dex_target_name = "${_template_name}__final_dex" | 1491 _final_dex_target_name = "${_template_name}__final_dex" |
| 1491 | 1492 |
| 1492 _final_apk_path = "" | 1493 _final_apk_path = "" |
| 1493 if (defined(invoker.final_apk_path)) { | 1494 if (defined(invoker.final_apk_path)) { |
| 1494 _final_apk_path = invoker.final_apk_path | 1495 _final_apk_path = invoker.final_apk_path |
| 1495 } else if (defined(invoker.apk_name)) { | 1496 } else if (defined(invoker.apk_name)) { |
| 1496 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" | 1497 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" |
| 1497 } | 1498 } |
| 1498 _final_apk_path_no_ext_list = | 1499 _final_apk_path_no_ext_list = |
| 1499 process_file_template([ _final_apk_path ], | 1500 process_file_template([ _final_apk_path ], |
| 1500 "{{source_dir}}/{{source_name_part}}") | 1501 "{{source_dir}}/{{source_name_part}}") |
| 1501 _final_apk_path_no_ext = _final_apk_path_no_ext_list[0] | 1502 _final_apk_path_no_ext = _final_apk_path_no_ext_list[0] |
| 1502 assert(_final_apk_path_no_ext != "") # Mark as used. | 1503 assert(_final_apk_path_no_ext != "") # Mark as used. |
| 1503 | 1504 |
| 1504 _install_script_name = "install_$_template_name" | 1505 _install_script_name = "install_$_template_name" |
| 1505 if (defined(invoker.install_script_name)) { | 1506 if (defined(invoker.install_script_name)) { |
| 1506 _install_script_name = invoker.install_script_name | 1507 _install_script_name = invoker.install_script_name |
| 1507 } | 1508 } |
| 1508 _incremental_install_script_path = | 1509 _incremental_install_script_path = |
| 1509 "${root_out_dir}/bin/${_install_script_name}_incremental" | 1510 "${root_out_dir}/bin/${_install_script_name}_incremental" |
| 1510 | 1511 |
| 1511 _version_code = android_default_version_code | 1512 _version_code = android_default_version_code |
| 1512 if (defined(invoker.version_code)) { | 1513 if (defined(invoker.version_code)) { |
| 1513 _version_code = invoker.version_code | 1514 _version_code = invoker.version_code |
| 1514 } | 1515 } |
| 1515 | 1516 |
| 1516 _version_name = android_default_version_name | 1517 _version_name = android_default_version_name |
| 1517 if (defined(invoker.version_name)) { | 1518 if (defined(invoker.version_name)) { |
| 1518 _version_name = invoker.version_name | 1519 _version_name = invoker.version_name |
| 1519 } | 1520 } |
| 1521 | |
| 1520 _keystore_path = android_keystore_path | 1522 _keystore_path = android_keystore_path |
| 1521 _keystore_name = android_keystore_name | 1523 _keystore_name = android_keystore_name |
| 1522 _keystore_password = android_keystore_password | 1524 _keystore_password = android_keystore_password |
| 1523 | 1525 |
| 1524 if (defined(invoker.keystore_path)) { | 1526 if (defined(invoker.keystore_path)) { |
| 1525 _keystore_path = invoker.keystore_path | 1527 _keystore_path = invoker.keystore_path |
| 1526 _keystore_name = invoker.keystore_name | 1528 _keystore_name = invoker.keystore_name |
| 1527 _keystore_password = invoker.keystore_password | 1529 _keystore_password = invoker.keystore_password |
| 1528 } | 1530 } |
| 1529 | 1531 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1609 _create_density_splits = | 1611 _create_density_splits = |
| 1610 defined(invoker.create_density_splits) && invoker.create_density_splits | 1612 defined(invoker.create_density_splits) && invoker.create_density_splits |
| 1611 _create_language_splits = | 1613 _create_language_splits = |
| 1612 defined(invoker.language_splits) && invoker.language_splits != [] | 1614 defined(invoker.language_splits) && invoker.language_splits != [] |
| 1613 | 1615 |
| 1614 # Help GN understand that _create_abi_split is not unused (bug in GN). | 1616 # Help GN understand that _create_abi_split is not unused (bug in GN). |
| 1615 assert(_create_abi_split || true) | 1617 assert(_create_abi_split || true) |
| 1616 | 1618 |
| 1617 _proguard_enabled = | 1619 _proguard_enabled = |
| 1618 defined(invoker.proguard_enabled) && invoker.proguard_enabled | 1620 defined(invoker.proguard_enabled) && invoker.proguard_enabled |
| 1621 | |
| 1622 # We are creating an .apk just for instrumentation tests to run on. | |
| 1623 # This allows us to turn on optimizations for the 'real' .apk, optimizations which wouldn't cause | |
| 1624 # any real issues, but would break instrumentation tests due to inlining (an d possibly other harmless optimizations). | |
| 1625 # Thus, we make a copy of the 'real' apk and apply another proguard file to it. | |
| 1626 _create_apk_for_test = _proguard_enabled && !defined(invoker.apk_under_test) | |
| 1627 | |
| 1619 if (_proguard_enabled) { | 1628 if (_proguard_enabled) { |
| 1620 _proguard_output_jar_path = "$base_path.proguard.jar" | 1629 _proguard_output_jar_path = "$_base_path.proguard.jar" |
| 1630 } | |
| 1631 if (_create_apk_for_test) { | |
| 1632 _template_name_for_test = "${_template_name}_for_test" | |
| 1633 _proguard_output_jar_for_test_path = "${_base_path}_for_test.proguard.jar" | |
| 1634 _final_dex_for_test_path = "$gen_dir/classes_for_test.dex" | |
| 1635 | |
| 1636 assert( | |
| 1637 !defined(invoker.final_apk_path), | |
| 1638 "Setting final_apk_path for proguarded .apks is not yet implemented.") | |
| 1639 _final_apk_for_test_path = | |
| 1640 "$root_build_dir/apks/${invoker.apk_name}ForTest.apk" | |
| 1621 } | 1641 } |
| 1622 | 1642 |
| 1623 _emma_never_instrument = defined(invoker.testonly) && invoker.testonly | 1643 _emma_never_instrument = defined(invoker.testonly) && invoker.testonly |
| 1624 | 1644 |
| 1625 build_config_target = "${_template_name}__build_config" | 1645 build_config_target = "${_template_name}__build_config" |
| 1626 write_build_config(build_config_target) { | 1646 write_build_config(build_config_target) { |
| 1627 forward_variables_from(invoker, [ "apk_under_test" ]) | 1647 forward_variables_from(invoker, [ "apk_under_test" ]) |
| 1628 type = "android_apk" | 1648 type = "android_apk" |
| 1629 jar_path = _jar_path | 1649 jar_path = _jar_path |
| 1630 dex_path = final_dex_path | 1650 dex_path = _final_dex_path |
| 1631 apk_path = _final_apk_path | 1651 apk_path = _final_apk_path |
| 1652 if (_create_apk_for_test) { | |
| 1653 apk_for_test_path = _final_apk_for_test_path | |
| 1654 } | |
| 1632 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" | 1655 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" |
| 1633 incremental_install_script_path = _incremental_install_script_path | 1656 incremental_install_script_path = _incremental_install_script_path |
| 1634 resources_zip = resources_zip_path | 1657 resources_zip = resources_zip_path |
| 1635 build_config = _build_config | 1658 build_config = _build_config |
| 1636 android_manifest = _android_manifest | 1659 android_manifest = _android_manifest |
| 1637 | 1660 |
| 1638 deps = _android_manifest_deps | 1661 deps = _android_manifest_deps |
| 1639 | 1662 |
| 1640 if (defined(invoker.deps)) { | 1663 if (defined(invoker.deps)) { |
| 1641 possible_config_deps = invoker.deps | 1664 possible_config_deps = invoker.deps |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1660 # build the native libraries just to create the .build_config file. | 1683 # build the native libraries just to create the .build_config file. |
| 1661 # The dep is unnecessary since the runtime_deps file is created by gn gen | 1684 # The dep is unnecessary since the runtime_deps file is created by gn gen |
| 1662 # and the runtime_deps file is added to write_build_config.py's depfile. | 1685 # and the runtime_deps file is added to write_build_config.py's depfile. |
| 1663 if (_native_libs_deps != []) { | 1686 if (_native_libs_deps != []) { |
| 1664 shared_libraries_runtime_deps_file = _runtime_deps_file | 1687 shared_libraries_runtime_deps_file = _runtime_deps_file |
| 1665 } | 1688 } |
| 1666 } | 1689 } |
| 1667 | 1690 |
| 1668 _final_deps = [] | 1691 _final_deps = [] |
| 1669 | 1692 |
| 1670 _generated_proguard_config = "$base_path.resources.proguard.txt" | 1693 _generated_proguard_config = "$_base_path.resources.proguard.txt" |
| 1671 process_resources_target = "${_template_name}__process_resources" | 1694 process_resources_target = "${_template_name}__process_resources" |
| 1672 process_resources(process_resources_target) { | 1695 process_resources(process_resources_target) { |
| 1673 forward_variables_from(invoker, | 1696 forward_variables_from(invoker, |
| 1674 [ | 1697 [ |
| 1675 "alternative_android_sdk_jar", | 1698 "alternative_android_sdk_jar", |
| 1676 "android_aapt_path", | 1699 "android_aapt_path", |
| 1677 "app_as_shared_lib", | 1700 "app_as_shared_lib", |
| 1678 "include_all_resources", | 1701 "include_all_resources", |
| 1679 "shared_resources", | 1702 "shared_resources", |
| 1680 ]) | 1703 ]) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1832 ":$java_target", # Generates the jar file. | 1855 ":$java_target", # Generates the jar file. |
| 1833 ] | 1856 ] |
| 1834 } | 1857 } |
| 1835 } | 1858 } |
| 1836 | 1859 |
| 1837 if (_proguard_enabled) { | 1860 if (_proguard_enabled) { |
| 1838 _proguard_configs = [ _generated_proguard_config ] | 1861 _proguard_configs = [ _generated_proguard_config ] |
| 1839 if (defined(invoker.proguard_configs)) { | 1862 if (defined(invoker.proguard_configs)) { |
| 1840 _proguard_configs += invoker.proguard_configs | 1863 _proguard_configs += invoker.proguard_configs |
| 1841 } | 1864 } |
| 1865 | |
| 1866 # These assertions are to mark variables as used that will be used by prog uard_helper, | |
| 1867 # since GN doesn't recognize they are being used. See crbug.com/395883. | |
| 1868 assert(_proguard_configs != []) # Mark as used. | |
| 1869 _proguard_helper_vars = [ | |
| 1870 "alternative_android_sdk_jar", | |
| 1871 "proguard_jar_path", | |
| 1872 ] | |
| 1873 template("proguard_helper") { | |
| 1874 proguard(target_name) { | |
| 1875 forward_variables_from(invoker, | |
| 1876 _proguard_helper_vars + [ "output_jar_path" ]) | |
| 1877 deps = [ | |
| 1878 ":$build_config_target", | |
| 1879 ":$java_target", | |
| 1880 ":$process_resources_target", | |
| 1881 ] | |
| 1882 if (defined(invoker.deps)) { | |
| 1883 deps += invoker.deps | |
| 1884 } | |
| 1885 if (defined(invoker.proguard_configs)) { | |
| 1886 _proguard_configs += invoker.proguard_configs | |
| 1887 } | |
| 1888 inputs = [ | |
| 1889 _build_config, | |
| 1890 _jar_path, | |
| 1891 ] + _proguard_configs | |
| 1892 _rebased_proguard_configs = | |
| 1893 rebase_path(_proguard_configs, root_build_dir) | |
| 1894 | |
| 1895 args = [ | |
| 1896 "--proguard-configs=$_rebased_proguard_configs", | |
| 1897 "--input-paths=@FileArg($_rebased_build_config:proguard:input_paths) ", | |
| 1898 ] | |
| 1899 if (defined(invoker.additional_args)) { | |
| 1900 args += invoker.additional_args | |
| 1901 } | |
| 1902 } | |
| 1903 } | |
| 1842 _proguard_target = "${_template_name}__proguard" | 1904 _proguard_target = "${_template_name}__proguard" |
| 1843 proguard(_proguard_target) { | 1905 proguard_helper(_proguard_target) { |
| 1844 forward_variables_from(invoker, | 1906 forward_variables_from(invoker, _proguard_helper_vars) |
| 1845 [ | |
| 1846 "alternative_android_sdk_jar", | |
| 1847 "proguard_jar_path", | |
| 1848 ]) | |
| 1849 deps = [ | |
| 1850 ":$build_config_target", | |
| 1851 ":$java_target", | |
| 1852 ":$process_resources_target", | |
| 1853 ] | |
| 1854 inputs = [ | |
| 1855 _build_config, | |
| 1856 _jar_path, | |
| 1857 ] + _proguard_configs | |
| 1858 | |
| 1859 output_jar_path = _proguard_output_jar_path | 1907 output_jar_path = _proguard_output_jar_path |
| 1860 _rebased_proguard_configs = | |
| 1861 rebase_path(_proguard_configs, root_build_dir) | |
| 1862 args = [ | |
| 1863 "--proguard-configs=$_rebased_proguard_configs", | |
| 1864 "--input-paths=@FileArg($_rebased_build_config:proguard:input_paths)", | |
| 1865 ] | |
| 1866 if (defined(invoker.apk_under_test)) { | 1908 if (defined(invoker.apk_under_test)) { |
| 1867 deps += [ | 1909 deps = [ |
| 1868 "${invoker.apk_under_test}__build_config", | 1910 "${invoker.apk_under_test}__build_config", |
| 1869 "${invoker.apk_under_test}__proguard", | 1911 "${invoker.apk_under_test}__proguard", |
| 1870 ] | 1912 ] |
| 1871 _apk_under_test_build_config = | 1913 _apk_under_test_build_config = |
| 1872 get_label_info(invoker.apk_under_test, "target_gen_dir") + "/" + | 1914 get_label_info(invoker.apk_under_test, "target_gen_dir") + "/" + |
| 1873 get_label_info(invoker.apk_under_test, "name") + ".build_config" | 1915 get_label_info(invoker.apk_under_test, "name") + ".build_config" |
| 1874 _rebased_apk_under_test_build_config = | 1916 _rebased_apk_under_test_build_config = |
| 1875 rebase_path(_apk_under_test_build_config, root_build_dir) | 1917 rebase_path(_apk_under_test_build_config, root_build_dir) |
| 1876 args += [ "--tested-apk-info=@FileArg($_rebased_apk_under_test_build_c onfig:deps_info:proguard_info)" ] | 1918 additional_args = [ "--tested-apk-info=@FileArg($_rebased_apk_under_te st_build_config:deps_info:proguard_info)" ] |
| 1919 } | |
| 1920 } | |
| 1921 if (_create_apk_for_test) { | |
| 1922 _proguard_for_test_target = "${_template_name_for_test}__proguard" | |
| 1923 proguard_helper(_proguard_for_test_target) { | |
| 1924 forward_variables_from(invoker, _proguard_helper_vars) | |
| 1925 output_jar_path = _proguard_output_jar_for_test_path | |
| 1926 | |
| 1927 # This Proguard flags file will apply only to tested apks - true | |
| 1928 # release apks are not affected. | |
| 1929 proguard_configs = [ "//testing/android/proguard_for_test.flags" ] | |
| 1930 assert(proguard_configs != []) # Mark as used. | |
| 1877 } | 1931 } |
| 1878 } | 1932 } |
| 1879 _dex_sources = [ _proguard_output_jar_path ] | 1933 _dex_sources = [ _proguard_output_jar_path ] |
| 1880 _dex_deps = [ ":$_proguard_target" ] | 1934 _dex_deps = [ ":$_proguard_target" ] |
| 1881 | 1935 |
| 1882 _copy_proguard_mapping_target = "${_template_name}__copy_proguard_mapping" | 1936 _copy_proguard_mapping_target = "${_template_name}__copy_proguard_mapping" |
| 1883 copy(_copy_proguard_mapping_target) { | 1937 copy(_copy_proguard_mapping_target) { |
| 1884 sources = [ | 1938 sources = [ |
| 1885 "$_proguard_output_jar_path.mapping", | 1939 "$_proguard_output_jar_path.mapping", |
| 1886 ] | 1940 ] |
| 1887 outputs = [ | 1941 outputs = [ |
| 1888 "$_final_apk_path.mapping", | 1942 "$_final_apk_path.mapping", |
| 1889 ] | 1943 ] |
| 1890 deps = [ | 1944 deps = [ |
| 1891 ":$_proguard_target", | 1945 ":$_proguard_target", |
| 1892 ] | 1946 ] |
| 1893 } | 1947 } |
| 1894 } else { | 1948 } else { |
| 1895 if (enable_multidex) { | 1949 if (enable_multidex) { |
| 1896 _dex_sources = [ _jar_path ] | 1950 _dex_sources = [ _jar_path ] |
| 1897 } else { | 1951 } else { |
| 1898 _dex_sources = [ _lib_dex_path ] | 1952 _dex_sources = [ _lib_dex_path ] |
| 1899 } | 1953 } |
| 1900 _dex_deps = [ ":$java_target" ] | 1954 _dex_deps = [ ":$java_target" ] |
| 1901 } | 1955 } |
| 1902 | 1956 |
| 1903 dex("$final_dex_target_name") { | 1957 dex("$_final_dex_target_name") { |
| 1904 deps = _dex_deps + [ ":$build_config_target" ] | 1958 deps = _dex_deps + [ ":$build_config_target" ] |
| 1905 inputs = [ | 1959 inputs = [ |
| 1906 _build_config, | 1960 _build_config, |
| 1907 ] | 1961 ] |
| 1908 sources = _dex_sources | 1962 sources = _dex_sources |
| 1909 output = final_dex_path | 1963 output = _final_dex_path |
| 1910 | 1964 |
| 1911 # All deps are already included in _dex_sources when proguard is used. | 1965 # All deps are already included in _dex_sources when proguard is used. |
| 1912 if (!_proguard_enabled) { | 1966 if (!_proguard_enabled) { |
| 1913 if (enable_multidex) { | 1967 if (enable_multidex) { |
| 1914 _dex_arg_key = "${_rebased_build_config}:dist_jar:dependency_jars" | 1968 _dex_arg_key = "${_rebased_build_config}:dist_jar:dependency_jars" |
| 1915 } else { | 1969 } else { |
| 1916 _dex_arg_key = | 1970 _dex_arg_key = |
| 1917 "${_rebased_build_config}:final_dex:dependency_dex_files" | 1971 "${_rebased_build_config}:final_dex:dependency_dex_files" |
| 1918 } | 1972 } |
| 1919 args = [ "--inputs=@FileArg($_dex_arg_key)" ] | 1973 args = [ "--inputs=@FileArg($_dex_arg_key)" ] |
| 1920 } | 1974 } |
| 1921 } | 1975 } |
| 1922 | 1976 |
| 1977 if (_create_apk_for_test) { | |
| 1978 _final_dex_for_test_target_name = "${_final_dex_target_name}_for_test" | |
| 1979 dex("$_final_dex_for_test_target_name") { | |
| 1980 deps = [ | |
| 1981 ":$_proguard_for_test_target", | |
| 1982 ":$build_config_target", | |
| 1983 ] | |
| 1984 inputs = [ | |
| 1985 _build_config, | |
| 1986 ] | |
| 1987 sources = [ | |
| 1988 _proguard_output_jar_for_test_path, | |
| 1989 ] | |
| 1990 output = _final_dex_for_test_path | |
| 1991 } | |
| 1992 } | |
| 1993 | |
| 1923 _native_libs_file_arg_dep = ":$build_config_target" | 1994 _native_libs_file_arg_dep = ":$build_config_target" |
| 1924 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" | 1995 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" |
| 1925 | 1996 |
| 1926 if (_native_libs_deps != [] && _enable_relocation_packing) { | 1997 if (_native_libs_deps != [] && _enable_relocation_packing) { |
| 1927 _prepare_native_target_name = "${_template_name}__prepare_native" | 1998 _prepare_native_target_name = "${_template_name}__prepare_native" |
| 1928 _native_libs_dir = "$gen_dir/packed-libs" | 1999 _native_libs_dir = "$gen_dir/packed-libs" |
| 1929 _native_libs_json = "$gen_dir/packed-libs/filelist.json" | 2000 _native_libs_json = "$gen_dir/packed-libs/filelist.json" |
| 1930 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) | 2001 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) |
| 1931 | 2002 |
| 1932 _native_libs_file_arg_dep = ":$_prepare_native_target_name" | 2003 _native_libs_file_arg_dep = ":$_prepare_native_target_name" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1985 _extra_native_libs = | 2056 _extra_native_libs = |
| 1986 [ "$root_shlib_dir/libchromium_android_linker$shlib_extension" ] | 2057 [ "$root_shlib_dir/libchromium_android_linker$shlib_extension" ] |
| 1987 _extra_native_libs_deps += | 2058 _extra_native_libs_deps += |
| 1988 [ "//base/android/linker:chromium_android_linker" ] | 2059 [ "//base/android/linker:chromium_android_linker" ] |
| 1989 } | 2060 } |
| 1990 } | 2061 } |
| 1991 if (defined(invoker.loadable_modules) && invoker.loadable_modules != []) { | 2062 if (defined(invoker.loadable_modules) && invoker.loadable_modules != []) { |
| 1992 _extra_native_libs_even_when_incremental += invoker.loadable_modules | 2063 _extra_native_libs_even_when_incremental += invoker.loadable_modules |
| 1993 } | 2064 } |
| 1994 | 2065 |
| 2066 # These assertions are to mark variables as used that will be used by create _main_apk, | |
| 2067 # since GN doesn't recognize they are being used. See crbug.com/395883. | |
| 2068 assert(_extra_native_libs_even_when_incremental == [] || | |
| 2069 _extra_native_libs_even_when_incremental != []) # Mark as used. | |
| 2070 assert(_version_code != "") # Mark as used. | |
| 2071 assert(_version_code != "") # Mark as used. | |
| 2072 assert(_version_name != "") # Mark as used. | |
| 2073 assert(_keystore_path != "") # Mark as used. | |
| 2074 assert(_keystore_name != "") # Mark as used. | |
| 2075 assert(_keystore_password != "") # Mark as used. | |
| 2076 _create_apk_vars = [ | |
| 2077 "alternative_android_sdk_jar", | |
| 2078 "android_aapt_path", | |
| 2079 "app_as_shared_lib", | |
| 2080 "deps", | |
| 2081 "extensions_to_not_compress", | |
| 2082 "language_splits", | |
| 2083 "native_lib_placeholders", | |
| 2084 "page_align_shared_libraries", | |
| 2085 "public_deps", | |
| 2086 "secondary_native_libs", | |
| 2087 "shared_resources", | |
| 2088 "uncompress_shared_libraries", | |
| 2089 "write_asset_list", | |
| 2090 ] | |
| 2091 template("create_main_apk") { | |
| 2092 create_apk(target_name) { | |
| 2093 forward_variables_from(invoker, | |
| 2094 _create_apk_vars + [ | |
| 2095 "apk_path", | |
| 2096 "base_path", | |
| 2097 "dex_path", | |
| 2098 ]) | |
| 2099 | |
| 2100 if (!defined(deps)) { | |
| 2101 deps = [] | |
| 2102 } | |
| 2103 | |
| 2104 # This target generates the input file _all_resources_zip_path. | |
|
agrieve
2016/07/07 15:36:51
nit: can you remove this comment? It doesn't add m
| |
| 2105 deps += _android_manifest_deps + [ | |
| 2106 ":$build_config_target", | |
| 2107 ":$process_resources_target", | |
| 2108 invoker.dex_target, | |
| 2109 ] | |
| 2110 android_manifest = _android_manifest | |
| 2111 assets_build_config = _build_config | |
| 2112 resources_zip = _all_resources_zip_path | |
| 2113 load_library_from_apk = _load_library_from_apk | |
| 2114 create_density_splits = _create_density_splits | |
| 2115 emma_instrument = emma_coverage && !_emma_never_instrument | |
| 2116 | |
| 2117 if (!defined(extensions_to_not_compress)) { | |
| 2118 # Allow icu data, v8 snapshots, and pak files to be loaded directly fr om | |
| 2119 # the .apk. | |
| 2120 # Note: These are actually suffix matches, not necessarily extensions. | |
| 2121 extensions_to_not_compress = ".dat,.bin,.pak" | |
| 2122 } | |
| 2123 | |
| 2124 version_code = _version_code | |
| 2125 version_name = _version_name | |
| 2126 | |
| 2127 keystore_name = _keystore_name | |
| 2128 keystore_path = _keystore_path | |
| 2129 keystore_password = _keystore_password | |
| 2130 | |
| 2131 # Incremental apk does not use native libs nor final dex. | |
| 2132 incremental_deps = deps + _android_manifest_deps + [ | |
| 2133 ":$build_config_target", | |
| 2134 ":$process_resources_target", | |
| 2135 ] | |
| 2136 if ((_native_libs_deps != [] || | |
| 2137 _extra_native_libs_even_when_incremental != []) && | |
| 2138 !_create_abi_split) { | |
| 2139 deps += _native_libs_deps + _extra_native_libs_deps + | |
| 2140 _extra_native_libs_even_when_incremental_deps + | |
| 2141 [ _native_libs_file_arg_dep ] | |
| 2142 native_libs_filearg = _native_libs_file_arg | |
| 2143 native_libs = _extra_native_libs | |
| 2144 native_libs_even_when_incremental = | |
| 2145 _extra_native_libs_even_when_incremental | |
| 2146 } | |
| 2147 } | |
| 2148 } | |
| 2149 | |
| 1995 _final_deps += [ ":${_template_name}__create" ] | 2150 _final_deps += [ ":${_template_name}__create" ] |
| 1996 create_apk("${_template_name}__create") { | 2151 create_main_apk("${_template_name}__create") { |
|
agrieve
2016/07/07 15:36:51
nit: "${var}" -> var
| |
| 1997 forward_variables_from(invoker, | 2152 forward_variables_from(invoker, _create_apk_vars) |
| 1998 [ | 2153 apk_path = _final_apk_path |
| 1999 "alternative_android_sdk_jar", | 2154 base_path = _base_path |
| 2000 "android_aapt_path", | 2155 dex_path = _final_dex_path |
| 2001 "app_as_shared_lib", | 2156 dex_target = ":$_final_dex_target_name" |
| 2002 "deps", | 2157 } |
| 2003 "extensions_to_not_compress", | 2158 |
| 2004 "language_splits", | 2159 if (_create_apk_for_test) { |
| 2005 "page_align_shared_libraries", | 2160 # We are going to create a second apk, very similiar to the above |
| 2006 "public_deps", | 2161 # create_apk("${_template_name}__create"), but with this one being an |
| 2007 "secondary_native_libs", | 2162 # externally visible rule which will build an .apk with the additional |
| 2008 "shared_resources", | 2163 # test-only proguard flags. |
| 2009 "uncompress_shared_libraries", | 2164 create_main_apk("${_template_name_for_test}") { |
| 2010 "write_asset_list", | 2165 forward_variables_from(invoker, _create_apk_vars) |
| 2011 ]) | 2166 apk_path = _final_apk_for_test_path |
| 2012 if (!defined(deps)) { | 2167 base_path = _base_path + "_for_test" |
| 2013 deps = [] | 2168 dex_path = _final_dex_for_test_path |
| 2169 dex_target = ":$_final_dex_for_test_target_name" | |
| 2014 } | 2170 } |
| 2015 apk_path = _final_apk_path | |
| 2016 android_manifest = _android_manifest | |
| 2017 assets_build_config = _build_config | |
| 2018 resources_zip = _all_resources_zip_path | |
| 2019 dex_path = final_dex_path | |
| 2020 load_library_from_apk = _load_library_from_apk | |
| 2021 create_density_splits = _create_density_splits | |
| 2022 emma_instrument = emma_coverage && !_emma_never_instrument | |
| 2023 | |
| 2024 if (!defined(extensions_to_not_compress)) { | |
| 2025 # Allow icu data, v8 snapshots, and pak files to be loaded directly from | |
| 2026 # the .apk. | |
| 2027 # Note: These are actually suffix matches, not necessarily extensions. | |
| 2028 extensions_to_not_compress = ".dat,.bin,.pak" | |
| 2029 } | |
| 2030 | |
| 2031 version_code = _version_code | |
| 2032 version_name = _version_name | |
| 2033 | |
| 2034 keystore_name = _keystore_name | |
| 2035 keystore_path = _keystore_path | |
| 2036 keystore_password = _keystore_password | |
| 2037 | |
| 2038 # Incremental apk does not use native libs nor final dex. | |
| 2039 incremental_deps = deps + _android_manifest_deps + [ | |
| 2040 ":$build_config_target", | |
| 2041 ":$process_resources_target", | |
| 2042 ] | |
| 2043 | |
| 2044 # This target generates the input file _all_resources_zip_path. | |
| 2045 deps += _android_manifest_deps + [ | |
| 2046 ":$build_config_target", | |
| 2047 ":$process_resources_target", | |
| 2048 ":$final_dex_target_name", | |
| 2049 ] | |
| 2050 | |
| 2051 if ((_native_libs_deps != [] || | |
| 2052 _extra_native_libs_even_when_incremental != []) && | |
| 2053 !_create_abi_split) { | |
| 2054 deps += _native_libs_deps + _extra_native_libs_deps + | |
| 2055 _extra_native_libs_even_when_incremental_deps + | |
| 2056 [ _native_libs_file_arg_dep ] | |
| 2057 native_libs_filearg = _native_libs_file_arg | |
| 2058 native_libs = _extra_native_libs | |
| 2059 native_libs_even_when_incremental = | |
| 2060 _extra_native_libs_even_when_incremental | |
| 2061 } | |
| 2062 | |
| 2063 # Placeholders necessary for some older devices. | |
| 2064 # http://crbug.com/395038 | |
| 2065 forward_variables_from(invoker, [ "native_lib_placeholders" ]) | |
| 2066 } | 2171 } |
| 2067 | 2172 |
| 2068 if ((_native_libs_deps != [] || | 2173 if ((_native_libs_deps != [] || |
| 2069 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { | 2174 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { |
| 2070 _manifest_rule = | 2175 _manifest_rule = |
| 2071 "${_template_name}__split_manifest_abi_${android_app_abi}" | 2176 "${_template_name}__split_manifest_abi_${android_app_abi}" |
| 2072 generate_split_manifest(_manifest_rule) { | 2177 generate_split_manifest(_manifest_rule) { |
| 2073 main_manifest = _android_manifest | 2178 main_manifest = _android_manifest |
| 2074 out_manifest = | 2179 out_manifest = |
| 2075 "$gen_dir/split-manifests/${android_app_abi}/AndroidManifest.xml" | 2180 "$gen_dir/split-manifests/${android_app_abi}/AndroidManifest.xml" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2306 | 2411 |
| 2307 group(target_name) { | 2412 group(target_name) { |
| 2308 public_deps = [ | 2413 public_deps = [ |
| 2309 ":$_apk_target_name", | 2414 ":$_apk_target_name", |
| 2310 ":$_test_runner_target_name", | 2415 ":$_test_runner_target_name", |
| 2311 | 2416 |
| 2312 # Required by test runner to enumerate test list. | 2417 # Required by test runner to enumerate test list. |
| 2313 ":${_apk_target_name}_dist_ijar", | 2418 ":${_apk_target_name}_dist_ijar", |
| 2314 ] | 2419 ] |
| 2315 if (defined(invoker.apk_under_test)) { | 2420 if (defined(invoker.apk_under_test)) { |
| 2316 public_deps += [ invoker.apk_under_test ] | 2421 if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) { |
| 2422 public_deps += [ "${invoker.apk_under_test}_for_test" ] | |
| 2423 } else { | |
| 2424 public_deps += [ invoker.apk_under_test ] | |
| 2425 } | |
| 2317 } | 2426 } |
| 2318 if (defined(invoker.isolate_file)) { | 2427 if (defined(invoker.isolate_file)) { |
| 2319 isolate_values = exec_script("//build/gypi_to_gn.py", | 2428 isolate_values = exec_script("//build/gypi_to_gn.py", |
| 2320 [ | 2429 [ |
| 2321 rebase_path(invoker.isolate_file), | 2430 rebase_path(invoker.isolate_file), |
| 2322 "--replace", | 2431 "--replace", |
| 2323 "<(DEPTH)=/", | 2432 "<(DEPTH)=/", |
| 2324 ], | 2433 ], |
| 2325 "scope", | 2434 "scope", |
| 2326 [ invoker.isolate_file ]) | 2435 [ invoker.isolate_file ]) |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2559 android_library(target_name) { | 2668 android_library(target_name) { |
| 2560 chromium_code = false | 2669 chromium_code = false |
| 2561 java_files = [] | 2670 java_files = [] |
| 2562 srcjar_deps = [ ":${_template_name}__protoc_java" ] | 2671 srcjar_deps = [ ":${_template_name}__protoc_java" ] |
| 2563 deps = [ | 2672 deps = [ |
| 2564 "//third_party/android_protobuf:protobuf_nano_javalib", | 2673 "//third_party/android_protobuf:protobuf_nano_javalib", |
| 2565 ] | 2674 ] |
| 2566 } | 2675 } |
| 2567 } | 2676 } |
| 2568 } | 2677 } |
| OLD | NEW |