File: BUILD.gn

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (194 lines) | stat: -rw-r--r-- 5,643 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
# Copyright 2016 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/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")

assert(is_chromeos)

group("build") {
  deps = [
    ":copy_misc_files",
    ":minify_js",
  ]
}

select_to_speak_out_dir =
    "$root_out_dir/resources/chromeos/accessibility/select_to_speak/mv2"

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

tsc_out_dir = "$target_gen_dir/tsc"

common_tsc_dir =
    "$root_gen_dir/chrome/browser/resources/chromeos/accessibility/common/tsc"

# Add typescript files to compile here.
ts_modules = [
  "select_to_speak_main.ts",
  "metrics_utils.ts",
  "select_to_speak_constants.ts",
  "tts_manager.ts",
  "input_handler.ts",
  "ui_manager.ts",
  "prefs_manager.ts",
  "select_to_speak.ts",
]

# 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

  composite = true

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

  extra_deps = [ ":stage_ts_build" ]

  path_mappings =
      [ "/common/*|" + rebase_path("$common_tsc_dir/*", target_gen_dir) ]

  definitions = [
    "../../definitions/accessibility_private_mv2.d.ts",
    "../../definitions/automation.d.ts",
    "../../definitions/clipboard_mv2.d.ts",
    "../../definitions/extensions.d.ts",
    "../../definitions/extension_types.d.ts",
    "../../definitions/i18n.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",
    "../../definitions/windows.d.ts",
    "//tools/typescript/definitions/chrome_event.d.ts",
    "//tools/typescript/definitions/context_menus.d.ts",
    "//tools/typescript/definitions/metrics_private.d.ts",
  ]

  in_files = ts_modules

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

bundle_js("bundle_js") {
  visibility = [ ":minify_js" ]

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

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

minify_js("minify_js") {
  visibility = [ ":build" ]

  deps = [ ":bundle_js" ]
  in_folder = "$target_gen_dir/bundle"
  in_files = [ "select_to_speak_main.rollup.js" ]
  out_folder = "$select_to_speak_out_dir"
}

copy("copy_misc_files") {
  sources = [
    "background.html",
    "checked.png",
    "earcons/null_selection.ogg",
    "select_to_speak-2x.svg",
    "sts-icon-128.png",
    "sts-icon-16.png",
    "sts-icon-48.png",
    "unchecked.png",
  ]

  outputs = [ "$select_to_speak_out_dir/{{source_target_relative}}" ]
}

# 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 = ts_modules
  outputs = [ "$ts_build_staging_dir/{{source_target_relative}}" ]
}

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

  deps = [ ":select_to_speak_extjs_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/resources.pak",
    "$root_out_dir/resources/chromeos/accessibility/select_to_speak/",
    "$root_out_dir/test_data/chrome/browser/resources/chromeos/accessibility/select_to_speak/",

    # The test uses data from the original location, not the copied one.
    "//chrome/browser/resources/chromeos/accessibility/common/",
    "//chrome/browser/resources/chromeos/accessibility/select_to_speak/",
  ]
  data += js2gtest_js_libraries
}

js2gtest("select_to_speak_extjs_tests") {
  test_type = "extension"
  sources = [
    # These are end-to-end tests.
    "select_to_speak_context_menu_tests.js",
    "select_to_speak_enhanced_voices_test.js",
    "select_to_speak_keystroke_selection_test.js",
    "select_to_speak_mouse_selection_test.js",
    "select_to_speak_navigation_control_test.js",
    "select_to_speak_prefs_test.js",
  ]

  # These are unit tests run under an extension environment to get ES6 module support.
  sources += [
    "select_to_speak_unittest.js",
    "tts_manager_unittest.js",
    "ui_manager_unittest.js",
  ]
  gen_include_files = [
    "../../common/testing/accessibility_test_base.js",
    "../../common/testing/callback_helper.js",
    "../../common/testing/e2e_test_base.js",
    "../../common/testing/fake_chrome_event.js",
    "../../common/testing/fake_settings_private.js",
    "../../common/testing/mock_storage.js",
    "../../common/testing/mock_tts.js",
    "select_to_speak_e2e_test_base.js",
    "pipe.jpg",
  ]

  # The test base classes generate C++ code with these deps.
  deps = [
    "//ash",
    "//ash/keyboard/ui",
    "//base",
    "//chrome/browser/ash/accessibility",
    "//chrome/browser/ash/crosapi",
    "//chrome/browser/ash/system_web_apps",
    "//chrome/common",
  ]
  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
}