summaryrefslogtreecommitdiff
path: root/chromium/remoting/resources/BUILD.gn
blob: cf5d4cdee285bcae057df607d23535fc3c7fa09c (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright 2014 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.

import("//remoting/remoting_locales.gni")
import("//tools/grit/grit_rule.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
}

group("resources") {
  public_deps = [
    ":copy_locales",
    ":strings",
    ":verify_resources",
  ]
}

# TODO(GYP) enable verify_resources. The bots are complaining about
# gen/main.html not being found but this doesn't seems to reproduce locally.

action("verify_resources") {
  script = "//remoting/tools/verify_resources.py"

  sources_to_verify = [
    #    "$root_gen_dir/main.html",
    "../host/continue_window_mac.mm",
    "../host/disconnect_window_mac.mm",
    "../host/installer/mac/uninstaller/remoting_uninstaller-InfoPlist.strings.jinja2",
    "../host/win/core.rc.jinja2",
    "../host/win/host_messages.mc.jinja2",
    "../host/win/version.rc.jinja2",
    "../webapp/crd/js/background.js",
    "../webapp/base/js/error.js",
    "../webapp/crd/js/host_list.js",
    "../webapp/crd/js/host_setup_dialog.js",
    "../webapp/crd/js/host_table_entry.js",
    "../webapp/crd/manifest.json.jinja2",
    "../webapp/crd/js/paired_client_manager.js",
    "../webapp/crd/js/desktop_remoting.js",
    "../webapp/crd/js/window_frame.js",
  ]

  inputs = [ "remoting_strings.grd" ] + sources_to_verify

  stampfile = "$root_out_dir/remoting_resources_verified_stamp"
  outputs = [
    stampfile,
  ]

  args = [
           "-t",
           rebase_path(stampfile, root_build_dir),
           "-r",
           rebase_path("remoting_strings.grd", root_build_dir),
         ] + rebase_path(sources_to_verify, root_build_dir)

  deps = [
    #    "//remoting/webapp:webapp",
  ]  # Generates main.html.
}

if (is_android) {
  android_string_outputs =
      [ "remoting/android/res/values/remoting_strings.xml" ]
  android_string_outputs += process_file_template(
          remoting_android_locales,
          [ "remoting/android/res/values-{{source_name_part}}/remoting_strings.xml" ])
}

grit("strings") {
  source = "remoting_strings.grd"
  output_name = "remoting_strings"

  # The grd file encodes "remoting/..." in the name, so root everything in the
  # generated file root.
  output_dir = root_gen_dir

  outputs = [
    "remoting/base/string_resources.h",
  ]

  # The grd produces a *.pak file and a messages.json file (this one uses
  # underscores instead of hyphens) for each locale.
  outputs +=
      process_file_template(remoting_locales,
                            [ "remoting/resources/{{source_name_part}}.pak" ])

  outputs += remoting_webapp_locale_files

  if (is_android) {
    outputs += android_string_outputs
  }

  if (is_official_build) {
    defines = [ "_official_build" ]
  }
}

if (is_android) {
  java_strings_grd_prebuilt("strings_java") {
    grit_output_dir = "$root_gen_dir/remoting/android/res"
    generated_files =
        rebase_path(android_string_outputs, "remoting/android/res", ".")
    deps = [
      ":strings",
    ]
  }
}

action("copy_locales") {
  script = "../tools/build/remoting_copy_locales.py"

  # The gyp build calls out to Python, but the Python just computes a simple
  # replacement over the locales. Here, we can do this in GN script by
  # pretending the locale list is a list of files. The {{source_name_part}}
  # will just expand to the locale name.
  inputs = process_file_template(
          remoting_locales,
          [ "$root_gen_dir/remoting/resources/{{source_name_part}}.pak" ])

  # Likewise, process the outputs in the same way as the inputs.
  if (is_mac || is_ios) {
    # On mac, use underscores instead of hyphens and put the files in a
    # different place.
    outputs = process_file_template(
            remoting_locales_with_underscores,
            [ "$root_out_dir/remoting/resources/{{source_name_part}}.lproj/locale.pak" ])
  } else {
    outputs = process_file_template(
            remoting_locales,
            [ "$root_out_dir/remoting_locales/{{source_name_part}}.pak" ])
  }

  args = [
           "-p",
           current_os,
           "-g",
           rebase_path(root_gen_dir, root_build_dir),
           "-x",
           rebase_path(root_out_dir, root_build_dir),
         ] + remoting_locales

  deps = [
    ":strings",
  ]
}