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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 include_path = invoker.include_path + "" | 212 include_path = invoker.include_path + "" |
213 } else { | 213 } else { |
214 include_path = "//" | 214 include_path = "//" |
215 } | 215 } |
216 | 216 |
217 action_foreach("${target_name}__apply_gcc") { | 217 action_foreach("${target_name}__apply_gcc") { |
218 script = "//build/android/gyp/gcc_preprocess.py" | 218 script = "//build/android/gyp/gcc_preprocess.py" |
219 if (defined(invoker.inputs)) { | 219 if (defined(invoker.inputs)) { |
220 inputs = invoker.inputs + [] | 220 inputs = invoker.inputs + [] |
221 } | 221 } |
222 depfile = "${target_gen_dir}/${target_name}.d" | 222 depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d" |
223 | 223 |
224 sources = invoker.sources | 224 sources = invoker.sources |
225 | 225 |
226 gen_dir = "${target_gen_dir}/${target_name}/java_cpp_template/${package_name
}" | 226 gen_dir = "${target_gen_dir}/${target_name}/java_cpp_template/${package_name
}" |
227 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" | 227 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" |
228 | 228 |
229 outputs = [ | 229 outputs = [ |
230 depfile, | 230 depfile, |
231 gcc_template_output_pattern | 231 gcc_template_output_pattern |
232 ] | 232 ] |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 # This target creates an Android library containing java code and Android | 398 # This target creates an Android library containing java code and Android |
399 # resources. | 399 # resources. |
400 # | 400 # |
401 # Variables | 401 # Variables |
402 # deps: Specifies the dependencies of this target. Java targets in this list | 402 # deps: Specifies the dependencies of this target. Java targets in this list |
403 # will be added to the javac classpath. Android resources in dependencies | 403 # will be added to the javac classpath. Android resources in dependencies |
404 # will be used when building this library. | 404 # will be used when building this library. |
405 # java_files: List of .java files included in this library. | 405 # java_files: List of .java files included in this library. |
406 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars | 406 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars |
407 # will be added to java_files and be included in this library. | 407 # will be added to java_files and be included in this library. |
408 # chromium_code: If true, extra static analysis warning/errors will be enabled
. | 408 # chromium_code: If true, extra analysis warning/errors will be enabled. |
409 # jar_excluded_patterns: List of patterns of .class files to exclude from the | 409 # jar_excluded_patterns: List of patterns of .class files to exclude from the |
410 # final jar. | 410 # final jar. |
411 # proguard_preprocess: If true, proguard preprocessing will be run. This can | 411 # proguard_preprocess: If true, proguard preprocessing will be run. This can |
412 # be used to remove unwanted parts of the library. | 412 # be used to remove unwanted parts of the library. |
413 # proguard_config: Path to the proguard config for preprocessing. | 413 # proguard_config: Path to the proguard config for preprocessing. |
414 # | 414 # |
| 415 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in |
| 416 # this directory will be included in the library. This is only supported to |
| 417 # ease the gyp->gn conversion and will be removed in the future. |
| 418 # |
415 # Example | 419 # Example |
416 # android_library("foo_java") { | 420 # android_library("foo_java") { |
417 # java_files = [ | 421 # java_files = [ |
418 # "android/org/chromium/foo/Foo.java", | 422 # "android/org/chromium/foo/Foo.java", |
419 # "android/org/chromium/foo/FooInterface.java", | 423 # "android/org/chromium/foo/FooInterface.java", |
420 # "android/org/chromium/foo/FooService.java", | 424 # "android/org/chromium/foo/FooService.java", |
421 # ] | 425 # ] |
422 # deps = [ | 426 # deps = [ |
423 # ":bar_java" | 427 # ":bar_java" |
424 # ] | 428 # ] |
425 # srcjar_deps = [ | 429 # srcjar_deps = [ |
426 # ":foo_generated_enum" | 430 # ":foo_generated_enum" |
427 # ] | 431 # ] |
428 # jar_excluded_patterns = [ | 432 # jar_excluded_patterns = [ |
429 # "*/FooService.class", "*/FooService##*.class" | 433 # "*/FooService.class", "*/FooService##*.class" |
430 # ] | 434 # ] |
431 # } | 435 # } |
432 template("android_library") { | 436 template("android_library") { |
433 assert(defined(invoker.java_files)) | 437 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)) |
434 base_path = "$target_gen_dir/$target_name" | 438 _base_path = "$target_gen_dir/$target_name" |
435 build_config = base_path + ".build_config" | 439 _build_config = _base_path + ".build_config" |
436 jar_path = base_path + ".jar" | 440 _jar_path = _base_path + ".jar" |
437 dex_path = base_path + ".dex.jar" | 441 _dex_path = _base_path + ".dex.jar" |
438 | 442 |
439 write_build_config("${target_name}__build_config") { | 443 write_build_config("${target_name}__build_config") { |
440 type = "android_library" | 444 type = "android_library" |
441 | 445 |
442 deps = [] | 446 deps = [] |
443 if (defined(invoker.deps)) { | 447 if (defined(invoker.deps)) { |
444 deps += invoker.deps | 448 deps += invoker.deps |
445 } | 449 } |
446 | 450 |
447 # base_path | 451 build_config = _build_config |
| 452 jar_path = _jar_path |
| 453 dex_path = _dex_path |
448 } | 454 } |
449 | 455 |
450 _chromium_code = true | 456 _chromium_code = true |
451 if (defined(invoker.chromium_code)) { | 457 if (defined(invoker.chromium_code)) { |
452 _chromium_code = invoker.chromium_code | 458 _chromium_code = invoker.chromium_code |
453 } | 459 } |
454 | 460 |
455 android_java_library(target_name) { | 461 android_java_library(target_name) { |
456 chromium_code = _chromium_code | 462 chromium_code = _chromium_code |
457 java_files = invoker.java_files | 463 if (defined(invoker.java_files)) { |
458 build_config = build_config | 464 java_files = invoker.java_files |
| 465 } else { |
| 466 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir |
| 467 } |
| 468 build_config = _build_config |
| 469 jar_path = _jar_path |
| 470 dex_path = _dex_path |
459 | 471 |
460 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { | 472 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
461 proguard_preprocess = true | 473 proguard_preprocess = true |
462 proguard_config = invoker.proguard_config | 474 proguard_config = invoker.proguard_config |
463 } | 475 } |
464 | 476 |
465 if (defined(invoker.jar_excluded_patterns)) { | 477 if (defined(invoker.jar_excluded_patterns)) { |
466 jar_excluded_patterns = invoker.jar_excluded_patterns | 478 jar_excluded_patterns = invoker.jar_excluded_patterns |
467 } | 479 } |
468 | 480 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 551 |
540 | 552 |
541 | 553 |
542 # Declare an Android apk target | 554 # Declare an Android apk target |
543 # | 555 # |
544 # This target creates an Android APK containing java code, resources, assets, | 556 # This target creates an Android APK containing java code, resources, assets, |
545 # and (possibly) native libraries. | 557 # and (possibly) native libraries. |
546 # | 558 # |
547 # Variables | 559 # Variables |
548 # android_manifest: Path to AndroidManifest.xml. | 560 # android_manifest: Path to AndroidManifest.xml. |
| 561 # datadeps: List of dependencies needed at runtime. These will be built but |
| 562 # won't change the generated .apk in any way (in fact they may be built |
| 563 # after the .apk is). |
549 # deps: List of dependencies. All Android java resources and libraries in the | 564 # deps: List of dependencies. All Android java resources and libraries in the |
550 # "transitive closure" of these dependencies will be included in the apk. | 565 # "transitive closure" of these dependencies will be included in the apk. |
551 # Note: this "transitive closure" actually only includes such targets if | 566 # Note: this "transitive closure" actually only includes such targets if |
552 # they are depended on through android_library or android_resources targets | 567 # they are depended on through android_library or android_resources targets |
553 # (and so not through builtin targets like 'action', 'group', etc). | 568 # (and so not through builtin targets like 'action', 'group', etc). |
554 # java_files: List of .java files to include in the apk. | 569 # java_files: List of .java files to include in the apk. |
555 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars | 570 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars |
556 # will be added to java_files and be included in this apk. | 571 # will be added to java_files and be included in this apk. |
557 # apk_name: Name for final apk. | 572 # apk_name: Name for final apk. |
558 # final_apk_path: Path to final built apk. Default is | 573 # final_apk_path: Path to final built apk. Default is |
559 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name. | 574 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name. |
560 # native_libs: List paths of native libraries to include in this apk. If these | 575 # native_libs: List paths of native libraries to include in this apk. If these |
561 # libraries depend on other shared_library targets, those dependencies will | 576 # libraries depend on other shared_library targets, those dependencies will |
562 # also be included in the apk. | 577 # also be included in the apk. |
563 # | 578 # |
| 579 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in |
| 580 # this directory will be included in the library. This is only supported to |
| 581 # ease the gyp->gn conversion and will be removed in the future. |
| 582 # |
564 # Example | 583 # Example |
565 # android_apk("foo_apk") { | 584 # android_apk("foo_apk") { |
566 # android_manifest = "AndroidManifest.xml" | 585 # android_manifest = "AndroidManifest.xml" |
567 # java_files = [ | 586 # java_files = [ |
568 # "android/org/chromium/foo/FooApplication.java", | 587 # "android/org/chromium/foo/FooApplication.java", |
569 # "android/org/chromium/foo/FooActivity.java", | 588 # "android/org/chromium/foo/FooActivity.java", |
570 # ] | 589 # ] |
571 # deps = [ | 590 # deps = [ |
572 # ":foo_support_java" | 591 # ":foo_support_java" |
573 # ":foo_resources" | 592 # ":foo_resources" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] | 688 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] |
670 } | 689 } |
671 } | 690 } |
672 _srcjar_deps += [ ":${target_name}__native_libraries_java" ] | 691 _srcjar_deps += [ ":${target_name}__native_libraries_java" ] |
673 | 692 |
674 rebased_build_config = rebase_path(build_config, root_build_dir) | 693 rebased_build_config = rebase_path(build_config, root_build_dir) |
675 | 694 |
676 final_deps += [":${target_name}__java"] | 695 final_deps += [":${target_name}__java"] |
677 android_java_library("${target_name}__java") { | 696 android_java_library("${target_name}__java") { |
678 android_manifest = invoker.android_manifest | 697 android_manifest = invoker.android_manifest |
679 java_files = invoker.java_files | 698 if (defined(invoker.java_files)) { |
| 699 java_files = invoker.java_files |
| 700 } else { |
| 701 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir |
| 702 } |
680 srcjar_deps = _srcjar_deps | 703 srcjar_deps = _srcjar_deps |
681 dex_path = base_path + ".dex.jar" | 704 dex_path = base_path + ".dex.jar" |
682 } | 705 } |
683 | 706 |
684 final_deps += [":${target_name}__final_dex"] | 707 final_deps += [":${target_name}__final_dex"] |
685 dex("${target_name}__final_dex") { | 708 dex("${target_name}__final_dex") { |
686 sources = [jar_path] | 709 sources = [jar_path] |
687 inputs = [build_config] | 710 inputs = [build_config] |
688 output = final_dex_path | 711 output = final_dex_path |
689 dex_arg_key = "${rebased_build_config}:apk_dex:dependency_dex_files" | 712 dex_arg_key = "${rebased_build_config}:apk_dex:dependency_dex_files" |
(...skipping 29 matching lines...) Expand all Loading... |
719 keystore_password = _keystore_password | 742 keystore_password = _keystore_password |
720 | 743 |
721 if (_native_libs != []) { | 744 if (_native_libs != []) { |
722 native_libs_dir = _native_libs_dir | 745 native_libs_dir = _native_libs_dir |
723 deps = [":${_template_name}__prepare_native"] | 746 deps = [":${_template_name}__prepare_native"] |
724 } | 747 } |
725 } | 748 } |
726 | 749 |
727 group(target_name) { | 750 group(target_name) { |
728 deps = final_deps | 751 deps = final_deps |
| 752 if (defined(invoker.datadeps)) { |
| 753 datadeps = invoker.datadeps |
| 754 } |
729 } | 755 } |
730 } | 756 } |
731 | 757 |
732 | 758 |
733 # Declare an Android gtest apk | 759 # Declare an Android gtest apk |
734 # | 760 # |
735 # This target creates an Android apk for running gtest-based unittests. | 761 # This target creates an Android apk for running gtest-based unittests. |
736 # | 762 # |
737 # Variables | 763 # Variables |
738 # deps: Specifies the dependencies of this target. These will be passed to | 764 # deps: Specifies the dependencies of this target. These will be passed to |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv
ity.java" | 796 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv
ity.java" |
771 ] | 797 ] |
772 android_manifest = "//testing/android/java/AndroidManifest.xml" | 798 android_manifest = "//testing/android/java/AndroidManifest.xml" |
773 unittests_outputs = [ unittests_binary ] | 799 unittests_outputs = [ unittests_binary ] |
774 native_libs = [unittests_outputs[0]] | 800 native_libs = [unittests_outputs[0]] |
775 if (defined(invoker.deps)) { | 801 if (defined(invoker.deps)) { |
776 deps = invoker.deps | 802 deps = invoker.deps |
777 } | 803 } |
778 } | 804 } |
779 } | 805 } |
| 806 |
| 807 # Generate .java files from .aidl files. |
| 808 # |
| 809 # This target will store the .java files in a srcjar and should be included in |
| 810 # an android_library or android_apk's srcjar_deps. |
| 811 # |
| 812 # Variables |
| 813 # sources: Paths to .aidl files to compile. |
| 814 # import_include: Path to directory containing .java files imported by the |
| 815 # .aidl files. |
| 816 # interface_file: Preprocessed aidl file to import. |
| 817 # |
| 818 # Example |
| 819 # android_aidl("foo_aidl") { |
| 820 # import_include = "java/src" |
| 821 # sources = [ |
| 822 # "java/src/com/foo/bar/FooBarService.aidl", |
| 823 # "java/src/com/foo/bar/FooBarServiceCallback.aidl", |
| 824 # ] |
| 825 # } |
| 826 template("android_aidl") { |
| 827 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" |
| 828 aidl_path = "${android_sdk_build_tools}/aidl" |
| 829 framework_aidl = "$android_sdk/framework.aidl" |
| 830 |
| 831 action(target_name) { |
| 832 script = "//build/android/gyp/aidl.py" |
| 833 sources = invoker.sources |
| 834 |
| 835 imports = [ framework_aidl ] |
| 836 if (defined(invoker.interface_file)) { |
| 837 assert(invoker.interface_file != "") |
| 838 imports += [ invoker.interface_file ] |
| 839 } |
| 840 |
| 841 inputs = [ |
| 842 aidl_path, |
| 843 ] + imports |
| 844 |
| 845 depfile = "${target_gen_dir}/${target_name}.d" |
| 846 outputs = [ |
| 847 depfile, |
| 848 srcjar_path |
| 849 ] |
| 850 rebased_imports = rebase_path(imports, root_build_dir) |
| 851 args = [ |
| 852 "--depfile", rebase_path(depfile, root_build_dir), |
| 853 "--aidl-path", rebase_path(aidl_path, root_build_dir), |
| 854 "--imports=$rebased_imports", |
| 855 "--srcjar", rebase_path(srcjar_path, root_build_dir), |
| 856 ] |
| 857 if (defined(invoker.import_include) && invoker.import_include != "") { |
| 858 # TODO(cjhopman): aidl supports creating a depfile. We should be able to |
| 859 # switch to constructing a depfile for the overall action from that |
| 860 # instead of having all the .java files in the include paths as inputs. |
| 861 rebased_import_includes = rebase_path( |
| 862 [invoker.import_include], root_build_dir) |
| 863 args += [ "--includes=$rebased_import_includes" ] |
| 864 |
| 865 _java_files_build_rel = exec_script( |
| 866 "//build/android/gyp/find.py", |
| 867 rebase_path([invoker.import_include], root_build_dir), |
| 868 "list lines" |
| 869 ) |
| 870 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) |
| 871 inputs += _java_files |
| 872 } |
| 873 args += rebase_path(sources, root_build_dir) |
| 874 } |
| 875 } |
OLD | NEW |