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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 # grd_file: Path to the .grd file to generate strings.xml from. | 337 # grd_file: Path to the .grd file to generate strings.xml from. |
338 # outputs: Expected grit outputs (see grit rule). | 338 # outputs: Expected grit outputs (see grit rule). |
339 # | 339 # |
340 # Example | 340 # Example |
341 # java_strings_grd("foo_strings_grd") { | 341 # java_strings_grd("foo_strings_grd") { |
342 # grd_file = "foo_strings.grd" | 342 # grd_file = "foo_strings.grd" |
343 # } | 343 # } |
344 template("java_strings_grd") { | 344 template("java_strings_grd") { |
345 base_path = "$target_gen_dir/$target_name" | 345 base_path = "$target_gen_dir/$target_name" |
346 resources_zip = base_path + ".resources.zip" | 346 resources_zip = base_path + ".resources.zip" |
| 347 build_config = base_path + ".build_config" |
347 | 348 |
348 write_build_config("${target_name}__build_config") { | 349 write_build_config("${target_name}__build_config") { |
349 type = "android_resources" | 350 type = "android_resources" |
350 if (defined(invoker.deps)) { | 351 if (defined(invoker.deps)) { |
351 deps = invoker.deps | 352 deps = invoker.deps |
352 } | 353 } |
353 } | 354 } |
354 | 355 |
355 # Put grit files into this subdirectory of target_gen_dir. | 356 # Put grit files into this subdirectory of target_gen_dir. |
356 extra_output_path = target_name + "_grit_output" | 357 extra_output_path = target_name + "_grit_output" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 # ] | 415 # ] |
415 # srcjar_deps = [ | 416 # srcjar_deps = [ |
416 # ":foo_generated_enum" | 417 # ":foo_generated_enum" |
417 # ] | 418 # ] |
418 # jar_excluded_patterns = [ | 419 # jar_excluded_patterns = [ |
419 # "*/FooService.class", "*/FooService##*.class" | 420 # "*/FooService.class", "*/FooService##*.class" |
420 # ] | 421 # ] |
421 # } | 422 # } |
422 template("android_library") { | 423 template("android_library") { |
423 assert(defined(invoker.java_files)) | 424 assert(defined(invoker.java_files)) |
424 | |
425 base_path = "$target_gen_dir/$target_name" | 425 base_path = "$target_gen_dir/$target_name" |
426 build_config = base_path + ".build_config" | 426 build_config = base_path + ".build_config" |
| 427 jar_path = base_path + ".jar" |
427 | 428 |
428 write_build_config("${target_name}__build_config") { | 429 write_build_config("${target_name}__build_config") { |
429 type = "android_library" | 430 type = "android_library" |
430 | 431 |
431 deps = [] | 432 deps = [] |
432 if (defined(invoker.deps)) { | 433 if (defined(invoker.deps)) { |
433 deps += invoker.deps | 434 deps += invoker.deps |
434 } | 435 } |
435 | 436 |
436 # base_path | 437 # base_path |
437 } | 438 } |
438 | 439 |
439 jar_path = base_path + ".jar" | |
440 android_java_library(target_name) { | 440 android_java_library(target_name) { |
441 java_files = invoker.java_files | 441 java_files = invoker.java_files |
442 build_config = build_config | 442 build_config = build_config |
443 | 443 |
444 if (defined(invoker.jar_excluded_patterns)) { | 444 if (defined(invoker.jar_excluded_patterns)) { |
445 jar_excluded_patterns = invoker.jar_excluded_patterns | 445 jar_excluded_patterns = invoker.jar_excluded_patterns |
446 } | 446 } |
447 | 447 |
448 if (defined(invoker.srcjar_deps)) { | 448 if (defined(invoker.srcjar_deps)) { |
449 srcjar_deps = invoker.srcjar_deps | 449 srcjar_deps = invoker.srcjar_deps |
450 } | 450 } |
451 } | 451 } |
452 } | 452 } |
| 453 |
| 454 |
| 455 # Declare an Android apk target |
| 456 # |
| 457 # This target creates an Android APK containing java code, resources, assets, |
| 458 # and (possibly) native libraries. |
| 459 # |
| 460 # Variables |
| 461 # android_manifest: Path to AndroidManifest.xml. |
| 462 # deps: List of dependencies. All Android java resources and libraries in the |
| 463 # "transitive closure" of these dependencies will be included in the apk. |
| 464 # Note: this "transitive closure" actually only includes such targets if |
| 465 # they are depended on through android_library or android_resources targets |
| 466 # (and so not through builtin targets like 'action', 'group', etc). |
| 467 # java_files: List of .java files to include in the apk. |
| 468 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars |
| 469 # will be added to java_files and be included in this apk. |
| 470 # apk_name: Name for final apk. |
| 471 # final_apk_path: Path to final built apk. Default is |
| 472 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name. |
| 473 # native_libs: List paths of native libraries to include in this apk. If these |
| 474 # libraries depend on other shared_library targets, those dependencies will |
| 475 # also be included in the apk. |
| 476 # |
| 477 # Example |
| 478 # android_apk("foo_apk") { |
| 479 # android_manifest = "AndroidManifest.xml" |
| 480 # java_files = [ |
| 481 # "android/org/chromium/foo/FooApplication.java", |
| 482 # "android/org/chromium/foo/FooActivity.java", |
| 483 # ] |
| 484 # deps = [ |
| 485 # ":foo_support_java" |
| 486 # ":foo_resources" |
| 487 # ] |
| 488 # srcjar_deps = [ |
| 489 # ":foo_generated_enum" |
| 490 # ] |
| 491 # native_libs = [ |
| 492 # native_lib_path |
| 493 # ] |
| 494 # } |
| 495 template("android_apk") { |
| 496 gen_dir = "$target_gen_dir/$target_name" |
| 497 base_path = "$gen_dir/$target_name" |
| 498 build_config = base_path + ".build_config" |
| 499 resource_zip_path = base_path + ".resources.zip" |
| 500 all_resources_zip_path = base_path + ".resources.all.zip" |
| 501 resource_srcjar_path = base_path + ".resources.srcjar" |
| 502 jar_path = base_path + ".jar" |
| 503 |
| 504 # Just mark these as used for now. |
| 505 assert(!defined(invoker.native_libs) |
| 506 || invoker.native_libs == [] || true) |
| 507 assert(!defined(invoker.final_apk_path) |
| 508 || invoker.final_apk_path == "" || true) |
| 509 |
| 510 final_deps = [] |
| 511 |
| 512 # TODO(cjhopman): Remove this once we correctly generate the real |
| 513 # NativeLibraries.java |
| 514 srcjar_deps = [ "//base:base_native_libraries_gen" ] |
| 515 if (defined(invoker.srcjar_deps)) { |
| 516 srcjar_deps += invoker.srcjar_deps |
| 517 } |
| 518 |
| 519 write_build_config("${target_name}__build_config") { |
| 520 type = "android_apk" |
| 521 srcjar = resource_srcjar_path |
| 522 resources_zip = resource_zip_path |
| 523 |
| 524 if (defined(invoker.deps)) { |
| 525 deps = invoker.deps |
| 526 } |
| 527 } |
| 528 |
| 529 final_deps += [":${target_name}__process_resources"] |
| 530 process_resources("${target_name}__process_resources") { |
| 531 android_manifest = invoker.android_manifest |
| 532 |
| 533 resource_dirs = ["//build/android/ant/empty/res"] |
| 534 zip_path = resource_zip_path |
| 535 srcjar_path = resource_srcjar_path |
| 536 |
| 537 generate_constant_ids = true |
| 538 } |
| 539 |
| 540 final_deps += [":${target_name}__java"] |
| 541 android_java_library("${target_name}__java") { |
| 542 java_files = invoker.java_files |
| 543 } |
| 544 |
| 545 # TODO(cjhopman): dex |
| 546 # TODO(cjhopman): native |
| 547 # TODO(cjhopman): create+finalize apk |
| 548 |
| 549 group(target_name) { |
| 550 deps = final_deps |
| 551 } |
| 552 } |
| 553 |
| 554 |
| 555 # Declare an Android gtest apk |
| 556 # |
| 557 # This target creates an Android apk for running gtest-based unittests. |
| 558 # |
| 559 # Variables |
| 560 # deps: Specifies the dependencies of this target. These will be passed to |
| 561 # the underlying android_apk invocation and should include the java and |
| 562 # resource dependencies of the apk. |
| 563 # unittests_dep: This should be the label of the gtest native target. This |
| 564 # target must be defined previously in the same file. |
| 565 # |
| 566 # Example |
| 567 # unittest_apk("foo_unittests_apk") { |
| 568 # deps = [ ":foo_java", ":foo_resources" ] |
| 569 # unittests_dep = ":foo_unittests" |
| 570 # } |
| 571 template("unittest_apk") { |
| 572 test_suite_name = get_label_info(invoker.unittests_dep, "name") |
| 573 android_apk(target_name) { |
| 574 apk_name = test_suite_name |
| 575 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk" |
| 576 java_files = [ |
| 577 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv
ity.java" |
| 578 ] |
| 579 android_manifest = "//testing/android/java/AndroidManifest.xml" |
| 580 unittests_outputs = get_target_outputs(invoker.unittests_dep) |
| 581 native_libs = [unittests_outputs[0]] |
| 582 if (defined(invoker.deps)) { |
| 583 deps = invoker.deps |
| 584 } |
| 585 } |
| 586 } |
OLD | NEW |