Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1005)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/BUILD.gn

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

Powered by Google App Engine
This is Rietveld 408576698