Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 assert(defined(invoker.jni_package)) | 39 assert(defined(invoker.jni_package)) |
| 40 jni_package = invoker.jni_package | 40 jni_package = invoker.jni_package |
| 41 base_output_dir = "${target_gen_dir}/${target_name}" | 41 base_output_dir = "${target_gen_dir}/${target_name}" |
| 42 package_output_dir = "${base_output_dir}/${jni_package}" | 42 package_output_dir = "${base_output_dir}/${jni_package}" |
| 43 jni_output_dir = "${package_output_dir}/jni" | 43 jni_output_dir = "${package_output_dir}/jni" |
| 44 | 44 |
| 45 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h" | 45 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h" |
| 46 | 46 |
| 47 foreach_target_name = "${target_name}__jni_gen" | 47 foreach_target_name = "${target_name}__jni_gen" |
| 48 action_foreach(foreach_target_name) { | 48 action_foreach(foreach_target_name) { |
| 49 forward_variables_from(invoker, [ "deps" ]) | |
| 49 script = "//base/android/jni_generator/jni_generator.py" | 50 script = "//base/android/jni_generator/jni_generator.py" |
| 50 depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d" | 51 depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d" |
| 51 sources = invoker.sources | 52 sources = invoker.sources |
| 52 outputs = [ | 53 outputs = [ |
| 53 depfile, | 54 depfile, |
| 54 "${jni_output_dir}/{{source_name_part}}_jni.h", | 55 "${jni_output_dir}/{{source_name_part}}_jni.h", |
| 55 ] | 56 ] |
| 56 | 57 |
| 57 args = [ | 58 args = [ |
| 58 "--depfile", | 59 "--depfile", |
| (...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2105 # target must be defined previously in the same file. | 2106 # target must be defined previously in the same file. |
| 2106 # unittests_binary: The basename of the library produced by the unittests_dep | 2107 # 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 | 2108 # target. If unspecified, it assumes the name of the unittests_dep target |
| 2108 # (which will be correct unless that target specifies an "output_name". | 2109 # (which will be correct unless that target specifies an "output_name". |
| 2109 # TODO(brettw) make this automatic by allowing get_target_outputs to | 2110 # TODO(brettw) make this automatic by allowing get_target_outputs to |
| 2110 # support executables. | 2111 # support executables. |
| 2111 # apk_name: The name of the produced apk. If unspecified, it uses the name | 2112 # apk_name: The name of the produced apk. If unspecified, it uses the name |
| 2112 # of the unittests_dep target postfixed with "_apk" | 2113 # of the unittests_dep target postfixed with "_apk" |
| 2113 # use_default_launcher: Whether the default activity (NativeUnitTestActivity) | 2114 # use_default_launcher: Whether the default activity (NativeUnitTestActivity) |
| 2114 # should be used for launching tests. | 2115 # should be used for launching tests. |
| 2116 # use_native_activity: Test implements ANativeActivity_onCreate(). | |
| 2115 # | 2117 # |
| 2116 # Example | 2118 # Example |
| 2117 # unittest_apk("foo_unittests_apk") { | 2119 # unittest_apk("foo_unittests_apk") { |
| 2118 # deps = [ ":foo_java", ":foo_resources" ] | 2120 # deps = [ ":foo_java", ":foo_resources" ] |
| 2119 # unittests_dep = ":foo_unittests" | 2121 # unittests_dep = ":foo_unittests" |
| 2120 # } | 2122 # } |
| 2121 template("unittest_apk") { | 2123 template("unittest_apk") { |
| 2124 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name") | |
| 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 | |
| 2134 # This trivial assert is needed in case both android_manifest and !use_default _launcher | |
|
Dirk Pranke
2016/05/20 17:18:41
nit: wrap long line?
ynovikov
2016/05/26 03:16:15
Done.
| |
| 2135 # are defined, as otherwise _use_native_activity would not be used. | |
| 2136 assert(_use_native_activity != "") | |
| 2137 _android_manifest = "$target_gen_dir/$target_name/AndroidManifest.xml" | |
| 2138 | |
| 2139 # This trivial assert is needed in case android_manifest | |
| 2140 # is defined, as otherwise _android_manifest would not be used. | |
| 2141 assert(_android_manifest != "") | |
| 2142 | |
| 2143 if (!defined(invoker.android_manifest)) { | |
| 2144 jinja_template("${target_name}_manifest") { | |
| 2145 if (!defined(invoker.unittests_binary)) { | |
| 2146 native_library_name = _test_suite_name | |
| 2147 } else { | |
| 2148 native_library_name = invoker.unittests_binary | |
| 2149 } | |
| 2150 input = "//testing/android/native_test/java/AndroidManifest.xml.jinja2" | |
| 2151 output = _android_manifest | |
| 2152 variables = [ | |
| 2153 "is_component_build=${is_component_build}", | |
| 2154 "native_library_name=${native_library_name}", | |
| 2155 "use_native_activity=${_use_native_activity}", | |
| 2156 ] | |
| 2157 } | |
| 2158 } | |
| 2159 | |
| 2122 android_apk(target_name) { | 2160 android_apk(target_name) { |
| 2123 set_sources_assignment_filter([]) | 2161 set_sources_assignment_filter([]) |
| 2124 data_deps = [] | 2162 data_deps = [] |
| 2125 deps = [] | 2163 deps = [] |
| 2126 forward_variables_from(invoker, "*") | 2164 forward_variables_from(invoker, "*") |
| 2127 testonly = true | 2165 testonly = true |
| 2128 | 2166 |
| 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(apk_name)) { | 2167 if (!defined(apk_name)) { |
| 2138 apk_name = test_suite_name | 2168 apk_name = test_suite_name |
| 2139 } | 2169 } |
| 2140 | 2170 |
| 2141 if (!defined(android_manifest)) { | 2171 if (!defined(android_manifest)) { |
| 2142 android_manifest = | 2172 deps += [ ":${target_name}_manifest" ] |
| 2143 "//testing/android/native_test/java/AndroidManifest.xml" | 2173 android_manifest = _android_manifest |
| 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 Loading... | |
| 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 } |
| OLD | NEW |