| # Copyright 2015 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/chromeos/ui_mode.gni") |
| import("//build/config/features.gni") |
| import( |
| "//chrome/browser/resources/chromeos/accessibility/tools/run_jsbundler.gni") |
| import("//chrome/common/features.gni") |
| import("//chrome/test/base/js2gtest.gni") |
| import("//testing/test.gni") |
| import("//third_party/closure_compiler/compile_js.gni") |
| |
| closure_library_dir = |
| "//third_party/chromevox/third_party/closure-library/closure/goog" |
| |
| # List of all modules that are included in one or more of the production |
| # chromevox scripts. |
| # |
| # These files all use older Closure provide/require support for dependency management and will be transitioned to ES6 modules (see below). |
| chromevox_modules = [ |
| "../common/constants.js", |
| "background/braille/cursor_dots.js", |
| "background/braille/pan_strategy.js", |
| "common/extension_bridge.js", |
| "injected/api_implementation.js", |
| "injected/extension_bridge.js", |
| "injected/loader.js", |
| "injected/script_installer.js", |
| "options/bluetooth_braille_display_manager.js", |
| "third_party/tamachiyomi/ja_phonetic_data.js", |
| ] |
| |
| # ES6 modules. |
| chromevox_es6_modules = [ |
| "../common/automation_predicate.js", |
| "../common/automation_util.js", |
| "../common/cursors/cursor.js", |
| "../common/cursors/range.js", |
| "../common/cursors/recovery_strategy.js", |
| "../common/event_generator.js", |
| "../common/instance_checker.js", |
| "../common/key_code.js", |
| "../common/string_util.js", |
| "../common/tree_walker.js", |
| "background/automation_object_constructor_installer.js", |
| "background/auto_scroll_handler.js", |
| "background/background.js", |
| "background/base_automation_handler.js", |
| "background/braille/braille_background.js", |
| "background/braille/braille_captions_background.js", |
| "background/braille/braille_command_handler.js", |
| "background/braille/braille_display_manager.js", |
| "background/braille/braille_input_handler.js", |
| "background/braille/braille_key_event_rewriter.js", |
| "background/braille/braille_translator_manager.js", |
| "background/braille/cursor_dots.js", |
| "background/braille/expanding_braille_translator.js", |
| "background/braille/liblouis.js", |
| "background/braille/pan_strategy.js", |
| "background/braille/spans.js", |
| "background/chromevox_state.js", |
| "background/chromevox.js", |
| "background/classic_background.js", |
| "background/color.js", |
| "background/command_handler.js", |
| "background/command_handler_interface.js", |
| "background/console_tts.js", |
| "background/desktop_automation_handler.js", |
| "background/desktop_automation_interface.js", |
| "background/download_handler.js", |
| "background/earcon_engine.js", |
| "background/earcons.js", |
| "background/editing/editable_line.js", |
| "background/editing/editable_text_base.js", |
| "background/editing/editing.js", |
| "background/editing/intent_handler.js", |
| "background/es6_loader.js", |
| "background/event_source.js", |
| "background/find_handler.js", |
| "background/focus_automation_handler.js", |
| "background/focus_bounds.js", |
| "background/gesture_command_handler.js", |
| "background/gesture_interface.js", |
| "background/injected_script_loader.js", |
| "background/keyboard_handler.js", |
| "background/live_regions.js", |
| "background/logging/event_stream_logger.js", |
| "background/logging/log_store.js", |
| "background/logging/log_url_watcher.js", |
| "background/math_handler.js", |
| "background/media_automation_handler.js", |
| "background/output/output.js", |
| "background/output/output_ancestry_info.js", |
| "background/output/output_format_parser.js", |
| "background/output/output_format_tree.js", |
| "background/output/output_logger.js", |
| "background/output/output_role_info.js", |
| "background/output/output_types.js", |
| "background/page_load_sound_handler.js", |
| "background/panel/i_search.js", |
| "background/panel/i_search_handler.js", |
| "background/panel/panel_background.js", |
| "background/panel/panel_node_menu_background.js", |
| "background/panel/panel_tab_menu_background.js", |
| "background/phonetic_data.js", |
| "background/pointer_handler.js", |
| "background/prefs.js", |
| "background/range_automation_handler.js", |
| "background/smart_sticky_mode.js", |
| "background/tts_background.js", |
| "background/user_action_monitor.js", |
| "common/abstract_earcons.js", |
| "common/abstract_tts.js", |
| "common/background_bridge.js", |
| "common/braille/braille_command_data.js", |
| "common/braille/braille_interface.js", |
| "common/braille/braille_key_types.js", |
| "common/braille/braille_table.js", |
| "common/braille/nav_braille.js", |
| "common/bridge_constants.js", |
| "common/bridge_helper.js", |
| "common/command_store.js", |
| "common/composite_tts.js", |
| "common/custom_automation_event.js", |
| "common/event_source_type.js", |
| "common/extension_bridge.js", |
| "common/gesture_command_data.js", |
| "common/key_map.js", |
| "common/key_sequence.js", |
| "common/key_util.js", |
| "common/keyboard_handler.js", |
| "common/locale_output_helper.js", |
| "common/log_types.js", |
| "common/msgs.js", |
| "common/panel_bridge.js", |
| "common/panel_command.js", |
| "common/panel_menu_data.js", |
| "common/spannable.js", |
| "common/tree_dumper.js", |
| "common/tts_base.js", |
| "common/tts_interface.js", |
| "learn_mode/learn_mode.js", |
| "log_page/log.js", |
| "options/bluetooth_braille_display_ui.js", |
| "options/options.js", |
| "panel/i_search_ui.js", |
| "panel/panel.js", |
| "panel/panel_interface.js", |
| "panel/panel_menu.js", |
| "panel/panel_menu_item.js", |
| "panel/panel_mode.js", |
| "third_party/tamachiyomi/ja_phonetic_map.js", |
| ] |
| |
| # Closure library modules needed by chromevox. |
| relative_closure_library_modules = [ |
| "asserts/asserts.js", |
| "base.js", |
| "debug/error.js", |
| "dom/nodetype.js", |
| "i18n/pluralrules.js", |
| "i18n/ordinalrules.js", |
| "i18n/messageformat.js", |
| "object/object.js", |
| "string/string.js", |
| ] |
| |
| closure_library_modules = |
| rebase_path(relative_closure_library_modules, ".", closure_library_dir) |
| |
| chromevox_gen_dir = |
| "$root_gen_dir/chrome/browser/resources/chromeos/accessibility/chromevox" |
| |
| chromevox_out_dir = "$root_out_dir/resources/chromeos/accessibility/chromevox" |
| |
| group("build") { |
| deps = [ |
| ":chromevox_background_script", |
| ":chromevox_copied_files", |
| ":chromevox_learn_mode_script", |
| ":chromevox_log_script", |
| ":chromevox_min_content_script", |
| ":chromevox_options_script", |
| ":chromevox_panel_script", |
| ":chromevox_phonetic_dictionaries_js", |
| "//chrome/browser/resources/chromeos/accessibility/braille_ime:braille_ime_manifest", |
| "//third_party/chromevox:chromevox_third_party_resources", |
| "//third_party/liblouis", |
| ] |
| } |
| |
| chromevox_background_script_loader_file = "background/loader.js" |
| chromevox_learn_mode_loader_file = "learn_mode/kbexplorer_loader.js" |
| chromevox_log_loader_file = "log_page/log_loader.js" |
| chromevox_min_content_script_loader_file = "injected/loader.js" |
| chromevox_options_script_loader_file = "options/options_loader.js" |
| chromevox_panel_script_loader_file = "panel/panel_loader.js" |
| |
| # Instead of setting up one copy target for each subdirectory, use a script |
| # to copy all files. |
| run_jsbundler("chromevox_copied_files") { |
| mode = "copy" |
| dest_dir = chromevox_out_dir |
| sources = [ |
| "background/background.html", |
| "background/earcons/control.wav", |
| "background/earcons/selection.wav", |
| "background/earcons/selection_reverse.wav", |
| "background/earcons/skim.wav", |
| "background/earcons/small_room_2.wav", |
| "background/earcons/static.wav", |
| "images/chromevox.svg", |
| "images/close-36.png", |
| "images/close-hover-36.png", |
| "images/options-36.png", |
| "images/options-hover-36.png", |
| "images/triangle-6.png", |
| "injected/api.js", |
| "learn_mode/learn_mode.html", |
| "log_page/log.css", |
| "log_page/log.html", |
| "options/checked.png", |
| "options/options.css", |
| "options/options.html", |
| "options/unchecked.png", |
| "panel/panel.css", |
| "panel/panel.html", |
| "tutorial/practice_areas/jump_commands.html", |
| "tutorial/practice_areas/selects.html", |
| ] |
| sources += chromevox_es6_modules |
| rewrite_rules = [ |
| rebase_path(".", root_build_dir) + ":", |
| rebase_path(closure_library_dir, root_build_dir) + ":closure", |
| ] |
| } |
| |
| template("generate_deps_js") { |
| if (defined(invoker.rewrite_rules)) { |
| rewrite_rules = invoker.rewrite_rules |
| } else { |
| rewrite_rules = [] |
| } |
| action(target_name) { |
| if (defined(invoker.testonly)) { |
| testonly = invoker.testonly |
| } |
| script = "tools/generate_deps.py" |
| inputs = jsbundler_modules |
| sources = invoker.sources |
| outputs = [ invoker.output_file ] |
| args = [ |
| "-o", |
| rebase_path(invoker.output_file, root_build_dir), |
| ] |
| foreach(rule, rewrite_rules) { |
| args += [ |
| "-w", |
| rule, |
| ] |
| } |
| args += rebase_path(sources, root_build_dir) |
| if (defined(invoker.deps)) { |
| deps = invoker.deps |
| } |
| } |
| } |
| |
| action("chromevox_phonetic_dictionaries_js") { |
| script = "tools/phonetic_dictionaries.py" |
| src_dir = [ "$root_out_dir/resources/chromeos/accessibility/_locales" ] |
| output_file = "$chromevox_out_dir/phonetic_dictionaries.js" |
| outputs = [ output_file ] |
| deps = [ |
| "//chrome/browser/resources/chromeos/accessibility:accessibility_strings", |
| ] |
| args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| ] + rebase_path(src_dir, root_build_dir) |
| } |
| |
| template("compress_js") { |
| run_jsbundler(target_name) { |
| assert(defined(invoker.output_file)) |
| mode = "compressed_bundle" |
| modules = chromevox_modules + closure_library_modules |
| sources = invoker.sources |
| output_file = invoker.output_file |
| } |
| } |
| |
| compress_js("chromevox_learn_mode_script") { |
| sources = [ chromevox_learn_mode_loader_file ] |
| output_file = "$chromevox_out_dir/chromeVoxKbExplorerScript.js" |
| } |
| |
| compress_js("chromevox_log_script") { |
| sources = [ chromevox_log_loader_file ] |
| output_file = "$chromevox_out_dir/chromeVoxLogScript.js" |
| } |
| |
| compress_js("chromevox_options_script") { |
| sources = [ chromevox_options_script_loader_file ] |
| output_file = "$chromevox_out_dir/chromeVoxChromeOptionsScript.js" |
| } |
| |
| compress_js("chromevox_background_script") { |
| sources = [ chromevox_background_script_loader_file ] |
| output_file = "$chromevox_out_dir/chromeVoxChromeBackgroundScript.js" |
| } |
| |
| compress_js("chromevox_min_content_script") { |
| sources = [ chromevox_min_content_script_loader_file ] |
| output_file = "$chromevox_out_dir/chromeVoxChromePageScript.js" |
| } |
| |
| compress_js("chromevox_panel_script") { |
| sources = [ chromevox_panel_script_loader_file ] |
| output_file = "$chromevox_out_dir/chromeVoxPanelScript.js" |
| } |
| |
| if (is_chromeos_ash) { |
| source_set("browser_tests") { |
| testonly = true |
| assert(enable_extensions) |
| |
| deps = [ |
| ":chromevox_extension_js_tests", |
| ":chromevox_webui_js_tests", |
| ] |
| |
| # TODO(jamescook): Figure out which of these are really necessary. |
| data = [ |
| "$root_out_dir/chrome_100_percent.pak", |
| "$root_out_dir/chrome_200_percent.pak", |
| "$root_out_dir/locales/en-US.pak", |
| "$root_out_dir/locales/fr.pak", |
| "$root_out_dir/resources.pak", |
| "$root_out_dir/resources/chromeos/accessibility/chromevox/", |
| "$root_out_dir/test_data/chrome/browser/resources/chromeos/accessibility/chromevox/", |
| |
| "//chrome/browser/resources/chromeos/accessibility/common", |
| "//chrome/browser/resources/chromeos/accessibility/chromevox/", |
| "//third_party/chromevox/", |
| ] |
| data += js2gtest_js_libraries |
| } |
| |
| action("chromevox_test_messages_js") { |
| script = "tools/generate_test_messages.py" |
| sources = [ "$root_out_dir/resources/chromeos/accessibility/_locales/en/messages.json.gz" ] |
| output_file = "$root_out_dir/test_data/chrome/browser/resources/chromeos/accessibility/chromevox/host/testing/test_messages.js" |
| outputs = [ output_file ] |
| deps = [ |
| "//chrome/browser/resources/chromeos/accessibility:accessibility_strings", |
| ] |
| args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| ] + rebase_path(sources, root_build_dir) |
| } |
| |
| chromevox_test_modules = get_target_outputs(":chromevox_test_messages_js") |
| |
| generate_deps_js("chromevox_test_deps_js") { |
| sources = |
| closure_library_modules + chromevox_modules + chromevox_test_modules |
| output_file = "$target_gen_dir/test_deps.js" |
| rewrite_rules = [ |
| rebase_path("//", root_build_dir) + ":", |
| rebase_path("$root_out_dir/test_data", root_build_dir) + ":", |
| ] |
| deps = [ ":chromevox_test_messages_js" ] |
| } |
| |
| # These tests can run in a pure V8 renderer (e.g. no DOM). |
| js2gtest("chromevox_unit_js_tests") { |
| test_type = "unit" |
| sources = [ |
| "background/braille/expanding_braille_translator_test.js", |
| "background/braille/pan_strategy_test.js", |
| "background/editing/editable_text_base_test.js", |
| "background/phonetic_data_test.js", |
| "common/key_sequence_test.js", |
| "common/spannable_test.js", |
| "testing/mock_feedback_test.js", |
| ] |
| gen_include_files = [ "../common/testing/accessibility_test_base.js" ] |
| extra_js_files = [ |
| "../common/testing/accessibility_test_base.js", |
| "../common/testing/assert_additions.js", |
| "../common/testing/callback_helper.js", |
| "../common/closure_shim.js", |
| "background/braille/expanding_braille_translator.js", |
| "background/braille/pan_strategy.js", |
| "background/braille/spans.js", |
| "background/braille/liblouis.js", |
| "background/editing/editable_text_base.js", |
| "background/phonetic_data.js", |
| "common/key_sequence.js", |
| "common/msgs.js", |
| "common/spannable.js", |
| "testing/fake_dom.js", |
| "testing/mock_feedback.js", |
| "third_party/tamachiyomi/ja_phonetic_data.js", |
| ] |
| } |
| |
| # These tests need a Blink renderer (e.g. DOM), but not a full extension |
| # renderer. |
| js2gtest("chromevox_webui_js_tests") { |
| test_type = "webui" |
| sources = [ "options/bluetooth_braille_display_manager_test.js" ] |
| gen_include_files = [ |
| "../common/testing/accessibility_test_base.js", |
| "../common/testing/assert_additions.js", |
| "../common/testing/callback_helper.js", |
| "testing/chromevox_webui_test_base.js", |
| "testing/mock_feedback.js", |
| ] |
| test_deps_js_outputs = get_target_outputs(":chromevox_test_deps_js") |
| deps_js = test_deps_js_outputs[0] |
| deps = [ ":chromevox_test_deps_js" ] |
| defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] |
| } |
| |
| # These tests need a full extension renderer. |
| js2gtest("chromevox_extension_js_tests") { |
| test_type = "extension" |
| sources = [ |
| "background/auto_scroll_handler_test.js", |
| "background/background_test.js", |
| "background/braille/braille_display_manager_test.js", |
| "background/braille/braille_input_handler_test.js", |
| "background/braille/braille_translator_manager_test.js", |
| "background/braille/liblouis_test.js", |
| "background/color_test.js", |
| "background/desktop_automation_handler_test.js", |
| "background/download_handler_test.js", |
| "background/editing/editing_test.js", |
| "background/editing/intent_handler_test.js", |
| "background/keyboard_handler_test.js", |
| "background/live_regions_test.js", |
| "background/logging/log_store_test.js", |
| "background/output/output_test.js", |
| "background/panel/i_search_test.js", |
| "background/panel/panel_node_menu_background_test.js", |
| "background/portals_test.js", |
| "background/settings_test.js", |
| "background/smart_sticky_mode_test.js", |
| "background/tts_background_test.js", |
| "background/user_action_monitor_test.js", |
| "common/braille/braille_command_data_test.js", |
| "common/braille/braille_table_test.js", |
| "common/locale_output_helper_test.js", |
| "learn_mode/learn_mode_test.js", |
| "options/bluetooth_braille_display_ui_test.js", |
| "options/options_test.js", |
| "panel/panel_test.js", |
| "panel/panel_test_base.js", |
| "panel/tutorial_test.js", |
| ] |
| gen_include_files = [ |
| "../common/testing/accessibility_test_base.js", |
| "../common/testing/assert_additions.js", |
| "../common/testing/callback_helper.js", |
| "../common/testing/documents.js", |
| "../common/testing/e2e_test_base.js", |
| "testing/chromevox_e2e_test_base.js", |
| "testing/chromevox_next_e2e_test_base.js", |
| "testing/mock_feedback.js", |
| ] |
| |
| # The test base classes generate C++ code with these deps. |
| deps = [ |
| "//ash", |
| "//base", |
| "//chrome/browser/ash", |
| "//chrome/browser/ash/crosapi", |
| "//chrome/common", |
| ] |
| test_deps_js_outputs = get_target_outputs(":chromevox_test_deps_js") |
| deps_js = test_deps_js_outputs[0] |
| deps += [ ":chromevox_test_deps_js" ] |
| defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] |
| } |
| } |
| |
| # Closure type check compilation and associated js libraries. |
| js_type_check("closure_compile") { |
| deps = [ |
| ":chromevox_es6_library", |
| ":chromevox_library", |
| ] |
| } |
| |
| js_library("chromevox_library") { |
| sources = chromevox_modules |
| deps = [ "//third_party/chromevox/third_party/closure-library:library" ] |
| externs_list = [ |
| "background/externs.js", |
| "$externs_path/accessibility_private.js", |
| "$externs_path/audio.js", |
| "$externs_path/automation.js", |
| "$externs_path/braille_display_private.js", |
| "$externs_path/chromeos_info_private.js", |
| "$externs_path/chrome_extensions.js", |
| "$externs_path/clipboard.js", |
| "$externs_path/command_line_private.js", |
| "$externs_path/login_state.js", |
| "$externs_path/metrics_private.js", |
| "$externs_path/settings_private.js", |
| "$externs_path/tts.js", |
| "$externs_path/virtual_keyboard_private.js", |
| ] |
| } |
| |
| js_library("chromevox_es6_library") { |
| sources = chromevox_es6_modules |
| } |