Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/android/internal_rules.gni") | 6 import("//build/config/android/internal_rules.gni") |
| 7 import("//tools/grit/grit_rule.gni") | 7 import("//tools/grit/grit_rule.gni") |
| 8 | 8 |
| 9 assert(is_android) | 9 assert(is_android) |
| 10 | 10 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 base_dir = base_gen_dir | 336 base_dir = base_gen_dir |
| 337 } | 337 } |
| 338 | 338 |
| 339 group(target_name) { | 339 group(target_name) { |
| 340 deps = [ | 340 deps = [ |
| 341 ":${target_name}__zip_srcjar" | 341 ":${target_name}__zip_srcjar" |
| 342 ] | 342 ] |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 # Declare a target for processing a Jinja template. | |
| 347 # | |
| 348 # Variables | |
| 349 # input: The template file to be processed. | |
| 350 # output: Where to save the result. | |
| 351 # variables: (Optional) A list of variables to make available to the template | |
| 352 # processing environment, e.g. ["name=foo", "color=red"]. | |
| 353 # | |
| 354 # Example | |
| 355 # jinja_template("chrome_shell_manifest") { | |
| 356 # input = "shell/java/AndroidManifest.xml" | |
| 357 # output = "$target_gen_dir/AndroidManifest.xml" | |
| 358 # } | |
| 359 template("jinja_template") { | |
| 360 if (defined(invoker.testonly)) { testonly = invoker.testonly } | |
| 361 | |
| 362 assert(defined(invoker.input)) | |
| 363 assert(defined(invoker.output)) | |
| 364 | |
| 365 action(target_name) { | |
| 366 sources = [invoker.input] | |
| 367 script = "//build/android/gyp/jinja_template.py" | |
| 368 depfile = "$target_gen_dir/$target_name.d" | |
| 369 | |
| 370 outputs = [ | |
| 371 depfile, | |
| 372 invoker.output, | |
| 373 ] | |
| 374 | |
| 375 args = [ | |
| 376 "--inputs", rebase_path(invoker.input, root_build_dir), | |
| 377 "--output", rebase_path(invoker.output, root_build_dir), | |
| 378 "--depfile", rebase_path(depfile, root_build_dir), | |
| 379 ] | |
| 380 if (defined(invoker.variables)) { | |
| 381 variables = invoker.variables | |
| 382 args += ["--variables=${variables}" ] | |
| 383 } | |
| 384 } | |
| 385 } | |
| 386 | |
| 387 # Declare a target for processing Android resources as Jinja templates. | |
| 388 # | |
| 389 # This takes an Android resource directory where each resource is a Jinja | |
| 390 # template, processes each template, then packages the results in a zip file | |
| 391 # which can be consumed by an android resources, library, or apk target. | |
| 392 # | |
| 393 # If this target is included in the deps of an android resources/library/apk, | |
| 394 # the resources will be included with that target. | |
| 395 # | |
| 396 # Variables | |
| 397 # resources: The list of resources files to process. | |
| 398 # res_dir: The resource directory containing the resources. | |
| 399 # variables: (Optional) A list of variables to make available to the template | |
| 400 # processing environment, e.g. ["name=foo", "color=red"]. | |
| 401 # | |
| 402 # Example | |
| 403 # jinja_template_resources("chrome_shell_template_resources") { | |
| 404 # res_dir = "shell/res_template" | |
| 405 # resources = ["shell/res_template/xml/syncable.xml"] | |
| 406 # variables = ["color=red"] | |
| 407 # } | |
| 408 template("jinja_template_resources") { | |
| 409 if (defined(invoker.testonly)) { testonly = invoker.testonly } | |
| 410 | |
| 411 assert(defined(invoker.resources)) | |
| 412 assert(defined(invoker.res_dir)) | |
| 413 | |
| 414 base_path = "$target_gen_dir/$target_name" | |
|
cjhopman
2014/10/17 18:54:25
for these variables set at the top level of the te
newt (away)
2014/10/20 22:45:12
Done.
| |
| 415 resources_zip = base_path + ".resources.zip" | |
| 416 build_config = base_path + ".build_config" | |
| 417 | |
| 418 write_build_config("${target_name}__build_config") { | |
| 419 type = "android_resources" | |
| 420 # Why?? I just copy-pasted this | |
|
cjhopman
2014/10/17 18:54:25
You shouldn't need to forward the deps. Since deps
newt (away)
2014/10/20 22:45:12
Done.
| |
| 421 if (defined(invoker.deps)) { | |
| 422 deps = invoker.deps | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 action("${target_name}__template") { | |
| 427 sources = invoker.resources | |
| 428 script = "//build/android/gyp/jinja_template.py" | |
| 429 depfile = "$target_gen_dir/$target_name.d" | |
| 430 | |
| 431 outputs = [ | |
| 432 depfile, | |
| 433 resources_zip, | |
| 434 ] | |
| 435 | |
| 436 rebased_resources = rebase_path(invoker.resources, root_build_dir) | |
| 437 args = [ | |
| 438 "--inputs=${rebased_resources}", | |
| 439 "--inputs-base-dir", rebase_path(invoker.res_dir, root_build_dir), | |
| 440 "--outputs-zip", rebase_path(resources_zip, root_build_dir), | |
| 441 "--depfile", rebase_path(depfile, root_build_dir), | |
| 442 ] | |
| 443 if (defined(invoker.variables)) { | |
| 444 variables = invoker.variables | |
| 445 args += ["--variables=${variables}" ] | |
| 446 } | |
| 447 } | |
| 448 | |
| 449 group(target_name) { | |
| 450 deps = [ | |
| 451 ":${target_name}__build_config", | |
| 452 ":${target_name}__template", | |
| 453 ] | |
| 454 } | |
| 455 } | |
| 346 | 456 |
| 347 # Declare an Android resources target | 457 # Declare an Android resources target |
| 348 # | 458 # |
| 349 # This creates a resources zip file that will be used when building an Android | 459 # This creates a resources zip file that will be used when building an Android |
| 350 # library or apk and included into a final apk. | 460 # library or apk and included into a final apk. |
| 351 # | 461 # |
| 352 # To include these resources in a library/apk, this target should be listed in | 462 # To include these resources in a library/apk, this target should be listed in |
| 353 # the library's deps. A library/apk will also include any resources used by its | 463 # the library's deps. A library/apk will also include any resources used by its |
| 354 # own dependencies. | 464 # own dependencies. |
| 355 # | 465 # |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 output_jar_path = _jar_path | 791 output_jar_path = _jar_path |
| 682 } | 792 } |
| 683 | 793 |
| 684 dex("${target_name}__dex") { | 794 dex("${target_name}__dex") { |
| 685 sources = [_jar_path] | 795 sources = [_jar_path] |
| 686 output = _dex_path | 796 output = _dex_path |
| 687 } | 797 } |
| 688 | 798 |
| 689 group(target_name) { | 799 group(target_name) { |
| 690 deps = [ | 800 deps = [ |
| 691 ":${target_name}__dex", | 801 ":${target_name}__dex", |
|
cjhopman
2014/10/17 18:54:25
sort.
newt (away)
2014/10/20 22:45:12
Done.
| |
| 802 ":${target_name}__build_config", | |
| 692 ] | 803 ] |
| 693 } | 804 } |
| 694 } | 805 } |
| 695 | 806 |
| 696 | 807 |
| 697 | 808 |
| 698 # Declare an Android apk target | 809 # Declare an Android apk target |
| 699 # | 810 # |
| 700 # This target creates an Android APK containing java code, resources, assets, | 811 # This target creates an Android APK containing java code, resources, assets, |
| 701 # and (possibly) native libraries. | 812 # and (possibly) native libraries. |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 } | 1316 } |
| 1206 | 1317 |
| 1207 # TODO(GYP): implement this. | 1318 # TODO(GYP): implement this. |
| 1208 template("uiautomator_test") { | 1319 template("uiautomator_test") { |
| 1209 if (defined(invoker.testonly)) { testonly = invoker.testonly } | 1320 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 1210 assert(target_name != "") | 1321 assert(target_name != "") |
| 1211 assert(invoker.deps != [] || true) | 1322 assert(invoker.deps != [] || true) |
| 1212 group(target_name) { | 1323 group(target_name) { |
| 1213 } | 1324 } |
| 1214 } | 1325 } |
| OLD | NEW |