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

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

Issue 766573003: gn format //build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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/config/android/internal_rules.gni ('k') | build/config/arm.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("//base/android/linker/config.gni") 5 import("//base/android/linker/config.gni")
6 import("//build/config/android/config.gni") 6 import("//build/config/android/config.gni")
7 import("//build/config/android/internal_rules.gni") 7 import("//build/config/android/internal_rules.gni")
8 import("//tools/grit/grit_rule.gni") 8 import("//tools/grit/grit_rule.gni")
9 import("//tools/relocation_packer/config.gni") 9 import("//tools/relocation_packer/config.gni")
10 10
(...skipping 12 matching lines...) Expand all
23 # 23 #
24 # Example 24 # Example
25 # generate_jni("foo_jni") { 25 # generate_jni("foo_jni") {
26 # sources = [ 26 # sources = [
27 # "android/java/src/org/chromium/foo/Foo.java", 27 # "android/java/src/org/chromium/foo/Foo.java",
28 # "android/java/src/org/chromium/foo/FooUtil.java", 28 # "android/java/src/org/chromium/foo/FooUtil.java",
29 # ] 29 # ]
30 # jni_package = "foo" 30 # jni_package = "foo"
31 # } 31 # }
32 template("generate_jni") { 32 template("generate_jni") {
33 if (defined(invoker.testonly)) { testonly = invoker.testonly } 33 if (defined(invoker.testonly)) {
34 testonly = invoker.testonly
35 }
34 36
35 assert(defined(invoker.sources)) 37 assert(defined(invoker.sources))
36 assert(defined(invoker.jni_package)) 38 assert(defined(invoker.jni_package))
37 jni_package = invoker.jni_package 39 jni_package = invoker.jni_package
38 base_output_dir = "${target_gen_dir}/${target_name}" 40 base_output_dir = "${target_gen_dir}/${target_name}"
39 package_output_dir = "${base_output_dir}/${jni_package}" 41 package_output_dir = "${base_output_dir}/${jni_package}"
40 jni_output_dir = "${package_output_dir}/jni" 42 jni_output_dir = "${package_output_dir}/jni"
41 43
42 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h" 44 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h"
43 45
44 foreach_target_name = "${target_name}__jni_gen" 46 foreach_target_name = "${target_name}__jni_gen"
45 action_foreach(foreach_target_name) { 47 action_foreach(foreach_target_name) {
46 script = "//base/android/jni_generator/jni_generator.py" 48 script = "//base/android/jni_generator/jni_generator.py"
47 depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d" 49 depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d"
48 sources = invoker.sources 50 sources = invoker.sources
49 inputs = [ jni_generator_include ] 51 inputs = [
52 jni_generator_include,
53 ]
50 outputs = [ 54 outputs = [
51 depfile, 55 depfile,
52 "${jni_output_dir}/{{source_name_part}}_jni.h" 56 "${jni_output_dir}/{{source_name_part}}_jni.h",
53 ] 57 ]
54 58
55 args = [ 59 args = [
56 "--depfile", rebase_path(depfile, root_build_dir), 60 "--depfile",
61 rebase_path(depfile, root_build_dir),
57 "--input_file={{source}}", 62 "--input_file={{source}}",
58 "--optimize_generation=1", 63 "--optimize_generation=1",
59 "--ptr_type=long", 64 "--ptr_type=long",
60 "--output_dir", rebase_path(jni_output_dir, root_build_dir), 65 "--output_dir",
61 "--includes", rebase_path(jni_generator_include, "//"), 66 rebase_path(jni_output_dir, root_build_dir),
67 "--includes",
68 rebase_path(jni_generator_include, "//"),
62 ] 69 ]
63 if (defined(invoker.jni_generator_jarjar_file)) { 70 if (defined(invoker.jni_generator_jarjar_file)) {
64 args += [ 71 args += [
65 "--jarjar", rebase_path(jni_generator_jarjar_file, root_build_dir), 72 "--jarjar",
73 rebase_path(jni_generator_jarjar_file, root_build_dir),
66 ] 74 ]
67 } 75 }
68 } 76 }
69 77
70 config("jni_includes_${target_name}") { 78 config("jni_includes_${target_name}") {
71 # TODO(cjhopman): #includes should probably all be relative to 79 # TODO(cjhopman): #includes should probably all be relative to
72 # base_output_dir. Remove that from this config once the includes are 80 # base_output_dir. Remove that from this config once the includes are
73 # updated. 81 # updated.
74 include_dirs = [ 82 include_dirs = [
75 base_output_dir, 83 base_output_dir,
76 package_output_dir, 84 package_output_dir,
77 ] 85 ]
78 } 86 }
79 87
80 group(target_name) { 88 group(target_name) {
81 deps = [ ":$foreach_target_name" ] 89 deps = [
90 ":$foreach_target_name",
91 ]
82 public_configs = [ ":jni_includes_${target_name}" ] 92 public_configs = [ ":jni_includes_${target_name}" ]
83 93
84 if (defined(invoker.deps)) { 94 if (defined(invoker.deps)) {
85 deps += invoker.deps 95 deps += invoker.deps
86 } 96 }
87 if (defined(invoker.public_deps)) { 97 if (defined(invoker.public_deps)) {
88 public_deps = invoker.public_deps 98 public_deps = invoker.public_deps
89 } 99 }
90 100
91 if (defined(invoker.visibility)) { visibility = invoker.visibility } 101 if (defined(invoker.visibility)) {
102 visibility = invoker.visibility
103 }
92 } 104 }
93 } 105 }
94 106
95
96 # Declare a jni target for a prebuilt jar 107 # Declare a jni target for a prebuilt jar
97 # 108 #
98 # This target generates the native jni bindings for a set of classes in a .jar. 109 # This target generates the native jni bindings for a set of classes in a .jar.
99 # 110 #
100 # See base/android/jni_generator/jni_generator.py for more info about the 111 # See base/android/jni_generator/jni_generator.py for more info about the
101 # format of generating JNI bindings. 112 # format of generating JNI bindings.
102 # 113 #
103 # Variables 114 # Variables
104 # classes: list of .class files in the jar to generate jni for. These should 115 # classes: list of .class files in the jar to generate jni for. These should
105 # include the full path to the .class file. 116 # include the full path to the .class file.
106 # jni_package: subdirectory path for generated bindings 117 # jni_package: subdirectory path for generated bindings
107 # jar_file: the path to the .jar. If not provided, will default to the sdk's 118 # jar_file: the path to the .jar. If not provided, will default to the sdk's
108 # android.jar 119 # android.jar
109 # 120 #
110 # deps, public_deps: As normal 121 # deps, public_deps: As normal
111 # 122 #
112 # Example 123 # Example
113 # generate_jar_jni("foo_jni") { 124 # generate_jar_jni("foo_jni") {
114 # classes = [ 125 # classes = [
115 # "android/view/Foo.class", 126 # "android/view/Foo.class",
116 # ] 127 # ]
117 # jni_package = "foo" 128 # jni_package = "foo"
118 # } 129 # }
119 template("generate_jar_jni") { 130 template("generate_jar_jni") {
120 if (defined(invoker.testonly)) { testonly = invoker.testonly } 131 if (defined(invoker.testonly)) {
132 testonly = invoker.testonly
133 }
121 134
122 assert(defined(invoker.classes)) 135 assert(defined(invoker.classes))
123 assert(defined(invoker.jni_package)) 136 assert(defined(invoker.jni_package))
124 137
125 if (defined(invoker.jar_file)) { 138 if (defined(invoker.jar_file)) {
126 jar_file = invoker.jar_file 139 jar_file = invoker.jar_file
127 } else { 140 } else {
128 jar_file = android_sdk_jar 141 jar_file = android_sdk_jar
129 } 142 }
130 143
131 jni_package = invoker.jni_package 144 jni_package = invoker.jni_package
132 base_output_dir = "${root_gen_dir}/${target_name}/${jni_package}" 145 base_output_dir = "${root_gen_dir}/${target_name}/${jni_package}"
133 jni_output_dir = "${base_output_dir}/jni" 146 jni_output_dir = "${base_output_dir}/jni"
134 147
135 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h" 148 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h"
136 149
137 # TODO(cjhopman): make jni_generator.py support generating jni for multiple 150 # TODO(cjhopman): make jni_generator.py support generating jni for multiple
138 # .class files from a .jar. 151 # .class files from a .jar.
139 jni_actions = [] 152 jni_actions = []
140 foreach(class, invoker.classes) { 153 foreach(class, invoker.classes) {
141 _classname_list = [] 154 _classname_list = []
142 _classname_list = process_file_template( 155 _classname_list = process_file_template([ class ], "{{source_name_part}}")
143 [class], "{{source_name_part}}")
144 classname = _classname_list[0] 156 classname = _classname_list[0]
145 jni_target_name = "${target_name}__jni_${classname}" 157 jni_target_name = "${target_name}__jni_${classname}"
146 jni_actions += [ ":$jni_target_name" ] 158 jni_actions += [ ":$jni_target_name" ]
147 action(jni_target_name) { 159 action(jni_target_name) {
148 depfile = "$target_gen_dir/$target_name.d" 160 depfile = "$target_gen_dir/$target_name.d"
149 script = "//base/android/jni_generator/jni_generator.py" 161 script = "//base/android/jni_generator/jni_generator.py"
150 sources = [ 162 sources = [
151 jni_generator_include, 163 jni_generator_include,
152 jar_file, 164 jar_file,
153 ] 165 ]
154 outputs = [ 166 outputs = [
155 depfile, 167 depfile,
156 "${jni_output_dir}/${classname}_jni.h" 168 "${jni_output_dir}/${classname}_jni.h",
157 ] 169 ]
158 170
159 args = [ 171 args = [
160 "--depfile", rebase_path(depfile, root_build_dir), 172 "--depfile",
161 "--jar_file", rebase_path(jar_file, root_build_dir), 173 rebase_path(depfile, root_build_dir),
162 "--input_file", class, 174 "--jar_file",
175 rebase_path(jar_file, root_build_dir),
176 "--input_file",
177 class,
163 "--optimize_generation=1", 178 "--optimize_generation=1",
164 "--ptr_type=long", 179 "--ptr_type=long",
165 "--output_dir", rebase_path(jni_output_dir, root_build_dir), 180 "--output_dir",
166 "--includes", rebase_path(jni_generator_include, root_build_dir), 181 rebase_path(jni_output_dir, root_build_dir),
182 "--includes",
183 rebase_path(jni_generator_include, root_build_dir),
167 ] 184 ]
168 } 185 }
169 } 186 }
170 187
171 config("jni_includes_${target_name}") { 188 config("jni_includes_${target_name}") {
172 include_dirs = [ base_output_dir ] 189 include_dirs = [ base_output_dir ]
173 } 190 }
174 191
175 group(target_name) { 192 group(target_name) {
176 deps = jni_actions 193 deps = jni_actions
177 if (defined(invoker.deps)) { 194 if (defined(invoker.deps)) {
178 deps += invoker.deps 195 deps += invoker.deps
179 } 196 }
180 if (defined(invoker.public_deps)) { 197 if (defined(invoker.public_deps)) {
181 public_deps = invoker.public_deps 198 public_deps = invoker.public_deps
182 } 199 }
183 public_configs = [ ":jni_includes_${target_name}" ] 200 public_configs = [ ":jni_includes_${target_name}" ]
184 } 201 }
185 } 202 }
186 203
187
188 # Declare a target for c-preprocessor-generated java files 204 # Declare a target for c-preprocessor-generated java files
189 # 205 #
190 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum 206 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
191 # rule instead. 207 # rule instead.
192 # 208 #
193 # This target generates java files using the host C pre-processor. Each file in 209 # This target generates java files using the host C pre-processor. Each file in
194 # sources will be compiled using the C pre-processor. If include_path is 210 # sources will be compiled using the C pre-processor. If include_path is
195 # specified, it will be passed (with --I) to the pre-processor. 211 # specified, it will be passed (with --I) to the pre-processor.
196 # 212 #
197 # This target will create a single .srcjar. Adding this target to an 213 # This target will create a single .srcjar. Adding this target to an
(...skipping 16 matching lines...) Expand all
214 # "android/java/templates/Foo.template", 230 # "android/java/templates/Foo.template",
215 # ] 231 # ]
216 # inputs = [ 232 # inputs = [
217 # "android/java/templates/native_foo_header.h", 233 # "android/java/templates/native_foo_header.h",
218 # ] 234 # ]
219 # 235 #
220 # package_name = "org/chromium/base/library_loader" 236 # package_name = "org/chromium/base/library_loader"
221 # include_path = "android/java/templates" 237 # include_path = "android/java/templates"
222 # } 238 # }
223 template("java_cpp_template") { 239 template("java_cpp_template") {
224 if (defined(invoker.testonly)) { testonly = invoker.testonly } 240 if (defined(invoker.testonly)) {
241 testonly = invoker.testonly
242 }
225 243
226 assert(defined(invoker.sources)) 244 assert(defined(invoker.sources))
227 package_name = invoker.package_name + "" 245 package_name = invoker.package_name + ""
228 246
229 if (defined(invoker.include_path)) { 247 if (defined(invoker.include_path)) {
230 include_path = invoker.include_path + "" 248 include_path = invoker.include_path + ""
231 } else { 249 } else {
232 include_path = "//" 250 include_path = "//"
233 } 251 }
234 252
235 action_foreach("${target_name}__apply_gcc") { 253 action_foreach("${target_name}__apply_gcc") {
236 script = "//build/android/gyp/gcc_preprocess.py" 254 script = "//build/android/gyp/gcc_preprocess.py"
237 if (defined(invoker.inputs)) { 255 if (defined(invoker.inputs)) {
238 inputs = invoker.inputs + [] 256 inputs = invoker.inputs + []
239 } 257 }
240 depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d" 258 depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d"
241 259
242 sources = invoker.sources 260 sources = invoker.sources
243 261
244 gen_dir = "${target_gen_dir}/${target_name}/java_cpp_template/${package_name }" 262 gen_dir =
263 "${target_gen_dir}/${target_name}/java_cpp_template/${package_name}"
245 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" 264 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java"
246 265
247 outputs = [ 266 outputs = [
248 depfile, 267 depfile,
249 gcc_template_output_pattern 268 gcc_template_output_pattern,
250 ] 269 ]
251 270
252 args = [ 271 args = [
253 "--depfile", rebase_path(depfile, root_build_dir), 272 "--depfile",
254 "--include-path", rebase_path(include_path, root_build_dir), 273 rebase_path(depfile, root_build_dir),
255 "--output", rebase_path(gen_dir, root_build_dir) + "/{{source_name_part}}. java", 274 "--include-path",
275 rebase_path(include_path, root_build_dir),
276 "--output",
277 rebase_path(gen_dir, root_build_dir) + "/{{source_name_part}}.java",
256 "--template={{source}}", 278 "--template={{source}}",
257 ] 279 ]
258 280
259 if (defined(invoker.defines)) { 281 if (defined(invoker.defines)) {
260 foreach(def, invoker.defines) { 282 foreach(def, invoker.defines) {
261 args += ["--defines", def] 283 args += [
284 "--defines",
285 def,
286 ]
262 } 287 }
263 } 288 }
264 } 289 }
265 290
266 apply_gcc_outputs = get_target_outputs(":${target_name}__apply_gcc") 291 apply_gcc_outputs = get_target_outputs(":${target_name}__apply_gcc")
267 base_gen_dir = get_label_info(":${target_name}__apply_gcc", "target_gen_dir") 292 base_gen_dir = get_label_info(":${target_name}__apply_gcc", "target_gen_dir")
268 293
269 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" 294 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
270 zip("${target_name}__zip_srcjar") { 295 zip("${target_name}__zip_srcjar") {
271 inputs = apply_gcc_outputs 296 inputs = apply_gcc_outputs
272 output = srcjar_path 297 output = srcjar_path
273 base_dir = base_gen_dir 298 base_dir = base_gen_dir
274 } 299 }
275 300
276 group(target_name) { 301 group(target_name) {
277 deps = [ 302 deps = [
278 ":${target_name}__zip_srcjar" 303 ":${target_name}__zip_srcjar",
279 ] 304 ]
280 } 305 }
281 } 306 }
282 307
283 # Declare a target for generating Java classes from C++ enums. 308 # Declare a target for generating Java classes from C++ enums.
284 # 309 #
285 # This target generates Java files from C++ enums using a script. 310 # This target generates Java files from C++ enums using a script.
286 # 311 #
287 # This target will create a single .srcjar. Adding this target to an 312 # This target will create a single .srcjar. Adding this target to an
288 # android_library target's srcjar_deps will make the generated java files be 313 # android_library target's srcjar_deps will make the generated java files be
(...skipping 12 matching lines...) Expand all
301 # Example 326 # Example
302 # java_cpp_enum("foo_generated_enum") { 327 # java_cpp_enum("foo_generated_enum") {
303 # sources = [ 328 # sources = [
304 # "src/native_foo_header.h", 329 # "src/native_foo_header.h",
305 # ] 330 # ]
306 # outputs = [ 331 # outputs = [
307 # "org/chromium/FooEnum.java", 332 # "org/chromium/FooEnum.java",
308 # ] 333 # ]
309 # } 334 # }
310 template("java_cpp_enum") { 335 template("java_cpp_enum") {
311 if (defined(invoker.testonly)) { testonly = invoker.testonly } 336 if (defined(invoker.testonly)) {
337 testonly = invoker.testonly
338 }
312 339
313 assert(defined(invoker.sources)) 340 assert(defined(invoker.sources))
314 assert(defined(invoker.outputs)) 341 assert(defined(invoker.outputs))
315 342
316 action("${target_name}__generate_enum") { 343 action("${target_name}__generate_enum") {
317 sources = invoker.sources 344 sources = invoker.sources
318 script = "//build/android/gyp/java_cpp_enum.py" 345 script = "//build/android/gyp/java_cpp_enum.py"
319 gen_dir = "${target_gen_dir}/${target_name}/enums" 346 gen_dir = "${target_gen_dir}/${target_name}/enums"
320 outputs = get_path_info( 347 outputs =
321 rebase_path(invoker.outputs, ".", gen_dir), "abspath") 348 get_path_info(rebase_path(invoker.outputs, ".", gen_dir), "abspath")
322 349
323 args = [ 350 args = [
324 "--output_dir", rebase_path(gen_dir, root_build_dir), 351 "--output_dir",
352 rebase_path(gen_dir, root_build_dir),
325 ] 353 ]
326 foreach(output, rebase_path(outputs, root_build_dir)) { 354 foreach(output, rebase_path(outputs, root_build_dir)) {
327 args += ["--assert_file", output] 355 args += [
356 "--assert_file",
357 output,
358 ]
328 } 359 }
329 args += rebase_path(invoker.sources, root_build_dir) 360 args += rebase_path(invoker.sources, root_build_dir)
330 } 361 }
331 362
332 generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum") 363 generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
333 base_gen_dir = get_label_info(":${target_name}__generate_enum", 364 base_gen_dir =
334 "target_gen_dir") 365 get_label_info(":${target_name}__generate_enum", "target_gen_dir")
335 366
336 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" 367 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
337 zip("${target_name}__zip_srcjar") { 368 zip("${target_name}__zip_srcjar") {
338 inputs = generate_enum_outputs 369 inputs = generate_enum_outputs
339 output = srcjar_path 370 output = srcjar_path
340 base_dir = base_gen_dir 371 base_dir = base_gen_dir
341 } 372 }
342 373
343 group(target_name) { 374 group(target_name) {
344 deps = [ 375 deps = [
345 ":${target_name}__zip_srcjar" 376 ":${target_name}__zip_srcjar",
346 ] 377 ]
347 } 378 }
348 } 379 }
349 380
350 # Declare a target for processing a Jinja template. 381 # Declare a target for processing a Jinja template.
351 # 382 #
352 # Variables 383 # Variables
353 # input: The template file to be processed. 384 # input: The template file to be processed.
354 # output: Where to save the result. 385 # output: Where to save the result.
355 # variables: (Optional) A list of variables to make available to the template 386 # variables: (Optional) A list of variables to make available to the template
356 # processing environment, e.g. ["name=foo", "color=red"]. 387 # processing environment, e.g. ["name=foo", "color=red"].
357 # 388 #
358 # Example 389 # Example
359 # jinja_template("chrome_shell_manifest") { 390 # jinja_template("chrome_shell_manifest") {
360 # input = "shell/java/AndroidManifest.xml" 391 # input = "shell/java/AndroidManifest.xml"
361 # output = "$target_gen_dir/AndroidManifest.xml" 392 # output = "$target_gen_dir/AndroidManifest.xml"
362 # } 393 # }
363 template("jinja_template") { 394 template("jinja_template") {
364 if (defined(invoker.testonly)) { testonly = invoker.testonly } 395 if (defined(invoker.testonly)) {
396 testonly = invoker.testonly
397 }
365 398
366 assert(defined(invoker.input)) 399 assert(defined(invoker.input))
367 assert(defined(invoker.output)) 400 assert(defined(invoker.output))
368 401
369 action(target_name) { 402 action(target_name) {
370 sources = [invoker.input] 403 sources = [
404 invoker.input,
405 ]
371 script = "//build/android/gyp/jinja_template.py" 406 script = "//build/android/gyp/jinja_template.py"
372 depfile = "$target_gen_dir/$target_name.d" 407 depfile = "$target_gen_dir/$target_name.d"
373 408
374 outputs = [ 409 outputs = [
375 depfile, 410 depfile,
376 invoker.output, 411 invoker.output,
377 ] 412 ]
378 413
379 args = [ 414 args = [
380 "--inputs", rebase_path(invoker.input, root_build_dir), 415 "--inputs",
381 "--output", rebase_path(invoker.output, root_build_dir), 416 rebase_path(invoker.input, root_build_dir),
382 "--depfile", rebase_path(depfile, root_build_dir), 417 "--output",
418 rebase_path(invoker.output, root_build_dir),
419 "--depfile",
420 rebase_path(depfile, root_build_dir),
383 ] 421 ]
384 if (defined(invoker.variables)) { 422 if (defined(invoker.variables)) {
385 variables = invoker.variables 423 variables = invoker.variables
386 args += ["--variables=${variables}" ] 424 args += [ "--variables=${variables}" ]
387 } 425 }
388 } 426 }
389 } 427 }
390 428
391 # Declare a target for processing Android resources as Jinja templates. 429 # Declare a target for processing Android resources as Jinja templates.
392 # 430 #
393 # This takes an Android resource directory where each resource is a Jinja 431 # This takes an Android resource directory where each resource is a Jinja
394 # template, processes each template, then packages the results in a zip file 432 # template, processes each template, then packages the results in a zip file
395 # which can be consumed by an android resources, library, or apk target. 433 # which can be consumed by an android resources, library, or apk target.
396 # 434 #
397 # If this target is included in the deps of an android resources/library/apk, 435 # If this target is included in the deps of an android resources/library/apk,
398 # the resources will be included with that target. 436 # the resources will be included with that target.
399 # 437 #
400 # Variables 438 # Variables
401 # resources: The list of resources files to process. 439 # resources: The list of resources files to process.
402 # res_dir: The resource directory containing the resources. 440 # res_dir: The resource directory containing the resources.
403 # variables: (Optional) A list of variables to make available to the template 441 # variables: (Optional) A list of variables to make available to the template
404 # processing environment, e.g. ["name=foo", "color=red"]. 442 # processing environment, e.g. ["name=foo", "color=red"].
405 # 443 #
406 # Example 444 # Example
407 # jinja_template_resources("chrome_shell_template_resources") { 445 # jinja_template_resources("chrome_shell_template_resources") {
408 # res_dir = "shell/res_template" 446 # res_dir = "shell/res_template"
409 # resources = ["shell/res_template/xml/syncable.xml"] 447 # resources = ["shell/res_template/xml/syncable.xml"]
410 # variables = ["color=red"] 448 # variables = ["color=red"]
411 # } 449 # }
412 template("jinja_template_resources") { 450 template("jinja_template_resources") {
413 if (defined(invoker.testonly)) { testonly = invoker.testonly } 451 if (defined(invoker.testonly)) {
452 testonly = invoker.testonly
453 }
414 454
415 assert(defined(invoker.resources)) 455 assert(defined(invoker.resources))
416 assert(defined(invoker.res_dir)) 456 assert(defined(invoker.res_dir))
417 457
418 _base_path = "$target_gen_dir/$target_name" 458 _base_path = "$target_gen_dir/$target_name"
419 _resources_zip = _base_path + ".resources.zip" 459 _resources_zip = _base_path + ".resources.zip"
420 _build_config = _base_path + ".build_config" 460 _build_config = _base_path + ".build_config"
421 461
422 write_build_config("${target_name}__build_config") { 462 write_build_config("${target_name}__build_config") {
423 build_config = _build_config 463 build_config = _build_config
424 resources_zip = _resources_zip 464 resources_zip = _resources_zip
425 type = "android_resources" 465 type = "android_resources"
426 } 466 }
427 467
428 action("${target_name}__template") { 468 action("${target_name}__template") {
429 sources = invoker.resources 469 sources = invoker.resources
430 script = "//build/android/gyp/jinja_template.py" 470 script = "//build/android/gyp/jinja_template.py"
431 depfile = "$target_gen_dir/$target_name.d" 471 depfile = "$target_gen_dir/$target_name.d"
432 472
433 outputs = [ 473 outputs = [
434 depfile, 474 depfile,
435 _resources_zip, 475 _resources_zip,
436 ] 476 ]
437 477
438 rebased_resources = rebase_path(invoker.resources, root_build_dir) 478 rebased_resources = rebase_path(invoker.resources, root_build_dir)
439 args = [ 479 args = [
440 "--inputs=${rebased_resources}", 480 "--inputs=${rebased_resources}",
441 "--inputs-base-dir", rebase_path(invoker.res_dir, root_build_dir), 481 "--inputs-base-dir",
442 "--outputs-zip", rebase_path(_resources_zip, root_build_dir), 482 rebase_path(invoker.res_dir, root_build_dir),
443 "--depfile", rebase_path(depfile, root_build_dir), 483 "--outputs-zip",
484 rebase_path(_resources_zip, root_build_dir),
485 "--depfile",
486 rebase_path(depfile, root_build_dir),
444 ] 487 ]
445 if (defined(invoker.variables)) { 488 if (defined(invoker.variables)) {
446 variables = invoker.variables 489 variables = invoker.variables
447 args += ["--variables=${variables}" ] 490 args += [ "--variables=${variables}" ]
448 } 491 }
449 } 492 }
450 493
451 group(target_name) { 494 group(target_name) {
452 deps = [ 495 deps = [
453 ":${target_name}__build_config", 496 ":${target_name}__build_config",
454 ":${target_name}__template", 497 ":${target_name}__template",
455 ] 498 ]
456 } 499 }
457 } 500 }
(...skipping 22 matching lines...) Expand all
480 # shared_resources: If true make a resource package that can be loaded by a 523 # shared_resources: If true make a resource package that can be loaded by a
481 # different application at runtime to access the package's resources. 524 # different application at runtime to access the package's resources.
482 # 525 #
483 # Example 526 # Example
484 # android_resources("foo_resources") { 527 # android_resources("foo_resources") {
485 # deps = [":foo_strings_grd"] 528 # deps = [":foo_strings_grd"]
486 # resource_dirs = ["res"] 529 # resource_dirs = ["res"]
487 # custom_package = "org.chromium.foo" 530 # custom_package = "org.chromium.foo"
488 # } 531 # }
489 template("android_resources") { 532 template("android_resources") {
490 if (defined(invoker.testonly)) { testonly = invoker.testonly } 533 if (defined(invoker.testonly)) {
534 testonly = invoker.testonly
535 }
491 536
492 assert(defined(invoker.resource_dirs)) 537 assert(defined(invoker.resource_dirs))
493 assert(defined(invoker.android_manifest) || defined(invoker.custom_package)) 538 assert(defined(invoker.android_manifest) || defined(invoker.custom_package))
494 539
495 base_path = "$target_gen_dir/$target_name" 540 base_path = "$target_gen_dir/$target_name"
496 zip_path = base_path + ".resources.zip" 541 zip_path = base_path + ".resources.zip"
497 srcjar_path = base_path + ".srcjar" 542 srcjar_path = base_path + ".srcjar"
498 build_config = base_path + ".build_config" 543 build_config = base_path + ".build_config"
499 544
500 write_build_config("${target_name}__build_config") { 545 write_build_config("${target_name}__build_config") {
501 type = "android_resources" 546 type = "android_resources"
502 resources_zip = zip_path 547 resources_zip = zip_path
503 srcjar = srcjar_path 548 srcjar = srcjar_path
504 if (defined(invoker.deps)) { deps = invoker.deps } 549 if (defined(invoker.deps)) {
505 if (defined(invoker.android_manifest)) { android_manifest = invoker.android_ manifest } 550 deps = invoker.deps
506 if (defined(invoker.custom_package)) { custom_package = invoker.custom_packa ge } 551 }
552 if (defined(invoker.android_manifest)) {
553 android_manifest = invoker.android_manifest
554 }
555 if (defined(invoker.custom_package)) {
556 custom_package = invoker.custom_package
557 }
507 } 558 }
508 559
509 android_manifest = "//build/android/AndroidManifest.xml" 560 android_manifest = "//build/android/AndroidManifest.xml"
510 if (defined(invoker.android_manifest)) { 561 if (defined(invoker.android_manifest)) {
511 android_manifest = invoker.android_manifest 562 android_manifest = invoker.android_manifest
512 } 563 }
513 564
514 process_resources("${target_name}__process_resources") { 565 process_resources("${target_name}__process_resources") {
515 resource_dirs = invoker.resource_dirs 566 resource_dirs = invoker.resource_dirs
516 if (defined(invoker.custom_package)) { 567 if (defined(invoker.custom_package)) {
(...skipping 10 matching lines...) Expand all
527 } 578 }
528 579
529 group(target_name) { 580 group(target_name) {
530 deps = [ 581 deps = [
531 ":${target_name}__build_config", 582 ":${target_name}__build_config",
532 ":${target_name}__process_resources", 583 ":${target_name}__process_resources",
533 ] 584 ]
534 } 585 }
535 } 586 }
536 587
537
538 # Declare a target that generates localized strings.xml from a .grd file. 588 # Declare a target that generates localized strings.xml from a .grd file.
539 # 589 #
540 # If this target is included in the deps of an android resources/library/apk, 590 # If this target is included in the deps of an android resources/library/apk,
541 # the strings.xml will be included with that target. 591 # the strings.xml will be included with that target.
542 # 592 #
543 # Variables 593 # Variables
544 # deps: Specifies the dependencies of this target. 594 # deps: Specifies the dependencies of this target.
545 # grd_file: Path to the .grd file to generate strings.xml from. 595 # grd_file: Path to the .grd file to generate strings.xml from.
546 # outputs: Expected grit outputs (see grit rule). 596 # outputs: Expected grit outputs (see grit rule).
547 # 597 #
548 # Example 598 # Example
549 # java_strings_grd("foo_strings_grd") { 599 # java_strings_grd("foo_strings_grd") {
550 # grd_file = "foo_strings.grd" 600 # grd_file = "foo_strings.grd"
551 # } 601 # }
552 template("java_strings_grd") { 602 template("java_strings_grd") {
553 if (defined(invoker.testonly)) { testonly = invoker.testonly } 603 if (defined(invoker.testonly)) {
604 testonly = invoker.testonly
605 }
554 606
555 base_path = "$target_gen_dir/$target_name" 607 base_path = "$target_gen_dir/$target_name"
556 resources_zip = base_path + ".resources.zip" 608 resources_zip = base_path + ".resources.zip"
557 build_config = base_path + ".build_config" 609 build_config = base_path + ".build_config"
558 610
559 write_build_config("${target_name}__build_config") { 611 write_build_config("${target_name}__build_config") {
560 type = "android_resources" 612 type = "android_resources"
561 if (defined(invoker.deps)) { 613 if (defined(invoker.deps)) {
562 deps = invoker.deps 614 deps = invoker.deps
563 } 615 }
564 } 616 }
565 617
566 # Put grit files into this subdirectory of target_gen_dir. 618 # Put grit files into this subdirectory of target_gen_dir.
567 extra_output_path = target_name + "_grit_output" 619 extra_output_path = target_name + "_grit_output"
568 620
569 grit_target_name = "${target_name}__grit" 621 grit_target_name = "${target_name}__grit"
570 grit_output_dir = "$target_gen_dir/$extra_output_path" 622 grit_output_dir = "$target_gen_dir/$extra_output_path"
571 grit(grit_target_name) { 623 grit(grit_target_name) {
572 grit_flags = [ 624 grit_flags = [
573 "-E", "ANDROID_JAVA_TAGGED_ONLY=false", 625 "-E",
626 "ANDROID_JAVA_TAGGED_ONLY=false",
574 ] 627 ]
575 output_dir = grit_output_dir 628 output_dir = grit_output_dir
576 resource_ids = "" 629 resource_ids = ""
577 source = invoker.grd_file 630 source = invoker.grd_file
578 outputs = invoker.outputs 631 outputs = invoker.outputs
579 } 632 }
580 633
581 # This needs to get outputs from grit's internal target, not the final 634 # This needs to get outputs from grit's internal target, not the final
582 # source_set. 635 # source_set.
583 generate_strings_outputs = get_target_outputs(":${grit_target_name}_grit") 636 generate_strings_outputs = get_target_outputs(":${grit_target_name}_grit")
(...skipping 22 matching lines...) Expand all
606 # generated_files: list of android resource files to package. 659 # generated_files: list of android resource files to package.
607 # 660 #
608 # Example 661 # Example
609 # java_strings_grd_prebuilt("foo_strings_grd") { 662 # java_strings_grd_prebuilt("foo_strings_grd") {
610 # grit_output_dir = "$root_gen_dir/foo/grit" 663 # grit_output_dir = "$root_gen_dir/foo/grit"
611 # generated_files = [ 664 # generated_files = [
612 # "values/strings.xml" 665 # "values/strings.xml"
613 # ] 666 # ]
614 # } 667 # }
615 template("java_strings_grd_prebuilt") { 668 template("java_strings_grd_prebuilt") {
616 if (defined(invoker.testonly)) { testonly = invoker.testonly } 669 if (defined(invoker.testonly)) {
670 testonly = invoker.testonly
671 }
617 672
618 base_path = "$target_gen_dir/$target_name" 673 base_path = "$target_gen_dir/$target_name"
619 resources_zip = base_path + ".resources.zip" 674 resources_zip = base_path + ".resources.zip"
620 build_config = base_path + ".build_config" 675 build_config = base_path + ".build_config"
621 676
622 write_build_config("${target_name}__build_config") { 677 write_build_config("${target_name}__build_config") {
623 type = "android_resources" 678 type = "android_resources"
624 if (defined(invoker.deps)) { 679 if (defined(invoker.deps)) {
625 deps = invoker.deps 680 deps = invoker.deps
626 } 681 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 # Example 721 # Example
667 # java_library("foo") { 722 # java_library("foo") {
668 # java_files = [ "org/chromium/foo/FooMain.java" ] 723 # java_files = [ "org/chromium/foo/FooMain.java" ]
669 # deps = [ ":bar_java" ] 724 # deps = [ ":bar_java" ]
670 # main_class = "org.chromium.foo.FooMain" 725 # main_class = "org.chromium.foo.FooMain"
671 # } 726 # }
672 template("java_binary") { 727 template("java_binary") {
673 # TODO(cjhopman): This should not act like a java_library for dependents (i.e. 728 # TODO(cjhopman): This should not act like a java_library for dependents (i.e.
674 # dependents shouldn't get the jar in their classpath, etc.). 729 # dependents shouldn't get the jar in their classpath, etc.).
675 java_library_impl(target_name) { 730 java_library_impl(target_name) {
676 if (defined(invoker.DEPRECATED_java_in_dir)) { DEPRECATED_java_in_dir = invo ker.DEPRECATED_java_in_dir } 731 if (defined(invoker.DEPRECATED_java_in_dir)) {
677 if (defined(invoker.chromium_code)) { chromium_code = invoker.chromium_code } 732 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
678 if (defined(invoker.datadeps)) { deps = invoker.datadeps } 733 }
679 if (defined(invoker.deps)) { deps = invoker.deps } 734 if (defined(invoker.chromium_code)) {
680 if (defined(invoker.java_files)) { java_files = invoker.java_files } 735 chromium_code = invoker.chromium_code
681 if (defined(invoker.srcjar_deps)) { srcjar_deps = invoker.srcjar_deps } 736 }
682 if (defined(invoker.srcjars)) { srcjars = invoker.srcjars } 737 if (defined(invoker.datadeps)) {
683 if (defined(invoker.bypass_platform_checks)) { bypass_platform_checks = invo ker.bypass_platform_checks } 738 deps = invoker.datadeps
684 if (defined(invoker.testonly)) { testonly = invoker.testonly } 739 }
740 if (defined(invoker.deps)) {
741 deps = invoker.deps
742 }
743 if (defined(invoker.java_files)) {
744 java_files = invoker.java_files
745 }
746 if (defined(invoker.srcjar_deps)) {
747 srcjar_deps = invoker.srcjar_deps
748 }
749 if (defined(invoker.srcjars)) {
750 srcjars = invoker.srcjars
751 }
752 if (defined(invoker.bypass_platform_checks)) {
753 bypass_platform_checks = invoker.bypass_platform_checks
754 }
755 if (defined(invoker.testonly)) {
756 testonly = invoker.testonly
757 }
685 758
686 main_class = invoker.main_class 759 main_class = invoker.main_class
687 } 760 }
688 } 761 }
689 762
690
691 # Declare an java library target 763 # Declare an java library target
692 # 764 #
693 # Variables 765 # Variables
694 # deps: Specifies the dependencies of this target. Java targets in this list 766 # deps: Specifies the dependencies of this target. Java targets in this list
695 # will be added to the javac classpath. 767 # will be added to the javac classpath.
696 # 768 #
697 # java_files: List of .java files included in this library. 769 # java_files: List of .java files included in this library.
698 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars 770 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
699 # will be added to java_files and be included in this library. 771 # will be added to java_files and be included in this library.
700 # srcjars: List of srcjars to be included in this library, together with the 772 # srcjars: List of srcjars to be included in this library, together with the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 # ] 804 # ]
733 # srcjar_deps = [ 805 # srcjar_deps = [
734 # ":foo_generated_enum" 806 # ":foo_generated_enum"
735 # ] 807 # ]
736 # jar_excluded_patterns = [ 808 # jar_excluded_patterns = [
737 # "*/FooService.class", "*/FooService##*.class" 809 # "*/FooService.class", "*/FooService##*.class"
738 # ] 810 # ]
739 # } 811 # }
740 template("java_library") { 812 template("java_library") {
741 java_library_impl(target_name) { 813 java_library_impl(target_name) {
742 if (defined(invoker.DEPRECATED_java_in_dir)) { DEPRECATED_java_in_dir = invo ker.DEPRECATED_java_in_dir } 814 if (defined(invoker.DEPRECATED_java_in_dir)) {
743 if (defined(invoker.chromium_code)) { chromium_code = invoker.chromium_code } 815 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
744 if (defined(invoker.datadeps)) { deps = invoker.datadeps } 816 }
745 if (defined(invoker.deps)) { deps = invoker.deps } 817 if (defined(invoker.chromium_code)) {
746 if (defined(invoker.jar_excluded_patterns)) { jar_excluded_patterns = invoke r.jar_excluded_patterns } 818 chromium_code = invoker.chromium_code
747 if (defined(invoker.java_files)) { java_files = invoker.java_files } 819 }
748 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig } 820 if (defined(invoker.datadeps)) {
749 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess } 821 deps = invoker.datadeps
750 if (defined(invoker.srcjar_deps)) { srcjar_deps = invoker.srcjar_deps } 822 }
751 if (defined(invoker.srcjars)) { srcjars = invoker.srcjars } 823 if (defined(invoker.deps)) {
752 if (defined(invoker.bypass_platform_checks)) { bypass_platform_checks = invo ker.bypass_platform_checks } 824 deps = invoker.deps
753 if (defined(invoker.testonly)) { testonly = invoker.testonly } 825 }
754 if (defined(invoker.jar_path)) { jar_path = invoker.jar_path } 826 if (defined(invoker.jar_excluded_patterns)) {
827 jar_excluded_patterns = invoker.jar_excluded_patterns
828 }
829 if (defined(invoker.java_files)) {
830 java_files = invoker.java_files
831 }
832 if (defined(invoker.proguard_config)) {
833 proguard_config = invoker.proguard_config
834 }
835 if (defined(invoker.proguard_preprocess)) {
836 proguard_preprocess = invoker.proguard_preprocess
837 }
838 if (defined(invoker.srcjar_deps)) {
839 srcjar_deps = invoker.srcjar_deps
840 }
841 if (defined(invoker.srcjars)) {
842 srcjars = invoker.srcjars
843 }
844 if (defined(invoker.bypass_platform_checks)) {
845 bypass_platform_checks = invoker.bypass_platform_checks
846 }
847 if (defined(invoker.testonly)) {
848 testonly = invoker.testonly
849 }
850 if (defined(invoker.jar_path)) {
851 jar_path = invoker.jar_path
852 }
755 853
756 if (defined(invoker.supports_android) && invoker.supports_android) { 854 if (defined(invoker.supports_android) && invoker.supports_android) {
757 supports_android = true 855 supports_android = true
758 } 856 }
759 } 857 }
760 } 858 }
761 859
762
763 # Declare an java library target for a prebuilt jar 860 # Declare an java library target for a prebuilt jar
764 # 861 #
765 # Variables 862 # Variables
766 # deps: Specifies the dependencies of this target. Java targets in this list 863 # deps: Specifies the dependencies of this target. Java targets in this list
767 # will be added to the javac classpath. 864 # will be added to the javac classpath.
768 # jar_path: Path to the prebuilt jar. 865 # jar_path: Path to the prebuilt jar.
769 # proguard_preprocess: If true, proguard preprocessing will be run. This can 866 # proguard_preprocess: If true, proguard preprocessing will be run. This can
770 # be used to remove unwanted parts of the library. 867 # be used to remove unwanted parts of the library.
771 # proguard_config: Path to the proguard config for preprocessing. 868 # proguard_config: Path to the proguard config for preprocessing.
772 # 869 #
773 # Example 870 # Example
774 # java_prebuilt("foo_java") { 871 # java_prebuilt("foo_java") {
775 # jar_path = "foo.jar" 872 # jar_path = "foo.jar"
776 # deps = [ 873 # deps = [
777 # ":foo_resources", 874 # ":foo_resources",
778 # ":bar_java" 875 # ":bar_java"
779 # ] 876 # ]
780 # } 877 # }
781 template("java_prebuilt") { 878 template("java_prebuilt") {
782 java_prebuilt_impl(target_name) { 879 java_prebuilt_impl(target_name) {
783 jar_path = invoker.jar_path 880 jar_path = invoker.jar_path
784 if (defined(invoker.testonly)) { testonly = invoker.testonly } 881 if (defined(invoker.testonly)) {
785 if (defined(invoker.deps)) { deps = invoker.deps } 882 testonly = invoker.testonly
786 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig } 883 }
787 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess } 884 if (defined(invoker.deps)) {
885 deps = invoker.deps
886 }
887 if (defined(invoker.proguard_config)) {
888 proguard_config = invoker.proguard_config
889 }
890 if (defined(invoker.proguard_preprocess)) {
891 proguard_preprocess = invoker.proguard_preprocess
892 }
788 } 893 }
789 } 894 }
790 895
791 # Declare an Android library target 896 # Declare an Android library target
792 # 897 #
793 # This target creates an Android library containing java code and Android 898 # This target creates an Android library containing java code and Android
794 # resources. 899 # resources.
795 # 900 #
796 # Variables 901 # Variables
797 # deps: Specifies the dependencies of this target. Java targets in this list 902 # deps: Specifies the dependencies of this target. Java targets in this list
(...skipping 30 matching lines...) Expand all
828 # ] 933 # ]
829 # srcjar_deps = [ 934 # srcjar_deps = [
830 # ":foo_generated_enum" 935 # ":foo_generated_enum"
831 # ] 936 # ]
832 # jar_excluded_patterns = [ 937 # jar_excluded_patterns = [
833 # "*/FooService.class", "*/FooService##*.class" 938 # "*/FooService.class", "*/FooService##*.class"
834 # ] 939 # ]
835 # } 940 # }
836 template("android_library") { 941 template("android_library") {
837 assert(!defined(invoker.jar_path), 942 assert(!defined(invoker.jar_path),
838 "android_library does not support a custom jar path") 943 "android_library does not support a custom jar path")
839 java_library_impl(target_name) { 944 java_library_impl(target_name) {
840 if (defined(invoker.DEPRECATED_java_in_dir)) { DEPRECATED_java_in_dir = invo ker.DEPRECATED_java_in_dir } 945 if (defined(invoker.DEPRECATED_java_in_dir)) {
841 if (defined(invoker.chromium_code)) { chromium_code = invoker.chromium_code } 946 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
842 if (defined(invoker.datadeps)) { deps = invoker.datadeps } 947 }
843 if (defined(invoker.deps)) { deps = invoker.deps } 948 if (defined(invoker.chromium_code)) {
844 if (defined(invoker.jar_excluded_patterns)) { jar_excluded_patterns = invoke r.jar_excluded_patterns } 949 chromium_code = invoker.chromium_code
845 if (defined(invoker.java_files)) { java_files = invoker.java_files } 950 }
846 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig } 951 if (defined(invoker.datadeps)) {
847 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess } 952 deps = invoker.datadeps
848 if (defined(invoker.srcjar_deps)) { srcjar_deps = invoker.srcjar_deps } 953 }
849 if (defined(invoker.srcjars)) { srcjars = invoker.srcjars } 954 if (defined(invoker.deps)) {
850 if (defined(invoker.testonly)) { testonly = invoker.testonly } 955 deps = invoker.deps
851 if (defined(invoker.visibility)) { visibility = invoker.visibility } 956 }
852 if (defined(invoker.dex_path)) { dex_path = invoker.dex_path } 957 if (defined(invoker.jar_excluded_patterns)) {
958 jar_excluded_patterns = invoker.jar_excluded_patterns
959 }
960 if (defined(invoker.java_files)) {
961 java_files = invoker.java_files
962 }
963 if (defined(invoker.proguard_config)) {
964 proguard_config = invoker.proguard_config
965 }
966 if (defined(invoker.proguard_preprocess)) {
967 proguard_preprocess = invoker.proguard_preprocess
968 }
969 if (defined(invoker.srcjar_deps)) {
970 srcjar_deps = invoker.srcjar_deps
971 }
972 if (defined(invoker.srcjars)) {
973 srcjars = invoker.srcjars
974 }
975 if (defined(invoker.testonly)) {
976 testonly = invoker.testonly
977 }
978 if (defined(invoker.visibility)) {
979 visibility = invoker.visibility
980 }
981 if (defined(invoker.dex_path)) {
982 dex_path = invoker.dex_path
983 }
853 984
854 supports_android = true 985 supports_android = true
855 requires_android = true 986 requires_android = true
856 987
857 if (!defined(jar_excluded_patterns)) { jar_excluded_patterns = [] } 988 if (!defined(jar_excluded_patterns)) {
989 jar_excluded_patterns = []
990 }
858 jar_excluded_patterns += [ 991 jar_excluded_patterns += [
859 "*/R.class", "*/R##*.class", 992 "*/R.class",
860 "*/Manifest.class", "*/Manifest##*.class", 993 "*/R##*.class",
994 "*/Manifest.class",
995 "*/Manifest##*.class",
861 ] 996 ]
862 } 997 }
863 } 998 }
864 999
865 # Declare an Android library target for a prebuilt jar 1000 # Declare an Android library target for a prebuilt jar
866 # 1001 #
867 # This target creates an Android library containing java code and Android 1002 # This target creates an Android library containing java code and Android
868 # resources. 1003 # resources.
869 # 1004 #
870 # Variables 1005 # Variables
(...skipping 11 matching lines...) Expand all
882 # deps = [ 1017 # deps = [
883 # ":foo_resources", 1018 # ":foo_resources",
884 # ":bar_java" 1019 # ":bar_java"
885 # ] 1020 # ]
886 # } 1021 # }
887 template("android_java_prebuilt") { 1022 template("android_java_prebuilt") {
888 java_prebuilt_impl(target_name) { 1023 java_prebuilt_impl(target_name) {
889 jar_path = invoker.jar_path 1024 jar_path = invoker.jar_path
890 supports_android = true 1025 supports_android = true
891 requires_android = true 1026 requires_android = true
892 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1027 if (defined(invoker.testonly)) {
893 if (defined(invoker.deps)) { deps = invoker.deps } 1028 testonly = invoker.testonly
894 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig } 1029 }
895 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess } 1030 if (defined(invoker.deps)) {
1031 deps = invoker.deps
1032 }
1033 if (defined(invoker.proguard_config)) {
1034 proguard_config = invoker.proguard_config
1035 }
1036 if (defined(invoker.proguard_preprocess)) {
1037 proguard_preprocess = invoker.proguard_preprocess
1038 }
896 } 1039 }
897 } 1040 }
898 1041
899
900
901 # Declare an Android apk target 1042 # Declare an Android apk target
902 # 1043 #
903 # This target creates an Android APK containing java code, resources, assets, 1044 # This target creates an Android APK containing java code, resources, assets,
904 # and (possibly) native libraries. 1045 # and (possibly) native libraries.
905 # 1046 #
906 # Variables 1047 # Variables
907 # android_manifest: Path to AndroidManifest.xml. 1048 # android_manifest: Path to AndroidManifest.xml.
908 # datadeps: List of dependencies needed at runtime. These will be built but 1049 # datadeps: List of dependencies needed at runtime. These will be built but
909 # won't change the generated .apk in any way (in fact they may be built 1050 # won't change the generated .apk in any way (in fact they may be built
910 # after the .apk is). 1051 # after the .apk is).
(...skipping 29 matching lines...) Expand all
940 # ":foo_resources" 1081 # ":foo_resources"
941 # ] 1082 # ]
942 # srcjar_deps = [ 1083 # srcjar_deps = [
943 # ":foo_generated_enum" 1084 # ":foo_generated_enum"
944 # ] 1085 # ]
945 # native_libs = [ 1086 # native_libs = [
946 # native_lib_path 1087 # native_lib_path
947 # ] 1088 # ]
948 # } 1089 # }
949 template("android_apk") { 1090 template("android_apk") {
950 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1091 if (defined(invoker.testonly)) {
1092 testonly = invoker.testonly
1093 }
951 1094
952 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) 1095 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
953 gen_dir = "$target_gen_dir/$target_name" 1096 gen_dir = "$target_gen_dir/$target_name"
954 base_path = "$gen_dir/$target_name" 1097 base_path = "$gen_dir/$target_name"
955 _build_config = "$base_path.build_config" 1098 _build_config = "$base_path.build_config"
956 resources_zip_path = "$base_path.resources.zip" 1099 resources_zip_path = "$base_path.resources.zip"
957 all_resources_zip_path = "$base_path.resources.all.zip" 1100 all_resources_zip_path = "$base_path.resources.all.zip"
958 jar_path = "$base_path.jar" 1101 jar_path = "$base_path.jar"
959 final_dex_path = "$gen_dir/classes.dex" 1102 final_dex_path = "$gen_dir/classes.dex"
960 _template_name = target_name 1103 _template_name = target_name
961 _final_apk_path = "" 1104 _final_apk_path = ""
962 if (defined(invoker.final_apk_path)) { 1105 if (defined(invoker.final_apk_path)) {
963 _final_apk_path = invoker.final_apk_path 1106 _final_apk_path = invoker.final_apk_path
964 } else if (defined(invoker.apk_name)) { 1107 } else if (defined(invoker.apk_name)) {
965 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" 1108 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
966 } 1109 }
967 _dist_jar_path_list = process_file_template( 1110 _dist_jar_path_list =
968 [ _final_apk_path ], 1111 process_file_template(
969 "$root_build_dir/test.lib.java/{{source_name_part}}.jar" 1112 [ _final_apk_path ],
970 ) 1113 "$root_build_dir/test.lib.java/{{source_name_part}}.jar")
971 _dist_jar_path = _dist_jar_path_list[0] 1114 _dist_jar_path = _dist_jar_path_list[0]
972 1115
973 _native_libs = [] 1116 _native_libs = []
974 1117
975 _keystore_path = android_default_keystore_path 1118 _keystore_path = android_default_keystore_path
976 _keystore_name = android_default_keystore_name 1119 _keystore_name = android_default_keystore_name
977 _keystore_password = android_default_keystore_password 1120 _keystore_password = android_default_keystore_password
978 1121
979 if (defined(invoker.keystore_path)) { 1122 if (defined(invoker.keystore_path)) {
980 _keystore_path = invoker.keystore_path 1123 _keystore_path = invoker.keystore_path
981 _keystore_name = invoker.keystore_name 1124 _keystore_name = invoker.keystore_name
982 _keystore_password = invoker.keystore_password 1125 _keystore_password = invoker.keystore_password
983 } 1126 }
984 1127
985 _srcjar_deps = [] 1128 _srcjar_deps = []
986 if (defined(invoker.srcjar_deps)) { 1129 if (defined(invoker.srcjar_deps)) {
987 _srcjar_deps += invoker.srcjar_deps 1130 _srcjar_deps += invoker.srcjar_deps
988 } 1131 }
989 1132
990 _load_library_from_apk = false 1133 _load_library_from_apk = false
991 1134
992 if (defined(invoker.native_libs)) { 1135 if (defined(invoker.native_libs)) {
993 _use_chromium_linker = false 1136 _use_chromium_linker = false
994 if (defined(invoker.use_chromium_linker)) { 1137 if (defined(invoker.use_chromium_linker)) {
995 _use_chromium_linker = (invoker.use_chromium_linker && 1138 _use_chromium_linker =
996 chromium_linker_supported) 1139 invoker.use_chromium_linker && chromium_linker_supported
997 } 1140 }
998 1141
999 if (defined(invoker.load_library_from_apk) && 1142 if (defined(invoker.load_library_from_apk) &&
1000 invoker.load_library_from_apk) { 1143 invoker.load_library_from_apk) {
1001 _load_library_from_apk = true 1144 _load_library_from_apk = true
1002 assert(_use_chromium_linker, "Loading library from the apk requires use" + 1145 assert(_use_chromium_linker,
1003 " of the Chromium linker.") 1146 "Loading library from the apk requires use" +
1147 " of the Chromium linker.")
1004 } 1148 }
1005 1149
1006 _enable_relocation_packing = false 1150 _enable_relocation_packing = false
1007 if (defined(invoker.enable_relocation_packing) && 1151 if (defined(invoker.enable_relocation_packing) &&
1008 invoker.enable_relocation_packing) { 1152 invoker.enable_relocation_packing) {
1009 _enable_relocation_packing = relocation_packing_supported 1153 _enable_relocation_packing = relocation_packing_supported
1010 assert(_use_chromium_linker, "Relocation packing requires use of the" + 1154 assert(_use_chromium_linker,
1011 " Chromium linker.") 1155 "Relocation packing requires use of the" + " Chromium linker.")
1012 } 1156 }
1013 1157
1014 _native_libs = process_file_template( 1158 _native_libs = process_file_template(
1015 invoker.native_libs, 1159 invoker.native_libs,
1016 "$root_build_dir/lib.stripped/{{source_file_part}}") 1160 "$root_build_dir/lib.stripped/{{source_file_part}}")
1017 1161
1018 _native_libs_dir = base_path + "/libs" 1162 _native_libs_dir = base_path + "/libs"
1019 1163
1020 if (_use_chromium_linker) { 1164 if (_use_chromium_linker) {
1021 _native_libs += [ 1165 _native_libs +=
1022 "$root_build_dir/lib.stripped/libchromium_android_linker.so" 1166 [ "$root_build_dir/lib.stripped/libchromium_android_linker.so" ]
1023 ]
1024 } 1167 }
1025 1168
1026 _enable_relocation_packing = false 1169 _enable_relocation_packing = false
1027 if (_use_chromium_linker && defined(invoker.enable_relocation_packing) && 1170 if (_use_chromium_linker && defined(invoker.enable_relocation_packing) &&
1028 invoker.enable_relocation_packing) { 1171 invoker.enable_relocation_packing) {
1029 _enable_relocation_packing = true 1172 _enable_relocation_packing = true
1030 } 1173 }
1031 } 1174 }
1032 1175
1033 _rebased_build_config = rebase_path(_build_config, root_build_dir) 1176 _rebased_build_config = rebase_path(_build_config, root_build_dir)
1034 1177
1035 write_build_config("${_template_name}__build_config") { 1178 write_build_config("${_template_name}__build_config") {
1036 type = "android_apk" 1179 type = "android_apk"
1037 dex_path = final_dex_path 1180 dex_path = final_dex_path
1038 resources_zip = resources_zip_path 1181 resources_zip = resources_zip_path
1039 build_config = _build_config 1182 build_config = _build_config
1040 1183
1041 if (defined(invoker.deps)) { 1184 if (defined(invoker.deps)) {
1042 deps = invoker.deps 1185 deps = invoker.deps
1043 } 1186 }
1044 1187
1045 native_libs = _native_libs 1188 native_libs = _native_libs
1046 } 1189 }
1047 1190
1048 final_deps = [] 1191 final_deps = []
1049 1192
1050 final_deps += [":${_template_name}__process_resources"] 1193 final_deps += [ ":${_template_name}__process_resources" ]
1051 process_resources("${_template_name}__process_resources") { 1194 process_resources("${_template_name}__process_resources") {
1052 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" 1195 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1053 android_manifest = invoker.android_manifest 1196 android_manifest = invoker.android_manifest
1054 resource_dirs = ["//build/android/ant/empty/res"] 1197 resource_dirs = [ "//build/android/ant/empty/res" ]
1055 zip_path = resources_zip_path 1198 zip_path = resources_zip_path
1056 generate_constant_ids = true 1199 generate_constant_ids = true
1057 build_config = _build_config 1200 build_config = _build_config
1058 } 1201 }
1059 _srcjar_deps += [":${_template_name}__process_resources"] 1202 _srcjar_deps += [ ":${_template_name}__process_resources" ]
1060 1203
1061 if (_native_libs != []) { 1204 if (_native_libs != []) {
1062 _enable_chromium_linker_tests = false 1205 _enable_chromium_linker_tests = false
1063 if (defined(invoker.enable_chromium_linker_tests)) { 1206 if (defined(invoker.enable_chromium_linker_tests)) {
1064 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests 1207 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
1065 } 1208 }
1066 1209
1067 _native_lib_version_name = "" 1210 _native_lib_version_name = ""
1068 1211
1069 java_cpp_template("${_template_name}__native_libraries_java") { 1212 java_cpp_template("${_template_name}__native_libraries_java") {
1070 package_name = "org/chromium/base/library_loader" 1213 package_name = "org/chromium/base/library_loader"
1071 sources = [ 1214 sources = [
1072 "//base/android/java/templates/NativeLibraries.template", 1215 "//base/android/java/templates/NativeLibraries.template",
1073 ] 1216 ]
1074 inputs = [ 1217 inputs = [
1075 _build_config, 1218 _build_config,
1076 ] 1219 ]
1077 1220
1078 defines = [ 1221 defines = [
1079 "NATIVE_LIBRARIES_LIST=" + 1222 "NATIVE_LIBRARIES_LIST=" +
1080 "@FileArg($_rebased_build_config:native:java_libraries_list)", 1223 "@FileArg($_rebased_build_config:native:java_libraries_list)",
1081 "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"", 1224 "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"",
1082 ] 1225 ]
1083 if (_use_chromium_linker) { 1226 if (_use_chromium_linker) {
1084 defines += ["ENABLE_CHROMIUM_LINKER"] 1227 defines += [ "ENABLE_CHROMIUM_LINKER" ]
1085 } 1228 }
1086 if (_load_library_from_apk) { 1229 if (_load_library_from_apk) {
1087 defines += ["ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE"] 1230 defines += [ "ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE" ]
1088 } 1231 }
1089 if (_enable_chromium_linker_tests) { 1232 if (_enable_chromium_linker_tests) {
1090 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] 1233 defines += [ "ENABLE_CHROMIUM_LINKER_TESTS" ]
1091 } 1234 }
1092 } 1235 }
1093 _srcjar_deps += [ ":${_template_name}__native_libraries_java" ] 1236 _srcjar_deps += [ ":${_template_name}__native_libraries_java" ]
1094 } 1237 }
1095 1238
1096 final_deps += [ ":${_template_name}__java" ] 1239 final_deps += [ ":${_template_name}__java" ]
1097 java_library_impl("${_template_name}__java") { 1240 java_library_impl("${_template_name}__java") {
1098 supports_android = true 1241 supports_android = true
1099 requires_android = true 1242 requires_android = true
1100 override_build_config = _build_config 1243 override_build_config = _build_config
1101 android_manifest = invoker.android_manifest 1244 android_manifest = invoker.android_manifest
1102 chromium_code = true 1245 chromium_code = true
1103 if (defined(invoker.java_files)) { 1246 if (defined(invoker.java_files)) {
1104 java_files = invoker.java_files 1247 java_files = invoker.java_files
1105 } else if (defined(invoker.DEPRECATED_java_in_dir)) { 1248 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
1106 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir 1249 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
1107 } else { 1250 } else {
1108 java_files = [] 1251 java_files = []
1109 } 1252 }
1110 srcjar_deps = _srcjar_deps 1253 srcjar_deps = _srcjar_deps
1111 dex_path = base_path + ".dex.jar" 1254 dex_path = base_path + ".dex.jar"
1112 } 1255 }
1113 1256
1114 if (_dist_jar_path != "") { 1257 if (_dist_jar_path != "") {
1115 final_deps += [ ":${_template_name}__create_dist_jar" ] 1258 final_deps += [ ":${_template_name}__create_dist_jar" ]
1259
1116 # TODO(cjhopman): This is only ever needed to calculate the list of tests to 1260 # TODO(cjhopman): This is only ever needed to calculate the list of tests to
1117 # run. See build/android/pylib/instrumentation/test_jar.py. We should be 1261 # run. See build/android/pylib/instrumentation/test_jar.py. We should be
1118 # able to just do that calculation at build time instead. 1262 # able to just do that calculation at build time instead.
1119 action("${_template_name}__create_dist_jar") { 1263 action("${_template_name}__create_dist_jar") {
1120 script = "//build/android/gyp/create_dist_jar.py" 1264 script = "//build/android/gyp/create_dist_jar.py"
1121 depfile = "$target_gen_dir/$target_name.d" 1265 depfile = "$target_gen_dir/$target_name.d"
1122 inputs = [ _build_config ] 1266 inputs = [
1267 _build_config,
1268 ]
1123 outputs = [ 1269 outputs = [
1124 depfile, 1270 depfile,
1125 _dist_jar_path, 1271 _dist_jar_path,
1126 ] 1272 ]
1127 args = [ 1273 args = [
1128 "--depfile", rebase_path(depfile, root_build_dir), 1274 "--depfile",
1129 "--output", rebase_path(_dist_jar_path, root_build_dir), 1275 rebase_path(depfile, root_build_dir),
1276 "--output",
1277 rebase_path(_dist_jar_path, root_build_dir),
1130 "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)", 1278 "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)",
1131 ] 1279 ]
1132 inputs += [ jar_path ] 1280 inputs += [ jar_path ]
1133 _rebased_jar_path = rebase_path([ jar_path ], root_build_dir) 1281 _rebased_jar_path = rebase_path([ jar_path ], root_build_dir)
1134 args += [ 1282 args += [ "--inputs=$_rebased_jar_path" ]
1135 "--inputs=$_rebased_jar_path",
1136 ]
1137 } 1283 }
1138 } 1284 }
1139 1285
1140 final_deps += [":${_template_name}__final_dex"] 1286 final_deps += [ ":${_template_name}__final_dex" ]
1141 dex("${_template_name}__final_dex") { 1287 dex("${_template_name}__final_dex") {
1142 deps = [ ":${_template_name}__java" ] 1288 deps = [
1143 sources = [ jar_path ] 1289 ":${_template_name}__java",
1144 inputs = [ _build_config ] 1290 ]
1291 sources = [
1292 jar_path,
1293 ]
1294 inputs = [
1295 _build_config,
1296 ]
1145 output = final_dex_path 1297 output = final_dex_path
1146 dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files" 1298 dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files"
1147 args = [ "--inputs=@FileArg($dex_arg_key)" ] 1299 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1148 } 1300 }
1149 1301
1150 if (_native_libs != []) { 1302 if (_native_libs != []) {
1151 action("${_template_name}__prepare_native") { 1303 action("${_template_name}__prepare_native") {
1152 script = "//build/android/gyp/pack_arm_relocations.py" 1304 script = "//build/android/gyp/pack_arm_relocations.py"
1153 packed_libraries_dir = "$_native_libs_dir/$android_app_abi" 1305 packed_libraries_dir = "$_native_libs_dir/$android_app_abi"
1154 depfile = "$target_gen_dir/$target_name.d" 1306 depfile = "$target_gen_dir/$target_name.d"
1155 outputs = [ 1307 outputs = [ depfile ]
1156 depfile
1157 ]
1158 inputs = [ 1308 inputs = [
1159 _build_config 1309 _build_config,
1160 ] 1310 ]
1161 deps = [] 1311 deps = []
1162 skip_packing_list = [ 1312 skip_packing_list = [
1163 "gdbserver", 1313 "gdbserver",
1164 "libchromium_android_linker.so", 1314 "libchromium_android_linker.so",
1165 ] 1315 ]
1166 1316
1167 enable_packing_arg = 0 1317 enable_packing_arg = 0
1168 if (_enable_relocation_packing) { 1318 if (_enable_relocation_packing) {
1169 enable_packing_arg = 1 1319 enable_packing_arg = 1
1170 deps += [ 1320 deps += [ relocation_packer_target ]
1171 relocation_packer_target
1172 ]
1173 } 1321 }
1174 1322
1175 args = [ 1323 args = [
1176 "--depfile", rebase_path(depfile, root_build_dir), 1324 "--depfile",
1325 rebase_path(depfile, root_build_dir),
1177 "--enable-packing=$enable_packing_arg", 1326 "--enable-packing=$enable_packing_arg",
1178 "--has-relocations-with-addends=$relocations_have_addends", 1327 "--has-relocations-with-addends=$relocations_have_addends",
1179 "--exclude-packing-list=$skip_packing_list", 1328 "--exclude-packing-list=$skip_packing_list",
1180 "--android-pack-relocations", rebase_path(relocation_packer_exe, root_bu ild_dir), 1329 "--android-pack-relocations",
1181 "--android-objcopy", rebase_path(android_objcopy, root_build_dir), 1330 rebase_path(relocation_packer_exe, root_build_dir),
1182 "--stripped-libraries-dir", rebase_path(root_build_dir, root_build_dir), 1331 "--android-objcopy",
1183 "--packed-libraries-dir", rebase_path(packed_libraries_dir, root_build_d ir), 1332 rebase_path(android_objcopy, root_build_dir),
1333 "--stripped-libraries-dir",
1334 rebase_path(root_build_dir, root_build_dir),
1335 "--packed-libraries-dir",
1336 rebase_path(packed_libraries_dir, root_build_dir),
1184 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)", 1337 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)",
1185 "--clear-dir" 1338 "--clear-dir",
1186 ] 1339 ]
1187 1340
1188 if (is_debug) { 1341 if (is_debug) {
1189 rebased_gdbserver = rebase_path([ android_gdbserver ], root_build_dir) 1342 rebased_gdbserver = rebase_path([ android_gdbserver ], root_build_dir)
1190 inputs += [ android_gdbserver ] 1343 inputs += [ android_gdbserver ]
1191 args += [ 1344 args += [ "--libraries=$rebased_gdbserver" ]
1192 "--libraries=$rebased_gdbserver"
1193 ]
1194 } 1345 }
1195 } 1346 }
1196 } 1347 }
1197 1348
1198 final_deps += [":${_template_name}__create"] 1349 final_deps += [ ":${_template_name}__create" ]
1199 create_apk("${_template_name}__create") { 1350 create_apk("${_template_name}__create") {
1200 apk_path = _final_apk_path 1351 apk_path = _final_apk_path
1201 android_manifest = invoker.android_manifest 1352 android_manifest = invoker.android_manifest
1202 resources_zip = all_resources_zip_path 1353 resources_zip = all_resources_zip_path
1203 dex_path = final_dex_path 1354 dex_path = final_dex_path
1204 load_library_from_apk = _load_library_from_apk 1355 load_library_from_apk = _load_library_from_apk
1205 1356
1206 version_code = "1" 1357 version_code = "1"
1207 if (defined(invoker.version_code)) { 1358 if (defined(invoker.version_code)) {
1208 version_code = invoker.version_code 1359 version_code = invoker.version_code
1209 } 1360 }
1210 1361
1211 version_name = "Developer Build" 1362 version_name = "Developer Build"
1212 if (defined(invoker.version_name)) { 1363 if (defined(invoker.version_name)) {
1213 version_name = invoker.version_name 1364 version_name = invoker.version_name
1214 } 1365 }
1215 1366
1216 keystore_name = _keystore_name 1367 keystore_name = _keystore_name
1217 keystore_path = _keystore_path 1368 keystore_path = _keystore_path
1218 keystore_password = _keystore_password 1369 keystore_password = _keystore_password
1219 1370
1220 deps = [] 1371 deps = []
1221 if (defined(invoker.asset_location)) { 1372 if (defined(invoker.asset_location)) {
1222 asset_location = invoker.asset_location 1373 asset_location = invoker.asset_location
1374
1223 # We don't know the exact dependencies that create the assets in 1375 # We don't know the exact dependencies that create the assets in
1224 # |asset_location|; we depend on all caller deps until a better solution 1376 # |asset_location|; we depend on all caller deps until a better solution
1225 # is figured out (http://crbug.com/433330). 1377 # is figured out (http://crbug.com/433330).
1226 if (defined(invoker.deps)) { 1378 if (defined(invoker.deps)) {
1227 deps += invoker.deps 1379 deps += invoker.deps
1228 } 1380 }
1229 } 1381 }
1230 1382
1231 if (_native_libs != []) { 1383 if (_native_libs != []) {
1232 native_libs_dir = _native_libs_dir 1384 native_libs_dir = _native_libs_dir
1233 deps += [":${_template_name}__prepare_native"] 1385 deps += [ ":${_template_name}__prepare_native" ]
1234 } 1386 }
1235 } 1387 }
1236 1388
1237 group(target_name) { 1389 group(target_name) {
1238 deps = final_deps 1390 deps = final_deps
1239 if (defined(invoker.datadeps)) { 1391 if (defined(invoker.datadeps)) {
1240 # TODO(cjhopman): Fix this when group datadeps works. 1392 # TODO(cjhopman): Fix this when group datadeps works.
1241 deps += invoker.datadeps 1393 deps += invoker.datadeps
1242 } 1394 }
1243 } 1395 }
1244 } 1396 }
1245 1397
1246
1247 # Declare an Android gtest apk 1398 # Declare an Android gtest apk
1248 # 1399 #
1249 # This target creates an Android apk for running gtest-based unittests. 1400 # This target creates an Android apk for running gtest-based unittests.
1250 # 1401 #
1251 # Variables 1402 # Variables
1252 # deps: Specifies the dependencies of this target. These will be passed to 1403 # deps: Specifies the dependencies of this target. These will be passed to
1253 # the underlying android_apk invocation and should include the java and 1404 # the underlying android_apk invocation and should include the java and
1254 # resource dependencies of the apk. 1405 # resource dependencies of the apk.
1255 # unittests_dep: This should be the label of the gtest native target. This 1406 # unittests_dep: This should be the label of the gtest native target. This
1256 # target must be defined previously in the same file. 1407 # target must be defined previously in the same file.
(...skipping 17 matching lines...) Expand all
1274 1425
1275 if (defined(invoker.unittests_binary)) { 1426 if (defined(invoker.unittests_binary)) {
1276 unittests_binary = invoker.unittests_binary 1427 unittests_binary = invoker.unittests_binary
1277 } else { 1428 } else {
1278 unittests_binary = "lib" + test_suite_name + ".so" 1429 unittests_binary = "lib" + test_suite_name + ".so"
1279 } 1430 }
1280 1431
1281 android_apk(target_name) { 1432 android_apk(target_name) {
1282 _apk_name = test_suite_name 1433 _apk_name = test_suite_name
1283 final_apk_path = "$root_build_dir/${_apk_name}_apk/${_apk_name}-debug.apk" 1434 final_apk_path = "$root_build_dir/${_apk_name}_apk/${_apk_name}-debug.apk"
1284 java_files = [ 1435 java_files =
1285 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java" 1436 [ "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestA ctivity.java" ]
1286 ]
1287 android_manifest = "//testing/android/java/AndroidManifest.xml" 1437 android_manifest = "//testing/android/java/AndroidManifest.xml"
1288 native_libs = [ unittests_binary ] 1438 native_libs = [ unittests_binary ]
1289 deps = [ "//base:base_java" ] 1439 deps = [
1440 "//base:base_java",
1441 ]
1290 if (defined(invoker.deps)) { 1442 if (defined(invoker.deps)) {
1291 deps += invoker.deps 1443 deps += invoker.deps
1292 } 1444 }
1293 datadeps = [ 1445 datadeps = [
1294 "//tools/android/forwarder2", 1446 "//tools/android/forwarder2",
1295 "//tools/android/md5sum", 1447 "//tools/android/md5sum",
1296 ] 1448 ]
1297 } 1449 }
1298 } 1450 }
1299 1451
(...skipping 10 matching lines...) Expand all
1310 # 1462 #
1311 # Example 1463 # Example
1312 # android_aidl("foo_aidl") { 1464 # android_aidl("foo_aidl") {
1313 # import_include = "java/src" 1465 # import_include = "java/src"
1314 # sources = [ 1466 # sources = [
1315 # "java/src/com/foo/bar/FooBarService.aidl", 1467 # "java/src/com/foo/bar/FooBarService.aidl",
1316 # "java/src/com/foo/bar/FooBarServiceCallback.aidl", 1468 # "java/src/com/foo/bar/FooBarServiceCallback.aidl",
1317 # ] 1469 # ]
1318 # } 1470 # }
1319 template("android_aidl") { 1471 template("android_aidl") {
1320 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1472 if (defined(invoker.testonly)) {
1473 testonly = invoker.testonly
1474 }
1321 1475
1322 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" 1476 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1323 aidl_path = "${android_sdk_build_tools}/aidl" 1477 aidl_path = "${android_sdk_build_tools}/aidl"
1324 framework_aidl = "$android_sdk/framework.aidl" 1478 framework_aidl = "$android_sdk/framework.aidl"
1325 1479
1326 action(target_name) { 1480 action(target_name) {
1327 script = "//build/android/gyp/aidl.py" 1481 script = "//build/android/gyp/aidl.py"
1328 sources = invoker.sources 1482 sources = invoker.sources
1329 1483
1330 imports = [ framework_aidl ] 1484 imports = [ framework_aidl ]
1331 if (defined(invoker.interface_file)) { 1485 if (defined(invoker.interface_file)) {
1332 assert(invoker.interface_file != "") 1486 assert(invoker.interface_file != "")
1333 imports += [ invoker.interface_file ] 1487 imports += [ invoker.interface_file ]
1334 } 1488 }
1335 1489
1336 inputs = [ 1490 inputs = [ aidl_path ] + imports
1337 aidl_path,
1338 ] + imports
1339 1491
1340 depfile = "${target_gen_dir}/${target_name}.d" 1492 depfile = "${target_gen_dir}/${target_name}.d"
1341 outputs = [ 1493 outputs = [
1342 depfile, 1494 depfile,
1343 srcjar_path 1495 srcjar_path,
1344 ] 1496 ]
1345 rebased_imports = rebase_path(imports, root_build_dir) 1497 rebased_imports = rebase_path(imports, root_build_dir)
1346 args = [ 1498 args = [
1347 "--depfile", rebase_path(depfile, root_build_dir), 1499 "--depfile",
1348 "--aidl-path", rebase_path(aidl_path, root_build_dir), 1500 rebase_path(depfile, root_build_dir),
1501 "--aidl-path",
1502 rebase_path(aidl_path, root_build_dir),
1349 "--imports=$rebased_imports", 1503 "--imports=$rebased_imports",
1350 "--srcjar", rebase_path(srcjar_path, root_build_dir), 1504 "--srcjar",
1505 rebase_path(srcjar_path, root_build_dir),
1351 ] 1506 ]
1352 if (defined(invoker.import_include) && invoker.import_include != "") { 1507 if (defined(invoker.import_include) && invoker.import_include != "") {
1353 # TODO(cjhopman): aidl supports creating a depfile. We should be able to 1508 # TODO(cjhopman): aidl supports creating a depfile. We should be able to
1354 # switch to constructing a depfile for the overall action from that 1509 # switch to constructing a depfile for the overall action from that
1355 # instead of having all the .java files in the include paths as inputs. 1510 # instead of having all the .java files in the include paths as inputs.
1356 rebased_import_includes = rebase_path( 1511 rebased_import_includes =
1357 [invoker.import_include], root_build_dir) 1512 rebase_path([ invoker.import_include ], root_build_dir)
1358 args += [ "--includes=$rebased_import_includes" ] 1513 args += [ "--includes=$rebased_import_includes" ]
1359 1514
1360 _java_files_build_rel = exec_script( 1515 _java_files_build_rel =
1361 "//build/android/gyp/find.py", 1516 exec_script("//build/android/gyp/find.py",
1362 rebase_path([invoker.import_include], root_build_dir), 1517 rebase_path([ invoker.import_include ], root_build_dir),
1363 "list lines" 1518 "list lines")
1364 )
1365 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) 1519 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
1366 inputs += _java_files 1520 inputs += _java_files
1367 } 1521 }
1368 args += rebase_path(sources, root_build_dir) 1522 args += rebase_path(sources, root_build_dir)
1369 } 1523 }
1370 } 1524 }
1371 1525
1372 # Creates a dist directory for a native executable. 1526 # Creates a dist directory for a native executable.
1373 # 1527 #
1374 # Running a native executable on a device requires all the shared library 1528 # Running a native executable on a device requires all the shared library
1375 # dependencies of that executable. To make it easier to install and run such an 1529 # dependencies of that executable. To make it easier to install and run such an
1376 # executable, this will create a directory containing the native exe and all 1530 # executable, this will create a directory containing the native exe and all
1377 # it's library dependencies. 1531 # it's library dependencies.
1378 # 1532 #
1379 # Note: It's usually better to package things as an APK than as a native 1533 # Note: It's usually better to package things as an APK than as a native
1380 # executable. 1534 # executable.
1381 # 1535 #
1382 # Variables 1536 # Variables
1383 # dist_dir: Directory for the exe and libraries. Everything in this directory 1537 # dist_dir: Directory for the exe and libraries. Everything in this directory
1384 # will be deleted before copying in the exe and libraries. 1538 # will be deleted before copying in the exe and libraries.
1385 # binary: Path to (stripped) executable. 1539 # binary: Path to (stripped) executable.
1386 # 1540 #
1387 # Example 1541 # Example
1388 # create_native_executable_dist("foo_dist") { 1542 # create_native_executable_dist("foo_dist") {
1389 # dist_dir = "$root_build_dir/foo_dist" 1543 # dist_dir = "$root_build_dir/foo_dist"
1390 # binary = "$root_build_dir/exe.stripped/foo" 1544 # binary = "$root_build_dir/exe.stripped/foo"
1391 # } 1545 # }
1392 template("create_native_executable_dist") { 1546 template("create_native_executable_dist") {
1393 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1547 if (defined(invoker.testonly)) {
1548 testonly = invoker.testonly
1549 }
1394 1550
1395 dist_dir = invoker.dist_dir 1551 dist_dir = invoker.dist_dir
1396 binary = invoker.binary 1552 binary = invoker.binary
1397 final_deps = [] 1553 final_deps = []
1398 template_name = target_name 1554 template_name = target_name
1399 1555
1400 libraries_list = "${target_gen_dir}/${template_name}_library_dependencies.list " 1556 libraries_list =
1557 "${target_gen_dir}/${template_name}_library_dependencies.list"
1401 1558
1402 # TODO(gyp) 1559 # TODO(gyp)
1403 #'dependencies': [ 1560 #'dependencies': [
1404 #'<(DEPTH)/build/android/setup.gyp:copy_system_libraries', 1561 #'<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
1405 #], 1562 #],
1406 1563
1407 stripped_libraries_dir = "$root_build_dir/lib.stripped" 1564 stripped_libraries_dir = "$root_build_dir/lib.stripped"
1408 final_deps += [ ":${template_name}__find_library_dependencies" ] 1565 final_deps += [ ":${template_name}__find_library_dependencies" ]
1409 action("${template_name}__find_library_dependencies") { 1566 action("${template_name}__find_library_dependencies") {
1410 script = "//build/android/gyp/write_ordered_libraries.py" 1567 script = "//build/android/gyp/write_ordered_libraries.py"
1411 depfile = "$target_gen_dir/$target_name.d" 1568 depfile = "$target_gen_dir/$target_name.d"
1412 inputs = [ 1569 inputs = [
1413 binary, 1570 binary,
1414 android_readelf, 1571 android_readelf,
1415 ] 1572 ]
1416 outputs = [ 1573 outputs = [
1417 depfile, 1574 depfile,
1418 libraries_list, 1575 libraries_list,
1419 ] 1576 ]
1420 rebased_binaries = rebase_path([ binary ], root_build_dir) 1577 rebased_binaries = rebase_path([ binary ], root_build_dir)
1421 args = [ 1578 args = [
1422 "--depfile", rebase_path(depfile, root_build_dir), 1579 "--depfile",
1580 rebase_path(depfile, root_build_dir),
1423 "--input-libraries=$rebased_binaries", 1581 "--input-libraries=$rebased_binaries",
1424 "--libraries-dir", rebase_path(stripped_libraries_dir, root_build_dir), 1582 "--libraries-dir",
1425 "--output", rebase_path(libraries_list, root_build_dir), 1583 rebase_path(stripped_libraries_dir, root_build_dir),
1426 "--readelf", rebase_path(android_readelf, root_build_dir), 1584 "--output",
1585 rebase_path(libraries_list, root_build_dir),
1586 "--readelf",
1587 rebase_path(android_readelf, root_build_dir),
1427 ] 1588 ]
1428 } 1589 }
1429 1590
1430 final_deps += [ ":${template_name}__copy_libraries_and_exe" ] 1591 final_deps += [ ":${template_name}__copy_libraries_and_exe" ]
1431 copy_ex("${template_name}__copy_libraries_and_exe") { 1592 copy_ex("${template_name}__copy_libraries_and_exe") {
1432 clear_dir = true 1593 clear_dir = true
1433 inputs = [ 1594 inputs = [
1434 binary, 1595 binary,
1435 libraries_list 1596 libraries_list,
1436 ] 1597 ]
1437 dest = dist_dir 1598 dest = dist_dir
1438 rebased_binaries_list = rebase_path([ binary ], root_build_dir) 1599 rebased_binaries_list = rebase_path([ binary ], root_build_dir)
1439 rebased_libraries_list = rebase_path(libraries_list, root_build_dir) 1600 rebased_libraries_list = rebase_path(libraries_list, root_build_dir)
1440 args = [ 1601 args = [
1441 "--files=$rebased_binaries_list", 1602 "--files=$rebased_binaries_list",
1442 "--files=@FileArg($rebased_libraries_list:libraries)", 1603 "--files=@FileArg($rebased_libraries_list:libraries)",
1443 ] 1604 ]
1444 } 1605 }
1445 1606
1446 group(target_name) { 1607 group(target_name) {
1447 deps = final_deps 1608 deps = final_deps
1448 } 1609 }
1449 } 1610 }
1450 1611
1451
1452 # Compile a protocol buffer to java. 1612 # Compile a protocol buffer to java.
1453 # 1613 #
1454 # This generates java files from protocol buffers and creates an Android library 1614 # This generates java files from protocol buffers and creates an Android library
1455 # containing the classes. 1615 # containing the classes.
1456 # 1616 #
1457 # Variables 1617 # Variables
1458 # sources: Paths to .proto files to compile. 1618 # sources: Paths to .proto files to compile.
1459 # proto_path: Root directory of .proto files. 1619 # proto_path: Root directory of .proto files.
1460 # 1620 #
1461 # Example: 1621 # Example:
1462 # proto_java_library("foo_proto_java") { 1622 # proto_java_library("foo_proto_java") {
1463 # proto_path = [ "src/foo" ] 1623 # proto_path = [ "src/foo" ]
1464 # sources = [ "$proto_path/foo.proto" ] 1624 # sources = [ "$proto_path/foo.proto" ]
1465 # } 1625 # }
1466 template("proto_java_library") { 1626 template("proto_java_library") {
1467 _protoc_dep = "//third_party/android_protobuf:android_protoc($host_toolchain)" 1627 _protoc_dep = "//third_party/android_protobuf:android_protoc($host_toolchain)"
1468 _protoc_out_dir = get_label_info(_protoc_dep, "root_out_dir") 1628 _protoc_out_dir = get_label_info(_protoc_dep, "root_out_dir")
1469 _protoc_bin = "$_protoc_out_dir/android_protoc" 1629 _protoc_bin = "$_protoc_out_dir/android_protoc"
1470 _proto_path = invoker.proto_path 1630 _proto_path = invoker.proto_path
1471 1631
1472 _template_name = target_name 1632 _template_name = target_name
1473 1633
1474 action("${_template_name}__protoc_java") { 1634 action("${_template_name}__protoc_java") {
1475 srcjar_path = "$target_gen_dir/$target_name.srcjar" 1635 srcjar_path = "$target_gen_dir/$target_name.srcjar"
1476 script = "//build/protoc_java.py" 1636 script = "//build/protoc_java.py"
1477 deps = [ 1637 deps = [
1478 _protoc_dep 1638 _protoc_dep,
1479 ] 1639 ]
1480 sources = invoker.sources 1640 sources = invoker.sources
1481 depfile = "$target_gen_dir/$target_name.d" 1641 depfile = "$target_gen_dir/$target_name.d"
1482 outputs = [ 1642 outputs = [
1483 depfile, 1643 depfile,
1484 srcjar_path, 1644 srcjar_path,
1485 ] 1645 ]
1486 args = [ 1646 args = [
1487 "--depfile", rebase_path(depfile, root_build_dir), 1647 "--depfile",
1488 "--protoc", rebase_path(_protoc_bin, root_build_dir), 1648 rebase_path(depfile, root_build_dir),
1489 "--proto-path", rebase_path(_proto_path, root_build_dir), 1649 "--protoc",
1490 "--srcjar", rebase_path(srcjar_path, root_build_dir), 1650 rebase_path(_protoc_bin, root_build_dir),
1491 ] + rebase_path(sources, root_build_dir) 1651 "--proto-path",
1652 rebase_path(_proto_path, root_build_dir),
1653 "--srcjar",
1654 rebase_path(srcjar_path, root_build_dir),
1655 ] + rebase_path(sources, root_build_dir)
1492 } 1656 }
1493 1657
1494 android_library(target_name) { 1658 android_library(target_name) {
1495 java_files = [] 1659 java_files = []
1496 srcjar_deps = [ ":${_template_name}__protoc_java" ] 1660 srcjar_deps = [ ":${_template_name}__protoc_java" ]
1497 deps = [ 1661 deps = [
1498 "//third_party/android_protobuf:protobuf_nano_javalib", 1662 "//third_party/android_protobuf:protobuf_nano_javalib",
1499 ] 1663 ]
1500 } 1664 }
1501 } 1665 }
1502 1666
1503 # TODO(GYP): implement this. 1667 # TODO(GYP): implement this.
1504 template("uiautomator_test") { 1668 template("uiautomator_test") {
1505 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1669 if (defined(invoker.testonly)) {
1670 testonly = invoker.testonly
1671 }
1506 assert(target_name != "") 1672 assert(target_name != "")
1507 assert(invoker.deps != [] || true) 1673 assert(invoker.deps != [] || true)
1508 group(target_name) { 1674 group(target_name) {
1509 } 1675 }
1510 } 1676 }
OLDNEW
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | build/config/arm.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698