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/util/version.gni")
9 import("//remoting/remoting_locales.gni")
10 import("//remoting/remoting_options.gni")
11 import("//remoting/remoting_version.gni")
12 import("//remoting/webapp/files.gni")
13 import("//third_party/closure_compiler/closure_args.gni")
15 # The base remoting directory that is used as the root directory for file
16 # references. Many of the scripts rely on the files being specified relative
18 remoting_dir = "//remoting"
22 if (is_official_build) {
23 buildtype = "Official"
29 template("build_locales_listfile") {
31 locales_listfile_output = invoker.locales_listfile_output
33 script = "../tools/build/remoting_localize.py"
37 locales_listfile_output,
42 rebase_path(webapp_locale_dir, root_build_dir) +
43 "/@{json_suffix}/messages.json",
45 rebase_path(locales_listfile_output, root_build_dir),
47 args += remoting_locales
51 template("build_webapp_html") {
54 if (enable_remoting_jscompile) {
55 target_jscompile = "${target_name}_jscompile"
56 target_jscompile_stamp = "$target_gen_dir/${target_jscompile}.stamp"
57 action(target_jscompile) {
58 js_files = remoting_webapp_js_proto_files + invoker.js_files
60 remoting_webapp_js_externs_files +
61 [ "../../third_party/closure_compiler/externs/chrome_extensions.js" ]
63 script = "../../third_party/closure_compiler/compile.py"
66 target_jscompile_stamp,
69 extra_closure_args = [
70 "jscomp_error=reportUnknownTypes",
71 "jscomp_error=duplicate",
72 "jscomp_error=misplacedTypeAnnotation",
75 args = rebase_path(js_files, root_build_dir)
79 rebase_path(target_jscompile_stamp, root_build_dir),
81 ] + closure_args + extra_closure_args
82 args += [ "--externs" ] + rebase_path(externs, root_build_dir)
87 html_template_file = invoker.html_template_file
88 html_template_include_files = invoker.html_template_include_files
89 js_files = invoker.js_files
90 html_output = invoker.html_output
92 script = rebase_path("//remoting/webapp/build-html.py", root_build_dir)
94 inputs = [ html_template_file ] + html_template_include_files + js_files
100 if (target_jscompile != "") {
102 ":$target_jscompile",
107 rebase_path(html_output, root_build_dir),
108 rebase_path(html_template_file, root_build_dir),
112 rebase_path(remoting_dir, root_build_dir),
114 args += [ "--templates" ] + html_template_include_files
115 args += [ "--js" ] + rebase_path(js_files, remoting_dir)
119 template("desktop_remoting_webapp") {
120 locales_listfile = target_name + "_locales"
121 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
123 build_locales_listfile(locales_listfile) {
124 # Template uses locales_listfile_output from outer scope.
127 background_html = target_name + "_background_html"
128 background_html_output = "$target_gen_dir/html/$target_name/background.html"
130 build_webapp_html(background_html) {
131 html_template_file = remoting_webapp_template_background
132 html_template_include_files = []
133 js_files = remoting_webapp_background_html_all_js_files
134 html_output = background_html_output
137 message_window_html = target_name + "_message_window_html"
138 message_window_html_output =
139 "$target_gen_dir/html/$target_name/message_window.html"
141 build_webapp_html(message_window_html) {
142 html_template_file = remoting_webapp_template_message_window
143 html_template_include_files = []
144 js_files = remoting_webapp_message_window_html_all_js_files
145 html_output = message_window_html_output
148 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
149 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
151 build_webapp_html(wcs_sandbox_html) {
152 html_template_file = remoting_webapp_template_wcs_sandbox
153 html_template_include_files = []
154 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
155 html_output = wcs_sandbox_html_output
158 main_html = target_name + "_main_html"
159 main_html_output = "$target_gen_dir/html/$target_name/main.html"
161 build_webapp_html(main_html) {
162 html_template_file = remoting_webapp_template_main
163 html_template_include_files = remoting_webapp_template_files
164 js_files = remoting_webapp_crd_main_html_all_js_files
165 html_output = main_html_output
168 action(target_name) {
169 script = "//remoting/webapp/build-webapp.py"
171 webapp_type = invoker.webapp_type
172 output_dir = invoker.output_dir
173 zip_path = invoker.zip_path
174 extra_files = invoker.extra_files
176 dr_generated_html_files = [
177 background_html_output,
178 message_window_html_output,
179 wcs_sandbox_html_output,
181 "$target_gen_dir/credits.html",
184 inputs = [ rebase_path("crd/manifest.json.jinja2", root_build_dir) ] +
185 remoting_version_files +
186 rebase_path(remoting_webapp_crd_files, root_build_dir) +
187 extra_files + dr_generated_html_files
190 "$target_gen_dir/$zip_path",
194 ":$locales_listfile",
196 ":$message_window_html",
197 ":$wcs_sandbox_html",
199 "//remoting/resources",
200 "//remoting/webapp:credits",
203 # Create a file that contains a list of all the resource files needed
204 # to build the webapp. This is needed to avoid problems on platforms that
205 # limit the size of a command line.
206 file_list = "$target_gen_dir/${target_name}_files.txt"
208 files += rebase_path(dr_generated_html_files, root_build_dir)
209 files += rebase_path(remoting_webapp_crd_files, root_build_dir)
210 files += rebase_path(extra_files, root_build_dir)
211 write_file(file_list, files)
218 rebase_path("crd/manifest.json.jinja2", root_build_dir),
223 rebase_path(file_list, root_build_dir),
226 "--locales_listfile",
227 rebase_path(locales_listfile_output, root_build_dir),
236 template("app_remoting_webapp") {
237 locales_listfile = target_name + "_locales"
238 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
240 build_locales_listfile(locales_listfile) {
241 # TODO(garykac) Replace resources with empty stub rather than duplicating
242 # all the resources needed by the shared module.
243 # Template uses locales_listfile_output from outer scope.
246 action(target_name) {
247 script = "//remoting/webapp/build-webapp.py"
249 app_key = invoker.app_key
250 app_id = invoker.app_id
251 app_client_id = invoker.app_client_id
252 app_vendor = invoker.app_vendor
253 app_name = invoker.app_name
254 app_fullname = invoker.app_fullname
255 app_description = invoker.app_description
256 app_capabilities = invoker.app_capabilities
257 manifest_key = invoker.manifest_key
259 # These asserts are so that these variables get marked as being used so
260 # that GN doesn't complain about them.
261 assert(app_key != "" || app_key == "")
262 assert(app_id != "" || app_id == "")
264 ar_base_path = "//remoting/webapp/app_remoting"
265 if (app_vendor != "") {
266 ar_app_path = "$ar_base_path/internal/apps/$app_vendor/$app_name"
268 ar_app_path = "$ar_base_path/apps/$app_name"
270 ar_app_manifest = "$ar_app_path/manifest.json.jinja2"
271 ar_app_manifest_common = "$ar_base_path/manifest_common.json.jinja2"
273 output_dir = "remoting/app_remoting/$ar_service_environment/$target_name"
274 zip_path = "remoting/app_remoting/$ar_service_environment/$target_name.zip"
276 # TODO(garykac) Move this list of files into files.gni.
277 ar_app_specific_files = [
278 "$ar_app_path/icon16.png",
279 "$ar_app_path/icon48.png",
280 "$ar_app_path/icon128.png",
281 "$ar_app_path/loading_splash.png",
285 ar_app_specific_files + ar_vendor_js_files + ar_vendor_html_files
288 rebase_path(ar_app_manifest, root_build_dir),
289 rebase_path(ar_app_manifest_common, root_build_dir),
290 ] + remoting_version_files + ar_webapp_files
293 "$target_gen_dir/$zip_path",
297 ":$locales_listfile",
298 "//remoting/resources",
301 # Create a file that contains a list of all the resource files needed
302 # to build the webapp. This is needed to avoid problems on platforms that
303 # limit the size of a command line.
304 file_list = "$target_gen_dir/${target_name}_files.txt"
306 files += rebase_path(ar_webapp_files, root_build_dir)
307 write_file(file_list, files)
314 rebase_path(ar_app_manifest, root_build_dir),
315 "app_remoting", # Web app type
319 rebase_path(file_list, root_build_dir),
322 "--locales_listfile",
323 rebase_path(locales_listfile_output, root_build_dir),
327 rebase_path("//remoting/webapp/app_remoting", root_build_dir),
331 # Normally, the app-id for the orchestrator is automatically extracted
332 # from the webapp's extension id, but that approach doesn't work for
333 # dev webapp builds (since they all share the same dev extension id).
334 # The --appid arg will create a webapp that registers the given app-id
335 # rather than using the extension id.
336 # This is only done for Dev apps because the app-id for Release apps
337 # *must* match the extension id.
352 args += [ "--app_capabilities" ] + app_capabilities
354 "--service_environment",
355 ar_service_environment,
368 template("app_remoting_shared_module") {
369 # TODO(garykac): Include the PNaCl plugin in the shared module once we have
370 # a GN toolchain (crbug.com/471924).
372 locales_listfile = target_name + "_locales"
373 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
375 build_locales_listfile(locales_listfile) {
376 # Template uses locales_listfile_output from outer scope.
379 feedback_consent_html = target_name + "_feedback_consent_html"
380 feedback_consent_html_output =
381 "$target_gen_dir/html/$target_name/feedback_consent.html"
383 build_webapp_html(feedback_consent_html) {
384 html_template_file = ar_feedback_consent_template
385 html_template_include_files = []
386 js_files = ar_feedback_consent_html_all_js_files
387 html_output = feedback_consent_html_output
390 loading_window_html = target_name + "_loading_window_html"
391 loading_window_html_output =
392 "$target_gen_dir/html/$target_name/loading_window.html"
394 build_webapp_html(loading_window_html) {
395 html_template_file = ar_loading_window_template
396 html_template_include_files = []
398 # The loading window is just a reskin of the message window -- all JS code
400 js_files = remoting_webapp_message_window_html_all_js_files
401 html_output = loading_window_html_output
404 message_window_html = target_name + "_message_window_html"
405 message_window_html_output =
406 "$target_gen_dir/html/$target_name/message_window.html"
408 build_webapp_html(message_window_html) {
409 html_template_file = remoting_webapp_template_message_window
410 html_template_include_files = []
411 js_files = remoting_webapp_message_window_html_all_js_files
412 html_output = message_window_html_output
415 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
416 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
418 build_webapp_html(wcs_sandbox_html) {
419 html_template_file = remoting_webapp_template_wcs_sandbox
420 html_template_include_files = []
421 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
422 html_output = wcs_sandbox_html_output
425 background_html = target_name + "_background_html"
426 background_html_output =
427 "$target_gen_dir/html/$target_name/ar_background.html"
429 build_webapp_html(background_html) {
430 html_template_file = ar_background_template
431 html_template_include_files = []
432 js_files = ar_background_html_js_files
433 html_output = background_html_output
436 main_html = target_name + "_main_html"
437 main_html_output = "$target_gen_dir/html/$target_name/main.html"
439 build_webapp_html(main_html) {
440 html_template_file = ar_main_template
441 html_template_include_files = ar_main_template_files
442 js_files = ar_main_js_files
443 html_output = main_html_output
446 action(target_name) {
447 script = "build-webapp.py"
449 app_name = invoker.app_name
451 ar_path = "app_remoting/$app_name"
452 ar_manifest = "$ar_path/manifest.json"
454 output_dir = "remoting/app_remoting/$target_name"
455 zip_path = "remoting/app_remoting/$target_name.zip"
457 ar_generated_html_files = [
458 background_html_output,
459 feedback_consent_html_output,
460 loading_window_html_output,
461 message_window_html_output,
462 wcs_sandbox_html_output,
464 "$target_gen_dir/credits.html",
468 ar_shared_resource_files + ar_all_js_files + ar_generated_html_files
470 inputs = [ rebase_path(ar_manifest, root_build_dir) ] +
471 remoting_version_files + ar_webapp_files
474 "$target_gen_dir/$zip_path",
478 ":$locales_listfile",
480 ":$feedback_consent_html",
481 ":$loading_window_html",
482 ":$message_window_html",
483 ":$wcs_sandbox_html",
485 "//remoting/resources",
486 "//remoting/webapp:credits",
489 # Create a file that contains a list of all the resource files needed
490 # to build the webapp. This is needed to avoid problems on platforms that
491 # limit the size of a command line.
492 file_list = "$target_gen_dir/${target_name}_files.txt"
494 files += rebase_path(ar_webapp_files, root_build_dir)
495 write_file(file_list, files)
502 rebase_path(ar_manifest, root_build_dir),
503 "shared_module", # Web app type
507 rebase_path(file_list, root_build_dir),
510 "--locales_listfile",
511 rebase_path(locales_listfile_output, root_build_dir),