OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 if (is_chromeos) { |
| 6 declare_args() { |
| 7 chromevox_compress_js = !is_debug |
| 8 } |
| 9 |
| 10 import("//build/config/features.gni") |
| 11 import("//testing/test.gni") |
| 12 import("//chrome/test/base/js2gtest.gni") |
| 13 import("chromevox.gni") |
| 14 |
| 15 group("chromevox") { |
| 16 deps = [ |
| 17 "//chrome/browser/resources/chromeos/braille_ime:braille_ime_manifest", |
| 18 "//chrome/third_party/chromevox:chromevox_third_party_resources", |
| 19 "//third_party/liblouis", |
| 20 |
| 21 #<(DEPTH)/third_party/liblouis/liblouis_nacl.gyp:liblouis_nacl_wrapper_nac
l' # TODO(GYP) |
| 22 ":chromevox_copied_files", |
| 23 ":chromevox_manifest", |
| 24 ":chromevox_guest_manifest", |
| 25 "strings:chromevox_strings", |
| 26 ] |
| 27 if (chromevox_compress_js) { |
| 28 deps += [ |
| 29 ":chromevox1_background_script", |
| 30 ":chromevox1_content_script", |
| 31 ":chromevox1_kbexplorer_script", |
| 32 ":chromevox1_options_script", |
| 33 ":chromevox2_background_script", |
| 34 ] |
| 35 } else { |
| 36 deps += [ ":chromevox_deps_js" ] |
| 37 } |
| 38 } |
| 39 |
| 40 template("run_jsbundler") { |
| 41 assert(defined(invoker.mode)) |
| 42 assert(defined(invoker.sources)) |
| 43 if (defined(invoker.modules)) { |
| 44 modules = invoker.modules |
| 45 } else { |
| 46 modules = [] |
| 47 } |
| 48 if (defined(invoker.rewrite_rules)) { |
| 49 rewrite_rules = invoker.rewrite_rules |
| 50 } else { |
| 51 rewrite_rules = [] |
| 52 } |
| 53 action(target_name) { |
| 54 script = "tools/jsbundler.py" |
| 55 inputs = jsbundler_modules |
| 56 sources = invoker.sources |
| 57 if (defined(invoker.output_file)) { |
| 58 if (defined(invoker.modules)) { |
| 59 depfile = "$target_out_dir/" + |
| 60 get_path_info(invoker.output_file, "name") + ".d" |
| 61 } |
| 62 outputs = [ |
| 63 invoker.output_file, |
| 64 ] |
| 65 } else { |
| 66 assert(!defined(invoker.modules)) |
| 67 outputs = [] |
| 68 } |
| 69 if (defined(invoker.outputs)) { |
| 70 outputs += invoker.outputs |
| 71 } |
| 72 args = [ |
| 73 "-m", |
| 74 invoker.mode, |
| 75 ] |
| 76 if (defined(depfile)) { |
| 77 args += [ |
| 78 "--depfile", |
| 79 rebase_path(depfile, root_build_dir), |
| 80 ] |
| 81 } |
| 82 if (defined(invoker.output_file)) { |
| 83 args += [ |
| 84 "-o", |
| 85 rebase_path(invoker.output_file, root_build_dir), |
| 86 ] |
| 87 } |
| 88 if (defined(invoker.dest_dir)) { |
| 89 args += [ |
| 90 "-d", |
| 91 rebase_path(invoker.dest_dir, root_build_dir), |
| 92 ] |
| 93 } |
| 94 foreach(module, modules) { |
| 95 args += [ |
| 96 "-M", |
| 97 rebase_path(module, root_build_dir), |
| 98 ] |
| 99 } |
| 100 foreach(rule, rewrite_rules) { |
| 101 args += [ |
| 102 "-w", |
| 103 rule, |
| 104 ] |
| 105 } |
| 106 args += rebase_path(sources, root_build_dir) |
| 107 } |
| 108 } |
| 109 |
| 110 chromevox_assets_gypi_values = |
| 111 exec_script("//build/gypi_to_gn.py", |
| 112 [ rebase_path("chromevox_assets.gypi") ], |
| 113 "scope", |
| 114 [ "chromevox_assets.gypi" ]) |
| 115 |
| 116 # Instead of setting up one copy target for each subdirectory, use a script |
| 117 # to copy all files. |
| 118 run_jsbundler("chromevox_copied_files") { |
| 119 mode = "copy" |
| 120 dest_dir = chromevox_out_dir |
| 121 sources = chromevox_assets_gypi_values.chromevox_assets_chromevox |
| 122 sources += chromevox_assets_gypi_values.chromevox_assets_chromevox_backgroun
d_earcons |
| 123 sources += chromevox_assets_gypi_values.chromevox_assets_chromevox_backgroun
d_keymaps |
| 124 sources += chromevox_assets_gypi_values.chromevox_assets_chromevox_backgroun
d_mathmaps_functions |
| 125 sources += chromevox_assets_gypi_values.chromevox_assets_chromevox_backgroun
d_mathmaps_symbols |
| 126 sources += [ |
| 127 "chromevox/background/background.html", |
| 128 "chromevox/background/kbexplorer.html", |
| 129 "chromevox/background/options.html", |
| 130 "chromevox/injected/api.js", |
| 131 "cvox2/background/background.html", |
| 132 ] |
| 133 if (chromevox_compress_js) { |
| 134 sources += [ "chromevox/injected/api_util.js" ] |
| 135 } else { |
| 136 sources += chromevox_modules |
| 137 sources += [ |
| 138 "closure/closure_preinit.js", |
| 139 chromevox_vars_gypi_values.chromevox1_background_script_loader_file, |
| 140 chromevox_vars_gypi_values.chromevox1_content_script_loader_file, |
| 141 chromevox_vars_gypi_values.chromevox1_kbexplorer_loader_file, |
| 142 chromevox_vars_gypi_values.chromevox1_options_script_loader_file, |
| 143 chromevox_vars_gypi_values.chromevox2_background_script_loader_file, |
| 144 ] |
| 145 } |
| 146 outputs = [] |
| 147 foreach(file, sources) { |
| 148 outputs += [ "$chromevox_out_dir/$file" ] |
| 149 } |
| 150 if (!chromevox_compress_js) { |
| 151 sources += closure_library_modules |
| 152 foreach(file, relative_closure_library_modules) { |
| 153 outputs += [ "$chromevox_out_dir/closure/$file" ] |
| 154 } |
| 155 } |
| 156 rewrite_rules = [ |
| 157 rebase_path(".", root_build_dir) + ":", |
| 158 rebase_path(closure_library_dir, root_build_dir) + ":closure", |
| 159 ] |
| 160 } |
| 161 |
| 162 template("manifest") { |
| 163 version_file = "//chrome/VERSION" |
| 164 version_script = "//build/util/version.py" |
| 165 template_file = "manifest.json.jinja2" |
| 166 output_file = invoker.output_file |
| 167 key = chromevox_vars_gypi_values.chromevox_extension_key |
| 168 action(target_name) { |
| 169 script = "tools/generate_manifest.py" |
| 170 inputs = [ |
| 171 version_file, |
| 172 version_script, |
| 173 ] |
| 174 sources = [ |
| 175 template_file, |
| 176 ] |
| 177 outputs = [ |
| 178 output_file, |
| 179 ] |
| 180 args = [ |
| 181 "--key=$key", |
| 182 "--version_file=" + rebase_path(version_file, root_build_dir), |
| 183 "--output_manifest=" + rebase_path(output_file, root_build_dir), |
| 184 ] |
| 185 if (defined(invoker.is_guest_manifest) && invoker.is_guest_manifest) { |
| 186 args += [ "--is_guest_manifest=1" ] |
| 187 } |
| 188 if (!chromevox_compress_js) { |
| 189 args += [ "--is_js_compressed=0" ] |
| 190 } |
| 191 args += rebase_path(sources, root_build_dir) |
| 192 } |
| 193 } |
| 194 |
| 195 manifest("chromevox_manifest") { |
| 196 output_file = "$chromevox_out_dir/manifest.json" |
| 197 } |
| 198 |
| 199 manifest("chromevox_guest_manifest") { |
| 200 output_file = "$chromevox_out_dir/manifest_guest.json" |
| 201 is_guest_manifest = true |
| 202 } |
| 203 |
| 204 template("generate_deps_js") { |
| 205 if (defined(invoker.rewrite_rules)) { |
| 206 rewrite_rules = invoker.rewrite_rules |
| 207 } else { |
| 208 rewrite_rules = [] |
| 209 } |
| 210 action(target_name) { |
| 211 if (defined(invoker.testonly)) { |
| 212 testonly = invoker.testonly |
| 213 } |
| 214 script = "tools/generate_deps.py" |
| 215 inputs = jsbundler_modules |
| 216 sources = invoker.sources |
| 217 outputs = [ |
| 218 invoker.output_file, |
| 219 ] |
| 220 args = [ |
| 221 "-o", |
| 222 rebase_path(invoker.output_file, root_build_dir), |
| 223 ] |
| 224 foreach(rule, rewrite_rules) { |
| 225 args += [ |
| 226 "-w", |
| 227 rule, |
| 228 ] |
| 229 } |
| 230 args += rebase_path(sources, root_build_dir) |
| 231 if (defined(invoker.deps)) { |
| 232 deps = invoker.deps |
| 233 } |
| 234 } |
| 235 } |
| 236 |
| 237 if (chromevox_compress_js) { |
| 238 template("compress_js") { |
| 239 run_jsbundler(target_name) { |
| 240 assert(defined(invoker.output_file)) |
| 241 mode = "compressed_bundle" |
| 242 modules = chromevox_modules + closure_library_modules |
| 243 sources = invoker.sources |
| 244 output_file = invoker.output_file |
| 245 } |
| 246 } |
| 247 |
| 248 compress_js("chromevox1_background_script") { |
| 249 sources = [ |
| 250 chromevox_vars_gypi_values.chromevox1_background_script_loader_file, |
| 251 ] |
| 252 output_file = "$chromevox_out_dir/chromeVoxChromeBackgroundScript.js" |
| 253 } |
| 254 |
| 255 compress_js("chromevox1_content_script") { |
| 256 sources = [ |
| 257 chromevox_vars_gypi_values.chromevox1_content_script_loader_file, |
| 258 ] |
| 259 output_file = "$chromevox_out_dir/chromeVoxChromePageScript.js" |
| 260 } |
| 261 |
| 262 compress_js("chromevox1_kbexplorer_script") { |
| 263 sources = [ |
| 264 chromevox_vars_gypi_values.chromevox1_kbexplorer_loader_file, |
| 265 ] |
| 266 output_file = "$chromevox_out_dir/chromeVoxKbExplorerScript.js" |
| 267 } |
| 268 |
| 269 compress_js("chromevox1_options_script") { |
| 270 sources = [ |
| 271 chromevox_vars_gypi_values.chromevox1_options_script_loader_file, |
| 272 ] |
| 273 output_file = "$chromevox_out_dir/chromeVoxChromeOptionsScript.js" |
| 274 } |
| 275 |
| 276 compress_js("chromevox2_background_script") { |
| 277 sources = [ |
| 278 chromevox_vars_gypi_values.chromevox1_background_script_loader_file, |
| 279 chromevox_vars_gypi_values.chromevox2_background_script_loader_file, |
| 280 ] |
| 281 output_file = "$chromevox_out_dir/chromeVox2ChromeBackgroundScript.js" |
| 282 } |
| 283 } else { |
| 284 generate_deps_js("chromevox_deps_js") { |
| 285 sources = chromevox_modules + closure_library_modules |
| 286 output_file = "$chromevox_out_dir/deps.js" |
| 287 rewrite_rules = [ |
| 288 rebase_path(".", root_build_dir) + ":..", |
| 289 rebase_path(closure_library_dir, root_build_dir) + ":../closure", |
| 290 ] |
| 291 } |
| 292 } |
| 293 |
| 294 chromevox_tests_gypi_values = |
| 295 exec_script("//build/gypi_to_gn.py", |
| 296 [ rebase_path("chromevox_tests.gypi") ], |
| 297 "scope", |
| 298 [ "chromevox_tests.gypi" ]) |
| 299 |
| 300 test("chromevox_tests") { |
| 301 sources = chromevox_tests_gypi_values.chromevox_tests_sources |
| 302 |
| 303 deps = [ |
| 304 "//base", |
| 305 "//base:i18n", |
| 306 "//base/test:test_support", |
| 307 "//chrome:browser_tests_pak", |
| 308 "//chrome:packed_extra_resources", |
| 309 "//chrome:packed_resources", |
| 310 "//chrome:resources", |
| 311 "//chrome:strings", |
| 312 "//chrome/browser", |
| 313 "//chrome/renderer", |
| 314 "//chrome/test:test_support", |
| 315 "//testing/gmock", |
| 316 "//testing/gtest", |
| 317 ":chromevox_extjs_tests", |
| 318 ":chromevox_unitjs_tests", |
| 319 ] |
| 320 if (cld_version == 0 || cld_version == 2) { |
| 321 # Because the browser_tests use translate, they need CLD data. |
| 322 deps += [ "//third_party/cld_2:cld2_platform_impl" ] |
| 323 } |
| 324 } |
| 325 |
| 326 action("chromevox_test_messages_js") { |
| 327 script = "tools/generate_test_messages.py" |
| 328 sources = [ |
| 329 "$chromevox_out_dir/_locales/en/messages.json", |
| 330 ] |
| 331 output_file = "$root_out_dir/test_data/chrome/browser/resources/chromeos/chr
omevox/host/testing/test_messages.js" |
| 332 outputs = [ |
| 333 output_file, |
| 334 ] |
| 335 deps = [ |
| 336 "strings:chromevox_strings", |
| 337 ] |
| 338 args = [ |
| 339 "-o", |
| 340 rebase_path(output_file, root_build_dir), |
| 341 ] + rebase_path(sources, root_build_dir) |
| 342 } |
| 343 |
| 344 chromevox_test_modules = [ |
| 345 "host/testing/earcons.js", |
| 346 "host/testing/host.js", |
| 347 "host/testing/mathjax.js", |
| 348 "host/testing/tts.js", |
| 349 "testing/spoken_list_builder.js", |
| 350 "testing/test_msgs.js", |
| 351 "testing/tester.js", |
| 352 ] + get_target_outputs(":chromevox_test_messages_js") |
| 353 |
| 354 generate_deps_js("chromevox_test_deps_js") { |
| 355 sources = |
| 356 closure_library_modules + chromevox_modules + chromevox_test_modules |
| 357 output_file = "$target_gen_dir/test_deps.js" |
| 358 rewrite_rules = [ |
| 359 rebase_path("//", root_build_dir) + ":", |
| 360 rebase_path("$root_out_dir/test_data", root_build_dir) + ":", |
| 361 ] |
| 362 deps = [ |
| 363 ":chromevox_test_messages_js", |
| 364 ] |
| 365 } |
| 366 |
| 367 js2gtest("chromevox_unitjs_tests") { |
| 368 test_type = "webui" |
| 369 sources = chromevox_tests_gypi_values.chromevox_tests_unitjs_sources |
| 370 test_deps_js_outputs = get_target_outputs(":chromevox_test_deps_js") |
| 371 deps_js = test_deps_js_outputs[0] |
| 372 deps = [ |
| 373 ":chromevox_test_deps_js", |
| 374 ] |
| 375 defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] |
| 376 } |
| 377 |
| 378 js2gtest("chromevox_extjs_tests") { |
| 379 test_type = "extension" |
| 380 sources = chromevox_tests_gypi_values.chromevox_tests_extjs_sources |
| 381 sources -= [ "braille/liblouis_test.extjs" ] # TODO(GYP) |
| 382 defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] |
| 383 } |
| 384 } |
OLD | NEW |