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

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

Issue 2842603002: (Reland x2) Expose resources in Robolectric/JUnit tests. (Closed)
Patch Set: Rebase Created 3 years, 7 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
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | chrome/android/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # Do not add any imports to non-//build directories here. 5 # Do not add any imports to non-//build directories here.
6 # Some projects (e.g. V8) do not have non-build directories DEPS'ed in. 6 # Some projects (e.g. V8) do not have non-build directories DEPS'ed in.
7 import("//build/config/android/config.gni") 7 import("//build/config/android/config.gni")
8 import("//build/config/android/internal_rules.gni") 8 import("//build/config/android/internal_rules.gni")
9 import("//build/config/compiler/compiler.gni") 9 import("//build/config/compiler/compiler.gni")
10 import("//build/config/dcheck_always_on.gni") 10 import("//build/config/dcheck_always_on.gni")
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 # variables = ["color=red"] 572 # variables = ["color=red"]
573 # } 573 # }
574 template("jinja_template_resources") { 574 template("jinja_template_resources") {
575 set_sources_assignment_filter([]) 575 set_sources_assignment_filter([])
576 forward_variables_from(invoker, [ "testonly" ]) 576 forward_variables_from(invoker, [ "testonly" ])
577 577
578 assert(defined(invoker.resources)) 578 assert(defined(invoker.resources))
579 assert(defined(invoker.res_dir)) 579 assert(defined(invoker.res_dir))
580 580
581 _base_path = "$target_gen_dir/$target_name" 581 _base_path = "$target_gen_dir/$target_name"
582 _resources_zip = _base_path + ".resources.zip" 582
583 # JUnit tests use resource zip files. These must not be put in gen/
584 # directory or they will not be available to tester bots.
585 _resources_zip = "${target_out_dir}/${target_name}.resources.zip"
583 _build_config = _base_path + ".build_config" 586 _build_config = _base_path + ".build_config"
584 587
585 write_build_config("${target_name}__build_config") { 588 write_build_config("${target_name}__build_config") {
586 build_config = _build_config 589 build_config = _build_config
587 resources_zip = _resources_zip 590 resources_zip = _resources_zip
588 type = "android_resources" 591 type = "android_resources"
589 if (defined(invoker.deps)) { 592 if (defined(invoker.deps)) {
590 possible_config_deps = invoker.deps 593 possible_config_deps = invoker.deps
591 } 594 }
592 } 595 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 # deps = [":foo_resources"] 672 # deps = [":foo_resources"]
670 # resource_dirs = ["res_overrides"] 673 # resource_dirs = ["res_overrides"]
671 # } 674 # }
672 template("android_resources") { 675 template("android_resources") {
673 set_sources_assignment_filter([]) 676 set_sources_assignment_filter([])
674 forward_variables_from(invoker, [ "testonly" ]) 677 forward_variables_from(invoker, [ "testonly" ])
675 678
676 assert(defined(invoker.resource_dirs)) 679 assert(defined(invoker.resource_dirs))
677 680
678 base_path = "$target_gen_dir/$target_name" 681 base_path = "$target_gen_dir/$target_name"
679 zip_path = base_path + ".resources.zip" 682
683 # JUnit tests use resource zip files. These must not be put in gen/
684 # directory or they will not be available to tester bots.
685 zip_path = "${target_out_dir}/${target_name}.resources.zip"
680 srcjar_path = base_path + ".srcjar" 686 srcjar_path = base_path + ".srcjar"
681 r_text_out_path = base_path + "_R.txt" 687 r_text_out_path = base_path + "_R.txt"
682 build_config = base_path + ".build_config" 688 build_config = base_path + ".build_config"
683 689
684 build_config_target_name = "${target_name}__build_config" 690 build_config_target_name = "${target_name}__build_config"
685 process_resources_target_name = "${target_name}__process_resources" 691 process_resources_target_name = "${target_name}__process_resources"
686 final_target_name = target_name 692 final_target_name = target_name
687 693
688 write_build_config(build_config_target_name) { 694 write_build_config(build_config_target_name) {
689 type = "android_resources" 695 type = "android_resources"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 # 894 #
889 # Example 895 # Example
890 # java_strings_grd("foo_strings_grd") { 896 # java_strings_grd("foo_strings_grd") {
891 # grd_file = "foo_strings.grd" 897 # grd_file = "foo_strings.grd"
892 # } 898 # }
893 template("java_strings_grd") { 899 template("java_strings_grd") {
894 set_sources_assignment_filter([]) 900 set_sources_assignment_filter([])
895 forward_variables_from(invoker, [ "testonly" ]) 901 forward_variables_from(invoker, [ "testonly" ])
896 902
897 base_path = "$target_gen_dir/$target_name" 903 base_path = "$target_gen_dir/$target_name"
898 resources_zip = base_path + ".resources.zip" 904
905 # JUnit tests use resource zip files. These must not be put in gen/
906 # directory or they will not be available to tester bots.
907 resources_zip = "${target_out_dir}/${target_name}.resources.zip"
899 build_config = base_path + ".build_config" 908 build_config = base_path + ".build_config"
900 909
901 write_build_config("${target_name}__build_config") { 910 write_build_config("${target_name}__build_config") {
902 type = "android_resources" 911 type = "android_resources"
903 } 912 }
904 913
905 # Put grit files into this subdirectory of target_gen_dir. 914 # Put grit files into this subdirectory of target_gen_dir.
906 extra_output_path = target_name + "_grit_output" 915 extra_output_path = target_name + "_grit_output"
907 916
908 grit_target_name = "${target_name}__grit" 917 grit_target_name = "${target_name}__grit"
909 grit_output_dir = "$target_gen_dir/$extra_output_path" 918 grit_output_dir = "$target_gen_dir/$extra_output_path"
919
910 grit(grit_target_name) { 920 grit(grit_target_name) {
911 forward_variables_from(invoker, [ "deps" ]) 921 forward_variables_from(invoker, [ "deps" ])
912 grit_flags = [ 922 grit_flags = [
913 "-E", 923 "-E",
914 "ANDROID_JAVA_TAGGED_ONLY=false", 924 "ANDROID_JAVA_TAGGED_ONLY=false",
915 ] 925 ]
916 output_dir = grit_output_dir 926 output_dir = grit_output_dir
917 resource_ids = "" 927 resource_ids = ""
918 source = invoker.grd_file 928 source = invoker.grd_file
919 outputs = invoker.outputs 929 outputs = invoker.outputs
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 # grit_output_dir = "$root_gen_dir/foo/grit" 964 # grit_output_dir = "$root_gen_dir/foo/grit"
955 # generated_files = [ 965 # generated_files = [
956 # "values/strings.xml" 966 # "values/strings.xml"
957 # ] 967 # ]
958 # } 968 # }
959 template("java_strings_grd_prebuilt") { 969 template("java_strings_grd_prebuilt") {
960 set_sources_assignment_filter([]) 970 set_sources_assignment_filter([])
961 forward_variables_from(invoker, [ "testonly" ]) 971 forward_variables_from(invoker, [ "testonly" ])
962 972
963 base_path = "$target_gen_dir/$target_name" 973 base_path = "$target_gen_dir/$target_name"
964 resources_zip = base_path + ".resources.zip" 974
975 # JUnit tests use resource zip files. These must not be put in gen/
976 # directory or they will not be available to tester bots.
977 resources_zip = "${target_out_dir}/${target_name}.resources.zip"
965 build_config = base_path + ".build_config" 978 build_config = base_path + ".build_config"
966 979
967 build_config_target_name = "${target_name}__build_config" 980 build_config_target_name = "${target_name}__build_config"
968 zip_target_name = "${target_name}__zip" 981 zip_target_name = "${target_name}__zip"
969 final_target_name = target_name 982 final_target_name = target_name
970 983
971 write_build_config(build_config_target_name) { 984 write_build_config(build_config_target_name) {
972 type = "android_resources" 985 type = "android_resources"
973 } 986 }
974 987
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 # java_files = [ "org/chromium/foo/FooTest.java" ] 1073 # java_files = [ "org/chromium/foo/FooTest.java" ]
1061 # deps = [ ":bar_java" ] 1074 # deps = [ ":bar_java" ]
1062 # } 1075 # }
1063 template("junit_binary") { 1076 template("junit_binary") {
1064 set_sources_assignment_filter([]) 1077 set_sources_assignment_filter([])
1065 testonly = true 1078 testonly = true
1066 1079
1067 _java_binary_target_name = "${target_name}__java_binary" 1080 _java_binary_target_name = "${target_name}__java_binary"
1068 _test_runner_target_name = "${target_name}__test_runner_script" 1081 _test_runner_target_name = "${target_name}__test_runner_script"
1069 1082
1083 _build_config = "$target_gen_dir/$target_name.build_config"
1084 _build_config_target_name = "${target_name}__build_config"
1085
1086 write_build_config(_build_config_target_name) {
1087 type = "junit_binary"
1088 build_config = _build_config
1089 if (defined(invoker.deps)) {
1090 possible_config_deps = invoker.deps
1091 }
1092 }
1093
1070 test_runner_script(_test_runner_target_name) { 1094 test_runner_script(_test_runner_target_name) {
1071 test_name = invoker.target_name 1095 test_name = invoker.target_name
1072 test_suite = invoker.target_name 1096 test_suite = invoker.target_name
1073 test_type = "junit" 1097 test_type = "junit"
1074 ignore_all_data_deps = true 1098 ignore_all_data_deps = true
1099 forward_variables_from(invoker,
1100 [
1101 "android_manifest_path",
1102 "package_name",
1103 ])
1075 } 1104 }
1076 1105
1077 java_binary(_java_binary_target_name) { 1106 java_binary(_java_binary_target_name) {
1078 deps = [] 1107 deps = []
1079 output_name = invoker.target_name 1108 output_name = invoker.target_name
1080 forward_variables_from(invoker, "*") 1109 forward_variables_from(invoker, "*")
1081 testonly = true 1110 testonly = true
1082 bypass_platform_checks = true 1111 bypass_platform_checks = true
1083 main_class = "org.chromium.testing.local.JunitTestMain" 1112 main_class = "org.chromium.testing.local.JunitTestMain"
1084 wrapper_script_name = "helper/$target_name" 1113 wrapper_script_name = "helper/$target_name"
1085 deps += [ 1114 deps += [
1086 "//testing/android/junit:junit_test_support", 1115 "//testing/android/junit:junit_test_support",
1087 "//third_party/junit", 1116 "//third_party/junit",
1088 "//third_party/mockito:mockito_java", 1117 "//third_party/mockito:mockito_java",
1089 "//third_party/robolectric:robolectric_all_java", 1118 "//third_party/robolectric:robolectric_all_java",
1090 ] 1119 ]
1091 } 1120 }
1092 group(target_name) { 1121 group(target_name) {
1093 public_deps = [ 1122 public_deps = [
1123 ":$_build_config_target_name",
1094 ":$_java_binary_target_name", 1124 ":$_java_binary_target_name",
1095 ":$_test_runner_target_name", 1125 ":$_test_runner_target_name",
1096 ] 1126 ]
1097 } 1127 }
1098 } 1128 }
1099 1129
1100 # Declare a java library target 1130 # Declare a java library target
1101 # 1131 #
1102 # Variables 1132 # Variables
1103 # deps: Specifies the dependencies of this target. Java targets in this list 1133 # deps: Specifies the dependencies of this target. Java targets in this list
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 # } 1539 # }
1510 template("android_apk") { 1540 template("android_apk") {
1511 set_sources_assignment_filter([]) 1541 set_sources_assignment_filter([])
1512 forward_variables_from(invoker, [ "testonly" ]) 1542 forward_variables_from(invoker, [ "testonly" ])
1513 1543
1514 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) 1544 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
1515 assert(defined(invoker.android_manifest)) 1545 assert(defined(invoker.android_manifest))
1516 gen_dir = "$target_gen_dir/$target_name" 1546 gen_dir = "$target_gen_dir/$target_name"
1517 base_path = "$gen_dir/$target_name" 1547 base_path = "$gen_dir/$target_name"
1518 _build_config = "$target_gen_dir/$target_name.build_config" 1548 _build_config = "$target_gen_dir/$target_name.build_config"
1519 resources_zip_path = "$base_path.resources.zip" 1549
1550 # JUnit tests use resource zip files. These must not be put in gen/
1551 # directory or they will not be available to tester bots.
1552 resources_zip_path = "${target_out_dir}/${target_name}.resources.zip"
1520 _all_resources_zip_path = "$base_path.resources.all.zip" 1553 _all_resources_zip_path = "$base_path.resources.all.zip"
1521 _jar_path = "$base_path.jar" 1554 _jar_path = "$base_path.jar"
1522 _lib_dex_path = "$base_path.dex.jar" 1555 _lib_dex_path = "$base_path.dex.jar"
1523 _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir) 1556 _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir)
1524 _template_name = target_name 1557 _template_name = target_name
1525 if (defined(invoker.java_files)) { 1558 if (defined(invoker.java_files)) {
1526 _java_sources_file = "$base_path.sources" 1559 _java_sources_file = "$base_path.sources"
1527 } 1560 }
1528 1561
1529 enable_multidex = 1562 enable_multidex =
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 # because in practice they seem to contain classes required to be in the 2949 # because in practice they seem to contain classes required to be in the
2917 # classpath. 2950 # classpath.
2918 deps += _subjar_targets 2951 deps += _subjar_targets
2919 } 2952 }
2920 if (defined(_res_target_name)) { 2953 if (defined(_res_target_name)) {
2921 deps += [ ":$_res_target_name" ] 2954 deps += [ ":$_res_target_name" ]
2922 } 2955 }
2923 } 2956 }
2924 } 2957 }
2925 } 2958 }
OLDNEW
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | chrome/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698