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