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

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

Issue 2109293003: 🎊 Reland #2 of Have build_config targets depend only on other build_config targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change // to * to fix downstream 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 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 if (_supports_android) { 1686 if (_supports_android) {
1595 _dex_target_name = "${_template_name}__dex" 1687 _dex_target_name = "${_template_name}__dex"
1596 } 1688 }
1597 1689
1598 write_build_config(_build_config_target_name) { 1690 write_build_config(_build_config_target_name) {
1599 type = "java_library" 1691 type = "java_library"
1600 supports_android = _supports_android 1692 supports_android = _supports_android
1601 requires_android = 1693 requires_android =
1602 defined(invoker.requires_android) && invoker.requires_android 1694 defined(invoker.requires_android) && invoker.requires_android
1603 1695
1604 deps = _deps 1696 if (defined(invoker.deps)) {
1697 possible_config_deps = _deps
1698 }
1605 build_config = _build_config 1699 build_config = _build_config
1606 jar_path = _jar_path 1700 jar_path = _jar_path
1607 if (_supports_android) { 1701 if (_supports_android) {
1608 dex_path = _dex_path 1702 dex_path = _dex_path
1609 } 1703 }
1610 } 1704 }
1611 1705
1612 process_java_prebuilt(_process_jar_target_name) { 1706 process_java_prebuilt(_process_jar_target_name) {
1613 forward_variables_from(invoker, 1707 forward_variables_from(invoker,
1614 [ 1708 [
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 2114
2021 # Define build_config_deps which will be a list of targets required to 2115 # Define build_config_deps which will be a list of targets required to
2022 # build the _build_config. 2116 # build the _build_config.
2023 if (defined(invoker.override_build_config)) { 2117 if (defined(invoker.override_build_config)) {
2024 _build_config = invoker.override_build_config 2118 _build_config = invoker.override_build_config
2025 } else { 2119 } else {
2026 _build_config = _base_path + ".build_config" 2120 _build_config = _base_path + ".build_config"
2027 build_config_target_name = "${_template_name}__build_config" 2121 build_config_target_name = "${_template_name}__build_config"
2028 2122
2029 write_build_config(build_config_target_name) { 2123 write_build_config(build_config_target_name) {
2030 deps = _accumulated_deps
2031 if (defined(invoker.is_java_binary) && invoker.is_java_binary) { 2124 if (defined(invoker.is_java_binary) && invoker.is_java_binary) {
2032 type = "java_binary" 2125 type = "java_binary"
2033 } else { 2126 } else {
2034 type = "java_library" 2127 type = "java_library"
2035 } 2128 }
2129 if (defined(invoker.deps)) {
2130 possible_config_deps = invoker.deps
2131 }
2036 supports_android = _supports_android 2132 supports_android = _supports_android
2037 requires_android = _requires_android 2133 requires_android = _requires_android
2038 bypass_platform_checks = defined(invoker.bypass_platform_checks) && 2134 bypass_platform_checks = defined(invoker.bypass_platform_checks) &&
2039 invoker.bypass_platform_checks 2135 invoker.bypass_platform_checks
2040 2136
2041 build_config = _build_config 2137 build_config = _build_config
2042 jar_path = _jar_path 2138 jar_path = _jar_path
2043 if (_supports_android) { 2139 if (_supports_android) {
2044 dex_path = _dex_path 2140 dex_path = _dex_path
2045 } 2141 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 } 2423 }
2328 } 2424 }
2329 2425
2330 # Produces a single .dex.jar out of a set of Java dependencies. 2426 # Produces a single .dex.jar out of a set of Java dependencies.
2331 template("deps_dex") { 2427 template("deps_dex") {
2332 set_sources_assignment_filter([]) 2428 set_sources_assignment_filter([])
2333 build_config = "$target_gen_dir/${target_name}.build_config" 2429 build_config = "$target_gen_dir/${target_name}.build_config"
2334 build_config_target_name = "${target_name}__build_config" 2430 build_config_target_name = "${target_name}__build_config"
2335 2431
2336 write_build_config(build_config_target_name) { 2432 write_build_config(build_config_target_name) {
2337 forward_variables_from(invoker, 2433 forward_variables_from(invoker, [ "dex_path" ])
2338 [ 2434 if (defined(invoker.deps)) {
2339 "deps", 2435 possible_config_deps = invoker.deps
2340 "dex_path", 2436 }
2341 ])
2342 type = "deps_dex" 2437 type = "deps_dex"
2343 build_config = build_config 2438 build_config = build_config
2344 } 2439 }
2345 2440
2346 rebased_build_config = rebase_path(build_config, root_build_dir) 2441 rebased_build_config = rebase_path(build_config, root_build_dir)
2347 dex(target_name) { 2442 dex(target_name) {
2348 inputs = [ 2443 inputs = [
2349 build_config, 2444 build_config,
2350 ] 2445 ]
2351 output = invoker.dex_path 2446 output = invoker.dex_path
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 outputs = [ 2504 outputs = [
2410 depfile, 2505 depfile,
2411 invoker.out_manifest, 2506 invoker.out_manifest,
2412 ] 2507 ]
2413 inputs = [ 2508 inputs = [
2414 invoker.main_manifest, 2509 invoker.main_manifest,
2415 ] 2510 ]
2416 } 2511 }
2417 } 2512 }
2418 } 2513 }
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