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

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

Issue 1975153003: Enable NativeActivity based Android tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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("//base/android/linker/config.gni") 5 import("//base/android/linker/config.gni")
6 import("//build/config/android/config.gni") 6 import("//build/config/android/config.gni")
7 import("//build/config/android/internal_rules.gni") 7 import("//build/config/android/internal_rules.gni")
8 import("//build/config/sanitizers/sanitizers.gni") 8 import("//build/config/sanitizers/sanitizers.gni")
9 import("//build/toolchain/toolchain.gni") 9 import("//build/toolchain/toolchain.gni")
10 import("//third_party/android_platform/config.gni") 10 import("//third_party/android_platform/config.gni")
(...skipping 15 matching lines...) Expand all
26 # Example 26 # Example
27 # generate_jni("foo_jni") { 27 # generate_jni("foo_jni") {
28 # sources = [ 28 # sources = [
29 # "android/java/src/org/chromium/foo/Foo.java", 29 # "android/java/src/org/chromium/foo/Foo.java",
30 # "android/java/src/org/chromium/foo/FooUtil.java", 30 # "android/java/src/org/chromium/foo/FooUtil.java",
31 # ] 31 # ]
32 # jni_package = "foo" 32 # jni_package = "foo"
33 # } 33 # }
34 template("generate_jni") { 34 template("generate_jni") {
35 set_sources_assignment_filter([]) 35 set_sources_assignment_filter([])
36 forward_variables_from(invoker, [ "testonly" ]) 36 forward_variables_from(invoker,
37 [
38 "testonly",
39 "deps",
agrieve 2016/05/19 00:42:50 Adding "deps" here makes it apply to all targets d
ynovikov 2016/05/20 02:38:10 Done.
40 ])
37 41
38 assert(defined(invoker.sources)) 42 assert(defined(invoker.sources))
39 assert(defined(invoker.jni_package)) 43 assert(defined(invoker.jni_package))
40 jni_package = invoker.jni_package 44 jni_package = invoker.jni_package
41 base_output_dir = "${target_gen_dir}/${target_name}" 45 base_output_dir = "${target_gen_dir}/${target_name}"
42 package_output_dir = "${base_output_dir}/${jni_package}" 46 package_output_dir = "${base_output_dir}/${jni_package}"
43 jni_output_dir = "${package_output_dir}/jni" 47 jni_output_dir = "${package_output_dir}/jni"
44 48
45 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h" 49 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h"
46 50
(...skipping 27 matching lines...) Expand all
74 # updated. 78 # updated.
75 include_dirs = [ 79 include_dirs = [
76 base_output_dir, 80 base_output_dir,
77 package_output_dir, 81 package_output_dir,
78 ] 82 ]
79 } 83 }
80 84
81 group(target_name) { 85 group(target_name) {
82 forward_variables_from(invoker, 86 forward_variables_from(invoker,
83 [ 87 [
84 "deps",
85 "public_deps", 88 "public_deps",
86 "visibility", 89 "visibility",
87 ]) 90 ])
88 if (!defined(public_deps)) { 91 if (!defined(public_deps)) {
89 public_deps = [] 92 public_deps = []
90 } 93 }
91 public_deps += [ ":$foreach_target_name" ] 94 public_deps += [ ":$foreach_target_name" ]
92 public_configs = [ ":jni_includes_${target_name}" ] 95 public_configs = [ ":jni_includes_${target_name}" ]
96 if (defined(invoker.deps)) {
97 deps += invoker.deps
98 }
93 } 99 }
94 } 100 }
95 101
96 # Declare a jni target for a prebuilt jar 102 # Declare a jni target for a prebuilt jar
97 # 103 #
98 # This target generates the native jni bindings for a set of classes in a .jar. 104 # This target generates the native jni bindings for a set of classes in a .jar.
99 # 105 #
100 # See base/android/jni_generator/jni_generator.py for more info about the 106 # See base/android/jni_generator/jni_generator.py for more info about the
101 # format of generating JNI bindings. 107 # format of generating JNI bindings.
102 # 108 #
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 # target must be defined previously in the same file. 2111 # target must be defined previously in the same file.
2106 # unittests_binary: The basename of the library produced by the unittests_dep 2112 # unittests_binary: The basename of the library produced by the unittests_dep
2107 # target. If unspecified, it assumes the name of the unittests_dep target 2113 # target. If unspecified, it assumes the name of the unittests_dep target
2108 # (which will be correct unless that target specifies an "output_name". 2114 # (which will be correct unless that target specifies an "output_name".
2109 # TODO(brettw) make this automatic by allowing get_target_outputs to 2115 # TODO(brettw) make this automatic by allowing get_target_outputs to
2110 # support executables. 2116 # support executables.
2111 # apk_name: The name of the produced apk. If unspecified, it uses the name 2117 # apk_name: The name of the produced apk. If unspecified, it uses the name
2112 # of the unittests_dep target postfixed with "_apk" 2118 # of the unittests_dep target postfixed with "_apk"
2113 # use_default_launcher: Whether the default activity (NativeUnitTestActivity) 2119 # use_default_launcher: Whether the default activity (NativeUnitTestActivity)
2114 # should be used for launching tests. 2120 # should be used for launching tests.
2121 # use_native_activity: Test implements ANativeActivity_onCreate().
2115 # 2122 #
2116 # Example 2123 # Example
2117 # unittest_apk("foo_unittests_apk") { 2124 # unittest_apk("foo_unittests_apk") {
2118 # deps = [ ":foo_java", ":foo_resources" ] 2125 # deps = [ ":foo_java", ":foo_resources" ]
2119 # unittests_dep = ":foo_unittests" 2126 # unittests_dep = ":foo_unittests"
2120 # } 2127 # }
2121 template("unittest_apk") { 2128 template("unittest_apk") {
2129 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name")
2130 _test_suite_name = get_label_info(invoker.unittests_dep, "name")
2131
2132 # This trivial assert is needed in case both unittests_binary and apk_name
2133 # are defined, as otherwise _test_suite_name would not be used.
2134 assert(_test_suite_name != "")
2135
2136 if (!defined(invoker.apk_name)) {
2137 _apk_name = _test_suite_name
2138 } else {
2139 _apk_name = invoker.apk_name
2140 }
2141 _use_native_activity =
2142 defined(invoker.use_native_activity) && invoker.use_native_activity
2143
2144 if (!defined(android_manifest)) {
agrieve 2016/05/19 00:42:50 This should be "invoker.android_manifest" I think.
ynovikov 2016/05/20 02:38:10 Done.
2145 jinja_template("${target_name}_manifest") {
2146 if (!defined(invoker.unittests_binary)) {
2147 native_library_name = _test_suite_name
2148 } else {
2149 native_library_name = invoker.unittests_binary
2150 }
2151 input = "//testing/android/native_test/java/AndroidManifest.xml.jinja2"
2152 output = "${root_gen_dir}/${_apk_name}_jinja/AndroidManifest.xml"
agrieve 2016/05/19 00:42:50 Better to use $target_gen_dir/$target_name/ rather
ynovikov 2016/05/20 02:38:10 Done.
2153 variables = [
2154 "is_component_build=${is_component_build}",
2155 "native_library_name=${native_library_name}",
2156 "use_native_activity=${_use_native_activity}",
2157 ]
2158 }
2159 }
2160
2122 android_apk(target_name) { 2161 android_apk(target_name) {
2123 set_sources_assignment_filter([]) 2162 set_sources_assignment_filter([])
2124 data_deps = [] 2163 data_deps = []
2125 deps = [] 2164 deps = []
2126 forward_variables_from(invoker, "*") 2165 forward_variables_from(invoker, "*")
2127 testonly = true 2166 testonly = true
2128 2167
2129 assert(defined(unittests_dep), "Need unittests_dep for $target_name") 2168 apk_name = _apk_name
2130
2131 test_suite_name = get_label_info(unittests_dep, "name")
2132
2133 # This trivial assert is needed in case both unittests_binary and apk_name
2134 # are defined, as otherwise test_suite_name would not be used.
2135 assert(test_suite_name != "")
2136
2137 if (!defined(apk_name)) {
2138 apk_name = test_suite_name
2139 }
2140 2169
2141 if (!defined(android_manifest)) { 2170 if (!defined(android_manifest)) {
2171 deps += [ ":${target_name}_manifest" ]
2142 android_manifest = 2172 android_manifest =
2143 "//testing/android/native_test/java/AndroidManifest.xml" 2173 "${root_gen_dir}/${_apk_name}_jinja/AndroidManifest.xml"
agrieve 2016/05/19 00:42:50 nit: Make a variable for this in the outer scope.
ynovikov 2016/05/20 02:38:10 Done.
2144 } 2174 }
2145 2175
2146 if (!defined(unittests_binary)) { 2176 if (!defined(unittests_binary)) {
2147 unittests_binary = "lib${test_suite_name}${shlib_extension}" 2177 unittests_binary = "lib${_test_suite_name}${shlib_extension}"
2148 } 2178 }
2149 2179
2150 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk" 2180 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk"
2151 2181
2152 if (!defined(use_default_launcher) || use_default_launcher) { 2182 if (!defined(use_default_launcher) || use_default_launcher) {
2153 deps += [ "//testing/android/native_test:native_test_java" ] 2183 if (_use_native_activity) {
2184 deps +=
2185 [ "//testing/android/native_test:native_test_native_activity_java" ]
2186 } else {
2187 deps += [ "//testing/android/native_test:native_test_java" ]
2188 }
2154 } 2189 }
2155 native_libs = [ unittests_binary ] 2190 native_libs = [ unittests_binary ]
2156 deps += [ 2191 deps += [
2157 "//base:base_java", 2192 "//base:base_java",
2158 "//testing/android/appurify_support:appurify_support_java", 2193 "//testing/android/appurify_support:appurify_support_java",
2159 "//testing/android/reporter:reporter_java", 2194 "//testing/android/reporter:reporter_java",
2160 ] 2195 ]
2161 data_deps += [ 2196 data_deps += [
2162 "//build/android/pylib/remote/device/dummy:remote_device_dummy_apk", 2197 "//build/android/pylib/remote/device/dummy:remote_device_dummy_apk",
2163 "//tools/android/md5sum", 2198 "//tools/android/md5sum",
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 "--target", 2462 "--target",
2428 rebase_path(invoker.target, root_build_dir), 2463 rebase_path(invoker.target, root_build_dir),
2429 "--output-directory", 2464 "--output-directory",
2430 rebase_path(root_out_dir, root_build_dir), 2465 rebase_path(root_out_dir, root_build_dir),
2431 ] 2466 ]
2432 if (defined(invoker.flag_name)) { 2467 if (defined(invoker.flag_name)) {
2433 args += [ "--flag-name=${invoker.flag_name}" ] 2468 args += [ "--flag-name=${invoker.flag_name}" ]
2434 } 2469 }
2435 } 2470 }
2436 } 2471 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698