File: BUILD.gn

package info (click to toggle)
chromium 139.0.7258.138-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,120,676 kB
  • sloc: cpp: 35,100,869; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (570 lines) | stat: -rw-r--r-- 18,740 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# Copyright 2015 The Chromium Authors
# 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/generate_message_formatting_data.gni")
import(
    "//chrome/browser/resources/chromeos/accessibility/tools/run_jsbundler.gni")
import("//chrome/common/features.gni")
import("//chrome/test/base/ash/js2gtest.gni")
import("//testing/test.gni")
import("//tools/typescript/ts_library.gni")
import("//ui/webui/resources/tools/bundle_js.gni")
import("//ui/webui/resources/tools/minify_js.gni")

group("build") {
  deps = [
    ":copied_files",
    ":minify_js_background",
    ":minify_js_panel",
    "//third_party/liblouis",
  ]
}

chromevox_out_dir =
    "$root_out_dir/resources/chromeos/accessibility/chromevox/mv2"

# Directory where typescript build will occur.
ts_build_staging_dir = "$target_gen_dir/ts_build_staging"

tsc_out_dir = "$target_gen_dir/tsc"

# Location of common typescript output.
common_tsc_dir =
    "$root_gen_dir/chrome/browser/resources/chromeos/accessibility/common/tsc"

# Messageformat third_party directory.
messageformat_dir = "//third_party/node/node_modules/messageformat/lib/"

# Location of sre dependency.
sre_browser_file = "//third_party/chromevox/third_party/sre/sre_browser.js"

# List of all modules that are included in one or more of the production
# chromevox scripts.
#
# TS files to compile.
ts_modules = [
  "background/abstract_earcons.ts",
  "background/abstract_tts.ts",
  "background/auto_scroll_handler.ts",
  "background/background.ts",
  "background/braille/braille_background.ts",
  "background/braille/braille_captions_background.ts",
  "background/braille/braille_command_handler.ts",
  "background/braille/braille_display_manager.ts",
  "background/braille/braille_input_handler.ts",
  "background/braille/braille_interface.ts",
  "background/braille/braille_key_event_rewriter.ts",
  "background/braille/braille_translator_manager.ts",
  "background/braille/cursor_dots.ts",
  "background/braille/expanding_braille_translator.ts",
  "background/braille/liblouis.ts",
  "background/braille/pan_strategy.ts",
  "background/braille/spans.ts",
  "background/captions_handler.ts",
  "background/chromevox.ts",
  "background/chromevox_range.ts",
  "background/chromevox_state.ts",
  "background/color.ts",
  "background/console_tts.ts",
  "background/download_handler.ts",
  "background/earcons.ts",
  "background/earcon_engine.ts",
  "background/editing/editable_line.ts",
  "background/editing/editable_text.ts",
  "background/editing/editable_text_base.ts",
  "background/editing/editing_range_observer.ts",
  "background/editing/intent_handler.ts",
  "background/editing/rich_editable_text.ts",
  "background/editing/text_edit_handler.ts",
  "background/editing/typing_echo.ts",
  "background/es6_loader.ts",
  "background/event_source.ts",
  "background/event/base_automation_handler.ts",
  "background/event/desktop_automation_handler.ts",
  "background/event/desktop_automation_interface.ts",
  "background/event/focus_automation_handler.ts",
  "background/event/media_automation_handler.ts",
  "background/event/page_load_sound_handler.ts",
  "background/event/pointer_handler.ts",
  "background/event/range_automation_handler.ts",
  "background/find_handler.ts",
  "background/focus_bounds.ts",
  "background/forced_action_path.ts",
  "background/injected_script_loader.ts",
  "background/input/background_keyboard_handler.ts",
  "background/input/clipboard_handler.ts",
  "background/input/command_handler_interface.ts",
  "background/input/command_handler.ts",
  "background/input/gesture_command_handler.ts",
  "background/input/gesture_interface.ts",
  "background/input/smart_sticky_mode.ts",
  "background/live_regions.ts",
  "background/logging/event_stream_logger.ts",
  "background/logging/log_manager.ts",
  "background/logging/log_url_watcher.ts",
  "background/logging/log_store.ts",
  "background/math_handler.ts",
  "background/output/braille_output.ts",
  "background/output/output.ts",
  "background/output/output_ancestry_info.ts",
  "background/output/output_format_parser.ts",
  "background/output/output_format_tree.ts",
  "background/output/output_formatter.ts",
  "background/output/output_role_info.ts",
  "background/output/output_interface.ts",
  "background/output/output_logger.ts",
  "background/output/output_rules.ts",
  "background/output/output_types.ts",
  "background/panel/i_search.ts",
  "background/panel/i_search_handler.ts",
  "background/panel/panel_background.ts",
  "background/panel/panel_node_menu_background.ts",
  "background/prefs.ts",
  "background/primary_tts.ts",
  "background/third_party/tamachiyomi/ja_phonetic_data.ts",
  "background/third_party/tamachiyomi/ja_phonetic_map.ts",
  "background/tts_background.ts",
  "background/tts_interface.ts",
  "chromevox_loader.ts",
  "common/background_bridge.ts",
  "common/braille/braille_command_data.ts",
  "common/braille/braille_key_types.ts",
  "common/braille/braille_table.ts",
  "common/braille/nav_braille.ts",
  "common/bridge_constants.ts",
  "common/command.ts",
  "common/command_store.ts",
  "common/custom_automation_event.ts",
  "common/earcon_id.ts",
  "common/event_source_type.ts",
  "common/gesture.ts",
  "common/gesture_command_data.ts",
  "common/keyboard_handler.ts",
  "common/key_map.ts",
  "common/key_sequence.ts",
  "common/key_util.ts",
  "common/learn_mode_bridge.ts",
  "common/locale_output_helper.ts",
  "common/log_types.ts",
  "common/msgs.ts",
  "common/panel_bridge.ts",
  "common/panel_command.ts",
  "common/role_type.ts",
  "common/panel_menu_data.ts",
  "common/permission_checker.ts",
  "common/settings_manager.ts",
  "common/spannable.ts",
  "common/tree_dumper.ts",
  "common/tts_types.ts",
  "learn_mode/learn_mode.ts",
  "log_page/log.ts",
  "log_page/log_loader.ts",
  "panel/i_search_ui.ts",
  "panel/menu_manager.ts",
  "panel/panel.ts",
  "panel/panel_captions.ts",
  "panel/panel_interface.ts",
  "panel/panel_menu.ts",
  "panel/panel_menu_item.ts",
  "panel/panel_mode.ts",
]

# ES6 modules.
js_modules = [
  "background/automation_object_constructor_installer.js",
  "background/composite_tts.js",
  "background/phonetic_data.js",
]

# Root dir must be the parent directory so it can reach common/.
ts_library("ts_build") {
  root_dir = "$ts_build_staging_dir"
  out_dir = tsc_out_dir

  deps = [ "../../common:ts_build" ]

  extra_deps = [
    #copied files
    ":stage_ts_build",
    ":stage_ts_build_sre",
  ]

  definitions = [
    "//tools/typescript/definitions/chrome_event.d.ts",
    "//tools/typescript/definitions/context_menus.d.ts",
    "//tools/typescript/definitions/metrics_private.d.ts",
    "../../definitions/windows.d.ts",
    "../../definitions/accessibility_private_mv2.d.ts",
    "../../definitions/audio.d.ts",
    "../../definitions/automation.d.ts",
    "../../definitions/braille_display_private_mv2.d.ts",
    "../../definitions/chromeos_info_private.d.ts",
    "../../definitions/clipboard_mv2.d.ts",
    "../../definitions/downloads.d.ts",
    "../../definitions/extension_types.d.ts",
    "../../definitions/extensions.d.ts",
    "../../definitions/i18n.d.ts",
    "../../definitions/login_state.d.ts",
    "../../definitions/runtime.d.ts",
    "../../definitions/settings_private_mv2.d.ts",
    "../../definitions/storage_mv2.d.ts",
    "../../definitions/tabs.d.ts",
    "../../definitions/tts.d.ts",
  ]

  path_mappings = [
    "/common/*|" + rebase_path("$common_tsc_dir/*", target_gen_dir),
    "/chromevox/mv2/third_party/messageformat/messageformat.rollup.js|" +
        rebase_path("$messageformat_dir/messageformat.d.ts", target_gen_dir),

    # Point the TS compiler to the copied version of sre_browser.js.
    "/chromevox/mv2/third_party/sre/sre_browser.js|" +
        rebase_path("$ts_build_staging_dir/third_party/sre/sre_browser.js",
                    target_gen_dir),
  ]

  in_files = ts_modules + js_modules

  tsconfig_base = "../../tsconfig.base.json"
}

generate_message_formatting_data("i18n_data") {
  inputs = [ "//third_party/cldr/src/common/supplemental/plurals.xml" ]
  output_dir = "$chromevox_out_dir"
}

# Bundles the background sources into a single file.
bundle_js("bundle_js_background") {
  visibility = [ ":minify_js_background" ]

  host = "_ignored_"
  input = rebase_path("$tsc_out_dir/background", root_build_dir)
  js_module_in_files = [ "es6_loader.js" ]
  external_paths =
      [ "/common/*|" + rebase_path("$common_tsc_dir/*", root_build_dir) ]

  excludes = [ "/chromevox/mv2/third_party/sre/sre_browser.js" ]

  out_folder = "$target_gen_dir/bundle/background"

  deps = [
    ":chromevox_phonetic_dictionaries_js",
    ":minify_js_messageformat",
    ":ts_build",
    "../../common:copied_files",
    "../../common:ts_build",
  ]
}

# Minifies the bundled background script to optimize memory footprint.
# The minified file gets written directly to $chromevox_out_dir/background.
minify_js("minify_js_background") {
  visibility = [ ":build" ]

  deps = [ ":bundle_js_background" ]
  in_folder = "$target_gen_dir/bundle/background"
  in_files = [ "es6_loader.rollup.js" ]
  out_folder = "$chromevox_out_dir/background"
}

# Bundles the panel sources into a single file.
bundle_js("bundle_js_panel") {
  visibility = [ ":minify_js_panel" ]

  host = "_ignored_"
  input = rebase_path("$tsc_out_dir/panel", root_build_dir)
  js_module_in_files = [ "panel.js" ]
  out_folder = "$target_gen_dir/bundle/panel"

  deps = [
    ":ts_build",
    "../../common:copied_files",
    "../../common:ts_build",
  ]
}

# Minifies the bundled panel script to optimize memory footprint.
# The minified file gets written directly to $chromevox_out_dir/panel.
minify_js("minify_js_panel") {
  visibility = [ ":build" ]

  deps = [ ":bundle_js_panel" ]
  in_folder = "$target_gen_dir/bundle/panel"
  in_files = [ "panel.rollup.js" ]
  out_folder = "$chromevox_out_dir/panel"
}

# Instead of setting up one copy target for each subdirectory, use a script
# to copy all files.
run_jsbundler("copied_files") {
  mode = "copy"
  dest_dir = chromevox_out_dir
  deps = [
    ":copy_sre",
    ":minify_js_messageformat",
    ":ts_build",
    "../../common:copied_files",
    "../../common:ts_build",
  ]

  clear_dest_dirs = [
    "common",
    "earcons",
    "images",
    "injected",
    "learn_mode",
    "log_page",
    "tutorial",
  ]

  sources = [
    "background/background.html",
    "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/cvox_gdocs_script.js",
    "learn_mode/learn_mode.html",
    "log_page/log.css",
    "log_page/log.html",
    "panel/panel.css",
    "panel/panel.html",
    "tutorial/practice_areas/jump_commands.html",
    "tutorial/practice_areas/selects.html",
  ]

  # Include JavaScript source files, but omit those for the background and
  # panel, since we bundle, minify, and write those separately (see
  # minfy_js_background and minify_js_panel).
  sources += filter_exclude(
          filter_include(get_target_outputs(":ts_build"), [ "*.js" ]),
          [
            "*/panel/*",
            "*/background/*",
          ])

  rewrite_rules = [
    rebase_path("$tsc_out_dir", root_build_dir) + ":",
    rebase_path(".", root_build_dir) + ":",
  ]
}

# Copy all JS and TS sources to a staging folder. All generated TS/JS files
# will also be copied into this folder, which will allow us to support a TS
# build that uses both checked-in and generated files.
copy("stage_ts_build") {
  sources = js_modules + ts_modules
  outputs = [ "$ts_build_staging_dir/{{source_target_relative}}" ]
}

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 = "//chrome/browser/resources/chromeos/accessibility/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 = "//chrome/browser/resources/chromeos/accessibility/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)
}

source_set("browser_tests") {
  testonly = true
  assert(enable_extensions)

  deps = [ ":chromevox_extension_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/chromevox/",
    "//chrome/browser/resources/chromeos/accessibility/common",
    "//third_party/chromevox/",
  ]
  data += js2gtest_js_libraries
}

action("chromevox_test_messages_js") {
  script = "//chrome/browser/resources/chromeos/accessibility/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/mv2/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 = 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 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_captions_background_test.js",
    "background/braille/braille_display_manager_test.js",
    "background/braille/braille_input_handler_test.js",
    "background/braille/braille_test.js",
    "background/braille/braille_translator_manager_test.js",
    "background/braille/liblouis_test.js",
    "background/captions_handler_test.js",
    "background/chromevox_range_test.js",
    "background/color_test.js",
    "background/download_handler_test.js",
    "background/editing/editing_test.js",
    "background/editing/intent_handler_test.js",
    "background/event/desktop_automation_handler_test.js",
    "background/forced_action_path_test.js",
    "background/input/keyboard_handler_test.js",
    "background/input/smart_sticky_mode_test.js",
    "background/live_regions_test.js",
    "background/logging/log_store_test.js",
    "background/math_handler_test.js",
    "background/output/output_test.js",
    "background/panel/i_search_test.js",
    "background/panel/panel_background_test.js",
    "background/panel/panel_node_menu_background_test.js",
    "background/settings_test.js",
    "background/tts_background_test.js",
    "common/braille/braille_command_data_test.js",
    "common/braille/braille_table_test.js",
    "common/locale_output_helper_test.js",
    "common/settings_manager_test.js",
    "learn_mode/learn_mode_test.js",
    "panel/menu_manager_test.js",
    "panel/panel_test.js",
    "panel/panel_test_base.js",
    "panel/tutorial_test.js",
  ]

  # These tests need support for async/await (b/317173285).
  sources += [
    "background/braille/expanding_braille_translator_test.js",
    "background/braille/pan_strategy_test.js",
    "background/editing/editable_text_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",
    "../../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/mock_feedback.js",
  ]

  # The test base classes generate C++ code with these deps.
  deps = [
    "//ash",
    "//base",
    "//chrome/browser/ash/accessibility",
    "//chrome/browser/ash/crosapi",
    "//chrome/browser/ash/system_web_apps",
    "//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" ]
}

bundle_js("bundle_js_messageformat") {
  visibility = [ ":minify_js_messageformat" ]

  host = "_ignored_"
  input = rebase_path("$messageformat_dir", root_build_dir)
  js_module_in_files = [ "messageformat.js" ]
  out_folder = "$target_gen_dir/messageformat"
}

minify_js("minify_js_messageformat") {
  visibility = [
    ":bundle_js_background",
    ":copied_files",
  ]

  deps = [ ":bundle_js_messageformat" ]
  in_folder = "$target_gen_dir/messageformat"
  in_files = [ "messageformat.rollup.js" ]
  out_folder = "$chromevox_out_dir/third_party/messageformat/"
}

# Copy sre_browser.js to the staging directory so that it can be used at build
# time.
copy("stage_ts_build_sre") {
  sources = [ "$sre_browser_file" ]
  outputs = [ "$ts_build_staging_dir/third_party/sre/sre_browser.js" ]
}

# Copy sre_browser.js to chromevox_out_dir so that it can be used at runtime.
copy("copy_sre") {
  sources = [ "$sre_browser_file" ]
  outputs = [ "$chromevox_out_dir/third_party/sre/sre_browser.js" ]
}