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("//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 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 # target must be defined previously in the same file. | 2113 # target must be defined previously in the same file. |
2114 # unittests_binary: The basename of the library produced by the unittests_dep | 2114 # unittests_binary: The basename of the library produced by the unittests_dep |
2115 # target. If unspecified, it assumes the name of the unittests_dep target | 2115 # target. If unspecified, it assumes the name of the unittests_dep target |
2116 # (which will be correct unless that target specifies an "output_name". | 2116 # (which will be correct unless that target specifies an "output_name". |
2117 # TODO(brettw) make this automatic by allowing get_target_outputs to | 2117 # TODO(brettw) make this automatic by allowing get_target_outputs to |
2118 # support executables. | 2118 # support executables. |
2119 # apk_name: The name of the produced apk. If unspecified, it uses the name | 2119 # apk_name: The name of the produced apk. If unspecified, it uses the name |
2120 # of the unittests_dep target postfixed with "_apk" | 2120 # of the unittests_dep target postfixed with "_apk" |
2121 # use_default_launcher: Whether the default activity (NativeUnitTestActivity) | 2121 # use_default_launcher: Whether the default activity (NativeUnitTestActivity) |
2122 # should be used for launching tests. | 2122 # should be used for launching tests. |
| 2123 # use_native_activity: Test implements ANativeActivity_onCreate(). |
2123 # | 2124 # |
2124 # Example | 2125 # Example |
2125 # unittest_apk("foo_unittests_apk") { | 2126 # unittest_apk("foo_unittests_apk") { |
2126 # deps = [ ":foo_java", ":foo_resources" ] | 2127 # deps = [ ":foo_java", ":foo_resources" ] |
2127 # unittests_dep = ":foo_unittests" | 2128 # unittests_dep = ":foo_unittests" |
2128 # } | 2129 # } |
2129 template("unittest_apk") { | 2130 template("unittest_apk") { |
| 2131 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name") |
| 2132 |
| 2133 test_suite_name = get_label_info(invoker.unittests_dep, "name") |
| 2134 |
| 2135 # This trivial assert is needed in case both unittests_binary and apk_name |
| 2136 # are defined, as otherwise test_suite_name would not be used. |
| 2137 assert(test_suite_name != "") |
| 2138 |
| 2139 _use_native_activity = |
| 2140 defined(invoker.use_native_activity) && invoker.use_native_activity |
| 2141 _android_manifest = "$target_gen_dir/$target_name/AndroidManifest.xml" |
| 2142 |
| 2143 # This trivial assert is needed in case android_manifest is defined, |
| 2144 # as otherwise _use_native_activity and _android_manifest would not be used. |
| 2145 assert(_use_native_activity != "" && _android_manifest != "") |
| 2146 |
| 2147 if (!defined(invoker.android_manifest)) { |
| 2148 jinja_template("${target_name}_manifest") { |
| 2149 if (!defined(invoker.unittests_binary)) { |
| 2150 native_library_name = test_suite_name |
| 2151 } else { |
| 2152 native_library_name = invoker.unittests_binary |
| 2153 } |
| 2154 input = "//testing/android/native_test/java/AndroidManifest.xml.jinja2" |
| 2155 output = _android_manifest |
| 2156 variables = [ |
| 2157 "is_component_build=${is_component_build}", |
| 2158 "native_library_name=${native_library_name}", |
| 2159 "use_native_activity=${_use_native_activity}", |
| 2160 ] |
| 2161 } |
| 2162 } |
| 2163 |
2130 android_apk(target_name) { | 2164 android_apk(target_name) { |
2131 set_sources_assignment_filter([]) | 2165 set_sources_assignment_filter([]) |
2132 data_deps = [] | 2166 data_deps = [] |
2133 deps = [] | 2167 deps = [] |
2134 forward_variables_from(invoker, "*") | 2168 forward_variables_from(invoker, "*") |
2135 testonly = true | 2169 testonly = true |
2136 | 2170 |
2137 assert(defined(unittests_dep), "Need unittests_dep for $target_name") | |
2138 | |
2139 test_suite_name = get_label_info(unittests_dep, "name") | |
2140 | |
2141 # This trivial assert is needed in case both unittests_binary and apk_name | |
2142 # are defined, as otherwise test_suite_name would not be used. | |
2143 assert(test_suite_name != "") | |
2144 | |
2145 if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) { | 2171 if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) { |
2146 assert(invoker.proguard_configs != []) | 2172 assert(invoker.proguard_configs != []) |
2147 proguard_enabled = true | 2173 proguard_enabled = true |
2148 proguard_configs = invoker.proguard_configs | 2174 proguard_configs = invoker.proguard_configs |
2149 } | 2175 } |
2150 | 2176 |
2151 if (!defined(apk_name)) { | 2177 if (!defined(apk_name)) { |
2152 apk_name = test_suite_name | 2178 apk_name = test_suite_name |
2153 } | 2179 } |
2154 | 2180 |
2155 if (!defined(android_manifest)) { | 2181 if (!defined(android_manifest)) { |
2156 android_manifest = | 2182 deps += [ ":${target_name}_manifest" ] |
2157 "//testing/android/native_test/java/AndroidManifest.xml" | 2183 android_manifest = _android_manifest |
2158 } | 2184 } |
2159 | 2185 |
2160 if (!defined(unittests_binary)) { | 2186 if (!defined(unittests_binary)) { |
2161 unittests_binary = "lib${test_suite_name}${shlib_extension}" | 2187 unittests_binary = "lib${test_suite_name}${shlib_extension}" |
2162 } | 2188 } |
2163 | 2189 |
2164 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk" | 2190 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk" |
2165 | 2191 |
2166 if (!defined(use_default_launcher) || use_default_launcher) { | 2192 if (!defined(use_default_launcher) || use_default_launcher) { |
2167 deps += [ "//testing/android/native_test:native_test_java" ] | 2193 deps += [ "//testing/android/native_test:native_test_java" ] |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 "--target", | 2467 "--target", |
2442 rebase_path(invoker.target, root_build_dir), | 2468 rebase_path(invoker.target, root_build_dir), |
2443 "--output-directory", | 2469 "--output-directory", |
2444 rebase_path(root_out_dir, root_build_dir), | 2470 rebase_path(root_out_dir, root_build_dir), |
2445 ] | 2471 ] |
2446 if (defined(invoker.flag_name)) { | 2472 if (defined(invoker.flag_name)) { |
2447 args += [ "--flag-name=${invoker.flag_name}" ] | 2473 args += [ "--flag-name=${invoker.flag_name}" ] |
2448 } | 2474 } |
2449 } | 2475 } |
2450 } | 2476 } |
OLD | NEW |