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