summaryrefslogtreecommitdiff
path: root/chromium/ui/resources/BUILD.gn
blob: c6183683d396f4dbddad38d476d9ecc1c0866cd6 (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# 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("//build/config/chromeos/ui_mode.gni")
import("//build/config/jumbo.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
import("//ui/webui/webui_features.gni")

group("resources") {
  public_deps = [
    ":ui_resources_grd",
    ":ui_unscaled_resources_grd",
    ":webui_generated_resources_grd",
    ":webui_resources_grd",
  ]
}

grit("ui_resources_grd") {
  source = "ui_resources.grd"
  outputs = [
    "grit/ui_resources.h",
    "grit/ui_resources_map.cc",
    "grit/ui_resources_map.h",
    "ui_resources_100_percent.pak",
    "ui_resources_200_percent.pak",
    "ui_resources_300_percent.pak",
  ]
}

grit("ui_unscaled_resources_grd") {
  source = "ui_unscaled_resources.grd"
  outputs = [
    "grit/ui_unscaled_resources.h",
    "ui_unscaled_resources.rc",
  ]
}

grit("webui_resources_grd") {
  defines = [ "optimize_webui=$optimize_webui" ]
  source = "../webui/resources/webui_resources.grd"

  deps = [ "//ui/webui/resources:modulize" ]
  if (is_chromeos_ash) {
    deps += [ "//ui/chromeos/colors:cros_colors_css" ]
  }

  outputs = [
    "grit/webui_resources.h",
    "grit/webui_resources_map.cc",
    "grit/webui_resources_map.h",
    "webui_resources.pak",
  ]
}

grit("webui_generated_resources_grd") {
  enable_input_discovery_for_gn_analyze = false
  source = "$root_gen_dir/ui/webui/resources/webui_generated_resources.grd"
  deps = [ "//ui/webui/resources:build_grd" ]

  outputs = [
    "grit/webui_generated_resources.h",
    "grit/webui_generated_resources_map.cc",
    "grit/webui_generated_resources_map.h",
    "webui_generated_resources.pak",
  ]
}

if (!is_mac) {
  copy("copy_ui_resources_100_percent") {
    sources = [ "$root_gen_dir/ui/resources/ui_resources_100_percent.pak" ]
    outputs = [ "$root_out_dir/ui_resources_100_percent.pak" ]
    deps = [ "//ui/resources" ]
  }
}

# On iOS and Mac the string resources need to go into a locale subfolder, which
# introduces an extra dependency.
if (is_apple) {
  group("ui_test_pak") {
    public_deps = [
      ":repack_ui_test_mac_locale_pack",
      ":repack_ui_test_pak_100_percent",
    ]
  }

  # This needs to be a separate target from ui_test_pak as ui_base_unittests
  # wants the generate .pak file in the bundle to be named en.lpro/locale.pak
  # while components_unittests wants it to be named ui_test.pak.
  bundle_data("ui_test_pak_bundle_data_locale") {
    testonly = true
    visibility = [ ":ui_test_pak_bundle_data" ]
    public_deps = [ ":ui_test_pak" ]
    sources = [ "$root_out_dir/ui_test.pak" ]
    outputs = [ "{{bundle_resources_dir}}/en.lproj/locale.pak" ]
  }

  bundle_data("ui_test_pak_bundle_data_test_pak") {
    testonly = true
    visibility = [ ":ui_test_pak_bundle_data" ]
    public_deps = [ ":ui_test_pak" ]
    sources = [ "$root_out_dir/ui_test.pak" ]
    outputs = [ "{{bundle_resources_dir}}/ui_test.pak" ]
  }

  bundle_data("ui_test_pak_bundle_data_100_percent") {
    testonly = true
    visibility = [ ":ui_test_pak_bundle_data" ]
    public_deps = [ ":ui_test_pak" ]
    sources = [ "$root_out_dir/ui_test.pak" ]
    outputs = [ "{{bundle_resources_dir}}/chrome_100_percent.pak" ]
  }

  group("ui_test_pak_bundle_data") {
    testonly = true
    public_deps = [
      ":ui_test_pak_bundle_data_100_percent",
      ":ui_test_pak_bundle_data_locale",
      ":ui_test_pak_bundle_data_test_pak",
    ]
  }
} else {
  copy("ui_test_pak") {
    sources = [ "$root_out_dir/ui_test.pak" ]
    outputs = [ "$root_out_dir/ui/en-US.pak" ]
    public_deps = [ ":repack_ui_test_pak_100_percent" ]
  }
}

# This group exists just for targets that need the data file to exist in the
# build directory so it can be loaded for test purposes. If a target requires
# 200 percent resources it should also depend on ui_test_pak_data_200_percent.
group("ui_test_pak_data") {
  data_deps = [ ":repack_ui_test_pak_100_percent" ]
}

group("ui_test_pak_data_200_percent") {
  data_deps = [ ":repack_ui_test_pak_200_percent" ]
}

repack("repack_ui_test_pak_100_percent") {
  # Depend on ui_test_pak or ui_test_pak_data instead of this one.
  visibility = [
    ":ui_test_pak",
    ":ui_test_pak_data",
  ]

  sources = [
    "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
    "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
    "$root_gen_dir/ui/resources/webui_generated_resources.pak",
    "$root_gen_dir/ui/resources/webui_resources.pak",
    "$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
    "$root_gen_dir/ui/strings/ui_strings_en-US.pak",
  ]

  if (is_chromeos_ash) {
    sources += [
      "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_100_percent.pak",
      "$root_gen_dir/ui/chromeos/strings/ui_chromeos_strings_en-US.pak",
    ]
  }

  output = "$root_out_dir/ui_test.pak"

  deps = [
    "//mojo/public/js:resources",
    "//ui/resources",
    "//ui/strings",
  ]

  if (!is_ios) {
    deps += [ "//third_party/blink/public:resources_grit" ]
  }

  if (!is_mac) {
    deps += [ ":copy_ui_resources_100_percent" ]
  }

  if (is_chromeos_ash) {
    deps += [
      "//ui/chromeos/resources",
      "//ui/chromeos/strings",
    ]
  }

  if (toolkit_views) {
    deps += [ "//ui/views/resources" ]
    sources += [
      "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
      "$root_gen_dir/ui/views/resources/views_resources_100_percent.pak",
    ]
  }

  if (use_aura && toolkit_views) {
    deps += [ "//ash/app_list/resources" ]
    sources += [
      "$root_gen_dir/ash/app_list/resources/app_list_resources_100_percent.pak",
    ]
  }
}

repack("repack_ui_test_pak_200_percent") {
  visibility = [ ":ui_test_pak_data_200_percent" ]

  sources = [ "$root_gen_dir/ui/resources/ui_resources_200_percent.pak" ]

  output = "$root_out_dir/ui_test_200_percent.pak"

  deps = [ "//ui/resources" ]

  if (toolkit_views) {
    deps += [ "//ui/views/resources" ]
    sources +=
        [ "$root_gen_dir/ui/views/resources/views_resources_200_percent.pak" ]
  }
}

# Repack just the strings for the framework locales on Mac and iOS. This
# emulates repack_locales(), but just for en-US. Note ui_test.pak is not simply
# copied, because it causes leaks from allocations within system libraries when
# trying to load non-string resources. http://crbug.com/413034.
repack("repack_ui_test_mac_locale_pack") {
  visibility = [ ":ui_test_pak" ]

  sources = [
    "$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
    "$root_gen_dir/ui/strings/ui_strings_en-US.pak",
  ]

  output = "$root_out_dir/ui/en.lproj/locale.pak"

  deps = [ "//ui/strings" ]
}