| 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 # Define a test as an executable (or apk on Android) with the "testonly" flag | 9 # Define a test as an executable (or apk on Android) with the "testonly" flag |
| 10 # set. | 10 # set. |
| 11 template("test") { | 11 template("test") { |
| 12 if (is_android) { | 12 if (is_android) { |
| 13 import("//build/config/android/config.gni") | 13 import("//build/config/android/config.gni") |
| 14 import("//build/config/android/rules.gni") | 14 import("//build/config/android/rules.gni") |
| 15 | 15 |
| 16 main_target_name = target_name | 16 main_target_name = target_name |
| 17 library_name = "_${target_name}__library" | 17 library_name = "_${target_name}__library" |
| 18 apk_name = "${target_name}_apk" | 18 apk_name = "${target_name}_apk" |
| 19 | 19 |
| 20 shared_library(library_name) { | 20 shared_library(library_name) { |
| 21 # Configs will always be defined since we set_defaults for a component | 21 # 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 | 22 # in the main config. We want to use those rather than whatever came with |
| 23 # the nested shared/static library inside the component. | 23 # the nested shared/static library inside the component. |
| 24 configs = [] # Prevent list overwriting warning. | 24 configs = [] # Prevent list overwriting warning. |
| 25 configs = invoker.configs | 25 configs = invoker.configs |
| 26 | 26 |
| 27 # See above call. | |
| 28 set_sources_assignment_filter([]) | |
| 29 | |
| 30 testonly = true | 27 testonly = true |
| 31 | 28 |
| 32 if (defined(invoker.all_dependent_configs)) { | 29 # Don't use "*" to forward all variables since some (like output_name |
| 33 all_dependent_configs = invoker.all_dependent_configs | 30 # and isolate_file) apply only to the APK below. |
| 34 } | 31 forward_variables_from(invoker, |
| 35 if (defined(invoker.allow_circular_includes_from)) { | 32 [ |
| 36 allow_circular_includes_from = invoker.allow_circular_includes_from | 33 "all_dependent_configs", |
| 37 } | 34 "allow_circular_includes_from", |
| 38 if (defined(invoker.cflags)) { | 35 "cflags", |
| 39 cflags = invoker.cflags | 36 "cflags_c", |
| 40 } | 37 "cflags_cc", |
| 41 if (defined(invoker.cflags_c)) { | 38 "check_includes", |
| 42 cflags_c = invoker.cflags_c | 39 "data", |
| 43 } | 40 "data_deps", |
| 44 if (defined(invoker.cflags_cc)) { | 41 "datadeps", |
| 45 cflags_cc = invoker.cflags_cc | 42 "defines", |
| 46 } | 43 "forward_dependent_configs_from", |
| 47 if (defined(invoker.cflags_objc)) { | 44 "include_dirs", |
| 48 cflags_objc = invoker.cflags_objc | 45 "ldflags", |
| 49 } | 46 "lib_dirs", |
| 50 if (defined(invoker.cflags_objcc)) { | 47 "libs", |
| 51 cflags_objcc = invoker.cflags_objcc | 48 "output_extension", |
| 52 } | 49 "output_name", |
| 53 if (defined(invoker.check_includes)) { | 50 "public", |
| 54 check_includes = invoker.check_includes | 51 "public_configs", |
| 55 } | 52 "public_deps", |
| 56 if (defined(invoker.data)) { | 53 "sources", |
| 57 data = invoker.data | 54 "visibility", |
| 58 } | 55 ]) |
| 59 if (defined(invoker.data_deps)) { | 56 |
| 60 data_deps = invoker.data_deps | |
| 61 } | |
| 62 if (defined(invoker.datadeps)) { | |
| 63 datadeps = invoker.datadeps | |
| 64 } | |
| 65 if (defined(invoker.defines)) { | |
| 66 defines = invoker.defines | |
| 67 } | |
| 68 deps = [] | 57 deps = [] |
| 69 if (!defined(invoker.use_launcher) || invoker.use_launcher) { | 58 if (!defined(invoker.use_launcher) || invoker.use_launcher) { |
| 70 deps += [ "//testing/android/native_test:native_test_native_code" ] | 59 deps += [ "//testing/android/native_test:native_test_native_code" ] |
| 71 } | 60 } |
| 72 if (defined(invoker.deps)) { | 61 if (defined(invoker.deps)) { |
| 73 deps += invoker.deps | 62 deps += invoker.deps |
| 74 } | 63 } |
| 75 if (defined(invoker.forward_dependent_configs_from)) { | |
| 76 forward_dependent_configs_from = invoker.forward_dependent_configs_from | |
| 77 } | |
| 78 if (defined(invoker.include_dirs)) { | |
| 79 include_dirs = invoker.include_dirs | |
| 80 } | |
| 81 if (defined(invoker.ldflags)) { | |
| 82 ldflags = invoker.ldflags | |
| 83 } | |
| 84 if (defined(invoker.lib_dirs)) { | |
| 85 lib_dirs = invoker.lib_dirs | |
| 86 } | |
| 87 if (defined(invoker.libs)) { | |
| 88 libs = invoker.libs | |
| 89 } | |
| 90 if (defined(invoker.output_extension)) { | |
| 91 output_extension = invoker.output_extension | |
| 92 } | |
| 93 if (defined(invoker.output_name)) { | |
| 94 output_name = invoker.output_name | |
| 95 } | |
| 96 if (defined(invoker.public)) { | |
| 97 public = invoker.public | |
| 98 } | |
| 99 if (defined(invoker.public_configs)) { | |
| 100 public_configs = invoker.public_configs | |
| 101 } | |
| 102 if (defined(invoker.public_deps)) { | |
| 103 public_deps = invoker.public_deps | |
| 104 } | |
| 105 if (defined(invoker.sources)) { | |
| 106 sources = invoker.sources | |
| 107 } | |
| 108 if (defined(invoker.visibility)) { | |
| 109 visibility = invoker.visibility | |
| 110 } | |
| 111 } | 64 } |
| 112 | 65 |
| 113 unittest_apk(apk_name) { | 66 unittest_apk(apk_name) { |
| 114 unittests_dep = ":$library_name" | 67 unittests_dep = ":$library_name" |
| 115 apk_name = main_target_name | 68 apk_name = main_target_name |
| 116 if (defined(invoker.output_name)) { | 69 if (defined(invoker.output_name)) { |
| 117 apk_name = invoker.output_name | 70 apk_name = invoker.output_name |
| 118 unittests_binary = "lib${apk_name}.so" | 71 unittests_binary = "lib${apk_name}.so" |
| 119 } | 72 } |
| 120 deps = [ | 73 deps = [ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 147 datadeps = [ | 100 datadeps = [ |
| 148 ":$test_runner_script_name", | 101 ":$test_runner_script_name", |
| 149 ] | 102 ] |
| 150 deps = [ | 103 deps = [ |
| 151 ":$library_name", | 104 ":$library_name", |
| 152 ":$apk_name", | 105 ":$apk_name", |
| 153 ] | 106 ] |
| 154 } | 107 } |
| 155 } else { | 108 } else { |
| 156 executable(target_name) { | 109 executable(target_name) { |
| 157 # See above. | 110 forward_variables_from(invoker, "*") |
| 158 configs = [] # Prevent list overwriting warning. | |
| 159 configs = invoker.configs | |
| 160 | |
| 161 # See above call. | |
| 162 set_sources_assignment_filter([]) | |
| 163 | 111 |
| 164 testonly = true | 112 testonly = true |
| 165 | 113 |
| 166 if (defined(invoker.all_dependent_configs)) { | 114 if (!defined(invoker.deps)) { |
| 167 all_dependent_configs = invoker.all_dependent_configs | |
| 168 } | |
| 169 if (defined(invoker.allow_circular_includes_from)) { | |
| 170 allow_circular_includes_from = invoker.allow_circular_includes_from | |
| 171 } | |
| 172 if (defined(invoker.cflags)) { | |
| 173 cflags = invoker.cflags | |
| 174 } | |
| 175 if (defined(invoker.cflags_c)) { | |
| 176 cflags_c = invoker.cflags_c | |
| 177 } | |
| 178 if (defined(invoker.cflags_cc)) { | |
| 179 cflags_cc = invoker.cflags_cc | |
| 180 } | |
| 181 if (defined(invoker.cflags_objc)) { | |
| 182 cflags_objc = invoker.cflags_objc | |
| 183 } | |
| 184 if (defined(invoker.cflags_objcc)) { | |
| 185 cflags_objcc = invoker.cflags_objcc | |
| 186 } | |
| 187 if (defined(invoker.check_includes)) { | |
| 188 check_includes = invoker.check_includes | |
| 189 } | |
| 190 if (defined(invoker.data)) { | |
| 191 data = invoker.data | |
| 192 } | |
| 193 if (defined(invoker.data_deps)) { | |
| 194 data_deps = invoker.data_deps | |
| 195 } | |
| 196 if (defined(invoker.datadeps)) { | |
| 197 datadeps = invoker.datadeps | |
| 198 } | |
| 199 if (defined(invoker.defines)) { | |
| 200 defines = invoker.defines | |
| 201 } | |
| 202 | |
| 203 if (defined(invoker.deps)) { | |
| 204 deps = invoker.deps | |
| 205 } else { | |
| 206 deps = [] | 115 deps = [] |
| 207 } | 116 } |
| 208 deps += [ | 117 deps += [ |
| 209 # All shared libraries must have the sanitizer deps to properly link in | 118 # All shared libraries must have the sanitizer deps to properly link in |
| 210 # asan mode (this target will be empty in other cases). | 119 # asan mode (this target will be empty in other cases). |
| 211 "//build/config/sanitizers:deps", | 120 "//build/config/sanitizers:deps", |
| 212 | 121 |
| 213 # Give tests the default manifest on Windows (a no-op elsewhere). | 122 # Give tests the default manifest on Windows (a no-op elsewhere). |
| 214 "//build/win:default_exe_manifest", | 123 "//build/win:default_exe_manifest", |
| 215 ] | 124 ] |
| 216 | |
| 217 if (defined(invoker.forward_dependent_configs_from)) { | |
| 218 forward_dependent_configs_from = invoker.forward_dependent_configs_from | |
| 219 } | |
| 220 if (defined(invoker.include_dirs)) { | |
| 221 include_dirs = invoker.include_dirs | |
| 222 } | |
| 223 if (defined(invoker.ldflags)) { | |
| 224 ldflags = invoker.ldflags | |
| 225 } | |
| 226 if (defined(invoker.lib_dirs)) { | |
| 227 lib_dirs = invoker.lib_dirs | |
| 228 } | |
| 229 if (defined(invoker.libs)) { | |
| 230 libs = invoker.libs | |
| 231 } | |
| 232 if (defined(invoker.output_extension)) { | |
| 233 output_extension = invoker.output_extension | |
| 234 } | |
| 235 if (defined(invoker.output_name)) { | |
| 236 output_name = invoker.output_name | |
| 237 } | |
| 238 if (defined(invoker.public)) { | |
| 239 public = invoker.public | |
| 240 } | |
| 241 if (defined(invoker.public_configs)) { | |
| 242 public_configs = invoker.public_configs | |
| 243 } | |
| 244 if (defined(invoker.public_deps)) { | |
| 245 public_deps = invoker.public_deps | |
| 246 } | |
| 247 if (defined(invoker.sources)) { | |
| 248 sources = invoker.sources | |
| 249 } | |
| 250 if (defined(invoker.visibility)) { | |
| 251 visibility = invoker.visibility | |
| 252 } | |
| 253 } | 125 } |
| 254 } | 126 } |
| 255 } | 127 } |
| OLD | NEW |