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.
5 import("//build/config/features.gni")
6 import("//testing/test.gni")
7 import("//chrome/test/base/js2gtest.gni")
8 import("chromevox.gni")
13 # Whether to compress the main Chromevox javascript files or load the
14 # modules individually from source files.
15 chromevox_compress_js = !is_debug
18 chromevox_out_dir = "$root_out_dir/resources/chromeos/chromevox"
22 "//chrome/browser/resources/chromeos/braille_ime:braille_ime_manifest",
23 "//chrome/browser/resources/chromeos/chromevox/strings:chromevox_strings",
24 "//chrome/third_party/chromevox:chromevox_third_party_resources",
25 "//third_party/liblouis",
27 #<(DEPTH)/third_party/liblouis/liblouis_nacl.gyp:liblouis_nacl_wrapper_nacl' # TODO(GYP)
28 ":chromevox_copied_files",
29 ":chromevox_manifest",
30 ":chromevox_guest_manifest",
32 if (chromevox_compress_js) {
34 ":chromevox1_background_script",
35 ":chromevox1_content_script",
36 ":chromevox1_kbexplorer_script",
37 ":chromevox1_options_script",
38 ":chromevox2_background_script",
41 deps += [ ":chromevox_deps_js" ]
45 template("run_jsbundler") {
46 assert(defined(invoker.mode))
47 assert(defined(invoker.sources))
48 if (defined(invoker.modules)) {
49 modules = invoker.modules
53 if (defined(invoker.rewrite_rules)) {
54 rewrite_rules = invoker.rewrite_rules
59 script = "tools/jsbundler.py"
60 inputs = jsbundler_modules
61 sources = invoker.sources
62 if (defined(invoker.output_file)) {
63 if (defined(invoker.modules)) {
64 depfile = "$target_out_dir/" +
65 get_path_info(invoker.output_file, "name") + ".d"
71 assert(!defined(invoker.modules))
72 stampfile = "$target_out_dir/${target_name}_copy.stamp"
81 if (defined(depfile)) {
84 rebase_path(depfile, root_build_dir),
87 if (defined(stampfile)) {
90 rebase_path(stampfile, root_build_dir),
93 if (defined(invoker.output_file)) {
96 rebase_path(invoker.output_file, root_build_dir),
99 if (defined(invoker.dest_dir)) {
102 rebase_path(invoker.dest_dir, root_build_dir),
105 foreach(module, modules) {
108 rebase_path(module, root_build_dir),
111 foreach(rule, rewrite_rules) {
117 args += rebase_path(sources, root_build_dir)
121 chromevox_assets_gypi_values =
122 exec_script("//build/gypi_to_gn.py",
123 [ rebase_path("chromevox_assets.gypi") ],
125 [ "chromevox_assets.gypi" ])
127 chromevox_vars_gypi_values = exec_script("//build/gypi_to_gn.py",
128 [ rebase_path("chromevox_vars.gypi") ],
130 [ "chromevox_vars.gypi" ])
132 # Instead of setting up one copy target for each subdirectory, use a script
134 run_jsbundler("chromevox_copied_files") {
136 dest_dir = chromevox_out_dir
137 sources = chromevox_assets_gypi_values.chromevox_assets_chromevox
139 chromevox_assets_gypi_values.chromevox_assets_chromevox_background_earcons
141 chromevox_assets_gypi_values.chromevox_assets_chromevox_background_keymaps
142 sources += chromevox_assets_gypi_values.chromevox_assets_chromevox_background_mathmaps_functions
143 sources += chromevox_assets_gypi_values.chromevox_assets_chromevox_background_mathmaps_symbols
145 "chromevox/background/background.html",
146 "chromevox/background/kbexplorer.html",
147 "chromevox/background/options.html",
148 "chromevox/injected/api.js",
149 "cvox2/background/background.html",
151 if (chromevox_compress_js) {
152 sources += [ "chromevox/injected/api_util.js" ]
154 sources += chromevox_modules
156 "closure/closure_preinit.js",
157 chromevox_vars_gypi_values.chromevox1_background_script_loader_file,
158 chromevox_vars_gypi_values.chromevox1_content_script_loader_file,
159 chromevox_vars_gypi_values.chromevox1_kbexplorer_loader_file,
160 chromevox_vars_gypi_values.chromevox1_options_script_loader_file,
161 chromevox_vars_gypi_values.chromevox2_background_script_loader_file,
164 if (!chromevox_compress_js) {
165 sources += closure_library_modules
168 rebase_path(".", root_build_dir) + ":",
169 rebase_path(closure_library_dir, root_build_dir) + ":closure",
173 template("manifest") {
174 version_file = "//chrome/VERSION"
175 version_script = "//build/util/version.py"
176 template_file = "manifest.json.jinja2"
177 output_file = invoker.output_file
178 key = chromevox_vars_gypi_values.chromevox_extension_key
179 action(target_name) {
180 script = "tools/generate_manifest.py"
193 "--version_file=" + rebase_path(version_file, root_build_dir),
194 "--output_manifest=" + rebase_path(output_file, root_build_dir),
196 if (defined(invoker.is_guest_manifest) && invoker.is_guest_manifest) {
197 args += [ "--is_guest_manifest=1" ]
199 if (!chromevox_compress_js) {
200 args += [ "--is_js_compressed=0" ]
202 args += rebase_path(sources, root_build_dir)
206 manifest("chromevox_manifest") {
207 output_file = "$chromevox_out_dir/manifest.json"
210 manifest("chromevox_guest_manifest") {
211 output_file = "$chromevox_out_dir/manifest_guest.json"
212 is_guest_manifest = true
215 template("generate_deps_js") {
216 if (defined(invoker.rewrite_rules)) {
217 rewrite_rules = invoker.rewrite_rules
221 action(target_name) {
222 if (defined(invoker.testonly)) {
223 testonly = invoker.testonly
225 script = "tools/generate_deps.py"
226 inputs = jsbundler_modules
227 sources = invoker.sources
233 rebase_path(invoker.output_file, root_build_dir),
235 foreach(rule, rewrite_rules) {
241 args += rebase_path(sources, root_build_dir)
242 if (defined(invoker.deps)) {
248 if (chromevox_compress_js) {
249 template("compress_js") {
250 run_jsbundler(target_name) {
251 assert(defined(invoker.output_file))
252 mode = "compressed_bundle"
253 modules = chromevox_modules + closure_library_modules
254 sources = invoker.sources
255 output_file = invoker.output_file
259 compress_js("chromevox1_background_script") {
261 chromevox_vars_gypi_values.chromevox1_background_script_loader_file,
263 output_file = "$chromevox_out_dir/chromeVoxChromeBackgroundScript.js"
266 compress_js("chromevox1_content_script") {
268 chromevox_vars_gypi_values.chromevox1_content_script_loader_file,
270 output_file = "$chromevox_out_dir/chromeVoxChromePageScript.js"
273 compress_js("chromevox1_kbexplorer_script") {
275 chromevox_vars_gypi_values.chromevox1_kbexplorer_loader_file,
277 output_file = "$chromevox_out_dir/chromeVoxKbExplorerScript.js"
280 compress_js("chromevox1_options_script") {
282 chromevox_vars_gypi_values.chromevox1_options_script_loader_file,
284 output_file = "$chromevox_out_dir/chromeVoxChromeOptionsScript.js"
287 compress_js("chromevox2_background_script") {
289 chromevox_vars_gypi_values.chromevox1_background_script_loader_file,
290 chromevox_vars_gypi_values.chromevox2_background_script_loader_file,
292 output_file = "$chromevox_out_dir/chromeVox2ChromeBackgroundScript.js"
295 generate_deps_js("chromevox_deps_js") {
296 sources = chromevox_modules + closure_library_modules
297 output_file = "$chromevox_out_dir/deps.js"
299 rebase_path(".", root_build_dir) + ":..",
300 rebase_path(closure_library_dir, root_build_dir) + ":../closure",
305 chromevox_tests_gypi_values =
306 exec_script("//build/gypi_to_gn.py",
307 [ rebase_path("chromevox_tests.gypi") ],
309 [ "chromevox_tests.gypi" ])
311 test("chromevox_tests") {
312 sources = chromevox_tests_gypi_values.chromevox_tests_sources
317 "//base/test:test_support",
318 "//chrome:browser_tests_pak",
319 "//chrome:packed_extra_resources",
320 "//chrome:packed_resources",
321 "//chrome:resources",
325 "//chrome/test:test_support",
328 ":chromevox_extjs_tests",
329 ":chromevox_unitjs_tests",
331 if (cld_version == 0 || cld_version == 2) {
332 # Because the browser_tests use translate, they need CLD data.
333 deps += [ "//third_party/cld_2:cld2_platform_impl" ]
337 action("chromevox_test_messages_js") {
338 script = "tools/generate_test_messages.py"
340 "$chromevox_out_dir/_locales/en/messages.json",
342 output_file = "$root_out_dir/test_data/chrome/browser/resources/chromeos/chromevox/host/testing/test_messages.js"
347 "strings:chromevox_strings",
351 rebase_path(output_file, root_build_dir),
352 ] + rebase_path(sources, root_build_dir)
355 chromevox_test_modules = [
356 "host/testing/earcons.js",
357 "host/testing/host.js",
358 "host/testing/mathjax.js",
359 "host/testing/tts.js",
360 "testing/spoken_list_builder.js",
361 "testing/test_msgs.js",
363 ] + get_target_outputs(":chromevox_test_messages_js")
365 generate_deps_js("chromevox_test_deps_js") {
366 sources = closure_library_modules + chromevox_modules + chromevox_test_modules
367 output_file = "$target_gen_dir/test_deps.js"
369 rebase_path("//", root_build_dir) + ":",
370 rebase_path("$root_out_dir/test_data", root_build_dir) + ":",
373 ":chromevox_test_messages_js",
377 js2gtest("chromevox_unitjs_tests") {
379 sources = chromevox_tests_gypi_values.chromevox_tests_unitjs_sources
381 chromevox_tests_gypi_values.chromevox_tests_unit_gen_include_sources
382 test_deps_js_outputs = get_target_outputs(":chromevox_test_deps_js")
383 deps_js = test_deps_js_outputs[0]
385 ":chromevox_test_deps_js",
387 defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
390 js2gtest("chromevox_extjs_tests") {
391 test_type = "extension"
392 sources = chromevox_tests_gypi_values.chromevox_tests_extjs_sources
393 sources -= [ "braille/liblouis_test.extjs" ] # TODO(GYP)
395 chromevox_tests_gypi_values.chromevox_tests_ext_gen_include_sources
396 defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]