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

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

Issue 512923002: Add support for Android aidl and support for gyp's java_in_dir (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
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("//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
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"
cjhopman 2014/08/27 18:37:59 This path has to be unique for each source file.
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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 # java_files: List of .java files to include in the apk. 566 # java_files: List of .java files to include in the apk.
555 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars 567 # 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. 568 # will be added to java_files and be included in this apk.
557 # apk_name: Name for final apk. 569 # apk_name: Name for final apk.
558 # final_apk_path: Path to final built apk. Default is 570 # final_apk_path: Path to final built apk. Default is
559 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name. 571 # $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 572 # 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 573 # libraries depend on other shared_library targets, those dependencies will
562 # also be included in the apk. 574 # also be included in the apk.
563 # 575 #
576 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
577 # this directory will be included in the library. This is only supported to
578 # ease the gyp->gn conversion and will be removed in the future.
579 #
564 # Example 580 # Example
565 # android_apk("foo_apk") { 581 # android_apk("foo_apk") {
566 # android_manifest = "AndroidManifest.xml" 582 # android_manifest = "AndroidManifest.xml"
567 # java_files = [ 583 # java_files = [
568 # "android/org/chromium/foo/FooApplication.java", 584 # "android/org/chromium/foo/FooApplication.java",
569 # "android/org/chromium/foo/FooActivity.java", 585 # "android/org/chromium/foo/FooActivity.java",
570 # ] 586 # ]
571 # deps = [ 587 # deps = [
572 # ":foo_support_java" 588 # ":foo_support_java"
573 # ":foo_resources" 589 # ":foo_resources"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] 685 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"]
670 } 686 }
671 } 687 }
672 _srcjar_deps += [ ":${target_name}__native_libraries_java" ] 688 _srcjar_deps += [ ":${target_name}__native_libraries_java" ]
673 689
674 rebased_build_config = rebase_path(build_config, root_build_dir) 690 rebased_build_config = rebase_path(build_config, root_build_dir)
675 691
676 final_deps += [":${target_name}__java"] 692 final_deps += [":${target_name}__java"]
677 android_java_library("${target_name}__java") { 693 android_java_library("${target_name}__java") {
678 android_manifest = invoker.android_manifest 694 android_manifest = invoker.android_manifest
679 java_files = invoker.java_files 695 if (defined(invoker.java_files)) {
696 java_files = invoker.java_files
697 } else {
698 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
699 }
680 srcjar_deps = _srcjar_deps 700 srcjar_deps = _srcjar_deps
681 dex_path = base_path + ".dex.jar" 701 dex_path = base_path + ".dex.jar"
682 } 702 }
683 703
684 final_deps += [":${target_name}__final_dex"] 704 final_deps += [":${target_name}__final_dex"]
685 dex("${target_name}__final_dex") { 705 dex("${target_name}__final_dex") {
686 sources = [jar_path] 706 sources = [jar_path]
687 inputs = [build_config] 707 inputs = [build_config]
688 output = final_dex_path 708 output = final_dex_path
689 dex_arg_key = "${rebased_build_config}:apk_dex:dependency_dex_files" 709 dex_arg_key = "${rebased_build_config}:apk_dex:dependency_dex_files"
(...skipping 29 matching lines...) Expand all
719 keystore_password = _keystore_password 739 keystore_password = _keystore_password
720 740
721 if (_native_libs != []) { 741 if (_native_libs != []) {
722 native_libs_dir = _native_libs_dir 742 native_libs_dir = _native_libs_dir
723 deps = [":${_template_name}__prepare_native"] 743 deps = [":${_template_name}__prepare_native"]
724 } 744 }
725 } 745 }
726 746
727 group(target_name) { 747 group(target_name) {
728 deps = final_deps 748 deps = final_deps
749 if (defined(invoker.datadeps)) {
newt (away) 2014/08/27 20:05:29 where are these datadeps coming from?
cjhopman 2014/08/27 21:05:22 The invoker. I added documentation above (this is
750 datadeps = invoker.datadeps
751 }
729 } 752 }
730 } 753 }
731 754
732 755
733 # Declare an Android gtest apk 756 # Declare an Android gtest apk
734 # 757 #
735 # This target creates an Android apk for running gtest-based unittests. 758 # This target creates an Android apk for running gtest-based unittests.
736 # 759 #
737 # Variables 760 # Variables
738 # deps: Specifies the dependencies of this target. These will be passed to 761 # deps: Specifies the dependencies of this target. These will be passed to
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java" 793 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java"
771 ] 794 ]
772 android_manifest = "//testing/android/java/AndroidManifest.xml" 795 android_manifest = "//testing/android/java/AndroidManifest.xml"
773 unittests_outputs = [ unittests_binary ] 796 unittests_outputs = [ unittests_binary ]
774 native_libs = [unittests_outputs[0]] 797 native_libs = [unittests_outputs[0]]
775 if (defined(invoker.deps)) { 798 if (defined(invoker.deps)) {
776 deps = invoker.deps 799 deps = invoker.deps
777 } 800 }
778 } 801 }
779 } 802 }
803
804 # Generate .java files from .aidl files.
805 #
806 # This target will store the .java files in a srcjar and should be included in
807 # an android_library or android_apk's srcjar_deps.
808 #
809 # Variables
newt (away) 2014/08/27 20:05:28 what about interface_file?
cjhopman 2014/08/27 21:05:22 Done.
810 # sources: Paths to .aidl files to compile.
811 # import_include: Paths to directories containing .java files imported by the
newt (away) 2014/08/27 20:05:29 s/Paths/Path ... right?
cjhopman 2014/08/27 21:05:22 Done.
812 # .aidl files.
813 #
814 # Example
815 # android_aidl("foo_aidl") {
816 # import_include = "java/src"
817 # sources = [
818 # "java/src/com/foo/bar/FooBarService.aidl",
819 # "java/src/com/foo/bar/FooBarServiceCallback.aidl",
820 # ]
821 # }
822 template("android_aidl") {
823 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
824 aidl_path = "${android_sdk_build_tools}/aidl"
825 framework_aidl = "$android_sdk/framework.aidl"
826
827 action(target_name) {
828 script = "//build/android/gyp/aidl.py"
829 sources = invoker.sources
830
831 imports = [ framework_aidl ]
832 if (defined(invoker.interface_file)) {
833 assert(invoker.interface_file != "")
834 imports += [ invoker.interface_file ]
835 }
836
837 inputs = [
838 aidl_path,
839 ] + imports
840
841 depfile = "${target_gen_dir}/${target_name}.d"
842 outputs = [
843 depfile,
844 srcjar_path
845 ]
846 rebased_imports = rebase_path(imports, root_build_dir)
847 args = [
848 "--depfile", rebase_path(depfile, root_build_dir),
849 "--aidl-path", rebase_path(aidl_path, root_build_dir),
850 "--imports=$rebased_imports",
851 "--srcjar", rebase_path(srcjar_path, root_build_dir),
852 ]
853 if (defined(invoker.import_include) && invoker.import_include != "") {
854 # TODO(cjhopman): aidl supports creating a depfile. We should be able to
855 # switch to constructing a depfile for the overall action from that
856 # instead of having all the .java files in the include paths as inputs.
857 rebased_import_includes = rebase_path(
858 [invoker.import_include], root_build_dir)
859 args += [ "--includes=$rebased_import_includes" ]
860
861 _java_files_build_rel = exec_script(
862 "//build/android/gyp/find.py",
newt (away) 2014/08/27 20:05:29 is the plan to get rid of this "find" after the gn
cjhopman 2014/08/27 21:05:22 It's complicated. The TODO a couple lines up desc
863 rebase_path([invoker.import_include], root_build_dir),
864 "list lines"
865 )
866 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
867 inputs += _java_files
868 }
869 args += rebase_path(sources, root_build_dir)
870 }
871 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698