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 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 # * dependencies of this .so are not automatically included | 1421 # * dependencies of this .so are not automatically included |
1422 # * ".cr.so" is never added | 1422 # * ".cr.so" is never added |
1423 # * they are not side-loaded for _incremental targets. | 1423 # * they are not side-loaded for _incremental targets. |
1424 # * load_library_from_apk, use_chromium_linker, | 1424 # * load_library_from_apk, use_chromium_linker, |
1425 # and enable_relocation_packing do not apply | 1425 # and enable_relocation_packing do not apply |
1426 # Use this instead of shared_libraries when you are going to load the libr
ary | 1426 # Use this instead of shared_libraries when you are going to load the libr
ary |
1427 # conditionally, and only when shared_libraries doesn't work for you. | 1427 # conditionally, and only when shared_libraries doesn't work for you. |
1428 # shared_libraries: List shared_library targets to bundle. If these | 1428 # shared_libraries: List shared_library targets to bundle. If these |
1429 # libraries depend on other shared_library targets, those dependencies wil
l | 1429 # libraries depend on other shared_library targets, those dependencies wil
l |
1430 # also be included in the apk (e.g. for is_component_build). | 1430 # also be included in the apk (e.g. for is_component_build). |
| 1431 # secondary_abi_shared_libraries: secondary abi shared_library targets to |
| 1432 # bundle. If these libraries depend on other shared_library targets, those |
| 1433 # dependencies will also be included in the apk (e.g. for is_component_bui
ld). |
1431 # native_lib_placeholders: List of placeholder filenames to add to the apk | 1434 # native_lib_placeholders: List of placeholder filenames to add to the apk |
1432 # (optional). | 1435 # (optional). |
1433 # apk_under_test: For an instrumentation test apk, this is the target of the | 1436 # apk_under_test: For an instrumentation test apk, this is the target of the |
1434 # tested apk. | 1437 # tested apk. |
1435 # include_all_resources - If true include all resource IDs in all generated | 1438 # include_all_resources - If true include all resource IDs in all generated |
1436 # R.java files. | 1439 # R.java files. |
1437 # testonly: Marks this target as "test-only". | 1440 # testonly: Marks this target as "test-only". |
1438 # write_asset_list: Adds an extra file to the assets, which contains a list
of | 1441 # write_asset_list: Adds an extra file to the assets, which contains a list
of |
1439 # all other asset files. | 1442 # all other asset files. |
1440 # alternative_locale_resource_dep: The locale resource target which override
s | 1443 # alternative_locale_resource_dep: The locale resource target which override
s |
1441 # any exsting locale resources in dep graph. | 1444 # any exsting locale resources in dep graph. |
1442 # requires_sdk_api_level_23: If defined and true, the apk is intended for | 1445 # requires_sdk_api_level_23: If defined and true, the apk is intended for |
1443 # installation only on Android M or later. In these releases the system | 1446 # installation only on Android M or later. In these releases the system |
1444 # linker does relocation unpacking, so we can enable it unconditionally. | 1447 # linker does relocation unpacking, so we can enable it unconditionally. |
1445 # secondary_native_libs: The path of native libraries for secondary app abi. | 1448 # secondary_native_libs (deprecated): The path of native libraries for secon
dary |
| 1449 # app abi. |
1446 # run_findbugs_override: Forces run_findbugs on or off. If undefined, the | 1450 # run_findbugs_override: Forces run_findbugs on or off. If undefined, the |
1447 # default will use the build arg run_findbugs. | 1451 # default will use the build arg run_findbugs. |
1448 # proguard_jar_path: The path to proguard.jar you wish to use. If undefined, | 1452 # proguard_jar_path: The path to proguard.jar you wish to use. If undefined, |
1449 # the proguard used will be the checked in one in //third_party/proguard. | 1453 # the proguard used will be the checked in one in //third_party/proguard. |
1450 # | 1454 # |
1451 # Example | 1455 # Example |
1452 # android_apk("foo_apk") { | 1456 # android_apk("foo_apk") { |
1453 # android_manifest = "AndroidManifest.xml" | 1457 # android_manifest = "AndroidManifest.xml" |
1454 # java_files = [ | 1458 # java_files = [ |
1455 # "android/org/chromium/foo/FooApplication.java", | 1459 # "android/org/chromium/foo/FooApplication.java", |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 "or requires_sdk_api_level_23") | 1555 "or requires_sdk_api_level_23") |
1552 } | 1556 } |
1553 if (_load_library_from_apk) { | 1557 if (_load_library_from_apk) { |
1554 assert(_use_chromium_linker || _requires_sdk_api_level_23, | 1558 assert(_use_chromium_linker || _requires_sdk_api_level_23, |
1555 "load_library_from_apk requires use_chromium_linker " + | 1559 "load_library_from_apk requires use_chromium_linker " + |
1556 "or requires_sdk_api_level_23") | 1560 "or requires_sdk_api_level_23") |
1557 } | 1561 } |
1558 | 1562 |
1559 # The dependency that makes the chromium linker, if any is needed. | 1563 # The dependency that makes the chromium linker, if any is needed. |
1560 _native_libs_deps = [] | 1564 _native_libs_deps = [] |
| 1565 _shared_libraries_is_valid = |
| 1566 defined(invoker.shared_libraries) && invoker.shared_libraries != [] |
| 1567 _secondary_abi_native_libs_deps = [] |
| 1568 assert(_secondary_abi_native_libs_deps == []) # mark as used. |
| 1569 _secondary_abi_shared_libraries_is_valid = |
| 1570 defined(invoker.secondary_abi_shared_libraries) && |
| 1571 invoker.secondary_abi_shared_libraries != [] |
1561 | 1572 |
1562 if (defined(invoker.shared_libraries) && invoker.shared_libraries != []) { | 1573 if (is_component_build || is_asan) { |
1563 _native_libs_deps += invoker.shared_libraries | 1574 if (_shared_libraries_is_valid) { |
1564 | |
1565 if (is_component_build || is_asan) { | |
1566 _native_libs_deps += [ "//build/android:cpplib_stripped" ] | 1575 _native_libs_deps += [ "//build/android:cpplib_stripped" ] |
1567 } | 1576 } |
| 1577 if (_secondary_abi_shared_libraries_is_valid) { |
| 1578 _secondary_abi_native_libs_deps += [ "//build/android:cpplib_stripped($a
ndroid_secondary_abi_toolchain)" ] |
| 1579 } |
| 1580 } |
| 1581 |
| 1582 if (_shared_libraries_is_valid) { |
| 1583 _native_libs_deps += invoker.shared_libraries |
1568 | 1584 |
1569 # To determine the filenames of all dependent shared libraries, write the | 1585 # To determine the filenames of all dependent shared libraries, write the |
1570 # runtime deps of |shared_libraries| to a file during "gn gen". | 1586 # runtime deps of |shared_libraries| to a file during "gn gen". |
1571 # write_build_config.py will then grep this file for *.so to obtain the | 1587 # write_build_config.py will then grep this file for *.so to obtain the |
1572 # complete list. | 1588 # complete list. |
1573 _runtime_deps_file = | 1589 _runtime_deps_file = |
1574 "$target_gen_dir/${_template_name}.native.runtimedeps" | 1590 "$target_gen_dir/${_template_name}.native.runtimedeps" |
1575 group("${_template_name}__runtime_deps") { | 1591 group("${_template_name}__runtime_deps") { |
1576 deps = _native_libs_deps | 1592 deps = _native_libs_deps |
1577 write_runtime_deps = _runtime_deps_file | 1593 write_runtime_deps = _runtime_deps_file |
1578 } | 1594 } |
1579 | 1595 |
1580 _native_lib_version_rule = "" | 1596 _native_lib_version_rule = "" |
1581 if (defined(invoker.native_lib_version_rule)) { | 1597 if (defined(invoker.native_lib_version_rule)) { |
1582 _native_lib_version_rule = invoker.native_lib_version_rule | 1598 _native_lib_version_rule = invoker.native_lib_version_rule |
1583 } | 1599 } |
1584 _native_lib_version_arg = "\"\"" | 1600 _native_lib_version_arg = "\"\"" |
1585 if (defined(invoker.native_lib_version_arg)) { | 1601 if (defined(invoker.native_lib_version_arg)) { |
1586 _native_lib_version_arg = invoker.native_lib_version_arg | 1602 _native_lib_version_arg = invoker.native_lib_version_arg |
1587 } | 1603 } |
1588 } | 1604 } |
1589 | 1605 |
| 1606 if (_secondary_abi_shared_libraries_is_valid) { |
| 1607 _secondary_abi_native_libs_deps += invoker.secondary_abi_shared_libraries |
| 1608 |
| 1609 # To determine the filenames of all dependent shared libraries, write the |
| 1610 # runtime deps of |shared_libraries| to a file during "gn gen". |
| 1611 # write_build_config.py will then grep this file for *.so to obtain the |
| 1612 # complete list. |
| 1613 _secondary_abi_runtime_deps_file = |
| 1614 "$target_gen_dir/${_template_name}.secondary.abi.native.runtimedeps" |
| 1615 group("${_template_name}_secondary_abi__runtime_deps") { |
| 1616 deps = _secondary_abi_native_libs_deps |
| 1617 write_runtime_deps = _secondary_abi_runtime_deps_file |
| 1618 } |
| 1619 } |
| 1620 |
1590 if (defined(invoker.deps)) { | 1621 if (defined(invoker.deps)) { |
1591 set_sources_assignment_filter([ "*manifest*" ]) | 1622 set_sources_assignment_filter([ "*manifest*" ]) |
1592 sources = invoker.deps | 1623 sources = invoker.deps |
1593 set_sources_assignment_filter([]) | 1624 set_sources_assignment_filter([]) |
1594 if (sources != invoker.deps) { | 1625 if (sources != invoker.deps) { |
1595 _bad_deps = invoker.deps - sources | 1626 _bad_deps = invoker.deps - sources |
1596 assert( | 1627 assert( |
1597 false, | 1628 false, |
1598 "Possible manifest-generating dep found in deps. Use android_manifes
t_dep for this instead. Found: $_bad_deps") | 1629 "Possible manifest-generating dep found in deps. Use android_manifes
t_dep for this instead. Found: $_bad_deps") |
1599 } | 1630 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 proguard_info = "$_proguard_output_jar_path.info" | 1689 proguard_info = "$_proguard_output_jar_path.info" |
1659 } | 1690 } |
1660 | 1691 |
1661 # Don't depend on the runtime_deps target in order to avoid having to | 1692 # Don't depend on the runtime_deps target in order to avoid having to |
1662 # build the native libraries just to create the .build_config file. | 1693 # build the native libraries just to create the .build_config file. |
1663 # The dep is unnecessary since the runtime_deps file is created by gn gen | 1694 # The dep is unnecessary since the runtime_deps file is created by gn gen |
1664 # and the runtime_deps file is added to write_build_config.py's depfile. | 1695 # and the runtime_deps file is added to write_build_config.py's depfile. |
1665 if (_native_libs_deps != []) { | 1696 if (_native_libs_deps != []) { |
1666 shared_libraries_runtime_deps_file = _runtime_deps_file | 1697 shared_libraries_runtime_deps_file = _runtime_deps_file |
1667 } | 1698 } |
| 1699 if (_secondary_abi_native_libs_deps != []) { |
| 1700 secondary_abi_shared_libraries_runtime_deps_file = |
| 1701 _secondary_abi_runtime_deps_file |
| 1702 } |
1668 } | 1703 } |
1669 | 1704 |
1670 _final_deps = [] | 1705 _final_deps = [] |
1671 | 1706 |
1672 _generated_proguard_config = "$base_path.resources.proguard.txt" | 1707 _generated_proguard_config = "$base_path.resources.proguard.txt" |
1673 process_resources_target = "${_template_name}__process_resources" | 1708 process_resources_target = "${_template_name}__process_resources" |
1674 process_resources(process_resources_target) { | 1709 process_resources(process_resources_target) { |
1675 forward_variables_from(invoker, | 1710 forward_variables_from(invoker, |
1676 [ | 1711 [ |
1677 "alternative_android_sdk_jar", | 1712 "alternative_android_sdk_jar", |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 } else { | 1961 } else { |
1927 _dex_arg_key = | 1962 _dex_arg_key = |
1928 "${_rebased_build_config}:final_dex:dependency_dex_files" | 1963 "${_rebased_build_config}:final_dex:dependency_dex_files" |
1929 } | 1964 } |
1930 args = [ "--inputs=@FileArg($_dex_arg_key)" ] | 1965 args = [ "--inputs=@FileArg($_dex_arg_key)" ] |
1931 } | 1966 } |
1932 } | 1967 } |
1933 | 1968 |
1934 _native_libs_file_arg_dep = ":$build_config_target" | 1969 _native_libs_file_arg_dep = ":$build_config_target" |
1935 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" | 1970 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" |
| 1971 _secondary_abi_native_libs_file_arg_dep = ":$build_config_target" |
| 1972 _secondary_abi_native_libs_file_arg = |
| 1973 "@FileArg($_rebased_build_config:native:secondary_abi_libraries)" |
| 1974 assert(_secondary_abi_native_libs_file_arg != "" && |
| 1975 _secondary_abi_native_libs_file_arg_dep != "") # Mark as used. |
1936 | 1976 |
1937 if (_native_libs_deps != [] && _enable_relocation_packing) { | 1977 if (_native_libs_deps != [] && _enable_relocation_packing) { |
1938 _prepare_native_target_name = "${_template_name}__prepare_native" | 1978 _prepare_native_target_name = "${_template_name}__prepare_native" |
1939 _native_libs_dir = "$gen_dir/packed-libs" | |
1940 _native_libs_json = "$gen_dir/packed-libs/filelist.json" | 1979 _native_libs_json = "$gen_dir/packed-libs/filelist.json" |
1941 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) | 1980 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) |
1942 | |
1943 _native_libs_file_arg_dep = ":$_prepare_native_target_name" | 1981 _native_libs_file_arg_dep = ":$_prepare_native_target_name" |
1944 _native_libs_file_arg = "@FileArg($_rebased_native_libs_json:files)" | 1982 _native_libs_file_arg = "@FileArg($_rebased_native_libs_json:files)" |
1945 | 1983 |
1946 action(_prepare_native_target_name) { | 1984 pack_relocation_section(_prepare_native_target_name) { |
1947 forward_variables_from(invoker, | 1985 forward_variables_from(invoker, |
1948 [ | 1986 [ |
1949 "deps", | 1987 "deps", |
1950 "public_deps", | 1988 "public_deps", |
1951 ]) | 1989 ]) |
1952 script = "//build/android/gyp/pack_relocations.py" | 1990 file_list_json = _native_libs_json |
1953 depfile = "$target_gen_dir/$target_name.d" | 1991 libraries_filearg = |
1954 outputs = [ | 1992 "@FileArg(${_rebased_build_config}:native:libraries)" |
1955 depfile, | |
1956 _native_libs_json, | |
1957 ] | |
1958 | |
1959 inputs = [ | 1993 inputs = [ |
1960 _build_config, | 1994 _build_config, |
1961 ] | 1995 ] |
1962 | 1996 |
1963 deps += _native_libs_deps | 1997 deps += _native_libs_deps |
1964 deps += [ | 1998 deps += [ ":$build_config_target" ] |
1965 ":$build_config_target", | 1999 } |
1966 relocation_packer_target, | 2000 if (_secondary_abi_native_libs_deps != []) { |
1967 ] | 2001 _prepare_native_target_name = |
| 2002 "${_template_name}_secondary_abi__prepare_native" |
| 2003 _native_libs_json = |
| 2004 "$gen_dir/packed-libs/$android_secondary_abi_cpu/filelist.json" |
| 2005 _rebased_native_libs_json = |
| 2006 rebase_path(_native_libs_json, root_build_dir) |
| 2007 _secondary_abi_native_libs_file_arg_dep = |
| 2008 ":$_prepare_native_target_name" |
| 2009 _secondary_abi_native_libs_file_arg = |
| 2010 "@FileArg($_rebased_native_libs_json:files)" |
1968 | 2011 |
1969 args = [ | 2012 pack_relocation_section(_prepare_native_target_name) { |
1970 "--depfile", | 2013 forward_variables_from(invoker, |
1971 rebase_path(depfile, root_build_dir), | 2014 [ |
1972 "--enable-packing=1", | 2015 "deps", |
1973 "--android-pack-relocations", | 2016 "public_deps", |
1974 rebase_path(relocation_packer_exe, root_build_dir), | 2017 ]) |
1975 "--stripped-libraries-dir", | 2018 file_list_json = _native_libs_json |
1976 rebase_path(root_build_dir, root_build_dir), | 2019 libraries_filearg = "@FileArg(${_rebased_build_config}:native:secondar
y_abi_libraries)" |
1977 "--packed-libraries-dir", | 2020 inputs = [ |
1978 rebase_path(_native_libs_dir, root_build_dir), | 2021 _build_config, |
1979 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)", | 2022 ] |
1980 "--filelistjson=$_rebased_native_libs_json", | 2023 |
1981 ] | 2024 deps += _secondary_abi_native_libs_deps |
| 2025 deps += [ ":$build_config_target" ] |
| 2026 } |
1982 } | 2027 } |
1983 } | 2028 } |
1984 | 2029 |
1985 _extra_native_libs = [] | 2030 _extra_native_libs = [] |
1986 _extra_native_libs_deps = [] | 2031 _extra_native_libs_deps = [] |
1987 _extra_native_libs_even_when_incremental = [] | 2032 _extra_native_libs_even_when_incremental = [] |
1988 _extra_native_libs_even_when_incremental_deps = [] | 2033 _extra_native_libs_even_when_incremental_deps = [] |
1989 assert(_extra_native_libs_even_when_incremental_deps == []) # Mark as used. | 2034 assert(_extra_native_libs_even_when_incremental_deps == []) # Mark as used. |
1990 if (_native_libs_deps != []) { | 2035 if (_native_libs_deps != []) { |
1991 # zipalign can't align gdb_server, don't pack gdbserver temporarily. | 2036 # zipalign can't align gdb_server, don't pack gdbserver temporarily. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2066 !_create_abi_split) { | 2111 !_create_abi_split) { |
2067 deps += _native_libs_deps + _extra_native_libs_deps + | 2112 deps += _native_libs_deps + _extra_native_libs_deps + |
2068 _extra_native_libs_even_when_incremental_deps + | 2113 _extra_native_libs_even_when_incremental_deps + |
2069 [ _native_libs_file_arg_dep ] | 2114 [ _native_libs_file_arg_dep ] |
2070 native_libs_filearg = _native_libs_file_arg | 2115 native_libs_filearg = _native_libs_file_arg |
2071 native_libs = _extra_native_libs | 2116 native_libs = _extra_native_libs |
2072 native_libs_even_when_incremental = | 2117 native_libs_even_when_incremental = |
2073 _extra_native_libs_even_when_incremental | 2118 _extra_native_libs_even_when_incremental |
2074 } | 2119 } |
2075 | 2120 |
| 2121 if (_secondary_abi_native_libs_deps != [] && !_create_abi_split) { |
| 2122 deps += [ _secondary_abi_native_libs_file_arg_dep ] |
| 2123 secondary_abi_native_libs_filearg = _secondary_abi_native_libs_file_arg |
| 2124 } |
| 2125 |
2076 # Placeholders necessary for some older devices. | 2126 # Placeholders necessary for some older devices. |
2077 # http://crbug.com/395038 | 2127 # http://crbug.com/395038 |
2078 forward_variables_from(invoker, [ "native_lib_placeholders" ]) | 2128 forward_variables_from(invoker, [ "native_lib_placeholders" ]) |
2079 } | 2129 } |
2080 | 2130 |
2081 if ((_native_libs_deps != [] || | 2131 if ((_native_libs_deps != [] || |
2082 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { | 2132 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { |
2083 _manifest_rule = | 2133 _manifest_rule = |
2084 "${_template_name}__split_manifest_abi_${android_app_abi}" | 2134 "${_template_name}__split_manifest_abi_${android_app_abi}" |
2085 generate_split_manifest(_manifest_rule) { | 2135 generate_split_manifest(_manifest_rule) { |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 supports_android = true | 2756 supports_android = true |
2707 jar_path = "${_output_path}/$jar" | 2757 jar_path = "${_output_path}/$jar" |
2708 } | 2758 } |
2709 } | 2759 } |
2710 | 2760 |
2711 java_group(target_name) { | 2761 java_group(target_name) { |
2712 deps = _resource_targets + _jar_targets | 2762 deps = _resource_targets + _jar_targets |
2713 } | 2763 } |
2714 } | 2764 } |
2715 } | 2765 } |
OLD | NEW |