| 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/sanitizers/sanitizers.gni") | 6 import("//build/config/sanitizers/sanitizers.gni") |
| 7 | 7 |
| 8 assert(is_android) | 8 assert(is_android) |
| 9 | 9 |
| 10 # These identify targets that have .build_config files (except for android_apk, | |
| 11 # java_binary, resource_rewriter, since we never need to depend on these). | |
| 12 _java_target_whitelist = [ | |
| 13 "*:*_java", | |
| 14 "*:*_javalib", | |
| 15 "*:*_java_*", # e.g. java_test_support | |
| 16 "*:java", | |
| 17 "*:junit", | |
| 18 "*:junit_*", | |
| 19 "*:*_junit_*", | |
| 20 "*:*javatests", | |
| 21 "*:*_assets", | |
| 22 "*android*:assets", | |
| 23 "*:*_apk_*resources", | |
| 24 "*android*:resources", | |
| 25 "*:*_resources", | |
| 26 "*:*_grd", | |
| 27 "*:*locale_paks", | |
| 28 | |
| 29 # TODO(agrieve): Rename targets below to match above patterns. | |
| 30 "//android_webview/glue:glue", | |
| 31 "//build/android/pylib/device/commands:chromium_commands", | |
| 32 "//build/android/rezip:rezip", | |
| 33 "//chrome/test/android/cast_emulator:cast_emulator", | |
| 34 "//components/cronet/android:cronet_api", | |
| 35 "//components/cronet/android:cronet_javadoc_classpath", | |
| 36 "//components/policy:app_restrictions_resources", | |
| 37 "//device/battery/android:battery_monitor_android", | |
| 38 "//device/vibration/android:vibration_manager_android", | |
| 39 "//mojo/public/java:bindings", | |
| 40 "//mojo/public/java:system", | |
| 41 "//third_party/android_tools:emma_device", | |
| 42 "//third_party/cardboard-java:cardboard-java", | |
| 43 "//third_party/custom_tabs_client:custom_tabs_client_shared_lib", | |
| 44 "//third_party/custom_tabs_client:custom_tabs_support_lib", | |
| 45 "//third_party/errorprone:chromium_errorprone", | |
| 46 "//third_party/haha:haha", | |
| 47 "//third_party/junit:hamcrest", | |
| 48 "//third_party/netty4:netty_all", | |
| 49 "//third_party/netty-tcnative:netty-tcnative", | |
| 50 "//third_party/robolectric:android-all-4.3_r2-robolectric-0", | |
| 51 "//third_party/robolectric:json-20080701", | |
| 52 "//third_party/robolectric:tagsoup-1.2", | |
| 53 ] | |
| 54 | |
| 55 # Targets that match the whitelist but are not actually java targets. | |
| 56 _java_target_blacklist = [ | |
| 57 "//chrome:packed_extra_resources", | |
| 58 "//chrome:packed_resources", | |
| 59 "//remoting/android:remoting_android_raw_resources", | |
| 60 ] | |
| 61 | |
| 62 # Write the target's .build_config file. This is a json file that contains a | 10 # Write the target's .build_config file. This is a json file that contains a |
| 63 # dictionary of information about how to build this target (things that | 11 # dictionary of information about how to build this target (things that |
| 64 # require knowledge about this target's dependencies and cannot be calculated | 12 # require knowledge about this target's dependencies and cannot be calculated |
| 65 # at gn-time). There is a special syntax to add a value in that dictionary to | 13 # at gn-time). There is a special syntax to add a value in that dictionary to |
| 66 # an action/action_foreachs args: | 14 # an action/action_foreachs args: |
| 67 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) | 15 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) |
| 68 # At runtime, such an arg will be replaced by the value in the build_config. | 16 # At runtime, such an arg will be replaced by the value in the build_config. |
| 69 # See build/android/gyp/write_build_config.py and | 17 # See build/android/gyp/write_build_config.py and |
| 70 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 18 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
| 71 template("write_build_config") { | 19 template("write_build_config") { |
| 72 type = invoker.type | |
| 73 | |
| 74 # Don't need to enforce naming scheme for these targets since we never | |
| 75 # consider them in dependency chains. | |
| 76 if (type != "android_apk" && type != "java_binary" && | |
| 77 type != "resource_rewriter") { | |
| 78 set_sources_assignment_filter(_java_target_whitelist) | |
| 79 _parent_invoker = invoker.invoker | |
| 80 _target_label = | |
| 81 get_label_info(":${_parent_invoker.target_name}", "label_no_toolchain") | |
| 82 sources = [ | |
| 83 _target_label, | |
| 84 ] | |
| 85 if (sources != []) { | |
| 86 set_sources_assignment_filter(_java_target_blacklist) | |
| 87 sources = [] | |
| 88 sources = [ | |
| 89 _target_label, | |
| 90 ] | |
| 91 if (sources != []) { | |
| 92 assert(false, "Invalid java target name: $_target_label") | |
| 93 } | |
| 94 } | |
| 95 sources = [] | |
| 96 } | |
| 97 | |
| 98 action(target_name) { | 20 action(target_name) { |
| 99 set_sources_assignment_filter([]) | 21 set_sources_assignment_filter([]) |
| 22 type = invoker.type |
| 100 build_config = invoker.build_config | 23 build_config = invoker.build_config |
| 101 | 24 |
| 102 assert(type == "android_apk" || type == "java_library" || | 25 assert(type == "android_apk" || type == "java_library" || |
| 103 type == "android_resources" || type == "deps_dex" || | 26 type == "android_resources" || type == "deps_dex" || |
| 104 type == "android_assets" || type == "resource_rewriter" || | 27 type == "android_assets" || type == "resource_rewriter" || |
| 105 type == "java_binary" || type == "group") | 28 type == "java_binary" || type == "group") |
| 106 | 29 |
| 107 forward_variables_from(invoker, | 30 forward_variables_from(invoker, |
| 108 [ | 31 [ |
| 109 "deps", | 32 "deps", |
| 110 "testonly", | 33 "testonly", |
| 34 "visibility", |
| 111 ]) | 35 ]) |
| 112 if (!defined(deps)) { | 36 if (!defined(deps)) { |
| 113 deps = [] | 37 deps = [] |
| 114 } | 38 } |
| 115 | 39 |
| 116 script = "//build/android/gyp/write_build_config.py" | 40 script = "//build/android/gyp/write_build_config.py" |
| 117 depfile = "$target_gen_dir/$target_name.d" | 41 depfile = "$target_gen_dir/$target_name.d" |
| 118 inputs = [] | 42 inputs = [] |
| 119 | 43 |
| 120 _deps_configs = [] | 44 possible_deps_configs = [] |
| 121 if (defined(invoker.possible_config_deps)) { | 45 foreach(d, deps) { |
| 122 foreach(_possible_dep, invoker.possible_config_deps) { | 46 dep_gen_dir = get_label_info(d, "target_gen_dir") |
| 123 set_sources_assignment_filter(_java_target_whitelist) | 47 dep_name = get_label_info(d, "name") |
| 124 _target_label = get_label_info(_possible_dep, "label_no_toolchain") | 48 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ] |
| 125 sources = [ | |
| 126 _target_label, | |
| 127 ] | |
| 128 if (sources == []) { | |
| 129 set_sources_assignment_filter(_java_target_blacklist) | |
| 130 sources = [] | |
| 131 sources = [ | |
| 132 _target_label, | |
| 133 ] | |
| 134 if (sources != []) { | |
| 135 deps += [ "${_target_label}__build_config" ] | |
| 136 _dep_gen_dir = get_label_info(_possible_dep, "target_gen_dir") | |
| 137 _dep_name = get_label_info(_possible_dep, "name") | |
| 138 _deps_configs += [ "$_dep_gen_dir/$_dep_name.build_config" ] | |
| 139 } | |
| 140 } | |
| 141 sources = [] | |
| 142 } | |
| 143 set_sources_assignment_filter([]) | |
| 144 } | 49 } |
| 145 _rebased_deps_configs = rebase_path(_deps_configs, root_build_dir) | 50 rebase_possible_deps_configs = |
| 51 rebase_path(possible_deps_configs, root_build_dir) |
| 146 | 52 |
| 147 outputs = [ | 53 outputs = [ |
| 148 depfile, | 54 depfile, |
| 149 build_config, | 55 build_config, |
| 150 ] | 56 ] |
| 151 | 57 |
| 152 args = [ | 58 args = [ |
| 153 "--type", | 59 "--type", |
| 154 type, | 60 type, |
| 155 "--depfile", | 61 "--depfile", |
| 156 rebase_path(depfile, root_build_dir), | 62 rebase_path(depfile, root_build_dir), |
| 157 "--deps-configs=$_rebased_deps_configs", | 63 "--possible-deps-configs=$rebase_possible_deps_configs", |
| 158 "--build-config", | 64 "--build-config", |
| 159 rebase_path(build_config, root_build_dir), | 65 rebase_path(build_config, root_build_dir), |
| 160 ] | 66 ] |
| 161 | 67 |
| 162 is_java = type == "java_library" || type == "java_binary" | 68 is_java = type == "java_library" || type == "java_binary" |
| 163 is_apk = type == "android_apk" | 69 is_apk = type == "android_apk" |
| 164 is_android_assets = type == "android_assets" | 70 is_android_assets = type == "android_assets" |
| 165 is_android_resources = type == "android_resources" | 71 is_android_resources = type == "android_resources" |
| 166 is_deps_dex = type == "deps_dex" | 72 is_deps_dex = type == "deps_dex" |
| 167 is_group = type == "group" | 73 is_group = type == "group" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 apk_under_test_config = | 123 apk_under_test_config = |
| 218 "$apk_under_test_gen_dir/$apk_under_test_name.build_config" | 124 "$apk_under_test_gen_dir/$apk_under_test_name.build_config" |
| 219 args += [ | 125 args += [ |
| 220 "--tested-apk-config", | 126 "--tested-apk-config", |
| 221 rebase_path(apk_under_test_config, root_build_dir), | 127 rebase_path(apk_under_test_config, root_build_dir), |
| 222 ] | 128 ] |
| 223 } | 129 } |
| 224 | 130 |
| 225 if (is_android_assets) { | 131 if (is_android_assets) { |
| 226 if (defined(invoker.asset_sources)) { | 132 if (defined(invoker.asset_sources)) { |
| 133 inputs += invoker.asset_sources |
| 227 _rebased_asset_sources = | 134 _rebased_asset_sources = |
| 228 rebase_path(invoker.asset_sources, root_build_dir) | 135 rebase_path(invoker.asset_sources, root_build_dir) |
| 229 args += [ "--asset-sources=$_rebased_asset_sources" ] | 136 args += [ "--asset-sources=$_rebased_asset_sources" ] |
| 230 } | 137 } |
| 231 if (defined(invoker.asset_renaming_sources)) { | 138 if (defined(invoker.asset_renaming_sources)) { |
| 139 inputs += invoker.asset_renaming_sources |
| 232 _rebased_asset_renaming_sources = | 140 _rebased_asset_renaming_sources = |
| 233 rebase_path(invoker.asset_renaming_sources, root_build_dir) | 141 rebase_path(invoker.asset_renaming_sources, root_build_dir) |
| 234 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ] | 142 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ] |
| 235 | 143 |
| 236 # These are zip paths, so no need to rebase. | 144 # These are zip paths, so no need to rebase. |
| 237 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin
ations}" ] | 145 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin
ations}" ] |
| 238 } | 146 } |
| 239 if (defined(invoker.disable_compression) && invoker.disable_compression) { | 147 if (defined(invoker.disable_compression) && invoker.disable_compression) { |
| 240 args += [ "--disable-asset-compression" ] | 148 args += [ "--disable-asset-compression" ] |
| 241 } | 149 } |
| (...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 if (_supports_android) { | 1584 if (_supports_android) { |
| 1677 _dex_target_name = "${_template_name}__dex" | 1585 _dex_target_name = "${_template_name}__dex" |
| 1678 } | 1586 } |
| 1679 | 1587 |
| 1680 write_build_config(_build_config_target_name) { | 1588 write_build_config(_build_config_target_name) { |
| 1681 type = "java_library" | 1589 type = "java_library" |
| 1682 supports_android = _supports_android | 1590 supports_android = _supports_android |
| 1683 requires_android = | 1591 requires_android = |
| 1684 defined(invoker.requires_android) && invoker.requires_android | 1592 defined(invoker.requires_android) && invoker.requires_android |
| 1685 | 1593 |
| 1686 if (defined(invoker.deps)) { | 1594 deps = _deps |
| 1687 possible_config_deps = _deps | |
| 1688 } | |
| 1689 build_config = _build_config | 1595 build_config = _build_config |
| 1690 jar_path = _jar_path | 1596 jar_path = _jar_path |
| 1691 if (_supports_android) { | 1597 if (_supports_android) { |
| 1692 dex_path = _dex_path | 1598 dex_path = _dex_path |
| 1693 } | 1599 } |
| 1694 } | 1600 } |
| 1695 | 1601 |
| 1696 process_java_prebuilt(_process_jar_target_name) { | 1602 process_java_prebuilt(_process_jar_target_name) { |
| 1697 forward_variables_from(invoker, | 1603 forward_variables_from(invoker, |
| 1698 [ | 1604 [ |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 | 1991 |
| 2086 # Define build_config_deps which will be a list of targets required to | 1992 # Define build_config_deps which will be a list of targets required to |
| 2087 # build the _build_config. | 1993 # build the _build_config. |
| 2088 if (defined(invoker.override_build_config)) { | 1994 if (defined(invoker.override_build_config)) { |
| 2089 _build_config = invoker.override_build_config | 1995 _build_config = invoker.override_build_config |
| 2090 } else { | 1996 } else { |
| 2091 _build_config = _base_path + ".build_config" | 1997 _build_config = _base_path + ".build_config" |
| 2092 build_config_target_name = "${_template_name}__build_config" | 1998 build_config_target_name = "${_template_name}__build_config" |
| 2093 | 1999 |
| 2094 write_build_config(build_config_target_name) { | 2000 write_build_config(build_config_target_name) { |
| 2001 deps = _accumulated_deps |
| 2095 if (defined(invoker.is_java_binary) && invoker.is_java_binary) { | 2002 if (defined(invoker.is_java_binary) && invoker.is_java_binary) { |
| 2096 type = "java_binary" | 2003 type = "java_binary" |
| 2097 } else { | 2004 } else { |
| 2098 type = "java_library" | 2005 type = "java_library" |
| 2099 } | 2006 } |
| 2100 if (defined(invoker.deps)) { | |
| 2101 possible_config_deps = invoker.deps | |
| 2102 } | |
| 2103 supports_android = _supports_android | 2007 supports_android = _supports_android |
| 2104 requires_android = _requires_android | 2008 requires_android = _requires_android |
| 2105 bypass_platform_checks = defined(invoker.bypass_platform_checks) && | 2009 bypass_platform_checks = defined(invoker.bypass_platform_checks) && |
| 2106 invoker.bypass_platform_checks | 2010 invoker.bypass_platform_checks |
| 2107 | 2011 |
| 2108 build_config = _build_config | 2012 build_config = _build_config |
| 2109 jar_path = _jar_path | 2013 jar_path = _jar_path |
| 2110 if (_supports_android) { | 2014 if (_supports_android) { |
| 2111 dex_path = _dex_path | 2015 dex_path = _dex_path |
| 2112 } | 2016 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 } | 2298 } |
| 2395 } | 2299 } |
| 2396 | 2300 |
| 2397 # Produces a single .dex.jar out of a set of Java dependencies. | 2301 # Produces a single .dex.jar out of a set of Java dependencies. |
| 2398 template("deps_dex") { | 2302 template("deps_dex") { |
| 2399 set_sources_assignment_filter([]) | 2303 set_sources_assignment_filter([]) |
| 2400 build_config = "$target_gen_dir/${target_name}.build_config" | 2304 build_config = "$target_gen_dir/${target_name}.build_config" |
| 2401 build_config_target_name = "${target_name}__build_config" | 2305 build_config_target_name = "${target_name}__build_config" |
| 2402 | 2306 |
| 2403 write_build_config(build_config_target_name) { | 2307 write_build_config(build_config_target_name) { |
| 2404 forward_variables_from(invoker, [ "dex_path" ]) | 2308 forward_variables_from(invoker, |
| 2405 if (defined(invoker.deps)) { | 2309 [ |
| 2406 possible_config_deps = invoker.deps | 2310 "deps", |
| 2407 } | 2311 "dex_path", |
| 2312 ]) |
| 2408 type = "deps_dex" | 2313 type = "deps_dex" |
| 2409 build_config = build_config | 2314 build_config = build_config |
| 2410 } | 2315 } |
| 2411 | 2316 |
| 2412 rebased_build_config = rebase_path(build_config, root_build_dir) | 2317 rebased_build_config = rebase_path(build_config, root_build_dir) |
| 2413 dex(target_name) { | 2318 dex(target_name) { |
| 2414 inputs = [ | 2319 inputs = [ |
| 2415 build_config, | 2320 build_config, |
| 2416 ] | 2321 ] |
| 2417 output = invoker.dex_path | 2322 output = invoker.dex_path |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 outputs = [ | 2380 outputs = [ |
| 2476 depfile, | 2381 depfile, |
| 2477 invoker.out_manifest, | 2382 invoker.out_manifest, |
| 2478 ] | 2383 ] |
| 2479 inputs = [ | 2384 inputs = [ |
| 2480 invoker.main_manifest, | 2385 invoker.main_manifest, |
| 2481 ] | 2386 ] |
| 2482 } | 2387 } |
| 2483 } | 2388 } |
| 2484 } | 2389 } |
| OLD | NEW |