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" |
| 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 } |
| 421 |
| 422 action("${target_name}__template") { |
| 423 sources = invoker.resources |
| 424 script = "//build/android/gyp/jinja_template.py" |
| 425 depfile = "$target_gen_dir/$target_name.d" |
| 426 |
| 427 outputs = [ |
| 428 depfile, |
| 429 _resources_zip, |
| 430 ] |
| 431 |
| 432 rebased_resources = rebase_path(invoker.resources, root_build_dir) |
| 433 args = [ |
| 434 "--inputs=${rebased_resources}", |
| 435 "--inputs-base-dir", rebase_path(invoker.res_dir, root_build_dir), |
| 436 "--outputs-zip", rebase_path(_resources_zip, root_build_dir), |
| 437 "--depfile", rebase_path(depfile, root_build_dir), |
| 438 ] |
| 439 if (defined(invoker.variables)) { |
| 440 variables = invoker.variables |
| 441 args += ["--variables=${variables}" ] |
| 442 } |
| 443 } |
| 444 |
| 445 group(target_name) { |
| 446 deps = [ |
| 447 ":${target_name}__build_config", |
| 448 ":${target_name}__template", |
| 449 ] |
| 450 } |
| 451 } |
346 | 452 |
347 # Declare an Android resources target | 453 # Declare an Android resources target |
348 # | 454 # |
349 # This creates a resources zip file that will be used when building an Android | 455 # This creates a resources zip file that will be used when building an Android |
350 # library or apk and included into a final apk. | 456 # library or apk and included into a final apk. |
351 # | 457 # |
352 # To include these resources in a library/apk, this target should be listed in | 458 # 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 | 459 # the library's deps. A library/apk will also include any resources used by its |
354 # own dependencies. | 460 # own dependencies. |
355 # | 461 # |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 output_jar_path = _jar_path | 787 output_jar_path = _jar_path |
682 } | 788 } |
683 | 789 |
684 dex("${target_name}__dex") { | 790 dex("${target_name}__dex") { |
685 sources = [_jar_path] | 791 sources = [_jar_path] |
686 output = _dex_path | 792 output = _dex_path |
687 } | 793 } |
688 | 794 |
689 group(target_name) { | 795 group(target_name) { |
690 deps = [ | 796 deps = [ |
| 797 ":${target_name}__build_config", |
691 ":${target_name}__dex", | 798 ":${target_name}__dex", |
692 ] | 799 ] |
693 } | 800 } |
694 } | 801 } |
695 | 802 |
696 | 803 |
697 | 804 |
698 # Declare an Android apk target | 805 # Declare an Android apk target |
699 # | 806 # |
700 # This target creates an Android APK containing java code, resources, assets, | 807 # This target creates an Android APK containing java code, resources, assets, |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 } | 1332 } |
1226 | 1333 |
1227 # TODO(GYP): implement this. | 1334 # TODO(GYP): implement this. |
1228 template("uiautomator_test") { | 1335 template("uiautomator_test") { |
1229 if (defined(invoker.testonly)) { testonly = invoker.testonly } | 1336 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
1230 assert(target_name != "") | 1337 assert(target_name != "") |
1231 assert(invoker.deps != [] || true) | 1338 assert(invoker.deps != [] || true) |
1232 group(target_name) { | 1339 group(target_name) { |
1233 } | 1340 } |
1234 } | 1341 } |
OLD | NEW |