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

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

Issue 2123753005: Creating new gn arg: enable_all_proguard_optimizations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed proguard_under_test.flags to proguard_for_test.flags Created 4 years, 5 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/toolchain/toolchain.gni") 7 import("//build/toolchain/toolchain.gni")
8 8
9 assert(is_android) 9 assert(is_android)
10 10
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 # ":my_shared_lib", 1464 # ":my_shared_lib",
1465 # ] 1465 # ]
1466 # } 1466 # }
1467 template("android_apk") { 1467 template("android_apk") {
1468 set_sources_assignment_filter([]) 1468 set_sources_assignment_filter([])
1469 forward_variables_from(invoker, [ "testonly" ]) 1469 forward_variables_from(invoker, [ "testonly" ])
1470 1470
1471 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) 1471 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
1472 assert(defined(invoker.android_manifest)) 1472 assert(defined(invoker.android_manifest))
1473 gen_dir = "$target_gen_dir/$target_name" 1473 gen_dir = "$target_gen_dir/$target_name"
1474 base_path = "$gen_dir/$target_name" 1474 _base_path = "$gen_dir/$target_name"
1475 _build_config = "$target_gen_dir/$target_name.build_config" 1475 _build_config = "$target_gen_dir/$target_name.build_config"
1476 resources_zip_path = "$base_path.resources.zip" 1476 resources_zip_path = "$_base_path.resources.zip"
1477 _all_resources_zip_path = "$base_path.resources.all.zip" 1477 _all_resources_zip_path = "$_base_path.resources.all.zip"
1478 _jar_path = "$base_path.jar" 1478 _jar_path = "$_base_path.jar"
1479 _lib_dex_path = "$base_path.dex.jar" 1479 _lib_dex_path = "$_base_path.dex.jar"
1480 _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir) 1480 _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir)
1481 _template_name = target_name 1481 _template_name = target_name
1482 1482
1483 enable_multidex = 1483 enable_multidex =
1484 defined(invoker.enable_multidex) && invoker.enable_multidex 1484 defined(invoker.enable_multidex) && invoker.enable_multidex
1485 if (enable_multidex) { 1485 if (enable_multidex) {
1486 final_dex_path = "$gen_dir/classes.dex.zip" 1486 final_dex_path = "$gen_dir/classes.dex.zip"
1487 } else { 1487 } else {
1488 final_dex_path = "$gen_dir/classes.dex" 1488 final_dex_path = "$gen_dir/classes.dex"
1489 } 1489 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 _create_density_splits = 1609 _create_density_splits =
1610 defined(invoker.create_density_splits) && invoker.create_density_splits 1610 defined(invoker.create_density_splits) && invoker.create_density_splits
1611 _create_language_splits = 1611 _create_language_splits =
1612 defined(invoker.language_splits) && invoker.language_splits != [] 1612 defined(invoker.language_splits) && invoker.language_splits != []
1613 1613
1614 # Help GN understand that _create_abi_split is not unused (bug in GN). 1614 # Help GN understand that _create_abi_split is not unused (bug in GN).
1615 assert(_create_abi_split || true) 1615 assert(_create_abi_split || true)
1616 1616
1617 _proguard_enabled = 1617 _proguard_enabled =
1618 defined(invoker.proguard_enabled) && invoker.proguard_enabled 1618 defined(invoker.proguard_enabled) && invoker.proguard_enabled
1619 _is_testable_apk = _proguard_enabled && !defined(invoker.apk_under_test)
Yaron 2016/07/06 14:01:41 Should at minimum have a comment but I feel like i
agrieve 2016/07/06 14:18:49 nit: non-proguarded apks are testable as well. How
smaier 2016/07/06 19:09:37 Done.
1619 if (_proguard_enabled) { 1620 if (_proguard_enabled) {
1620 _proguard_output_jar_path = "$base_path.proguard.jar" 1621 _proguard_output_jar_path = "$_base_path.proguard.jar"
1622 }
1623 if (_is_testable_apk) {
1624 _template_name_for_test = "${_template_name}_for_test"
1625 _proguard_output_jar_for_test_path = "${_base_path}_for_test.proguard.jar"
1626 final_dex_for_test_path = "$gen_dir/classes_for_test.dex"
agrieve 2016/07/06 14:18:49 nit: prefix with _
smaier 2016/07/06 19:09:37 Done.
1627
1628 assert(!defined(invoker.final_apk_path),
1629 "Cannot set final_apk_path for tested apk")
agrieve 2016/07/06 14:18:49 nit: this message misses the "why". How about: "S
smaier 2016/07/06 19:09:37 Done.
1630 _final_apk_for_test_path =
1631 "$root_build_dir/apks/${invoker.apk_name}_for_test.apk"
agrieve 2016/07/06 14:18:49 nit: apk_names are AllInCamelCase. So how about: $
smaier 2016/07/06 19:09:37 Done.
1621 } 1632 }
1622 1633
1623 _emma_never_instrument = defined(invoker.testonly) && invoker.testonly 1634 _emma_never_instrument = defined(invoker.testonly) && invoker.testonly
1624 1635
1625 build_config_target = "${_template_name}__build_config" 1636 build_config_target = "${_template_name}__build_config"
1626 write_build_config(build_config_target) { 1637 write_build_config(build_config_target) {
1627 forward_variables_from(invoker, [ "apk_under_test" ]) 1638 forward_variables_from(invoker, [ "apk_under_test" ])
1628 type = "android_apk" 1639 type = "android_apk"
1629 jar_path = _jar_path 1640 jar_path = _jar_path
1630 dex_path = final_dex_path 1641 dex_path = final_dex_path
1631 apk_path = _final_apk_path 1642 apk_path = _final_apk_path
1643 if (_is_testable_apk) {
1644 apk_for_test_path = _final_apk_for_test_path
1645 }
1632 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" 1646 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk"
1633 incremental_install_script_path = _incremental_install_script_path 1647 incremental_install_script_path = _incremental_install_script_path
1634 resources_zip = resources_zip_path 1648 resources_zip = resources_zip_path
1635 build_config = _build_config 1649 build_config = _build_config
1636 android_manifest = _android_manifest 1650 android_manifest = _android_manifest
1637 1651
1638 deps = _android_manifest_deps 1652 deps = _android_manifest_deps
1639 1653
1640 if (defined(invoker.deps)) { 1654 if (defined(invoker.deps)) {
1641 possible_config_deps = invoker.deps 1655 possible_config_deps = invoker.deps
(...skipping 18 matching lines...) Expand all
1660 # build the native libraries just to create the .build_config file. 1674 # 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 1675 # 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. 1676 # and the runtime_deps file is added to write_build_config.py's depfile.
1663 if (_native_libs_deps != []) { 1677 if (_native_libs_deps != []) {
1664 shared_libraries_runtime_deps_file = _runtime_deps_file 1678 shared_libraries_runtime_deps_file = _runtime_deps_file
1665 } 1679 }
1666 } 1680 }
1667 1681
1668 _final_deps = [] 1682 _final_deps = []
1669 1683
1670 _generated_proguard_config = "$base_path.resources.proguard.txt" 1684 _generated_proguard_config = "$_base_path.resources.proguard.txt"
1671 process_resources_target = "${_template_name}__process_resources" 1685 process_resources_target = "${_template_name}__process_resources"
1672 process_resources(process_resources_target) { 1686 process_resources(process_resources_target) {
1673 forward_variables_from(invoker, 1687 forward_variables_from(invoker,
1674 [ 1688 [
1675 "alternative_android_sdk_jar", 1689 "alternative_android_sdk_jar",
1676 "android_aapt_path", 1690 "android_aapt_path",
1677 "app_as_shared_lib", 1691 "app_as_shared_lib",
1678 "include_all_resources", 1692 "include_all_resources",
1679 "shared_resources", 1693 "shared_resources",
1680 ]) 1694 ])
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 sources = [ 1898 sources = [
1885 "$_proguard_output_jar_path.mapping", 1899 "$_proguard_output_jar_path.mapping",
1886 ] 1900 ]
1887 outputs = [ 1901 outputs = [
1888 "$_final_apk_path.mapping", 1902 "$_final_apk_path.mapping",
1889 ] 1903 ]
1890 deps = [ 1904 deps = [
1891 ":$_proguard_target", 1905 ":$_proguard_target",
1892 ] 1906 ]
1893 } 1907 }
1908
1909 if (_is_testable_apk) {
1910 _proguard_for_test_target = "${_template_name_for_test}__proguard"
1911 proguard(_proguard_for_test_target) {
1912 forward_variables_from(invoker,
1913 [
1914 "alternative_android_sdk_jar",
1915 "proguard_jar_path",
1916 ])
1917 deps = [
1918 ":$build_config_target",
1919 ":$java_target",
1920 ":$process_resources_target",
1921 ]
1922 inputs = [
1923 _build_config,
1924 _jar_path,
1925 ] + _proguard_configs
1926
1927 output_jar_path = _proguard_output_jar_for_test_path
1928
1929 # This Proguard flags file will apply only to tested apks - true
1930 # release apks are not affected.
1931 _proguard_configs +=
1932 [ "//chrome/android/java/proguard_for_test.flags" ]
1933 _rebased_proguard_configs =
1934 rebase_path(_proguard_configs, root_build_dir)
1935 args = [
1936 "--proguard-configs=$_rebased_proguard_configs",
1937 "--input-paths=@FileArg($_rebased_build_config:proguard:input_paths) ",
1938 ]
1939 }
1940 _dex_sources_for_test = [ _proguard_output_jar_for_test_path ]
agrieve 2016/07/06 14:18:49 nit: these are both used only once. Would be bette
smaier 2016/07/06 19:09:37 Done.
1941 _dex_deps_for_test = [ ":$_proguard_for_test_target" ]
1942 }
1894 } else { 1943 } else {
1895 if (enable_multidex) { 1944 if (enable_multidex) {
1896 _dex_sources = [ _jar_path ] 1945 _dex_sources = [ _jar_path ]
1897 } else { 1946 } else {
1898 _dex_sources = [ _lib_dex_path ] 1947 _dex_sources = [ _lib_dex_path ]
1899 } 1948 }
1900 _dex_deps = [ ":$java_target" ] 1949 _dex_deps = [ ":$java_target" ]
1901 } 1950 }
1902 1951
1903 dex("$final_dex_target_name") { 1952 dex("$final_dex_target_name") {
1904 deps = _dex_deps + [ ":$build_config_target" ] 1953 deps = _dex_deps + [ ":$build_config_target" ]
1905 inputs = [ 1954 inputs = [
1906 _build_config, 1955 _build_config,
1907 ] 1956 ]
1908 sources = _dex_sources 1957 sources = _dex_sources
1909 output = final_dex_path 1958 output = final_dex_path
1910 1959
1911 # All deps are already included in _dex_sources when proguard is used. 1960 # All deps are already included in _dex_sources when proguard is used.
1912 if (!_proguard_enabled) { 1961 if (!_proguard_enabled) {
1913 if (enable_multidex) { 1962 if (enable_multidex) {
1914 _dex_arg_key = "${_rebased_build_config}:dist_jar:dependency_jars" 1963 _dex_arg_key = "${_rebased_build_config}:dist_jar:dependency_jars"
1915 } else { 1964 } else {
1916 _dex_arg_key = 1965 _dex_arg_key =
1917 "${_rebased_build_config}:final_dex:dependency_dex_files" 1966 "${_rebased_build_config}:final_dex:dependency_dex_files"
1918 } 1967 }
1919 args = [ "--inputs=@FileArg($_dex_arg_key)" ] 1968 args = [ "--inputs=@FileArg($_dex_arg_key)" ]
1920 } 1969 }
1921 } 1970 }
1922 1971
1972 if (_is_testable_apk) {
1973 final_dex_for_test_target_name = "${final_dex_target_name}_for_test"
agrieve 2016/07/06 14:18:49 nit: prefix with _
smaier 2016/07/06 19:09:37 Done.
1974 dex("$final_dex_for_test_target_name") {
1975 deps = _dex_deps_for_test + [ ":$build_config_target" ]
1976 inputs = [
1977 _build_config,
1978 ]
1979 sources = _dex_sources_for_test
1980 output = final_dex_for_test_path
1981 }
1982 }
1983
1923 _native_libs_file_arg_dep = ":$build_config_target" 1984 _native_libs_file_arg_dep = ":$build_config_target"
1924 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)" 1985 _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)"
1925 1986
1926 if (_native_libs_deps != [] && _enable_relocation_packing) { 1987 if (_native_libs_deps != [] && _enable_relocation_packing) {
1927 _prepare_native_target_name = "${_template_name}__prepare_native" 1988 _prepare_native_target_name = "${_template_name}__prepare_native"
1928 _native_libs_dir = "$gen_dir/packed-libs" 1989 _native_libs_dir = "$gen_dir/packed-libs"
1929 _native_libs_json = "$gen_dir/packed-libs/filelist.json" 1990 _native_libs_json = "$gen_dir/packed-libs/filelist.json"
1930 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir) 1991 _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir)
1931 1992
1932 _native_libs_file_arg_dep = ":$_prepare_native_target_name" 1993 _native_libs_file_arg_dep = ":$_prepare_native_target_name"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 "public_deps", 2067 "public_deps",
2007 "secondary_native_libs", 2068 "secondary_native_libs",
2008 "shared_resources", 2069 "shared_resources",
2009 "uncompress_shared_libraries", 2070 "uncompress_shared_libraries",
2010 "write_asset_list", 2071 "write_asset_list",
2011 ]) 2072 ])
2012 if (!defined(deps)) { 2073 if (!defined(deps)) {
2013 deps = [] 2074 deps = []
2014 } 2075 }
2015 apk_path = _final_apk_path 2076 apk_path = _final_apk_path
2077 base_path = _base_path
2016 android_manifest = _android_manifest 2078 android_manifest = _android_manifest
2017 assets_build_config = _build_config 2079 assets_build_config = _build_config
2018 resources_zip = _all_resources_zip_path 2080 resources_zip = _all_resources_zip_path
2019 dex_path = final_dex_path 2081 dex_path = final_dex_path
2020 load_library_from_apk = _load_library_from_apk 2082 load_library_from_apk = _load_library_from_apk
2021 create_density_splits = _create_density_splits 2083 create_density_splits = _create_density_splits
2022 emma_instrument = emma_coverage && !_emma_never_instrument 2084 emma_instrument = emma_coverage && !_emma_never_instrument
2023 2085
2024 if (!defined(extensions_to_not_compress)) { 2086 if (!defined(extensions_to_not_compress)) {
2025 # Allow icu data, v8 snapshots, and pak files to be loaded directly from 2087 # Allow icu data, v8 snapshots, and pak files to be loaded directly from
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 native_libs = _extra_native_libs 2120 native_libs = _extra_native_libs
2059 native_libs_even_when_incremental = 2121 native_libs_even_when_incremental =
2060 _extra_native_libs_even_when_incremental 2122 _extra_native_libs_even_when_incremental
2061 } 2123 }
2062 2124
2063 # Placeholders necessary for some older devices. 2125 # Placeholders necessary for some older devices.
2064 # http://crbug.com/395038 2126 # http://crbug.com/395038
2065 forward_variables_from(invoker, [ "native_lib_placeholders" ]) 2127 forward_variables_from(invoker, [ "native_lib_placeholders" ])
2066 } 2128 }
2067 2129
2130 if (_is_testable_apk) {
2131 # We are going to create a second apk, very similiar to the above
Yaron 2016/07/06 14:01:41 seems like an awful lot of copy/paste :( is using
smaier 2016/07/06 19:09:37 Done.
2132 # create_apk("${_template_name}__create"), but with this one being an
2133 # externally visible rule which will build an .apk with the additional
2134 # test-only proguard flags.
2135 create_apk("${_template_name_for_test}") {
agrieve 2016/07/06 14:18:49 We can eliminate this copy / paste using a nested
smaier 2016/07/06 19:09:37 Done.
2136 forward_variables_from(invoker,
2137 [
2138 "alternative_android_sdk_jar",
2139 "android_aapt_path",
2140 "app_as_shared_lib",
2141 "deps",
2142 "extensions_to_not_compress",
2143 "language_splits",
2144 "page_align_shared_libraries",
2145 "public_deps",
2146 "secondary_native_libs",
2147 "shared_resources",
2148 "uncompress_shared_libraries",
2149 "write_asset_list",
2150 ])
2151 if (!defined(deps)) {
2152 deps = []
2153 }
2154 apk_path = _final_apk_for_test_path
2155 base_path = _base_path + "_for_test"
2156 android_manifest = _android_manifest
2157 assets_build_config = _build_config
2158 resources_zip = _all_resources_zip_path
2159 dex_path = final_dex_for_test_path
2160 load_library_from_apk = _load_library_from_apk
2161 create_density_splits = _create_density_splits
2162 emma_instrument = emma_coverage && !_emma_never_instrument
2163
2164 if (!defined(extensions_to_not_compress)) {
2165 # Allow icu data, v8 snapshots, and pak files to be loaded directly fr om
2166 # the .apk.
2167 # Note: These are actually suffix matches, not necessarily extensions.
2168 extensions_to_not_compress = ".dat,.bin,.pak"
2169 }
2170
2171 version_code = _version_code
2172 version_name = _version_name
2173
2174 keystore_name = _keystore_name
2175 keystore_path = _keystore_path
2176 keystore_password = _keystore_password
2177
2178 # Incremental apk does not use native libs nor final dex.
2179 incremental_deps = deps + _android_manifest_deps + [
2180 ":$build_config_target",
2181 ":$process_resources_target",
2182 ]
2183
2184 # This target generates the input file _all_resources_zip_path.
2185 deps += _android_manifest_deps + [
2186 ":$build_config_target",
2187 ":$process_resources_target",
2188 ":$final_dex_for_test_target_name",
2189 ]
2190
2191 if ((_native_libs_deps != [] ||
2192 _extra_native_libs_even_when_incremental != []) &&
2193 !_create_abi_split) {
2194 deps += _native_libs_deps + _extra_native_libs_deps +
2195 _extra_native_libs_even_when_incremental_deps +
2196 [ _native_libs_file_arg_dep ]
2197 native_libs_filearg = _native_libs_file_arg
2198 native_libs = _extra_native_libs
2199 native_libs_even_when_incremental =
2200 _extra_native_libs_even_when_incremental
2201 }
2202
2203 # Placeholders necessary for some older devices.
2204 # http://crbug.com/395038
2205 forward_variables_from(invoker, [ "native_lib_placeholders" ])
agrieve 2016/07/06 14:18:49 nit: since you're here, can you put this in with t
smaier 2016/07/06 19:09:37 Done.
2206 }
2207 }
2208
2068 if ((_native_libs_deps != [] || 2209 if ((_native_libs_deps != [] ||
2069 _extra_native_libs_even_when_incremental != []) && _create_abi_split) { 2210 _extra_native_libs_even_when_incremental != []) && _create_abi_split) {
2070 _manifest_rule = 2211 _manifest_rule =
2071 "${_template_name}__split_manifest_abi_${android_app_abi}" 2212 "${_template_name}__split_manifest_abi_${android_app_abi}"
2072 generate_split_manifest(_manifest_rule) { 2213 generate_split_manifest(_manifest_rule) {
2073 main_manifest = _android_manifest 2214 main_manifest = _android_manifest
2074 out_manifest = 2215 out_manifest =
2075 "$gen_dir/split-manifests/${android_app_abi}/AndroidManifest.xml" 2216 "$gen_dir/split-manifests/${android_app_abi}/AndroidManifest.xml"
2076 split_name = "abi_${android_app_abi}" 2217 split_name = "abi_${android_app_abi}"
2077 deps = _android_manifest_deps 2218 deps = _android_manifest_deps
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 2447
2307 group(target_name) { 2448 group(target_name) {
2308 public_deps = [ 2449 public_deps = [
2309 ":$_apk_target_name", 2450 ":$_apk_target_name",
2310 ":$_test_runner_target_name", 2451 ":$_test_runner_target_name",
2311 2452
2312 # Required by test runner to enumerate test list. 2453 # Required by test runner to enumerate test list.
2313 ":${_apk_target_name}_dist_ijar", 2454 ":${_apk_target_name}_dist_ijar",
2314 ] 2455 ]
2315 if (defined(invoker.apk_under_test)) { 2456 if (defined(invoker.apk_under_test)) {
2316 public_deps += [ invoker.apk_under_test ] 2457 if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
2458 public_deps += [ "${invoker.apk_under_test}_for_test" ]
2459 } else {
2460 public_deps += [ invoker.apk_under_test ]
2461 }
2317 } 2462 }
2318 if (defined(invoker.isolate_file)) { 2463 if (defined(invoker.isolate_file)) {
2319 isolate_values = exec_script("//build/gypi_to_gn.py", 2464 isolate_values = exec_script("//build/gypi_to_gn.py",
2320 [ 2465 [
2321 rebase_path(invoker.isolate_file), 2466 rebase_path(invoker.isolate_file),
2322 "--replace", 2467 "--replace",
2323 "<(DEPTH)=/", 2468 "<(DEPTH)=/",
2324 ], 2469 ],
2325 "scope", 2470 "scope",
2326 [ invoker.isolate_file ]) 2471 [ invoker.isolate_file ])
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 android_library(target_name) { 2704 android_library(target_name) {
2560 chromium_code = false 2705 chromium_code = false
2561 java_files = [] 2706 java_files = []
2562 srcjar_deps = [ ":${_template_name}__protoc_java" ] 2707 srcjar_deps = [ ":${_template_name}__protoc_java" ]
2563 deps = [ 2708 deps = [
2564 "//third_party/android_protobuf:protobuf_nano_javalib", 2709 "//third_party/android_protobuf:protobuf_nano_javalib",
2565 ] 2710 ]
2566 } 2711 }
2567 } 2712 }
2568 } 2713 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698