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",
62 "../../third_party/closure_compiler/externs/metrics_private.js",
65 script = "../../third_party/closure_compiler/compile.py"
68 target_jscompile_stamp,
71 extra_closure_args = [
72 "jscomp_error=reportUnknownTypes",
73 "jscomp_error=duplicate",
74 "jscomp_error=misplacedTypeAnnotation",
77 args = rebase_path(js_files, root_build_dir)
81 rebase_path(target_jscompile_stamp, root_build_dir),
83 ] + closure_args + extra_closure_args
84 args += [ "--externs" ] + rebase_path(externs, root_build_dir)
89 html_template_file = invoker.html_template_file
90 html_template_include_files = invoker.html_template_include_files
91 js_files = invoker.js_files
92 html_output = invoker.html_output
94 script = rebase_path("//remoting/webapp/build-html.py", root_build_dir)
96 inputs = [ html_template_file ] + html_template_include_files + js_files
102 if (target_jscompile != "") {
104 ":$target_jscompile",
109 rebase_path(html_output, root_build_dir),
110 rebase_path(html_template_file, root_build_dir),
114 rebase_path(remoting_dir, root_build_dir),
116 args += [ "--templates" ] + html_template_include_files
117 args += [ "--js" ] + rebase_path(js_files, remoting_dir)
121 template("desktop_remoting_webapp") {
122 locales_listfile = target_name + "_locales"
123 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
125 build_locales_listfile(locales_listfile) {
126 # Template uses locales_listfile_output from outer scope.
129 background_html = target_name + "_background_html"
130 background_html_output = "$target_gen_dir/html/$target_name/background.html"
132 build_webapp_html(background_html) {
133 html_template_file = remoting_webapp_template_background
134 html_template_include_files = []
135 js_files = remoting_webapp_background_html_all_js_files
136 html_output = background_html_output
139 message_window_html = target_name + "_message_window_html"
140 message_window_html_output =
141 "$target_gen_dir/html/$target_name/message_window.html"
143 build_webapp_html(message_window_html) {
144 html_template_file = remoting_webapp_template_message_window
145 html_template_include_files = []
146 js_files = remoting_webapp_message_window_html_all_js_files
147 html_output = message_window_html_output
150 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
151 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
153 build_webapp_html(wcs_sandbox_html) {
154 html_template_file = remoting_webapp_template_wcs_sandbox
155 html_template_include_files = []
156 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
157 html_output = wcs_sandbox_html_output
160 main_html = target_name + "_main_html"
161 main_html_output = "$target_gen_dir/html/$target_name/main.html"
163 build_webapp_html(main_html) {
164 html_template_file = remoting_webapp_template_main
165 html_template_include_files = remoting_webapp_template_files
166 js_files = remoting_webapp_crd_main_html_all_js_files
167 html_output = main_html_output
170 action(target_name) {
171 script = "//remoting/webapp/build-webapp.py"
173 webapp_type = invoker.webapp_type
174 output_dir = invoker.output_dir
175 zip_path = invoker.zip_path
176 extra_files = invoker.extra_files
178 dr_generated_html_files = [
179 background_html_output,
180 message_window_html_output,
181 wcs_sandbox_html_output,
183 "$target_gen_dir/credits.html",
186 inputs = [ rebase_path("crd/manifest.json.jinja2", root_build_dir) ] +
187 remoting_version_files +
188 rebase_path(remoting_webapp_crd_files, root_build_dir) +
189 extra_files + dr_generated_html_files
196 ":$locales_listfile",
198 ":$message_window_html",
199 ":$wcs_sandbox_html",
201 "//remoting/resources",
202 "//remoting/webapp:credits",
205 # Create a file that contains a list of all the resource files needed
206 # to build the webapp. This is needed to avoid problems on platforms that
207 # limit the size of a command line.
208 file_list = "$target_gen_dir/${target_name}_files.txt"
210 files += rebase_path(dr_generated_html_files, root_build_dir)
211 files += rebase_path(remoting_webapp_crd_files, root_build_dir)
212 files += rebase_path(extra_files, root_build_dir)
213 write_file(file_list, files)
218 rebase_path(output_dir, root_build_dir),
219 rebase_path(zip_path, root_build_dir),
220 rebase_path("crd/manifest.json.jinja2", root_build_dir),
225 rebase_path(file_list, root_build_dir),
228 "--locales_listfile",
229 rebase_path(locales_listfile_output, root_build_dir),
238 template("app_remoting_webapp") {
239 locales_listfile = target_name + "_locales"
240 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
242 build_locales_listfile(locales_listfile) {
243 # TODO(garykac) Replace resources with empty stub rather than duplicating
244 # all the resources needed by the shared module.
245 # Template uses locales_listfile_output from outer scope.
248 action(target_name) {
249 script = "//remoting/webapp/build-webapp.py"
251 app_key = invoker.app_key
252 app_id = invoker.app_id
253 app_client_id = invoker.app_client_id
254 app_vendor = invoker.app_vendor
255 app_name = invoker.app_name
256 app_fullname = invoker.app_fullname
257 app_description = invoker.app_description
258 app_capabilities = invoker.app_capabilities
259 manifest_key = invoker.manifest_key
261 # These asserts are so that these variables get marked as being used so
262 # that GN doesn't complain about them.
263 assert(app_key != "" || app_key == "")
264 assert(app_id != "" || app_id == "")
266 ar_base_path = "//remoting/webapp/app_remoting"
267 if (app_vendor != "") {
268 ar_app_path = "$ar_base_path/internal/apps/$app_vendor/$app_name"
270 ar_app_path = "$ar_base_path/apps/$app_name"
272 ar_app_manifest = "$ar_app_path/manifest.json.jinja2"
273 ar_app_manifest_common = "$ar_base_path/manifest_common.json.jinja2"
275 output_dir = "$root_build_dir/remoting/app_remoting/" +
276 "$ar_service_environment/$target_name"
277 zip_path = "$root_build_dir/remoting/app_remoting/" +
278 "$ar_service_environment/$target_name.zip"
280 # TODO(garykac) Move this list of files into files.gni.
281 ar_app_specific_files = [
282 "$ar_app_path/icon16.png",
283 "$ar_app_path/icon48.png",
284 "$ar_app_path/icon128.png",
285 "$ar_app_path/loading_splash.png",
289 ar_app_specific_files + ar_vendor_js_files + ar_vendor_html_files
292 rebase_path(ar_app_manifest, root_build_dir),
293 rebase_path(ar_app_manifest_common, root_build_dir),
294 ] + remoting_version_files + ar_webapp_files
301 ":$locales_listfile",
302 "//remoting/resources",
305 # Create a file that contains a list of all the resource files needed
306 # to build the webapp. This is needed to avoid problems on platforms that
307 # limit the size of a command line.
308 file_list = "$target_gen_dir/${target_name}_files.txt"
310 files += rebase_path(ar_webapp_files, root_build_dir)
311 write_file(file_list, files)
316 rebase_path(output_dir, root_build_dir),
317 rebase_path(zip_path, root_build_dir),
318 rebase_path(ar_app_manifest, root_build_dir),
319 "app_remoting", # Web app type
323 rebase_path(file_list, root_build_dir),
326 "--locales_listfile",
327 rebase_path(locales_listfile_output, root_build_dir),
331 rebase_path("//remoting/webapp/app_remoting", root_build_dir),
335 # Normally, the app-id for the orchestrator is automatically extracted
336 # from the webapp's extension id, but that approach doesn't work for
337 # dev webapp builds (since they all share the same dev extension id).
338 # The --appid arg will create a webapp that registers the given app-id
339 # rather than using the extension id.
340 # This is only done for Dev apps because the app-id for Release apps
341 # *must* match the extension id.
356 args += [ "--app_capabilities" ] + app_capabilities
358 "--service_environment",
359 ar_service_environment,
372 template("app_remoting_shared_module") {
373 # TODO(garykac): Include the PNaCl plugin in the shared module once we have
374 # a GN toolchain (crbug.com/471924).
376 locales_listfile = target_name + "_locales"
377 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
379 build_locales_listfile(locales_listfile) {
380 # Template uses locales_listfile_output from outer scope.
383 feedback_consent_html = target_name + "_feedback_consent_html"
384 feedback_consent_html_output =
385 "$target_gen_dir/html/$target_name/feedback_consent.html"
387 build_webapp_html(feedback_consent_html) {
388 html_template_file = ar_feedback_consent_template
389 html_template_include_files = []
390 js_files = ar_feedback_consent_html_all_js_files
391 html_output = feedback_consent_html_output
394 loading_window_html = target_name + "_loading_window_html"
395 loading_window_html_output =
396 "$target_gen_dir/html/$target_name/loading_window.html"
398 build_webapp_html(loading_window_html) {
399 html_template_file = ar_loading_window_template
400 html_template_include_files = []
402 # The loading window is just a reskin of the message window -- all JS code
404 js_files = remoting_webapp_message_window_html_all_js_files
405 html_output = loading_window_html_output
408 message_window_html = target_name + "_message_window_html"
409 message_window_html_output =
410 "$target_gen_dir/html/$target_name/message_window.html"
412 build_webapp_html(message_window_html) {
413 html_template_file = remoting_webapp_template_message_window
414 html_template_include_files = []
415 js_files = remoting_webapp_message_window_html_all_js_files
416 html_output = message_window_html_output
419 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
420 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
422 build_webapp_html(wcs_sandbox_html) {
423 html_template_file = remoting_webapp_template_wcs_sandbox
424 html_template_include_files = []
425 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
426 html_output = wcs_sandbox_html_output
429 background_html = target_name + "_background_html"
430 background_html_output =
431 "$target_gen_dir/html/$target_name/ar_background.html"
433 build_webapp_html(background_html) {
434 html_template_file = ar_background_template
435 html_template_include_files = []
436 js_files = ar_background_html_js_files
437 html_output = background_html_output
440 main_html = target_name + "_main_html"
441 main_html_output = "$target_gen_dir/html/$target_name/main.html"
443 build_webapp_html(main_html) {
444 html_template_file = ar_main_template
445 html_template_include_files = ar_main_template_files
446 js_files = ar_main_js_files
447 html_output = main_html_output
450 action(target_name) {
451 script = "build-webapp.py"
453 app_name = invoker.app_name
455 ar_path = "app_remoting/$app_name"
456 ar_manifest = "$ar_path/manifest.json"
458 output_dir = "$root_build_dir/remoting/app_remoting/$target_name"
459 zip_path = "$root_build_dir/remoting/app_remoting/$target_name.zip"
461 ar_generated_html_files = [
462 background_html_output,
463 feedback_consent_html_output,
464 loading_window_html_output,
465 message_window_html_output,
466 wcs_sandbox_html_output,
468 "$target_gen_dir/credits.html",
472 ar_shared_resource_files + ar_all_js_files + ar_generated_html_files
474 inputs = [ rebase_path(ar_manifest, root_build_dir) ] +
475 remoting_version_files + ar_webapp_files
482 ":$locales_listfile",
484 ":$feedback_consent_html",
485 ":$loading_window_html",
486 ":$message_window_html",
487 ":$wcs_sandbox_html",
489 "//remoting/resources",
490 "//remoting/webapp:credits",
493 # Create a file that contains a list of all the resource files needed
494 # to build the webapp. This is needed to avoid problems on platforms that
495 # limit the size of a command line.
496 file_list = "$target_gen_dir/${target_name}_files.txt"
498 files += rebase_path(ar_webapp_files, root_build_dir)
499 write_file(file_list, files)
504 rebase_path(output_dir, root_build_dir),
505 rebase_path(zip_path, root_build_dir),
506 rebase_path(ar_manifest, root_build_dir),
507 "shared_module", # Web app type
511 rebase_path(file_list, root_build_dir),
514 "--locales_listfile",
515 rebase_path(locales_listfile_output, root_build_dir),