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("//remoting/remoting_locales.gni")
9 import("//remoting/remoting_options.gni")
10 import("//remoting/remoting_version.gni")
11 import("//remoting/webapp/files.gni")
13 # The base remoting directory that is used as the root directory for file
14 # references. Many of the scripts rely on the files being specified relative
16 remoting_dir = "//remoting"
20 if (is_official_build) {
21 buildtype = "Official"
27 template("build_locales_listfile") {
29 locales_listfile_output = invoker.locales_listfile_output
31 script = "../tools/build/remoting_localize.py"
35 locales_listfile_output,
40 rebase_path(webapp_locale_dir, root_build_dir) +
41 "/@{json_suffix}/messages.json",
43 rebase_path(locales_listfile_output, root_build_dir),
45 args += remoting_locales
49 template("build_webapp_html") {
50 target_jscompile = "${target_name}_jscompile"
51 target_jscompile_stamp = "$target_gen_dir/${target_jscompile}.stamp"
52 action(target_jscompile) {
53 js_files = remoting_webapp_js_proto_files + invoker.js_files
55 script = "../../third_party/closure_compiler/compile.py"
58 target_jscompile_stamp,
65 "../../third_party/closure_compiler/externs/chrome_extensions.js",
67 rebase_path(target_jscompile_stamp, root_build_dir),
68 ] + rebase_path(js_files, root_build_dir)
72 html_template_file = invoker.html_template_file
73 html_template_include_files = invoker.html_template_include_files
74 js_files = invoker.js_files
75 html_output = invoker.html_output
77 script = "build-html.py"
79 inputs = [ html_template_file ] + html_template_include_files + js_files
92 rebase_path(html_output, root_build_dir),
93 rebase_path(html_template_file, root_build_dir),
97 rebase_path(remoting_dir, root_build_dir),
99 args += [ "--templates" ] + html_template_include_files
100 args += [ "--js" ] + rebase_path(js_files, remoting_dir)
104 template("desktop_remoting_webapp") {
105 locales_listfile = target_name + "_locales"
106 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
108 build_locales_listfile(locales_listfile) {
109 # Template uses locales_listfile_output from outer scope.
112 background_html = target_name + "_background_html"
113 background_html_output = "$target_gen_dir/html/$target_name/background.html"
115 build_webapp_html(background_html) {
116 html_template_file = remoting_webapp_template_background
117 html_template_include_files = []
118 js_files = remoting_webapp_background_html_all_js_files
119 html_output = background_html_output
122 message_window_html = target_name + "_message_window_html"
123 message_window_html_output =
124 "$target_gen_dir/html/$target_name/message_window.html"
126 build_webapp_html(message_window_html) {
127 html_template_file = remoting_webapp_template_message_window
128 html_template_include_files = []
129 js_files = remoting_webapp_message_window_html_all_js_files
130 html_output = message_window_html_output
133 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
134 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
136 build_webapp_html(wcs_sandbox_html) {
137 html_template_file = remoting_webapp_template_wcs_sandbox
138 html_template_include_files = []
139 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
140 html_output = wcs_sandbox_html_output
143 main_html = target_name + "_main_html"
144 main_html_output = "$target_gen_dir/html/$target_name/main.html"
146 build_webapp_html(main_html) {
147 html_template_file = remoting_webapp_template_main
148 html_template_include_files = remoting_webapp_template_files
149 js_files = remoting_webapp_crd_main_html_all_js_files
150 html_output = main_html_output
153 action(target_name) {
154 script = "build-webapp.py"
156 webapp_type = invoker.webapp_type
157 output_dir = invoker.output_dir
158 zip_path = invoker.zip_path
159 extra_files = invoker.extra_files
162 [ rebase_path("crd/manifest.json.jinja2", root_build_dir) ] +
163 remoting_version_files +
164 rebase_path(remoting_webapp_crd_files, root_build_dir) + extra_files
167 "$target_gen_dir/$zip_path",
171 ":$locales_listfile",
173 ":$message_window_html",
174 ":$wcs_sandbox_html",
176 "//remoting/resources",
179 dr_generated_html_files = [
180 background_html_output,
181 message_window_html_output,
182 wcs_sandbox_html_output,
186 # Create a file that contains a list of all the resource files needed
187 # to build the webapp. This is needed to avoid problems on platforms that
188 # limit the size of a command line.
189 file_list = "$target_gen_dir/${target_name}_files.txt"
191 files += rebase_path(dr_generated_html_files, root_build_dir)
192 files += rebase_path(remoting_webapp_crd_files, root_build_dir)
193 files += rebase_path(extra_files, root_build_dir)
194 write_file(file_list, files)
201 rebase_path("crd/manifest.json.jinja2", root_build_dir),
206 rebase_path(file_list, root_build_dir),
209 "--locales_listfile",
210 rebase_path(locales_listfile_output, root_build_dir),
219 template("app_remoting_webapp") {
220 locales_listfile = target_name + "_locales"
221 locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt"
223 build_locales_listfile(locales_listfile) {
224 # Template uses locales_listfile_output from outer scope.
227 feedback_consent_html = target_name + "_feedback_consent_html"
228 feedback_consent_html_output =
229 "$target_gen_dir/html/$target_name/feedback_consent.html"
231 build_webapp_html(feedback_consent_html) {
232 html_template_file = ar_feedback_consent_template
233 html_template_include_files = []
234 js_files = ar_feedback_consent_html_all_js_files
235 html_output = feedback_consent_html_output
238 loading_window_html = target_name + "_loading_window_html"
239 loading_window_html_output =
240 "$target_gen_dir/html/$target_name/loading_window.html"
242 build_webapp_html(loading_window_html) {
243 html_template_file = ar_loading_window_template
244 html_template_include_files = []
246 # The loading window is just a reskin of the message window -- all JS code
248 js_files = remoting_webapp_message_window_html_all_js_files
249 html_output = loading_window_html_output
252 message_window_html = target_name + "_message_window_html"
253 message_window_html_output =
254 "$target_gen_dir/html/$target_name/message_window.html"
256 build_webapp_html(message_window_html) {
257 html_template_file = remoting_webapp_template_message_window
258 html_template_include_files = []
259 js_files = remoting_webapp_message_window_html_all_js_files
260 html_output = message_window_html_output
263 wcs_sandbox_html = target_name + "_wcs_sandbox_html"
264 wcs_sandbox_html_output = "$target_gen_dir/html/$target_name/wcs_sandbox.html"
266 build_webapp_html(wcs_sandbox_html) {
267 html_template_file = remoting_webapp_template_wcs_sandbox
268 html_template_include_files = []
269 js_files = remoting_webapp_wcs_sandbox_html_all_js_files
270 html_output = wcs_sandbox_html_output
273 main_html = target_name + "_main_html"
274 main_html_output = "$target_gen_dir/html/$target_name/main.html"
276 build_webapp_html(main_html) {
277 html_template_file = ar_main_template
278 html_template_include_files = ar_main_template_files
279 js_files = ar_main_js_files
280 html_output = main_html_output
283 action(target_name) {
284 script = "build-webapp.py"
286 app_key = invoker.app_key
287 app_id = invoker.app_id
288 app_client_id = invoker.app_client_id
289 app_name = invoker.app_name
290 app_description = invoker.app_description
291 app_capabilities = invoker.app_capabilities
292 manifest_key = invoker.manifest_key
294 # These asserts are so that these variables get marked as being used so
295 # that GN doesn't complain about them.
296 assert(app_key != "" || app_key == "")
297 assert(app_id != "" || app_id == "")
299 # TODO(garykac) For internal targets, we need to extract the vendor and app
300 # name from the target.
301 ar_app_name = "sample_app" #target_name
302 ar_app_path = "app_remoting/apps/$ar_app_name"
303 ar_app_manifest = "$ar_app_path/manifest.json.jinja2"
304 ar_app_manifest_common = "app_remoting/manifest_common.json.jinja2"
306 output_dir = "remoting/app_remoting/$ar_service_environment/$target_name"
307 zip_path = "remoting/app_remoting/$ar_service_environment/$target_name.zip"
309 ar_app_specific_files = [
310 "$ar_app_path/icon16.png",
311 "$ar_app_path/icon48.png",
312 "$ar_app_path/icon128.png",
313 "$ar_app_path/loading_splash.png",
316 ar_generated_html_files = [
317 feedback_consent_html_output,
318 loading_window_html_output,
319 message_window_html_output,
320 wcs_sandbox_html_output,
325 ar_app_specific_files + ar_shared_resource_files + ar_all_js_files
328 rebase_path(ar_app_manifest, root_build_dir),
329 rebase_path(ar_app_manifest_common, root_build_dir),
330 ] + remoting_version_files + ar_webapp_files
333 "$target_gen_dir/$zip_path",
337 ":$locales_listfile",
338 ":$feedback_consent_html",
339 ":$loading_window_html",
340 ":$message_window_html",
341 ":$wcs_sandbox_html",
343 "//remoting/resources",
346 # Create a file that contains a list of all the resource files needed
347 # to build the webapp. This is needed to avoid problems on platforms that
348 # limit the size of a command line.
349 file_list = "$target_gen_dir/${target_name}_files.txt"
351 files += rebase_path(ar_generated_html_files, root_build_dir)
352 files += rebase_path(ar_webapp_files, root_build_dir)
353 write_file(file_list, files)
360 rebase_path(ar_app_manifest, root_build_dir),
361 "app_remoting", # Web app type
365 rebase_path(file_list, root_build_dir),
368 "--locales_listfile",
369 rebase_path(locales_listfile_output, root_build_dir),
373 rebase_path("app_remoting", root_build_dir),
377 # Normally, the app-id for the orchestrator is automatically extracted
378 # from the webapp's extension id, but that approach doesn't work for
379 # dev webapp builds (since they all share the same dev extension id).
380 # The --appid arg will create a webapp that registers the given app-id
381 # rather than using the extension id.
382 # This is only done for Dev apps because the app-id for Release apps
383 # *must* match the extension id.
398 args += [ "--app_capabilities" ] + app_capabilities
400 "--service_environment",
401 ar_service_environment,