| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 # ============================================================================== | 5 # ============================================================================== |
| 6 # TEST SETUP | 6 # TEST SETUP |
| 7 # ============================================================================== | 7 # ============================================================================== |
| 8 | 8 |
| 9 if (is_android) { |
| 10 template("_gen_apk_isolate") { |
| 11 action(target_name) { |
| 12 script = "//build/android/gyp/gen-android-test-isolate.py" |
| 13 outputs = [ |
| 14 invoker.output, |
| 15 ] |
| 16 args = [ |
| 17 "--out-file", |
| 18 rebase_path(invoker.output, root_build_dir), |
| 19 ".", |
| 20 invoker.lib_target, |
| 21 ] |
| 22 } |
| 23 } |
| 24 } |
| 25 |
| 9 # Define a test as an executable (or apk on Android) with the "testonly" flag | 26 # Define a test as an executable (or apk on Android) with the "testonly" flag |
| 10 # set. | 27 # set. |
| 11 template("test") { | 28 template("test") { |
| 12 if (is_android) { | 29 if (is_android) { |
| 13 import("//build/config/android/config.gni") | 30 import("//build/config/android/config.gni") |
| 14 import("//build/config/android/rules.gni") | 31 import("//build/config/android/rules.gni") |
| 15 | 32 |
| 16 main_target_name = target_name | 33 main_target_name = target_name |
| 17 library_name = "_${target_name}__library" | 34 library_name = "_${target_name}__library" |
| 18 apk_name = "${target_name}_apk" | 35 apk_name = "${target_name}_apk" |
| 19 | 36 |
| 37 # TODO(agrieve): Delete invoker.isolate_file when write_runtime_deps() is |
| 38 # available. http://crbug.com/593416 |
| 39 _requires_apk_isolate = |
| 40 defined(invoker.isolate_file) && invoker.isolate_file != "" |
| 41 |
| 42 if (_requires_apk_isolate) { |
| 43 _apk_isolate_target_name = "_${target_name}__apk_isolate" |
| 44 _apk_isolate_path = "$target_gen_dir/$target_name.apk.isolate" |
| 45 _gen_apk_isolate(_apk_isolate_target_name) { |
| 46 lib_target = get_label_info(":$library_name", "label_no_toolchain") |
| 47 output = _apk_isolate_path |
| 48 } |
| 49 } |
| 20 shared_library(library_name) { | 50 shared_library(library_name) { |
| 21 # Configs will always be defined since we set_defaults for a component | 51 # Configs will always be defined since we set_defaults for a component |
| 22 # in the main config. We want to use those rather than whatever came with | 52 # in the main config. We want to use those rather than whatever came with |
| 23 # the nested shared/static library inside the component. | 53 # the nested shared/static library inside the component. |
| 24 configs = [] # Prevent list overwriting warning. | 54 configs = [] # Prevent list overwriting warning. |
| 25 configs = invoker.configs | 55 configs = invoker.configs |
| 26 | 56 |
| 27 testonly = true | 57 testonly = true |
| 28 | 58 |
| 29 # Don't use "*" to forward all variables since some (like output_name | 59 # Don't use "*" to forward all variables since some (like output_name |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 _test_name = main_target_name | 112 _test_name = main_target_name |
| 83 if (defined(invoker.output_name)) { | 113 if (defined(invoker.output_name)) { |
| 84 _test_name = invoker.output_name | 114 _test_name = invoker.output_name |
| 85 } | 115 } |
| 86 test_runner_script_name = "${_test_name}__test_runner_script" | 116 test_runner_script_name = "${_test_name}__test_runner_script" |
| 87 test_runner_script(test_runner_script_name) { | 117 test_runner_script(test_runner_script_name) { |
| 88 apk_target = ":$apk_name" | 118 apk_target = ":$apk_name" |
| 89 test_name = _test_name | 119 test_name = _test_name |
| 90 test_type = "gtest" | 120 test_type = "gtest" |
| 91 test_suite = _test_name | 121 test_suite = _test_name |
| 92 if (defined(invoker.isolate_file)) { | 122 if (_requires_apk_isolate) { |
| 93 isolate_file = invoker.isolate_file | 123 isolate_file = _apk_isolate_path |
| 94 } | 124 } |
| 95 } | 125 } |
| 96 incremental_test_runner_script_name = | 126 incremental_test_runner_script_name = |
| 97 "${_test_name}_incremental__test_runner_script" | 127 "${_test_name}_incremental__test_runner_script" |
| 98 test_runner_script(incremental_test_runner_script_name) { | 128 test_runner_script(incremental_test_runner_script_name) { |
| 99 apk_target = ":$apk_name" | 129 apk_target = ":$apk_name" |
| 100 test_name = "${_test_name}_incremental" | 130 test_name = "${_test_name}_incremental" |
| 101 test_type = "gtest" | 131 test_type = "gtest" |
| 102 test_suite = _test_name | 132 test_suite = _test_name |
| 103 incremental_install = true | 133 incremental_install = true |
| 104 if (defined(invoker.isolate_file)) { | 134 if (_requires_apk_isolate) { |
| 105 isolate_file = invoker.isolate_file | 135 isolate_file = _apk_isolate_path |
| 106 } | 136 } |
| 107 } | 137 } |
| 108 | 138 |
| 109 group(target_name) { | 139 group(target_name) { |
| 110 testonly = true | 140 testonly = true |
| 111 datadeps = [ | 141 data_deps = [ |
| 112 ":$test_runner_script_name", | 142 ":$test_runner_script_name", |
| 113 ] | 143 ] |
| 144 if (_requires_apk_isolate) { |
| 145 data_deps += [ ":$_apk_isolate_target_name" ] |
| 146 } |
| 114 deps = [ | 147 deps = [ |
| 115 ":$apk_name", | 148 ":$apk_name", |
| 116 ] | 149 ] |
| 117 } | 150 } |
| 118 group("${target_name}_incremental") { | 151 group("${target_name}_incremental") { |
| 119 testonly = true | 152 testonly = true |
| 120 datadeps = [ | 153 data_deps = [ |
| 121 ":$incremental_test_runner_script_name", | 154 ":$incremental_test_runner_script_name", |
| 122 ] | 155 ] |
| 156 if (_requires_apk_isolate) { |
| 157 data_deps += [ ":$_apk_isolate_target_name" ] |
| 158 } |
| 123 deps = [ | 159 deps = [ |
| 124 ":${apk_name}_incremental", | 160 ":${apk_name}_incremental", |
| 125 ] | 161 ] |
| 126 } | 162 } |
| 127 | 163 |
| 128 # TODO(GYP): Delete this after we've converted everything to GN. | 164 # TODO(GYP): Delete this after we've converted everything to GN. |
| 129 # The _run targets exist only for compatibility w/ GYP. | 165 # The _run targets exist only for compatibility w/ GYP. |
| 130 group("${target_name}_apk_run") { | 166 group("${target_name}_apk_run") { |
| 131 testonly = true | 167 testonly = true |
| 132 deps = [ | 168 deps = [ |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 # TODO(GYP): Delete this after we've converted everything to GN. | 245 # TODO(GYP): Delete this after we've converted everything to GN. |
| 210 # The _run targets exist only for compatibility with GYP. | 246 # The _run targets exist only for compatibility with GYP. |
| 211 group("${target_name}_run") { | 247 group("${target_name}_run") { |
| 212 testonly = true | 248 testonly = true |
| 213 deps = [ | 249 deps = [ |
| 214 ":$main_target_name", | 250 ":$main_target_name", |
| 215 ] | 251 ] |
| 216 } | 252 } |
| 217 } | 253 } |
| 218 } | 254 } |
| OLD | NEW |