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.
5 # Keep in sync with 'remoting_webapp' target in remoting/remoting_client.gypi.
7 import("//build/config/chrome_build.gni")
8 import("//build/config/features.gni")
9 import("//build/util/version.gni")
10 import("//remoting/remoting_locales.gni")
11 import("//remoting/remoting_options.gni")
12 import("//remoting/remoting_version.gni")
13 import("//remoting/webapp/files.gni")
14 import("//third_party/closure_compiler/closure_args.gni")
16 # The base remoting directory that is used as the root directory for file
17 # references. Many of the scripts rely on the files being specified relative
19 remoting_dir = "//remoting"
23 if (is_official_build) {
24 buildtype = "Official"
30 template("build_locales_listfile") {
32 locales_listfile_output = invoker.locales_listfile_output
34 script = "../tools/build/remoting_localize.py"
38 locales_listfile_output,
43 rebase_path(webapp_locale_dir, root_build_dir) +
44 "/@{json_suffix}/messages.json",
46 rebase_path(locales_listfile_output, root_build_dir),
48 args += remoting_locales
52 template("build_webapp_html") {
55 if (enable_remoting_jscompile) {
56 target_jscompile = "${target_name}_jscompile"
57 target_jscompile_stamp = "$target_gen_dir/${target_jscompile}.stamp"
58 action(target_jscompile) {
59 js_files = remoting_webapp_js_proto_files + invoker.js_files
61 remoting_webapp_js_externs_files + [
62 "../../third_party/closure_compiler/externs/chrome_extensions.js",
63 "../../third_party/closure_compiler/externs/metrics_private.js",
66 script = "../../third_party/closure_compiler/compile.py"
69 target_jscompile_stamp,
72 extra_closure_args = [
73 "jscomp_error=reportUnknownTypes",
74 "jscomp_error=duplicate",
75 "jscomp_error=misplacedTypeAnnotation",
78 args = rebase_path(js_files, root_build_dir)
82 rebase_path(target_jscompile_stamp, root_build_dir),
84 ] + closure_args + extra_closure_args
85 args += [ "--externs" ] + rebase_path(externs, root_build_dir)
90 html_template_file = invoker.html_template_file
91 html_template_include_files = invoker.html_template_include_files
92 js_files = invoker.js_files
93 html_output = invoker.html_output
95 script = rebase_path("//remoting/webapp/build-html.py", root_build_dir)
97 inputs = [ html_template_file ] + html_template_include_files + js_files
103 if (target_jscompile != "") {
105 ":$target_jscompile",
110 rebase_path(html_output, root_build_dir),
111 rebase_path(html_template_file, root_build_dir),
115 rebase_path(remoting_dir, root_build_dir),
117 args += [ "--templates" ] + html_template_include_files
118 args += [ "--js" ] + rebase_path(js_files, remoting_dir)
122 template("desktop_remoting_webapp") {
123 locales_listfile = target_name + "_locales"
124 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
126 build_locales_listfile(locales_listfile) {
127 # Template uses locales_listfile_output from outer scope.
130 background_html = target_name + "_background_html"
131 background_html_output = "$target_gen_dir/html/$target_name/background.html"
133 build_webapp_html(background_html) {
134 html_template_file = remoting_webapp_template_background
135 html_template_include_files = []
136 js_files = remoting_webapp_background_html_all_js_files
137 html_output = background_html_output
140 message_window_html = target_name + "_message_window_html"
141 message_window_html_output =
142 "$target_gen_dir/html/$target_name/message_window.html"
144 build_webapp_html(message_window_html) {
145 html_template_file = remoting_webapp_template_message_window
146 html_template_include_files = []
147 js_files = remoting_webapp_message_window_html_all_js_files
148 html_output = message_window_html_output
151 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
152 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
154 build_webapp_html(wcs_sandbox_html) {
155 html_template_file = remoting_webapp_template_wcs_sandbox
156 html_template_include_files = []
157 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
158 html_output = wcs_sandbox_html_output
161 main_html = target_name + "_main_html"
162 main_html_output = "$target_gen_dir/html/$target_name/main.html"
164 build_webapp_html(main_html) {
165 html_template_file = remoting_webapp_template_main
166 html_template_include_files = remoting_webapp_template_files
167 js_files = remoting_webapp_crd_main_html_all_js_files
168 html_output = main_html_output
171 action(target_name) {
172 script = "//remoting/webapp/build-webapp.py"
174 webapp_type = invoker.webapp_type
175 output_dir = invoker.output_dir
176 zip_path = invoker.zip_path
177 extra_files = invoker.extra_files
179 dr_generated_html_files = [
180 background_html_output,
181 message_window_html_output,
182 wcs_sandbox_html_output,
184 "$target_gen_dir/credits.html",
188 pexe_dir = get_label_info(
189 "//remoting/client/plugin:remoting_client_plugin_newlib(//build/toolchain/nacl:newlib_pnacl)",
192 extra_files += [ "$pexe_dir/remoting_client_plugin_newlib.pexe" ]
194 extra_files += [ "$pexe_dir/remoting_client_plugin_newlib.pexe.debug" ]
198 inputs = [ rebase_path("crd/manifest.json.jinja2", root_build_dir) ] +
199 remoting_version_files +
200 rebase_path(remoting_webapp_crd_files, root_build_dir) +
201 extra_files + dr_generated_html_files
208 ":$locales_listfile",
210 ":$message_window_html",
211 ":$wcs_sandbox_html",
213 "//remoting/resources",
214 "//remoting/webapp:credits",
219 "//remoting/client/plugin:remoting_client_plugin_newlib(//build/toolchain/nacl:newlib_pnacl)",
223 # Create a file that contains a list of all the resource files needed
224 # to build the webapp. This is needed to avoid problems on platforms that
225 # limit the size of a command line.
226 file_list = "$target_gen_dir/${target_name}_files.txt"
228 files += rebase_path(dr_generated_html_files, root_build_dir)
229 files += rebase_path(remoting_webapp_crd_files, root_build_dir)
230 files += rebase_path(extra_files, root_build_dir)
231 write_file(file_list, files)
236 rebase_path(output_dir, root_build_dir),
237 rebase_path(zip_path, root_build_dir),
238 rebase_path("crd/manifest.json.jinja2", root_build_dir),
243 rebase_path(file_list, root_build_dir),
246 "--locales_listfile",
247 rebase_path(locales_listfile_output, root_build_dir),
256 template("app_remoting_webapp") {
257 locales_listfile = target_name + "_locales"
258 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
260 build_locales_listfile(locales_listfile) {
261 # TODO(garykac) Replace resources with empty stub rather than duplicating
262 # all the resources needed by the shared module.
263 # Template uses locales_listfile_output from outer scope.
266 action(target_name) {
267 script = "//remoting/webapp/build-webapp.py"
269 app_key = invoker.app_key
270 app_id = invoker.app_id
271 app_client_id = invoker.app_client_id
272 app_vendor = invoker.app_vendor
273 app_name = invoker.app_name
274 app_fullname = invoker.app_fullname
275 app_description = invoker.app_description
276 app_capabilities = invoker.app_capabilities
277 manifest_key = invoker.manifest_key
279 # These asserts are so that these variables get marked as being used so
280 # that GN doesn't complain about them.
281 assert(app_key != "" || app_key == "")
282 assert(app_id != "" || app_id == "")
284 ar_base_path = "//remoting/webapp/app_remoting"
285 if (app_vendor != "") {
286 ar_app_path = "$ar_base_path/internal/apps/$app_vendor/$app_name"
288 ar_app_path = "$ar_base_path/apps/$app_name"
290 ar_app_manifest = "$ar_app_path/manifest.json.jinja2"
291 ar_app_manifest_common = "$ar_base_path/manifest_common.json.jinja2"
293 output_dir = "$root_build_dir/remoting/app_remoting/" +
294 "$ar_service_environment/$target_name"
295 zip_path = "$root_build_dir/remoting/app_remoting/" +
296 "$ar_service_environment/$target_name.zip"
298 # TODO(garykac) Move this list of files into files.gni.
299 ar_app_specific_files = [
300 "$ar_app_path/icon16.png",
301 "$ar_app_path/icon48.png",
302 "$ar_app_path/icon128.png",
303 "$ar_app_path/loading_splash.png",
307 ar_app_specific_files + ar_vendor_js_files + ar_vendor_html_files
310 rebase_path(ar_app_manifest, root_build_dir),
311 rebase_path(ar_app_manifest_common, root_build_dir),
312 ] + remoting_version_files + ar_webapp_files
319 ":$locales_listfile",
320 "//remoting/resources",
323 # Create a file that contains a list of all the resource files needed
324 # to build the webapp. This is needed to avoid problems on platforms that
325 # limit the size of a command line.
326 file_list = "$target_gen_dir/${target_name}_files.txt"
328 files += rebase_path(ar_webapp_files, root_build_dir)
329 write_file(file_list, files)
334 rebase_path(output_dir, root_build_dir),
335 rebase_path(zip_path, root_build_dir),
336 rebase_path(ar_app_manifest, root_build_dir),
337 "app_remoting", # Web app type
341 rebase_path(file_list, root_build_dir),
344 "--locales_listfile",
345 rebase_path(locales_listfile_output, root_build_dir),
349 rebase_path("//remoting/webapp/app_remoting", root_build_dir),
353 # Normally, the app-id for the orchestrator is automatically extracted
354 # from the webapp's extension id, but that approach doesn't work for
355 # dev webapp builds (since they all share the same dev extension id).
356 # The --appid arg will create a webapp that registers the given app-id
357 # rather than using the extension id.
358 # This is only done for Dev apps because the app-id for Release apps
359 # *must* match the extension id.
374 args += [ "--app_capabilities" ] + app_capabilities
376 "--service_environment",
377 ar_service_environment,
390 template("app_remoting_shared_module") {
391 # TODO(garykac): Include the PNaCl plugin in the shared module once we have
392 # a GN toolchain (crbug.com/471924).
394 locales_listfile = target_name + "_locales"
395 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
397 build_locales_listfile(locales_listfile) {
398 # Template uses locales_listfile_output from outer scope.
401 feedback_consent_html = target_name + "_feedback_consent_html"
402 feedback_consent_html_output =
403 "$target_gen_dir/html/$target_name/feedback_consent.html"
405 build_webapp_html(feedback_consent_html) {
406 html_template_file = ar_feedback_consent_template
407 html_template_include_files = []
408 js_files = ar_feedback_consent_html_all_js_files
409 html_output = feedback_consent_html_output
412 loading_window_html = target_name + "_loading_window_html"
413 loading_window_html_output =
414 "$target_gen_dir/html/$target_name/loading_window.html"
416 build_webapp_html(loading_window_html) {
417 html_template_file = ar_loading_window_template
418 html_template_include_files = []
420 # The loading window is just a reskin of the message window -- all JS code
422 js_files = remoting_webapp_message_window_html_all_js_files
423 html_output = loading_window_html_output
426 message_window_html = target_name + "_message_window_html"
427 message_window_html_output =
428 "$target_gen_dir/html/$target_name/message_window.html"
430 build_webapp_html(message_window_html) {
431 html_template_file = remoting_webapp_template_message_window
432 html_template_include_files = []
433 js_files = remoting_webapp_message_window_html_all_js_files
434 html_output = message_window_html_output
437 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
438 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
440 build_webapp_html(wcs_sandbox_html) {
441 html_template_file = remoting_webapp_template_wcs_sandbox
442 html_template_include_files = []
443 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
444 html_output = wcs_sandbox_html_output
447 background_html = target_name + "_background_html"
448 background_html_output =
449 "$target_gen_dir/html/$target_name/ar_background.html"
451 build_webapp_html(background_html) {
452 html_template_file = ar_background_template
453 html_template_include_files = []
454 js_files = ar_background_html_js_files
455 html_output = background_html_output
458 main_html = target_name + "_main_html"
459 main_html_output = "$target_gen_dir/html/$target_name/main.html"
461 build_webapp_html(main_html) {
462 html_template_file = ar_main_template
463 html_template_include_files = ar_main_template_files
464 js_files = ar_main_js_files
465 html_output = main_html_output
468 action(target_name) {
469 script = "build-webapp.py"
471 app_name = invoker.app_name
473 ar_path = "app_remoting/$app_name"
474 ar_manifest = "$ar_path/manifest.json"
476 output_dir = "$root_build_dir/remoting/app_remoting/$target_name"
477 zip_path = "$root_build_dir/remoting/app_remoting/$target_name.zip"
479 ar_generated_html_files = [
480 background_html_output,
481 feedback_consent_html_output,
482 loading_window_html_output,
483 message_window_html_output,
484 wcs_sandbox_html_output,
486 "$target_gen_dir/credits.html",
490 ar_shared_resource_files + ar_all_js_files + ar_generated_html_files
492 inputs = [ rebase_path(ar_manifest, root_build_dir) ] +
493 remoting_version_files + ar_webapp_files
500 ":$locales_listfile",
502 ":$feedback_consent_html",
503 ":$loading_window_html",
504 ":$message_window_html",
505 ":$wcs_sandbox_html",
507 "//remoting/resources",
508 "//remoting/webapp:credits",
511 # Create a file that contains a list of all the resource files needed
512 # to build the webapp. This is needed to avoid problems on platforms that
513 # limit the size of a command line.
514 file_list = "$target_gen_dir/${target_name}_files.txt"
516 files += rebase_path(ar_webapp_files, root_build_dir)
517 write_file(file_list, files)
522 rebase_path(output_dir, root_build_dir),
523 rebase_path(zip_path, root_build_dir),
524 rebase_path(ar_manifest, root_build_dir),
525 "shared_module", # Web app type
529 rebase_path(file_list, root_build_dir),
532 "--locales_listfile",
533 rebase_path(locales_listfile_output, root_build_dir),