summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/build_template.gni
blob: 70ff555feab28283ee03b1110306ec0a6ba957f9 (plain)
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
# 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("//remoting/remoting_locales.gni")
import("//remoting/remoting_options.gni")
import("//remoting/remoting_version.gni")
import("//remoting/webapp/files.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"

template("remoting_webapp") {
  locales_listfile = target_name + "_locales"
  listfile = "$target_gen_dir/${target_name}_locales.txt"
  listfile_rel = rebase_path(listfile, root_build_dir)

  action(locales_listfile) {
    script = "../tools/build/remoting_localize.py"

    inputs = []
    outputs = [
      listfile,
    ]

    args = [
      "--locale_output",
      rebase_path(webapp_locale_dir, root_build_dir) +
          "/@{json_suffix}/messages.json",
      "--locales_listfile",
      listfile_rel,
    ]
    args += remoting_locales
  }

  action(target_name) {
    script = "build-webapp.py"

    webapp_type = invoker.webapp_type
    output_dir = invoker.output_dir
    zip_path = invoker.zip_path
    extra_files = invoker.extra_files

    inputs = []
    outputs = [
      "$target_gen_dir/$zip_path",
    ]

    deps = [
      ":html",
      ":$locales_listfile",
      "//remoting/resources",
    ]

    buildtype = "Dev"
    if (!is_debug) {
      if (is_official_build) {
        buildtype = "Official"
      } else {
        buildtype = "Release"
      }
    }

    generated_html_files = [
      "$target_gen_dir/background.html",
      "$target_gen_dir/main.html",
      "$target_gen_dir/message_window.html",
      "$target_gen_dir/wcs_sandbox.html",
    ]

    # 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}_file_list.txt"
    files = []
    files += rebase_path(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,
      version_full,
      output_dir,
      zip_path,
      rebase_path("crd/manifest.json.jinja2", root_build_dir),
      webapp_type,
    ]
    args += [
      "--files_listfile",
      rebase_path(file_list, root_build_dir),
    ]
    args += [
      "--locales_listfile",
      listfile_rel,
    ]
    args += [
      "--use_gcd",
      "$remoting_use_gcd",
    ]
  }
}