forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_template.gni
592 lines (506 loc) · 18 KB
/
build_template.gni
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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# 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.
# Keep in sync with 'remoting_webapp' target in remoting/remoting_client.gypi.
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")
import("//build/util/version.gni")
import("//remoting/remoting_locales.gni")
import("//remoting/remoting_options.gni")
import("//remoting/remoting_version.gni")
import("//remoting/webapp/files.gni")
import("//third_party/closure_compiler/closure_args.gni")
# The base remoting directory that is used as the root directory for file
# references. Many of the scripts rely on the files being specified relative
# to this directory.
remoting_dir = "//remoting"
buildtype = "Dev"
if (!is_debug) {
if (is_official_build) {
buildtype = "Official"
} else {
buildtype = "Release"
}
}
template("build_locales_listfile") {
action(target_name) {
locales_listfile_output = invoker.locales_listfile_output
script = "../tools/build/remoting_localize.py"
inputs = []
outputs = [
locales_listfile_output,
]
args = [
"--locale_output",
rebase_path(webapp_locale_dir, root_build_dir) +
"/@{json_suffix}/messages.json",
"--locales_listfile",
rebase_path(locales_listfile_output, root_build_dir),
]
args += remoting_locales
}
}
template("build_webapp_html") {
target_jscompile = ""
# Do not enable JSCompile on instrumented builds.
if (enable_remoting_jscompile && invoker.instrument_js == []) {
target_jscompile = "${target_name}_jscompile"
target_jscompile_stamp = "$target_gen_dir/${target_jscompile}.stamp"
action(target_jscompile) {
js_files = remoting_webapp_js_proto_files + invoker.js_files
externs =
remoting_webapp_js_externs_files + [
"../../third_party/closure_compiler/externs/chrome_extensions.js",
"../../third_party/closure_compiler/externs/metrics_private.js",
]
script = "../../third_party/closure_compiler/compile.py"
inputs = js_files
outputs = [
target_jscompile_stamp,
]
extra_closure_args = [
"jscomp_error=reportUnknownTypes",
"jscomp_error=duplicate",
"jscomp_error=misplacedTypeAnnotation",
]
args = rebase_path(js_files, root_build_dir)
args += [
"--no-single-file",
"--out-file",
rebase_path(target_jscompile_stamp, root_build_dir),
"--closure-args",
] + closure_args + extra_closure_args
args += [ "--externs" ] + rebase_path(externs, root_build_dir)
}
}
action(target_name) {
html_template_file = invoker.html_template_file
html_template_include_files = invoker.html_template_include_files
js_files = invoker.js_files
html_output = invoker.html_output
exclude_js = invoker.exclude_js
instrument_js = invoker.instrument_js
script = rebase_path("//remoting/webapp/build-html.py", root_build_dir)
# Create a file that contains a list of all the JavaScript files needed
# to build the unit test page. This is needed to avoid problems on platforms
# that limit the size of a command line.
file_list = "$target_gen_dir/${target_name}_files.txt"
files = rebase_path(js_files, root_build_dir)
write_file(file_list, files)
inputs = [ html_template_file ] + html_template_include_files + js_files
outputs = [
html_output,
]
if (target_jscompile != "") {
deps = [
":$target_jscompile",
]
}
args = [
rebase_path(html_output, root_build_dir),
rebase_path(html_template_file, root_build_dir),
]
args += [
"--template-dir",
rebase_path(remoting_dir, root_build_dir),
]
args += [ "--templates" ] + html_template_include_files
args += [
"--js-list-file",
rebase_path(file_list, root_build_dir),
]
args += [ "--templates" ] + html_template_include_files
args += [
"--js-list-file",
rebase_path(file_list, root_build_dir),
]
args += [ "--exclude-js" ] + rebase_path(exclude_js, root_build_dir)
args += [ "--instrument-js" ] + rebase_path(instrument_js, root_build_dir)
}
}
template("desktop_remoting_webapp") {
locales_listfile = target_name + "_locales"
locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
build_locales_listfile(locales_listfile) {
# Template uses locales_listfile_output from outer scope.
}
background_html = target_name + "_background_html"
background_html_output = "$target_gen_dir/html/$target_name/background.html"
build_webapp_html(background_html) {
html_template_file = remoting_webapp_template_background
html_template_include_files = []
js_files = remoting_webapp_background_html_all_js_files
html_output = background_html_output
exclude_js = []
instrument_js = []
}
message_window_html = target_name + "_message_window_html"
message_window_html_output =
"$target_gen_dir/html/$target_name/message_window.html"
build_webapp_html(message_window_html) {
html_template_file = remoting_webapp_template_message_window
html_template_include_files = []
js_files = remoting_webapp_message_window_html_all_js_files
html_output = message_window_html_output
exclude_js = []
instrument_js = []
}
wcs_sandbox_html = target_name + "_wcs_sandbox_html"
wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
build_webapp_html(wcs_sandbox_html) {
html_template_file = remoting_webapp_template_wcs_sandbox
html_template_include_files = []
js_files = remoting_webapp_wcs_sandbox_html_all_js_files
html_output = wcs_sandbox_html_output
exclude_js = []
instrument_js = []
}
main_html = target_name + "_main_html"
main_html_output = "$target_gen_dir/html/$target_name/main.html"
build_webapp_html(main_html) {
html_template_file = remoting_webapp_template_main
html_template_include_files = remoting_webapp_template_files
js_files = remoting_webapp_crd_main_html_all_js_files
html_output = main_html_output
exclude_js = []
instrument_js = []
}
public_session_html = target_name + "_public_session_html"
public_session_html_output =
"$target_gen_dir/html/$target_name/public_session.html"
build_webapp_html(public_session_html) {
html_template_file = remoting_webapp_template_public_session
html_template_include_files = remoting_webapp_public_session_template_files
js_files = remoting_webapp_public_session_html_all_js_files
html_output = public_session_html_output
exclude_js = []
instrument_js = []
}
action(target_name) {
script = "//remoting/webapp/build-webapp.py"
webapp_type = invoker.webapp_type
output_dir = invoker.output_dir
zip_path = invoker.zip_path
extra_files = invoker.extra_files
dr_generated_html_files = [
background_html_output,
message_window_html_output,
wcs_sandbox_html_output,
main_html_output,
public_session_html_output,
"$target_gen_dir/credits.html",
]
if (enable_nacl) {
pnacl_tc = "//build/toolchain/nacl:newlib_pnacl"
pexe_label = "//remoting/client/plugin:remoting_client_plugin_newlib"
pexe_dir = get_label_info("${pexe_label}($pnacl_tc)", "root_out_dir")
extra_files += [ "$pexe_dir/remoting_client_plugin_newlib.pexe" ]
if (is_debug) {
extra_files += [ "$pexe_dir/remoting_client_plugin_newlib.pexe.debug" ]
}
}
inputs = [ rebase_path("crd/manifest.json.jinja2", root_build_dir) ] +
remoting_version_files +
rebase_path(remoting_webapp_crd_files, root_build_dir) +
extra_files + dr_generated_html_files
outputs = [
zip_path,
]
deps = [
":$background_html",
":$locales_listfile",
":$main_html",
":$message_window_html",
":$public_session_html",
":$wcs_sandbox_html",
"//remoting/resources",
"//remoting/webapp:credits",
]
if (enable_nacl) {
deps += [ "${pexe_label}($pnacl_tc)" ]
if (is_debug) {
deps += [ "${pexe_label}_debug($pnacl_tc)" ]
}
}
# Create a file that contains a list of all the resource files needed
# to build the webapp. This is needed to avoid problems on platforms that
# limit the size of a command line.
file_list = "$target_gen_dir/${target_name}_files.txt"
files = []
files += rebase_path(dr_generated_html_files, root_build_dir)
files += rebase_path(remoting_webapp_crd_files, root_build_dir)
files += rebase_path(extra_files, root_build_dir)
write_file(file_list, files)
args = [
buildtype,
chrome_version_full,
rebase_path(output_dir, root_build_dir),
rebase_path(zip_path, root_build_dir),
rebase_path("crd/manifest.json.jinja2", root_build_dir),
webapp_type,
]
args += [
"--files_listfile",
rebase_path(file_list, root_build_dir),
]
args += [
"--locales_listfile",
rebase_path(locales_listfile_output, root_build_dir),
]
args += [
"--use_gcd",
"$remoting_use_gcd",
]
}
}
template("app_remoting_webapp") {
locales_listfile = target_name + "_locales"
locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
build_locales_listfile(locales_listfile) {
# TODO(garykac) Replace resources with empty stub rather than duplicating
# all the resources needed by the shared module.
# Template uses locales_listfile_output from outer scope.
}
action(target_name) {
script = "//remoting/webapp/build-webapp.py"
app_key = invoker.app_key
app_id = invoker.app_id
app_client_id = invoker.app_client_id
app_vendor = invoker.app_vendor
app_name = invoker.app_name
app_fullname = invoker.app_fullname
app_description = invoker.app_description
app_capabilities = invoker.app_capabilities
manifest_key = invoker.manifest_key
# These asserts are so that these variables get marked as being used so
# that GN doesn't complain about them.
assert(app_key != "" || app_key == "")
assert(app_id != "" || app_id == "")
ar_base_path = "//remoting/webapp/app_remoting"
if (app_vendor != "") {
ar_app_path = "$ar_base_path/internal/apps/$app_vendor/$app_name"
} else {
ar_app_path = "$ar_base_path/apps/$app_name"
}
ar_app_manifest = "$ar_app_path/manifest.json.jinja2"
ar_app_manifest_common = "$ar_base_path/manifest_common.json.jinja2"
output_dir = "$root_build_dir/remoting/app_remoting/" +
"$ar_service_environment/$target_name"
zip_path = "$root_build_dir/remoting/app_remoting/" +
"$ar_service_environment/$target_name.zip"
# TODO(garykac) Move this list of files into files.gni.
ar_app_specific_files = [
"$ar_app_path/icon16.png",
"$ar_app_path/icon48.png",
"$ar_app_path/icon128.png",
"$ar_app_path/loading_splash.png",
]
ar_webapp_files =
ar_app_specific_files + ar_vendor_js_files + ar_vendor_html_files
inputs = [
rebase_path(ar_app_manifest, root_build_dir),
rebase_path(ar_app_manifest_common, root_build_dir),
] + remoting_version_files + ar_webapp_files
outputs = [
zip_path,
]
deps = [
":$locales_listfile",
"//remoting/resources",
]
# Create a file that contains a list of all the resource files needed
# to build the webapp. This is needed to avoid problems on platforms that
# limit the size of a command line.
file_list = "$target_gen_dir/${target_name}_files.txt"
files = []
files += rebase_path(ar_webapp_files, root_build_dir)
write_file(file_list, files)
args = [
buildtype,
chrome_version_full,
rebase_path(output_dir, root_build_dir),
rebase_path(zip_path, root_build_dir),
rebase_path(ar_app_manifest, root_build_dir),
"app_remoting", # Web app type
]
args += [
"--files_listfile",
rebase_path(file_list, root_build_dir),
]
args += [
"--locales_listfile",
rebase_path(locales_listfile_output, root_build_dir),
]
args += [
"--jinja_paths",
rebase_path("//remoting/webapp/app_remoting", root_build_dir),
]
if (is_debug) {
# Normally, the app-id for the orchestrator is automatically extracted
# from the webapp's extension id, but that approach doesn't work for
# dev webapp builds (since they all share the same dev extension id).
# The --appid arg will create a webapp that registers the given app-id
# rather than using the extension id.
# This is only done for Dev apps because the app-id for Release apps
# *must* match the extension id.
args += [
"--appid",
app_id,
]
}
args += [
"--app_name",
app_fullname,
]
args += [
"--app_description",
app_description,
]
args += [ "--app_capabilities" ] + app_capabilities
args += [
"--service_environment",
ar_service_environment,
]
args += [
"--manifest_key",
manifest_key,
]
args += [
"--app_client_id",
app_client_id,
]
}
}
template("app_remoting_shared_module") {
# TODO(garykac): Include the PNaCl plugin in the shared module once we have
# a GN toolchain (crbug.com/471924).
locales_listfile = target_name + "_locales"
locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
build_locales_listfile(locales_listfile) {
# Template uses locales_listfile_output from outer scope.
}
feedback_consent_html = target_name + "_feedback_consent_html"
feedback_consent_html_output =
"$target_gen_dir/html/$target_name/feedback_consent.html"
build_webapp_html(feedback_consent_html) {
html_template_file = ar_feedback_consent_template
html_template_include_files = []
js_files = ar_feedback_consent_html_all_js_files
html_output = feedback_consent_html_output
exclude_js = []
instrument_js = []
}
loading_window_html = target_name + "_loading_window_html"
loading_window_html_output =
"$target_gen_dir/html/$target_name/loading_window.html"
build_webapp_html(loading_window_html) {
html_template_file = ar_loading_window_template
html_template_include_files = []
# The loading window is just a reskin of the message window -- all JS code
# is shared.
js_files = remoting_webapp_message_window_html_all_js_files
html_output = loading_window_html_output
exclude_js = []
instrument_js = []
}
message_window_html = target_name + "_message_window_html"
message_window_html_output =
"$target_gen_dir/html/$target_name/message_window.html"
build_webapp_html(message_window_html) {
html_template_file = remoting_webapp_template_message_window
html_template_include_files = []
js_files = remoting_webapp_message_window_html_all_js_files
html_output = message_window_html_output
exclude_js = []
instrument_js = []
}
wcs_sandbox_html = target_name + "_wcs_sandbox_html"
wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
build_webapp_html(wcs_sandbox_html) {
html_template_file = remoting_webapp_template_wcs_sandbox
html_template_include_files = []
js_files = remoting_webapp_wcs_sandbox_html_all_js_files
html_output = wcs_sandbox_html_output
exclude_js = []
instrument_js = []
}
background_html = target_name + "_background_html"
background_html_output =
"$target_gen_dir/html/$target_name/ar_background.html"
build_webapp_html(background_html) {
html_template_file = ar_background_template
html_template_include_files = []
js_files = ar_background_html_js_files
html_output = background_html_output
exclude_js = []
instrument_js = []
}
main_html = target_name + "_main_html"
main_html_output = "$target_gen_dir/html/$target_name/main.html"
build_webapp_html(main_html) {
html_template_file = ar_main_template
html_template_include_files = ar_main_template_files
js_files = ar_main_js_files
html_output = main_html_output
exclude_js = []
instrument_js = []
}
action(target_name) {
script = "build-webapp.py"
app_name = invoker.app_name
ar_path = "app_remoting/$app_name"
ar_manifest = "$ar_path/manifest.json"
output_dir = "$root_build_dir/remoting/app_remoting/$target_name"
zip_path = "$root_build_dir/remoting/app_remoting/$target_name.zip"
ar_generated_html_files = [
background_html_output,
feedback_consent_html_output,
loading_window_html_output,
message_window_html_output,
wcs_sandbox_html_output,
main_html_output,
"$target_gen_dir/credits.html",
]
ar_webapp_files =
ar_shared_resource_files + ar_all_js_files + ar_generated_html_files
inputs = [ rebase_path(ar_manifest, root_build_dir) ] +
remoting_version_files + ar_webapp_files
outputs = [
zip_path,
]
deps = [
":$background_html",
":$feedback_consent_html",
":$loading_window_html",
":$locales_listfile",
":$main_html",
":$message_window_html",
":$wcs_sandbox_html",
"//remoting/resources",
"//remoting/webapp:credits",
]
# Create a file that contains a list of all the resource files needed
# to build the webapp. This is needed to avoid problems on platforms that
# limit the size of a command line.
file_list = "$target_gen_dir/${target_name}_files.txt"
files = []
files += rebase_path(ar_webapp_files, root_build_dir)
write_file(file_list, files)
args = [
buildtype,
chrome_version_full,
rebase_path(output_dir, root_build_dir),
rebase_path(zip_path, root_build_dir),
rebase_path(ar_manifest, root_build_dir),
"shared_module", # Web app type
]
args += [
"--files_listfile",
rebase_path(file_list, root_build_dir),
]
args += [
"--locales_listfile",
rebase_path(locales_listfile_output, root_build_dir),
]
}
}