| 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/config/dcheck_always_on.gni") | 7 import("//build/config/dcheck_always_on.gni") |
| 8 import("//build/toolchain/toolchain.gni") | 8 import("//build/toolchain/toolchain.gni") |
| 9 | 9 |
| 10 assert(is_android) | 10 assert(is_android) |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 # * dependencies of this .so are not automatically included | 1413 # * dependencies of this .so are not automatically included |
| 1414 # * ".cr.so" is never added | 1414 # * ".cr.so" is never added |
| 1415 # * they are not side-loaded for _incremental targets. | 1415 # * they are not side-loaded for _incremental targets. |
| 1416 # * load_library_from_apk, use_chromium_linker, | 1416 # * load_library_from_apk, use_chromium_linker, |
| 1417 # and enable_relocation_packing do not apply | 1417 # and enable_relocation_packing do not apply |
| 1418 # Use this instead of shared_libraries when you are going to load the libr
ary | 1418 # Use this instead of shared_libraries when you are going to load the libr
ary |
| 1419 # conditionally, and only when shared_libraries doesn't work for you. | 1419 # conditionally, and only when shared_libraries doesn't work for you. |
| 1420 # shared_libraries: List shared_library targets to bundle. If these | 1420 # shared_libraries: List shared_library targets to bundle. If these |
| 1421 # libraries depend on other shared_library targets, those dependencies wil
l | 1421 # libraries depend on other shared_library targets, those dependencies wil
l |
| 1422 # also be included in the apk (e.g. for is_component_build). | 1422 # also be included in the apk (e.g. for is_component_build). |
| 1423 # secondary_abi_shared_libraries: secondary abi shared_library targets to | |
| 1424 # bundle. If these libraries depend on other shared_library targets, those | |
| 1425 # dependencies will also be included in the apk (e.g. for is_component_bui
ld). | |
| 1426 # native_lib_placeholders: List of placeholder filenames to add to the apk | 1423 # native_lib_placeholders: List of placeholder filenames to add to the apk |
| 1427 # (optional). | 1424 # (optional). |
| 1428 # apk_under_test: For an instrumentation test apk, this is the target of the | 1425 # apk_under_test: For an instrumentation test apk, this is the target of the |
| 1429 # tested apk. | 1426 # tested apk. |
| 1430 # include_all_resources - If true include all resource IDs in all generated | 1427 # include_all_resources - If true include all resource IDs in all generated |
| 1431 # R.java files. | 1428 # R.java files. |
| 1432 # testonly: Marks this target as "test-only". | 1429 # testonly: Marks this target as "test-only". |
| 1433 # write_asset_list: Adds an extra file to the assets, which contains a list
of | 1430 # write_asset_list: Adds an extra file to the assets, which contains a list
of |
| 1434 # all other asset files. | 1431 # all other asset files. |
| 1435 # alternative_locale_resource_dep: The locale resource target which override
s | 1432 # alternative_locale_resource_dep: The locale resource target which override
s |
| 1436 # any exsting locale resources in dep graph. | 1433 # any exsting locale resources in dep graph. |
| 1437 # requires_sdk_api_level_23: If defined and true, the apk is intended for | 1434 # requires_sdk_api_level_23: If defined and true, the apk is intended for |
| 1438 # installation only on Android M or later. In these releases the system | 1435 # installation only on Android M or later. In these releases the system |
| 1439 # linker does relocation unpacking, so we can enable it unconditionally. | 1436 # linker does relocation unpacking, so we can enable it unconditionally. |
| 1440 # secondary_native_libs (deprecated): The path of native libraries for secon
dary | 1437 # secondary_native_libs: The path of native libraries for secondary app abi. |
| 1441 # app abi. | |
| 1442 # run_findbugs_override: Forces run_findbugs on or off. If undefined, the | 1438 # run_findbugs_override: Forces run_findbugs on or off. If undefined, the |
| 1443 # default will use the build arg run_findbugs. | 1439 # default will use the build arg run_findbugs. |
| 1444 # proguard_jar_path: The path to proguard.jar you wish to use. If undefined, | 1440 # proguard_jar_path: The path to proguard.jar you wish to use. If undefined, |
| 1445 # the proguard used will be the checked in one in //third_party/proguard. | 1441 # the proguard used will be the checked in one in //third_party/proguard. |
| 1446 # | 1442 # |
| 1447 # Example | 1443 # Example |
| 1448 # android_apk("foo_apk") { | 1444 # android_apk("foo_apk") { |
| 1449 # android_manifest = "AndroidManifest.xml" | 1445 # android_manifest = "AndroidManifest.xml" |
| 1450 # java_files = [ | 1446 # java_files = [ |
| 1451 # "android/org/chromium/foo/FooApplication.java", | 1447 # "android/org/chromium/foo/FooApplication.java", |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 "or requires_sdk_api_level_23") | 1543 "or requires_sdk_api_level_23") |
| 1548 } | 1544 } |
| 1549 if (_load_library_from_apk) { | 1545 if (_load_library_from_apk) { |
| 1550 assert(_use_chromium_linker || _requires_sdk_api_level_23, | 1546 assert(_use_chromium_linker || _requires_sdk_api_level_23, |
| 1551 "load_library_from_apk requires use_chromium_linker " + | 1547 "load_library_from_apk requires use_chromium_linker " + |
| 1552 "or requires_sdk_api_level_23") | 1548 "or requires_sdk_api_level_23") |
| 1553 } | 1549 } |
| 1554 | 1550 |
| 1555 # The dependency that makes the chromium linker, if any is needed. | 1551 # The dependency that makes the chromium linker, if any is needed. |
| 1556 _native_libs_deps = [] | 1552 _native_libs_deps = [] |
| 1557 _shared_libraries_is_valid = | |
| 1558 defined(invoker.shared_libraries) && invoker.shared_libraries != [] | |
| 1559 _secondary_abi_native_libs_deps = [] | |
| 1560 assert(_secondary_abi_native_libs_deps == []) # mark as used. | |
| 1561 _secondary_abi_shared_libraries_is_valid = | |
| 1562 defined(invoker.secondary_abi_shared_libraries) && | |
| 1563 invoker.secondary_abi_shared_libraries != [] | |
| 1564 | 1553 |
| 1565 if (is_component_build || is_asan) { | 1554 if (defined(invoker.shared_libraries) && invoker.shared_libraries != []) { |
| 1566 if (_shared_libraries_is_valid) { | 1555 _native_libs_deps += invoker.shared_libraries |
| 1556 |
| 1557 if (is_component_build || is_asan) { |
| 1567 _native_libs_deps += [ "//build/android:cpplib_stripped" ] | 1558 _native_libs_deps += [ "//build/android:cpplib_stripped" ] |
| 1568 } | 1559 } |
| 1569 if (_secondary_abi_shared_libraries_is_valid) { | |
| 1570 _secondary_abi_native_libs_deps += [ "//build/android:cpplib_stripped($a
ndroid_secondary_abi_toolchain)" ] | |
| 1571 } | |
| 1572 } | |
| 1573 | |
| 1574 if (_shared_libraries_is_valid) { | |
| 1575 _native_libs_deps += invoker.shared_libraries | |
| 1576 | 1560 |
| 1577 # To determine the filenames of all dependent shared libraries, write the | 1561 # To determine the filenames of all dependent shared libraries, write the |
| 1578 # runtime deps of |shared_libraries| to a file during "gn gen". | 1562 # runtime deps of |shared_libraries| to a file during "gn gen". |
| 1579 # write_build_config.py will then grep this file for *.so to obtain the | 1563 # write_build_config.py will then grep this file for *.so to obtain the |
| 1580 # complete list. | 1564 # complete list. |
| 1581 _runtime_deps_file = | 1565 _runtime_deps_file = |
| 1582 "$target_gen_dir/${_template_name}.native.runtimedeps" | 1566 "$target_gen_dir/${_template_name}.native.runtimedeps" |
| 1583 group("${_template_name}__runtime_deps") { | 1567 group("${_template_name}__runtime_deps") { |
| 1584 deps = _native_libs_deps | 1568 deps = _native_libs_deps |
| 1585 write_runtime_deps = _runtime_deps_file | 1569 write_runtime_deps = _runtime_deps_file |
| 1586 } | 1570 } |
| 1587 | 1571 |
| 1588 _native_lib_version_rule = "" | 1572 _native_lib_version_rule = "" |
| 1589 if (defined(invoker.native_lib_version_rule)) { | 1573 if (defined(invoker.native_lib_version_rule)) { |
| 1590 _native_lib_version_rule = invoker.native_lib_version_rule | 1574 _native_lib_version_rule = invoker.native_lib_version_rule |
| 1591 } | 1575 } |
| 1592 _native_lib_version_arg = "\"\"" | 1576 _native_lib_version_arg = "\"\"" |
| 1593 if (defined(invoker.native_lib_version_arg)) { | 1577 if (defined(invoker.native_lib_version_arg)) { |
| 1594 _native_lib_version_arg = invoker.native_lib_version_arg | 1578 _native_lib_version_arg = invoker.native_lib_version_arg |
| 1595 } | 1579 } |
| 1596 } | 1580 } |
| 1597 | 1581 |
| 1598 if (_secondary_abi_shared_libraries_is_valid) { | |
| 1599 _secondary_abi_native_libs_deps += invoker.secondary_abi_shared_libraries | |
| 1600 | |
| 1601 # To determine the filenames of all dependent shared libraries, write the | |
| 1602 # runtime deps of |shared_libraries| to a file during "gn gen". | |
| 1603 # write_build_config.py will then grep this file for *.so to obtain the | |
| 1604 # complete list. | |
| 1605 _secondary_abi_runtime_deps_file = | |
| 1606 "$target_gen_dir/${_template_name}.secondary.abi.native.runtimedeps" | |
| 1607 group("${_template_name}_secondary_abi__runtime_deps") { | |
| 1608 deps = _secondary_abi_native_libs_deps | |
| 1609 write_runtime_deps = _secondary_abi_runtime_deps_file | |
| 1610 } | |
| 1611 } | |
| 1612 | |
| 1613 if (defined(invoker.deps)) { | 1582 if (defined(invoker.deps)) { |
| 1614 set_sources_assignment_filter([ "*manifest*" ]) | 1583 set_sources_assignment_filter([ "*manifest*" ]) |
| 1615 sources = invoker.deps | 1584 sources = invoker.deps |
| 1616 set_sources_assignment_filter([]) | 1585 set_sources_assignment_filter([]) |
| 1617 if (sources != invoker.deps) { | 1586 if (sources != invoker.deps) { |
| 1618 _bad_deps = invoker.deps - sources | 1587 _bad_deps = invoker.deps - sources |
| 1619 assert( | 1588 assert( |
| 1620 false, | 1589 false, |
| 1621 "Possible manifest-generating dep found in deps. Use android_manifes
t_dep for this instead. Found: $_bad_deps") | 1590 "Possible manifest-generating dep found in deps. Use android_manifes
t_dep for this instead. Found: $_bad_deps") |
| 1622 } | 1591 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 proguard_info = "$_proguard_output_jar_path.info" | 1650 proguard_info = "$_proguard_output_jar_path.info" |
| 1682 } | 1651 } |
| 1683 | 1652 |
| 1684 # Don't depend on the runtime_deps target in order to avoid having to | 1653 # Don't depend on the runtime_deps target in order to avoid having to |
| 1685 # build the native libraries just to create the .build_config file. | 1654 # build the native libraries just to create the .build_config file. |
| 1686 # The dep is unnecessary since the runtime_deps file is created by gn gen | 1655 # The dep is unnecessary since the runtime_deps file is created by gn gen |
| 1687 # and the runtime_deps file is added to write_build_config.py's depfile. | 1656 # and the runtime_deps file is added to write_build_config.py's depfile. |
| 1688 if (_native_libs_deps != []) { | 1657 if (_native_libs_deps != []) { |
| 1689 shared_libraries_runtime_deps_file = _runtime_deps_file | 1658 shared_libraries_runtime_deps_file = _runtime_deps_file |
| 1690 } | 1659 } |
| 1691 if (_secondary_abi_native_libs_deps != []) { | |
| 1692 secondary_abi_shared_libraries_runtime_deps_file = | |
| 1693 _secondary_abi_runtime_deps_file | |
| 1694 } | |
| 1695 } | 1660 } |
| 1696 | 1661 |
| 1697 _final_deps = [] | 1662 _final_deps = [] |
| 1698 | 1663 |
| 1699 _generated_proguard_config = "$base_path.resources.proguard.txt" | 1664 _generated_proguard_config = "$base_path.resources.proguard.txt" |
| 1700 process_resources_target = "${_template_name}__process_resources" | 1665 process_resources_target = "${_template_name}__process_resources" |
| 1701 process_resources(process_resources_target) { | 1666 process_resources(process_resources_target) { |
| 1702 forward_variables_from(invoker, | 1667 forward_variables_from(invoker, |
| 1703 [ | 1668 [ |
| 1704 "alternative_android_sdk_jar", | 1669 "alternative_android_sdk_jar", |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 } else { | 1917 } else { |
| 1953 _dex_arg_key = | 1918 _dex_arg_key = |
| 1954 "${_rebased_build_config}:final_dex:dependency_dex_files" | 1919 "${_rebased_build_config}:final_dex:dependency_dex_files" |
| 1955 } | 1920 } |
| 1956 args = [ "--inputs=@FileArg($_dex_arg_key)" ] | 1921 args = [ "--inputs=@FileArg($_dex_arg_key)" ] |
| 1957 } | 1922 } |
| 1958 } | 1923 } |
| 1959 | 1924 |
| 1960 _native_libs_file_arg_dep = ":$build_config_target" | 1925 _native_libs_file_arg_dep = ":$build_config_target" |
| 1961 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" | 1926 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" |
| 1962 _secondary_abi_native_libs_file_arg_dep = ":$build_config_target" | |
| 1963 _secondary_abi_native_libs_file_arg = | |
| 1964 "@FileArg($_rebased_build_config:native:secondary_abi_libraries)" | |
| 1965 assert(_secondary_abi_native_libs_file_arg != "" && | |
| 1966 _secondary_abi_native_libs_file_arg_dep != "") # Mark as used. | |
| 1967 | 1927 |
| 1968 if (_native_libs_deps != [] && _enable_relocation_packing) { | 1928 if (_native_libs_deps != [] && _enable_relocation_packing) { |
| 1969 _prepare_native_target_name = "${_template_name}__prepare_native" | 1929 _prepare_native_target_name = "${_template_name}__prepare_native" |
| 1930 _native_libs_dir = "$gen_dir/packed-libs" |
| 1970 _native_libs_json = "$gen_dir/packed-libs/filelist.json" | 1931 _native_libs_json = "$gen_dir/packed-libs/filelist.json" |
| 1971 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) | 1932 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) |
| 1933 |
| 1972 _native_libs_file_arg_dep = ":$_prepare_native_target_name" | 1934 _native_libs_file_arg_dep = ":$_prepare_native_target_name" |
| 1973 _native_libs_file_arg = "@FileArg($_rebased_native_libs_json:files)" | 1935 _native_libs_file_arg = "@FileArg($_rebased_native_libs_json:files)" |
| 1974 | 1936 |
| 1975 pack_relocation_section(_prepare_native_target_name) { | 1937 action(_prepare_native_target_name) { |
| 1976 forward_variables_from(invoker, | 1938 forward_variables_from(invoker, |
| 1977 [ | 1939 [ |
| 1978 "deps", | 1940 "deps", |
| 1979 "public_deps", | 1941 "public_deps", |
| 1980 ]) | 1942 ]) |
| 1981 file_list_json = _native_libs_json | 1943 script = "//build/android/gyp/pack_relocations.py" |
| 1982 libraries_filearg = | 1944 depfile = "$target_gen_dir/$target_name.d" |
| 1983 "@FileArg(${_rebased_build_config}:native:libraries)" | 1945 outputs = [ |
| 1946 _native_libs_json, |
| 1947 ] |
| 1948 |
| 1984 inputs = [ | 1949 inputs = [ |
| 1985 _build_config, | 1950 _build_config, |
| 1986 ] | 1951 ] |
| 1987 | 1952 |
| 1988 deps += _native_libs_deps | 1953 deps += _native_libs_deps |
| 1989 deps += [ ":$build_config_target" ] | 1954 deps += [ |
| 1990 } | 1955 ":$build_config_target", |
| 1991 if (_secondary_abi_native_libs_deps != []) { | 1956 relocation_packer_target, |
| 1992 _prepare_native_target_name = | 1957 ] |
| 1993 "${_template_name}_secondary_abi__prepare_native" | |
| 1994 _native_libs_json = | |
| 1995 "$gen_dir/packed-libs/$android_secondary_abi_cpu/filelist.json" | |
| 1996 _rebased_native_libs_json = | |
| 1997 rebase_path(_native_libs_json, root_build_dir) | |
| 1998 _secondary_abi_native_libs_file_arg_dep = | |
| 1999 ":$_prepare_native_target_name" | |
| 2000 _secondary_abi_native_libs_file_arg = | |
| 2001 "@FileArg($_rebased_native_libs_json:files)" | |
| 2002 | 1958 |
| 2003 pack_relocation_section(_prepare_native_target_name) { | 1959 args = [ |
| 2004 forward_variables_from(invoker, | 1960 "--depfile", |
| 2005 [ | 1961 rebase_path(depfile, root_build_dir), |
| 2006 "deps", | 1962 "--enable-packing=1", |
| 2007 "public_deps", | 1963 "--android-pack-relocations", |
| 2008 ]) | 1964 rebase_path(relocation_packer_exe, root_build_dir), |
| 2009 file_list_json = _native_libs_json | 1965 "--stripped-libraries-dir", |
| 2010 libraries_filearg = "@FileArg(${_rebased_build_config}:native:secondar
y_abi_libraries)" | 1966 rebase_path(root_build_dir, root_build_dir), |
| 2011 inputs = [ | 1967 "--packed-libraries-dir", |
| 2012 _build_config, | 1968 rebase_path(_native_libs_dir, root_build_dir), |
| 2013 ] | 1969 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)", |
| 2014 | 1970 "--filelistjson=$_rebased_native_libs_json", |
| 2015 deps += _secondary_abi_native_libs_deps | 1971 ] |
| 2016 deps += [ ":$build_config_target" ] | |
| 2017 } | |
| 2018 } | 1972 } |
| 2019 } | 1973 } |
| 2020 | 1974 |
| 2021 _extra_native_libs = [] | 1975 _extra_native_libs = [] |
| 2022 _extra_native_libs_deps = [] | 1976 _extra_native_libs_deps = [] |
| 2023 _extra_native_libs_even_when_incremental = [] | 1977 _extra_native_libs_even_when_incremental = [] |
| 2024 _extra_native_libs_even_when_incremental_deps = [] | 1978 _extra_native_libs_even_when_incremental_deps = [] |
| 2025 assert(_extra_native_libs_even_when_incremental_deps == []) # Mark as used. | 1979 assert(_extra_native_libs_even_when_incremental_deps == []) # Mark as used. |
| 2026 if (_native_libs_deps != []) { | 1980 if (_native_libs_deps != []) { |
| 2027 # zipalign can't align gdb_server, don't pack gdbserver temporarily. | 1981 # zipalign can't align gdb_server, don't pack gdbserver temporarily. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 !_create_abi_split) { | 2056 !_create_abi_split) { |
| 2103 deps += _native_libs_deps + _extra_native_libs_deps + | 2057 deps += _native_libs_deps + _extra_native_libs_deps + |
| 2104 _extra_native_libs_even_when_incremental_deps + | 2058 _extra_native_libs_even_when_incremental_deps + |
| 2105 [ _native_libs_file_arg_dep ] | 2059 [ _native_libs_file_arg_dep ] |
| 2106 native_libs_filearg = _native_libs_file_arg | 2060 native_libs_filearg = _native_libs_file_arg |
| 2107 native_libs = _extra_native_libs | 2061 native_libs = _extra_native_libs |
| 2108 native_libs_even_when_incremental = | 2062 native_libs_even_when_incremental = |
| 2109 _extra_native_libs_even_when_incremental | 2063 _extra_native_libs_even_when_incremental |
| 2110 } | 2064 } |
| 2111 | 2065 |
| 2112 if (_secondary_abi_native_libs_deps != [] && !_create_abi_split) { | |
| 2113 deps += _secondary_abi_native_libs_deps + | |
| 2114 [ _secondary_abi_native_libs_file_arg_dep ] | |
| 2115 secondary_abi_native_libs_filearg = _secondary_abi_native_libs_file_arg | |
| 2116 } | |
| 2117 | |
| 2118 # Placeholders necessary for some older devices. | 2066 # Placeholders necessary for some older devices. |
| 2119 # http://crbug.com/395038 | 2067 # http://crbug.com/395038 |
| 2120 forward_variables_from(invoker, [ "native_lib_placeholders" ]) | 2068 forward_variables_from(invoker, [ "native_lib_placeholders" ]) |
| 2121 } | 2069 } |
| 2122 | 2070 |
| 2123 if ((_native_libs_deps != [] || | 2071 if ((_native_libs_deps != [] || |
| 2124 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { | 2072 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { |
| 2125 _manifest_rule = | 2073 _manifest_rule = |
| 2126 "${_template_name}__split_manifest_abi_${android_app_abi}" | 2074 "${_template_name}__split_manifest_abi_${android_app_abi}" |
| 2127 generate_split_manifest(_manifest_rule) { | 2075 generate_split_manifest(_manifest_rule) { |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2812 # because in practice they seem to contain classes required to be in the | 2760 # because in practice they seem to contain classes required to be in the |
| 2813 # classpath. | 2761 # classpath. |
| 2814 deps += _subjar_targets | 2762 deps += _subjar_targets |
| 2815 } | 2763 } |
| 2816 if (defined(_res_target_name)) { | 2764 if (defined(_res_target_name)) { |
| 2817 deps += [ ":$_res_target_name" ] | 2765 deps += [ ":$_res_target_name" ] |
| 2818 } | 2766 } |
| 2819 } | 2767 } |
| 2820 } | 2768 } |
| 2821 } | 2769 } |
| OLD | NEW |