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 # 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 |
11 # dictionary of information about how to build this target (things that | 11 # dictionary of information about how to build this target (things that |
12 # require knowledge about this target's dependencies and cannot be calculated | 12 # 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 | 13 # at gn-time). There is a special syntax to add a value in that dictionary to |
14 # an action/action_foreachs args: | 14 # an action/action_foreachs args: |
15 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) | 15 # --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. | 16 # 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 | 17 # See build/android/gyp/write_build_config.py and |
18 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 18 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
19 template("write_build_config") { | 19 template("write_build_config") { |
20 action(target_name) { | 20 action(target_name) { |
21 set_sources_assignment_filter([]) | 21 set_sources_assignment_filter([]) |
22 type = invoker.type | 22 type = invoker.type |
23 build_config = invoker.build_config | 23 build_config = invoker.build_config |
24 | 24 |
25 assert(type == "android_apk" || type == "java_library" || | 25 assert(type == "android_apk" || type == "java_library" || |
26 type == "android_resources" || type == "deps_dex" || | 26 type == "android_resources" || type == "deps_dex" || |
27 type == "android_assets" || type == "resource_rewriter" || | 27 type == "android_assets" || type == "resource_rewriter" || |
28 type == "java_binary" || type == "group") | 28 type == "java_binary" || type == "group" || type == "android_aar") |
29 | 29 |
30 forward_variables_from(invoker, | 30 forward_variables_from(invoker, |
31 [ | 31 [ |
32 "deps", | 32 "deps", |
33 "testonly", | 33 "testonly", |
34 "visibility", | 34 "visibility", |
35 ]) | 35 ]) |
36 if (!defined(deps)) { | 36 if (!defined(deps)) { |
37 deps = [] | 37 deps = [] |
38 } | 38 } |
(...skipping 25 matching lines...) Expand all Loading... |
64 "--build-config", | 64 "--build-config", |
65 rebase_path(build_config, root_build_dir), | 65 rebase_path(build_config, root_build_dir), |
66 ] | 66 ] |
67 | 67 |
68 is_java = type == "java_library" || type == "java_binary" | 68 is_java = type == "java_library" || type == "java_binary" |
69 is_apk = type == "android_apk" | 69 is_apk = type == "android_apk" |
70 is_android_assets = type == "android_assets" | 70 is_android_assets = type == "android_assets" |
71 is_android_resources = type == "android_resources" | 71 is_android_resources = type == "android_resources" |
72 is_deps_dex = type == "deps_dex" | 72 is_deps_dex = type == "deps_dex" |
73 is_group = type == "group" | 73 is_group = type == "group" |
| 74 is_aar = type == "android_aar" |
74 | 75 |
75 supports_android = is_apk || is_android_assets || is_android_resources || | 76 supports_android = is_apk || is_android_assets || is_android_resources || |
76 is_deps_dex || is_group || | 77 is_deps_dex || is_group || is_aar || |
77 (is_java && defined(invoker.supports_android) && | 78 (is_java && defined(invoker.supports_android) && |
78 invoker.supports_android) | 79 invoker.supports_android) |
79 requires_android = | 80 requires_android = is_apk || is_android_assets || is_android_resources || |
80 is_apk || is_android_assets || is_android_resources || is_deps_dex || | 81 is_deps_dex || is_aar || |
81 (is_java && defined(invoker.requires_android) && | 82 (is_java && defined(invoker.requires_android) && |
82 invoker.requires_android) | 83 invoker.requires_android) |
83 | 84 |
84 assert(!requires_android || supports_android, | 85 assert(!requires_android || supports_android, |
85 "requires_android requires" + " supports_android") | 86 "requires_android requires" + " supports_android") |
86 | 87 |
87 # Mark these variables as used. | 88 # Mark these variables as used. |
88 assert(is_java || true) | 89 assert(is_java || true) |
89 assert(is_apk || true) | 90 assert(is_apk || true) |
90 assert(is_android_resources || true) | 91 assert(is_android_resources || true) |
91 assert(is_deps_dex || true) | 92 assert(is_deps_dex || true) |
92 assert(is_group || true) | 93 assert(is_group || true) |
| 94 assert(is_aar || true) |
93 | 95 |
94 if (is_java || is_apk) { | 96 if (is_java || is_apk || is_aar) { |
95 args += [ | 97 args += [ |
96 "--jar-path", | 98 "--jar-path", |
97 rebase_path(invoker.jar_path, root_build_dir), | 99 rebase_path(invoker.jar_path, root_build_dir), |
98 ] | 100 ] |
99 } | 101 } |
100 | 102 |
101 if (is_apk || is_deps_dex || (is_java && supports_android)) { | 103 if (is_apk || is_deps_dex || (is_java && supports_android)) { |
102 args += [ | 104 args += [ |
103 "--dex-path", | 105 "--dex-path", |
104 rebase_path(invoker.dex_path, root_build_dir), | 106 rebase_path(invoker.dex_path, root_build_dir), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ] | 144 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ] |
143 | 145 |
144 # These are zip paths, so no need to rebase. | 146 # These are zip paths, so no need to rebase. |
145 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin
ations}" ] | 147 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin
ations}" ] |
146 } | 148 } |
147 if (defined(invoker.disable_compression) && invoker.disable_compression) { | 149 if (defined(invoker.disable_compression) && invoker.disable_compression) { |
148 args += [ "--disable-asset-compression" ] | 150 args += [ "--disable-asset-compression" ] |
149 } | 151 } |
150 } | 152 } |
151 | 153 |
152 if (is_android_resources || is_apk) { | 154 if (is_android_resources || is_apk || is_aar) { |
153 assert(defined(invoker.resources_zip)) | 155 assert(defined(invoker.resources_zip)) |
154 args += [ | 156 args += [ |
155 "--resources-zip", | 157 "--resources-zip", |
156 rebase_path(invoker.resources_zip, root_build_dir), | 158 rebase_path(invoker.resources_zip, root_build_dir), |
157 ] | 159 ] |
158 if (defined(invoker.android_manifest)) { | 160 if (defined(invoker.android_manifest)) { |
159 inputs += [ invoker.android_manifest ] | 161 inputs += [ invoker.android_manifest ] |
160 args += [ | 162 args += [ |
161 "--android-manifest", | 163 "--android-manifest", |
162 rebase_path(invoker.android_manifest, root_build_dir), | 164 rebase_path(invoker.android_manifest, root_build_dir), |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 outputs = [ | 2374 outputs = [ |
2373 depfile, | 2375 depfile, |
2374 invoker.out_manifest, | 2376 invoker.out_manifest, |
2375 ] | 2377 ] |
2376 inputs = [ | 2378 inputs = [ |
2377 invoker.main_manifest, | 2379 invoker.main_manifest, |
2378 ] | 2380 ] |
2379 } | 2381 } |
2380 } | 2382 } |
2381 } | 2383 } |
OLD | NEW |