forked from chromiumembedded/cef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cef_repack_locales.gni
130 lines (115 loc) · 4.6 KB
/
cef_repack_locales.gni
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
# Copyright 2016 The Chromium Embedded Framework Authors. Portions 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.
#
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
# modifications to meet CEF's requirements.
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//tools/grit/repack.gni")
# Arguments:
#
# locale
# Internal name of locale. e.g. "pt-BR"
#
# output
# Output file name.
#
# visibility
# Normal meaning.
template("_repack_one_locale") {
locale = invoker.locale
repack(target_name) {
visibility = invoker.visibility
# Each input pak file should also have a deps line for completeness.
# Add associated .h files in the make_pack_header("strings") target.
sources = [
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
"${root_gen_dir}/chrome/chromium_strings_${locale}.pak",
"${root_gen_dir}/chrome/generated_resources_${locale}.pak",
"${root_gen_dir}/chrome/locale_settings_${locale}.pak",
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
"${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
]
# Use public_deps so that generated grit headers are discoverable from
# the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target.
public_deps = [
":cef_strings",
"//chrome/app:chromium_strings",
"//chrome/app:generated_resources",
"//chrome/app/resources:locale_settings",
"//chrome/app/resources:platform_locale_settings",
"//components/strings:components_locale_settings",
"//components/strings:components_strings",
"//content/app/strings",
"//extensions/strings",
"//ui/strings:app_locale_settings",
"//ui/strings:ui_strings",
]
output = invoker.output
}
}
# Creates an action to call the repack_locales script.
#
# The GYP version generates the locales in the "gen" directory and then copies
# it to the root build directory. This isn't easy to express in a GN copy
# rule since the files on Mac have a complex structure. So we generate the
# files into the final place and skip the "gen" directory.
#
# This template uses GN's looping constructs to avoid the complex call to
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
# GYP build.
#
# Arguments
#
# input_locales
# List of locale names to use as inputs.
#
# output_locales
# A list containing the corresponding output names for each of the
# input names. Mac uses different names in some cases.
#
# visibility
template("cef_repack_locales") {
# This is the name of the group below that will collect all the invidual
# locale targets. External targets will depend on this.
group_target_name = target_name
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
# to make a copy and do output_locales[foo].
output_locales = invoker.output_locales
# Collects all targets the loop generates.
locale_targets = []
# This loop iterates over the input locales and also keeps a counter so it
# can simultaneously iterate over the output locales (using GN's very
# limited looping capabilities).
current_index = 0
foreach(input_locale, invoker.input_locales) {
output_locale = output_locales[current_index]
# Compute the name of the target for the current file. Save it for the deps.
current_name = "${target_name}_${input_locale}"
locale_targets += [ ":$current_name" ]
_repack_one_locale(current_name) {
visibility = [ ":$group_target_name" ]
locale = input_locale
# Compute the output name. Mac uses a different location.
if (is_mac || is_ios) {
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
} else {
output = "${root_out_dir}/locales/${output_locale}.pak"
}
}
current_index = current_index + 1
}
# The group that external targets depend on which collects all deps.
group(group_target_name) {
forward_variables_from(invoker, [ "visibility" ])
public_deps = locale_targets
}
}