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

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

Issue 2095913003: 🎊 Have build_config targets depend only on other build_config targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix chromecast 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
« no previous file with comments | « build/android/gyp/write_build_config.py ('k') | build/config/android/rules.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
10 # Write the target's .build_config file. This is a json file that contains a 62 # Write the target's .build_config file. This is a json file that contains a
11 # dictionary of information about how to build this target (things that 63 # dictionary of information about how to build this target (things that
12 # require knowledge about this target's dependencies and cannot be calculated 64 # require knowledge about this target's dependencies and cannot be calculated
13 # at gn-time). There is a special syntax to add a value in that dictionary to 65 # at gn-time). There is a special syntax to add a value in that dictionary to
14 # an action/action_foreachs args: 66 # an action/action_foreachs args:
15 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) 67 # --python-arg=@FileArg($rebased_build_config_path:key0:key1)
16 # At runtime, such an arg will be replaced by the value in the build_config. 68 # At runtime, such an arg will be replaced by the value in the build_config.
17 # See build/android/gyp/write_build_config.py and 69 # See build/android/gyp/write_build_config.py and
18 # build/android/gyp/util/build_utils.py:ExpandFileArgs 70 # build/android/gyp/util/build_utils.py:ExpandFileArgs
19 template("write_build_config") { 71 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
20 action(target_name) { 98 action(target_name) {
21 set_sources_assignment_filter([]) 99 set_sources_assignment_filter([])
22 type = invoker.type
23 build_config = invoker.build_config 100 build_config = invoker.build_config
24 101
25 assert(type == "android_apk" || type == "java_library" || 102 assert(type == "android_apk" || type == "java_library" ||
26 type == "android_resources" || type == "deps_dex" || 103 type == "android_resources" || type == "deps_dex" ||
27 type == "android_assets" || type == "resource_rewriter" || 104 type == "android_assets" || type == "resource_rewriter" ||
28 type == "java_binary" || type == "group") 105 type == "java_binary" || type == "group")
29 106
30 forward_variables_from(invoker, 107 forward_variables_from(invoker,
31 [ 108 [
32 "deps", 109 "deps",
33 "testonly", 110 "testonly",
34 "visibility",
35 ]) 111 ])
36 if (!defined(deps)) { 112 if (!defined(deps)) {
37 deps = [] 113 deps = []
38 } 114 }
39 115
40 script = "//build/android/gyp/write_build_config.py" 116 script = "//build/android/gyp/write_build_config.py"
41 depfile = "$target_gen_dir/$target_name.d" 117 depfile = "$target_gen_dir/$target_name.d"
42 inputs = [] 118 inputs = []
43 119
44 possible_deps_configs = [] 120 _deps_configs = []
45 foreach(d, deps) { 121 if (defined(invoker.possible_config_deps)) {
46 dep_gen_dir = get_label_info(d, "target_gen_dir") 122 foreach(_possible_dep, invoker.possible_config_deps) {
47 dep_name = get_label_info(d, "name") 123 set_sources_assignment_filter(_java_target_whitelist)
48 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ] 124 _target_label = get_label_info(_possible_dep, "label_no_toolchain")
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([])
49 } 144 }
50 rebase_possible_deps_configs = 145 _rebased_deps_configs = rebase_path(_deps_configs, root_build_dir)
51 rebase_path(possible_deps_configs, root_build_dir)
52 146
53 outputs = [ 147 outputs = [
54 depfile, 148 depfile,
55 build_config, 149 build_config,
56 ] 150 ]
57 151
58 args = [ 152 args = [
59 "--type", 153 "--type",
60 type, 154 type,
61 "--depfile", 155 "--depfile",
62 rebase_path(depfile, root_build_dir), 156 rebase_path(depfile, root_build_dir),
63 "--possible-deps-configs=$rebase_possible_deps_configs", 157 "--deps-configs=$_rebased_deps_configs",
64 "--build-config", 158 "--build-config",
65 rebase_path(build_config, root_build_dir), 159 rebase_path(build_config, root_build_dir),
66 ] 160 ]
67 161
68 is_java = type == "java_library" || type == "java_binary" 162 is_java = type == "java_library" || type == "java_binary"
69 is_apk = type == "android_apk" 163 is_apk = type == "android_apk"
70 is_android_assets = type == "android_assets" 164 is_android_assets = type == "android_assets"
71 is_android_resources = type == "android_resources" 165 is_android_resources = type == "android_resources"
72 is_deps_dex = type == "deps_dex" 166 is_deps_dex = type == "deps_dex"
73 is_group = type == "group" 167 is_group = type == "group"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 apk_under_test_config = 217 apk_under_test_config =
124 "$apk_under_test_gen_dir/$apk_under_test_name.build_config" 218 "$apk_under_test_gen_dir/$apk_under_test_name.build_config"
125 args += [ 219 args += [
126 "--tested-apk-config", 220 "--tested-apk-config",
127 rebase_path(apk_under_test_config, root_build_dir), 221 rebase_path(apk_under_test_config, root_build_dir),
128 ] 222 ]
129 } 223 }
130 224
131 if (is_android_assets) { 225 if (is_android_assets) {
132 if (defined(invoker.asset_sources)) { 226 if (defined(invoker.asset_sources)) {
133 inputs += invoker.asset_sources
134 _rebased_asset_sources = 227 _rebased_asset_sources =
135 rebase_path(invoker.asset_sources, root_build_dir) 228 rebase_path(invoker.asset_sources, root_build_dir)
136 args += [ "--asset-sources=$_rebased_asset_sources" ] 229 args += [ "--asset-sources=$_rebased_asset_sources" ]
137 } 230 }
138 if (defined(invoker.asset_renaming_sources)) { 231 if (defined(invoker.asset_renaming_sources)) {
139 inputs += invoker.asset_renaming_sources
140 _rebased_asset_renaming_sources = 232 _rebased_asset_renaming_sources =
141 rebase_path(invoker.asset_renaming_sources, root_build_dir) 233 rebase_path(invoker.asset_renaming_sources, root_build_dir)
142 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ] 234 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ]
143 235
144 # These are zip paths, so no need to rebase. 236 # These are zip paths, so no need to rebase.
145 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin ations}" ] 237 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin ations}" ]
146 } 238 }
147 if (defined(invoker.disable_compression) && invoker.disable_compression) { 239 if (defined(invoker.disable_compression) && invoker.disable_compression) {
148 args += [ "--disable-asset-compression" ] 240 args += [ "--disable-asset-compression" ]
149 } 241 }
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 if (_supports_android) { 1676 if (_supports_android) {
1585 _dex_target_name = "${_template_name}__dex" 1677 _dex_target_name = "${_template_name}__dex"
1586 } 1678 }
1587 1679
1588 write_build_config(_build_config_target_name) { 1680 write_build_config(_build_config_target_name) {
1589 type = "java_library" 1681 type = "java_library"
1590 supports_android = _supports_android 1682 supports_android = _supports_android
1591 requires_android = 1683 requires_android =
1592 defined(invoker.requires_android) && invoker.requires_android 1684 defined(invoker.requires_android) && invoker.requires_android
1593 1685
1594 deps = _deps 1686 if (defined(invoker.deps)) {
1687 possible_config_deps = _deps
1688 }
1595 build_config = _build_config 1689 build_config = _build_config
1596 jar_path = _jar_path 1690 jar_path = _jar_path
1597 if (_supports_android) { 1691 if (_supports_android) {
1598 dex_path = _dex_path 1692 dex_path = _dex_path
1599 } 1693 }
1600 } 1694 }
1601 1695
1602 process_java_prebuilt(_process_jar_target_name) { 1696 process_java_prebuilt(_process_jar_target_name) {
1603 forward_variables_from(invoker, 1697 forward_variables_from(invoker,
1604 [ 1698 [
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 2085
1992 # Define build_config_deps which will be a list of targets required to 2086 # Define build_config_deps which will be a list of targets required to
1993 # build the _build_config. 2087 # build the _build_config.
1994 if (defined(invoker.override_build_config)) { 2088 if (defined(invoker.override_build_config)) {
1995 _build_config = invoker.override_build_config 2089 _build_config = invoker.override_build_config
1996 } else { 2090 } else {
1997 _build_config = _base_path + ".build_config" 2091 _build_config = _base_path + ".build_config"
1998 build_config_target_name = "${_template_name}__build_config" 2092 build_config_target_name = "${_template_name}__build_config"
1999 2093
2000 write_build_config(build_config_target_name) { 2094 write_build_config(build_config_target_name) {
2001 deps = _accumulated_deps
2002 if (defined(invoker.is_java_binary) && invoker.is_java_binary) { 2095 if (defined(invoker.is_java_binary) && invoker.is_java_binary) {
2003 type = "java_binary" 2096 type = "java_binary"
2004 } else { 2097 } else {
2005 type = "java_library" 2098 type = "java_library"
2006 } 2099 }
2100 if (defined(invoker.deps)) {
2101 possible_config_deps = invoker.deps
2102 }
2007 supports_android = _supports_android 2103 supports_android = _supports_android
2008 requires_android = _requires_android 2104 requires_android = _requires_android
2009 bypass_platform_checks = defined(invoker.bypass_platform_checks) && 2105 bypass_platform_checks = defined(invoker.bypass_platform_checks) &&
2010 invoker.bypass_platform_checks 2106 invoker.bypass_platform_checks
2011 2107
2012 build_config = _build_config 2108 build_config = _build_config
2013 jar_path = _jar_path 2109 jar_path = _jar_path
2014 if (_supports_android) { 2110 if (_supports_android) {
2015 dex_path = _dex_path 2111 dex_path = _dex_path
2016 } 2112 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 } 2394 }
2299 } 2395 }
2300 2396
2301 # Produces a single .dex.jar out of a set of Java dependencies. 2397 # Produces a single .dex.jar out of a set of Java dependencies.
2302 template("deps_dex") { 2398 template("deps_dex") {
2303 set_sources_assignment_filter([]) 2399 set_sources_assignment_filter([])
2304 build_config = "$target_gen_dir/${target_name}.build_config" 2400 build_config = "$target_gen_dir/${target_name}.build_config"
2305 build_config_target_name = "${target_name}__build_config" 2401 build_config_target_name = "${target_name}__build_config"
2306 2402
2307 write_build_config(build_config_target_name) { 2403 write_build_config(build_config_target_name) {
2308 forward_variables_from(invoker, 2404 forward_variables_from(invoker, [ "dex_path" ])
2309 [ 2405 if (defined(invoker.deps)) {
2310 "deps", 2406 possible_config_deps = invoker.deps
2311 "dex_path", 2407 }
2312 ])
2313 type = "deps_dex" 2408 type = "deps_dex"
2314 build_config = build_config 2409 build_config = build_config
2315 } 2410 }
2316 2411
2317 rebased_build_config = rebase_path(build_config, root_build_dir) 2412 rebased_build_config = rebase_path(build_config, root_build_dir)
2318 dex(target_name) { 2413 dex(target_name) {
2319 inputs = [ 2414 inputs = [
2320 build_config, 2415 build_config,
2321 ] 2416 ]
2322 output = invoker.dex_path 2417 output = invoker.dex_path
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 outputs = [ 2475 outputs = [
2381 depfile, 2476 depfile,
2382 invoker.out_manifest, 2477 invoker.out_manifest,
2383 ] 2478 ]
2384 inputs = [ 2479 inputs = [
2385 invoker.main_manifest, 2480 invoker.main_manifest,
2386 ] 2481 ]
2387 } 2482 }
2388 } 2483 }
2389 } 2484 }
OLDNEW
« no previous file with comments | « build/android/gyp/write_build_config.py ('k') | build/config/android/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698