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

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

Issue 2767613002: Expose resources in Robolectric/JUnit tests. (Closed)
Patch Set: GN generate resource dirs. Created 3 years, 8 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 # 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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 # grd_file = "foo_strings.grd" 882 # grd_file = "foo_strings.grd"
883 # } 883 # }
884 template("java_strings_grd") { 884 template("java_strings_grd") {
885 set_sources_assignment_filter([]) 885 set_sources_assignment_filter([])
886 forward_variables_from(invoker, [ "testonly" ]) 886 forward_variables_from(invoker, [ "testonly" ])
887 887
888 base_path = "$target_gen_dir/$target_name" 888 base_path = "$target_gen_dir/$target_name"
889 resources_zip = base_path + ".resources.zip" 889 resources_zip = base_path + ".resources.zip"
890 build_config = base_path + ".build_config" 890 build_config = base_path + ".build_config"
891 891
892 write_build_config("${target_name}__build_config") {
893 type = "android_resources"
894 }
895
896 # Put grit files into this subdirectory of target_gen_dir. 892 # Put grit files into this subdirectory of target_gen_dir.
897 extra_output_path = target_name + "_grit_output" 893 extra_output_path = target_name + "_grit_output"
898 894
899 grit_target_name = "${target_name}__grit" 895 grit_target_name = "${target_name}__grit"
900 grit_output_dir = "$target_gen_dir/$extra_output_path" 896 grit_output_dir = "$target_gen_dir/$extra_output_path"
897
898 write_build_config("${target_name}__build_config") {
899 type = "android_resources"
900 resource_dirs = [ grit_output_dir ]
mikecase (-- gone --) 2017/04/10 23:50:36 @agrieve, I looked into this a bit and am almost
901 }
902
901 grit(grit_target_name) { 903 grit(grit_target_name) {
902 forward_variables_from(invoker, [ "deps" ]) 904 forward_variables_from(invoker, [ "deps" ])
903 grit_flags = [ 905 grit_flags = [
904 "-E", 906 "-E",
905 "ANDROID_JAVA_TAGGED_ONLY=false", 907 "ANDROID_JAVA_TAGGED_ONLY=false",
906 ] 908 ]
907 output_dir = grit_output_dir 909 output_dir = grit_output_dir
908 resource_ids = "" 910 resource_ids = ""
909 source = invoker.grd_file 911 source = invoker.grd_file
910 outputs = invoker.outputs 912 outputs = invoker.outputs
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 base_path = "$target_gen_dir/$target_name" 956 base_path = "$target_gen_dir/$target_name"
955 resources_zip = base_path + ".resources.zip" 957 resources_zip = base_path + ".resources.zip"
956 build_config = base_path + ".build_config" 958 build_config = base_path + ".build_config"
957 959
958 build_config_target_name = "${target_name}__build_config" 960 build_config_target_name = "${target_name}__build_config"
959 zip_target_name = "${target_name}__zip" 961 zip_target_name = "${target_name}__zip"
960 final_target_name = target_name 962 final_target_name = target_name
961 963
962 write_build_config(build_config_target_name) { 964 write_build_config(build_config_target_name) {
963 type = "android_resources" 965 type = "android_resources"
966 resource_dirs = [ invoker.grit_output_dir ]
964 } 967 }
965 968
966 zip(zip_target_name) { 969 zip(zip_target_name) {
967 visibility = [ ":$final_target_name" ] 970 visibility = [ ":$final_target_name" ]
968 971
969 base_dir = invoker.grit_output_dir 972 base_dir = invoker.grit_output_dir
970 inputs = rebase_path(invoker.generated_files, ".", base_dir) 973 inputs = rebase_path(invoker.generated_files, ".", base_dir)
971 output = resources_zip 974 output = resources_zip
972 deps = [ 975 deps = [
973 ":$build_config_target_name", 976 ":$build_config_target_name",
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 # java_files = [ "org/chromium/foo/FooTest.java" ] 1054 # java_files = [ "org/chromium/foo/FooTest.java" ]
1052 # deps = [ ":bar_java" ] 1055 # deps = [ ":bar_java" ]
1053 # } 1056 # }
1054 template("junit_binary") { 1057 template("junit_binary") {
1055 set_sources_assignment_filter([]) 1058 set_sources_assignment_filter([])
1056 testonly = true 1059 testonly = true
1057 1060
1058 _java_binary_target_name = "${target_name}__java_binary" 1061 _java_binary_target_name = "${target_name}__java_binary"
1059 _test_runner_target_name = "${target_name}__test_runner_script" 1062 _test_runner_target_name = "${target_name}__test_runner_script"
1060 1063
1064 _build_config = "$target_gen_dir/$target_name.build_config"
1065 _build_config_target_name = "${target_name}__build_config"
1066
1067 write_build_config(_build_config_target_name) {
1068 type = "junit_binary"
1069 build_config = _build_config
1070 if (defined(invoker.deps)) {
1071 possible_config_deps = invoker.deps
1072 }
1073 }
1074
1061 test_runner_script(_test_runner_target_name) { 1075 test_runner_script(_test_runner_target_name) {
1062 test_name = invoker.target_name 1076 test_name = invoker.target_name
1063 test_suite = invoker.target_name 1077 test_suite = invoker.target_name
1064 test_type = "junit" 1078 test_type = "junit"
1065 ignore_all_data_deps = true 1079 ignore_all_data_deps = true
1080 forward_variables_from(invoker,
1081 [
1082 "android_manifest_path",
1083 "package_name",
1084 ])
1066 } 1085 }
1067 1086
1068 java_binary(_java_binary_target_name) { 1087 java_binary(_java_binary_target_name) {
1069 deps = [] 1088 deps = []
1070 output_name = invoker.target_name 1089 output_name = invoker.target_name
1071 forward_variables_from(invoker, "*") 1090 forward_variables_from(invoker, "*")
1072 testonly = true 1091 testonly = true
1073 bypass_platform_checks = true 1092 bypass_platform_checks = true
1074 main_class = "org.chromium.testing.local.JunitTestMain" 1093 main_class = "org.chromium.testing.local.JunitTestMain"
1075 wrapper_script_name = "helper/$target_name" 1094 wrapper_script_name = "helper/$target_name"
1076 deps += [ 1095 deps += [
1077 "//testing/android/junit:junit_test_support", 1096 "//testing/android/junit:junit_test_support",
1078 "//third_party/junit", 1097 "//third_party/junit",
1079 "//third_party/mockito:mockito_java", 1098 "//third_party/mockito:mockito_java",
1080 "//third_party/robolectric:robolectric_all_java", 1099 "//third_party/robolectric:robolectric_all_java",
1081 ] 1100 ]
1082 } 1101 }
1083 group(target_name) { 1102 group(target_name) {
1084 public_deps = [ 1103 public_deps = [
1104 ":$_build_config_target_name",
1085 ":$_java_binary_target_name", 1105 ":$_java_binary_target_name",
1086 ":$_test_runner_target_name", 1106 ":$_test_runner_target_name",
1087 ] 1107 ]
1088 } 1108 }
1089 } 1109 }
1090 1110
1091 # Declare a java library target 1111 # Declare a java library target
1092 # 1112 #
1093 # Variables 1113 # Variables
1094 # deps: Specifies the dependencies of this target. Java targets in this list 1114 # deps: Specifies the dependencies of this target. Java targets in this list
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 # because in practice they seem to contain classes required to be in the 2913 # because in practice they seem to contain classes required to be in the
2894 # classpath. 2914 # classpath.
2895 deps += _subjar_targets 2915 deps += _subjar_targets
2896 } 2916 }
2897 if (defined(_res_target_name)) { 2917 if (defined(_res_target_name)) {
2898 deps += [ ":$_res_target_name" ] 2918 deps += [ ":$_res_target_name" ]
2899 } 2919 }
2900 } 2920 }
2901 } 2921 }
2902 } 2922 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698