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 | 6 |
| 7 assert(is_android) |
| 8 |
| 9 |
| 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) |
| 11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) |
| 12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil
d_dir) |
| 13 |
7 | 14 |
8 # Write the target's .build_config file. This is a json file that contains a | 15 # Write the target's .build_config file. This is a json file that contains a |
9 # dictionary of information about how to build this target (things that | 16 # dictionary of information about how to build this target (things that |
10 # require knowledge about this target's dependencies and cannot be calculated | 17 # require knowledge about this target's dependencies and cannot be calculated |
11 # at gn-time). There is a special syntax to add a value in that dictionary to | 18 # at gn-time). There is a special syntax to add a value in that dictionary to |
12 # an action/action_foreachs args: | 19 # an action/action_foreachs args: |
13 # --python-arg=@($rebased_build_config_path:key0:key1) | 20 # --python-arg=@($rebased_build_config_path:key0:key1) |
14 # At runtime, such an arg will be replaced by the value in the build_config. | 21 # At runtime, such an arg will be replaced by the value in the build_config. |
15 # See build/android/gyp/write_build_config.py and | 22 # See build/android/gyp/write_build_config.py and |
16 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 23 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
17 template("write_build_config") { | 24 template("write_build_config") { |
18 assert(defined(invoker.type)) | 25 assert(defined(invoker.type)) |
19 assert(defined(invoker.base_path)) | 26 assert(defined(invoker.base_path)) |
20 | 27 |
21 base_path = invoker.base_path | 28 base_path = invoker.base_path |
22 type = invoker.type | 29 type = invoker.type |
23 build_config = base_path + ".build_config" | 30 build_config = base_path + ".build_config" |
24 | 31 |
25 assert(type == "android_library" || type == "android_binary") | 32 assert(type == "android_binary" || type == "android_library" || type == "andro
id_resources") |
26 | 33 |
27 action(target_name) { | 34 action(target_name) { |
28 script = "//build/android/gyp/write_build_config.py" | 35 script = "//build/android/gyp/write_build_config.py" |
29 depfile = "$target_gen_dir/$target_name.d" | 36 depfile = "$target_gen_dir/$target_name.d" |
30 | 37 |
31 deps = [] | 38 deps = [] |
32 if (defined(invoker.deps)) { | 39 if (defined(invoker.deps)) { |
33 deps += invoker.deps | 40 deps += invoker.deps |
34 } | 41 } |
35 | 42 |
(...skipping 15 matching lines...) Expand all Loading... |
51 "--possible-deps-configs=$rebase_possible_deps_configs", | 58 "--possible-deps-configs=$rebase_possible_deps_configs", |
52 "--build-config", rebase_path(build_config, root_build_dir), | 59 "--build-config", rebase_path(build_config, root_build_dir), |
53 ] | 60 ] |
54 | 61 |
55 if (type == "android_library") { | 62 if (type == "android_library") { |
56 jar_path = base_path + ".jar" | 63 jar_path = base_path + ".jar" |
57 args += [ | 64 args += [ |
58 "--jar-path", rebase_path(jar_path, root_build_dir), | 65 "--jar-path", rebase_path(jar_path, root_build_dir), |
59 ] | 66 ] |
60 } | 67 } |
| 68 |
| 69 if (type == "android_resources") { |
| 70 assert(defined(invoker.resources_zip)) |
| 71 args += [ |
| 72 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), |
| 73 ] |
| 74 if (defined(invoker.srcjar)) { |
| 75 args += [ |
| 76 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) |
| 77 ] |
| 78 } |
| 79 } |
61 } | 80 } |
62 } | 81 } |
63 | 82 |
| 83 |
64 # Creates a zip archive of the inputs. | 84 # Creates a zip archive of the inputs. |
65 # If base_dir is provided, the archive paths will be relative to it. | 85 # If base_dir is provided, the archive paths will be relative to it. |
66 template("zip") { | 86 template("zip") { |
67 assert(defined(invoker.inputs)) | 87 assert(defined(invoker.inputs)) |
68 assert(defined(invoker.output)) | 88 assert(defined(invoker.output)) |
69 | 89 |
70 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) | 90 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) |
71 rebase_output = rebase_path(invoker.output, root_build_dir) | 91 rebase_output = rebase_path(invoker.output, root_build_dir) |
72 action(target_name) { | 92 action(target_name) { |
73 script = "//build/android/gn/zip.py" | 93 script = "//build/android/gn/zip.py" |
74 depfile = "$target_gen_dir/$target_name.d" | 94 depfile = "$target_gen_dir/$target_name.d" |
75 inputs = invoker.inputs | 95 inputs = invoker.inputs |
76 outputs = [ | 96 outputs = [ |
77 depfile, | 97 depfile, |
78 invoker.output | 98 invoker.output |
79 ] | 99 ] |
80 args = [ | 100 args = [ |
81 "--depfile", rebase_path(depfile, root_build_dir), | 101 "--depfile", rebase_path(depfile, root_build_dir), |
82 "--inputs=$rebase_inputs", | 102 "--inputs=$rebase_inputs", |
83 "--output=$rebase_output", | 103 "--output=$rebase_output", |
84 ] | 104 ] |
85 if (defined(invoker.base_dir)) { | 105 if (defined(invoker.base_dir)) { |
86 args += [ | 106 args += [ |
87 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) | 107 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) |
88 ] | 108 ] |
89 } | 109 } |
90 } | 110 } |
91 } | 111 } |
92 | 112 |
93 # Compiles and jars a set of java_files. | 113 |
| 114 # Compiles and jars a set of java files. |
94 # | 115 # |
95 # Outputs: | 116 # Outputs: |
96 # $jar_path.jar | 117 # $jar_path.jar |
97 # $jar_path.jar.TOC | 118 # $jar_path.jar.TOC |
98 # | 119 # |
99 # Variables | 120 # Variables |
100 # java_files: List of .java files to compile. | 121 # java_files: List of .java files to compile. |
101 # java_deps: List of java dependencies. These should all have a .jar output | 122 # java_deps: List of java dependencies. These should all have a .jar output |
102 # at "${target_gen_dir}/${target_name}.jar. | 123 # at "${target_gen_dir}/${target_name}.jar. |
103 # chromium_code: If 1, enable extra warnings. | 124 # chromium_code: If 1, enable extra warnings. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 rebase_system_jars = rebase_path(system_jars, root_build_dir) | 178 rebase_system_jars = rebase_path(system_jars, root_build_dir) |
158 rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir) | 179 rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir) |
159 rebase_build_config = rebase_path(build_config, root_build_dir) | 180 rebase_build_config = rebase_path(build_config, root_build_dir) |
160 rebase_depfile = rebase_path(depfile, root_build_dir) | 181 rebase_depfile = rebase_path(depfile, root_build_dir) |
161 args = [ | 182 args = [ |
162 "--depfile=$rebase_depfile", | 183 "--depfile=$rebase_depfile", |
163 "--classpath=$rebase_system_jars", | 184 "--classpath=$rebase_system_jars", |
164 "--classpath=@($rebase_build_config:javac:classpath)", | 185 "--classpath=@($rebase_build_config:javac:classpath)", |
165 "--jar-path=$rebase_jar_path", | 186 "--jar-path=$rebase_jar_path", |
166 "--java-srcjars=$rebase_java_srcjars", | 187 "--java-srcjars=$rebase_java_srcjars", |
| 188 "--java-srcjars=@($rebase_build_config:javac:srcjars)", |
167 "--jar-excluded-classes=$jar_excluded_patterns", | 189 "--jar-excluded-classes=$jar_excluded_patterns", |
168 ] | 190 ] |
169 if (chromium_code) { | 191 if (chromium_code) { |
170 args += [ "--chromium-code" ] | 192 args += [ "--chromium-code" ] |
171 } | 193 } |
172 | 194 |
173 args += rebase_path(java_files, root_build_dir) | 195 args += rebase_path(java_files, root_build_dir) |
174 } | 196 } |
175 | 197 |
176 # TODO(cjhopman): proguard | 198 # TODO(cjhopman): proguard |
(...skipping 16 matching lines...) Expand all Loading... |
193 } | 215 } |
194 | 216 |
195 group(target_name) { | 217 group(target_name) { |
196 deps = [ | 218 deps = [ |
197 ":${target_name}__javac", | 219 ":${target_name}__javac", |
198 ":${target_name}__jar_toc", | 220 ":${target_name}__jar_toc", |
199 ] | 221 ] |
200 } | 222 } |
201 } | 223 } |
202 | 224 |
| 225 |
203 # This adds Android-specific parts to the java_library template. | 226 # This adds Android-specific parts to the java_library template. |
204 # | 227 # |
205 # Runs Android lint against the compiled java files. | 228 # Runs Android lint against the compiled java files. |
206 # Dexes the output jar for inclusion in an APK. | 229 # Dexes the output jar for inclusion in an APK. |
207 template("android_java_library") { | 230 template("android_java_library") { |
208 assert(defined(invoker.java_files)) | 231 assert(defined(invoker.java_files)) |
209 | 232 |
210 assert(defined(invoker.build_config)) | 233 assert(defined(invoker.build_config)) |
211 assert(defined(invoker.jar_path)) | 234 assert(defined(invoker.jar_path)) |
212 | 235 |
(...skipping 12 matching lines...) Expand all Loading... |
225 | 248 |
226 # TODO(cjhopman): lint | 249 # TODO(cjhopman): lint |
227 # TODO(cjhopman): dex | 250 # TODO(cjhopman): dex |
228 | 251 |
229 group(target_name) { | 252 group(target_name) { |
230 deps = [ | 253 deps = [ |
231 ":${target_name}__java_library" | 254 ":${target_name}__java_library" |
232 ] | 255 ] |
233 } | 256 } |
234 } | 257 } |
| 258 |
| 259 |
| 260 # Runs process_resources.py |
| 261 template("process_resources") { |
| 262 zip_path = invoker.zip_path |
| 263 srcjar_path = invoker.srcjar_path |
| 264 build_config = invoker.build_config |
| 265 resource_dirs = invoker.resource_dirs |
| 266 android_manifest = invoker.android_manifest |
| 267 |
| 268 action(target_name) { |
| 269 script = "//build/android/gyp/process_resources.py" |
| 270 |
| 271 depfile = "$target_gen_dir/$target_name.d" |
| 272 outputs = [ |
| 273 depfile, |
| 274 zip_path, |
| 275 srcjar_path, |
| 276 ] |
| 277 |
| 278 sources_build_rel = exec_script( |
| 279 "//build/android/gyp/find.py", |
| 280 rebase_path(resource_dirs, root_build_dir), |
| 281 "list lines" |
| 282 ) |
| 283 sources = rebase_path(sources_build_rel, ".", root_build_dir) |
| 284 |
| 285 source_prereqs = [ |
| 286 build_config, |
| 287 android_manifest, |
| 288 ] |
| 289 |
| 290 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) |
| 291 rebase_build_config = rebase_path(build_config, root_build_dir) |
| 292 args = [ |
| 293 "--depfile", rebase_path(depfile, root_build_dir), |
| 294 "--android-sdk", rebase_path(android_sdk, root_build_dir), |
| 295 "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir
), |
| 296 "--non-constant-id", |
| 297 "--android-manifest", rebase_path(android_manifest, root_build_dir), |
| 298 |
| 299 "--resource-dirs=$rebase_resource_dirs", |
| 300 "--srcjar-out", rebase_path(srcjar_path, root_build_dir), |
| 301 "--resource-zip-out", rebase_path(zip_path, root_build_dir), |
| 302 |
| 303 "--dependencies-res-zips=@($rebase_build_config:resources:dependency_zips)
", |
| 304 ] |
| 305 |
| 306 if (defined(invoker.custom_package)) { |
| 307 args += [ |
| 308 "--custom-package", invoker.custom_package, |
| 309 ] |
| 310 } |
| 311 |
| 312 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) { |
| 313 args += ["--v14-verify-only"] |
| 314 } |
| 315 } |
| 316 } |
OLD | NEW |