Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: build/config/android/rules.gni

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

Powered by Google App Engine
This is Rietveld 408576698