Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/chrome_repack_locales.gni

Issue 2339213003: Reland of Refactor the various locale_paks() templates to be more shared (Closed)
Patch Set: Fix output path of the repack template on iOS. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/monochrome_repack_locales.gni ('k') | ios/chrome/app/resources/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import("//build/config/chrome_build.gni") 5 import("//build/config/chrome_build.gni")
6 import("//build/config/features.gni") 6 import("//build/config/features.gni")
7 import("//build/config/ui.gni") 7 import("//build/config/ui.gni")
8 import("//tools/grit/repack.gni") 8 import("//tools/grit/repack.gni")
9 9
10 # Arguments: 10 # Wraps repack_locales(), setting the source_patterns and deps required for
11 # Chrome.
11 # 12 #
12 # locale 13 # Extra Parameters:
13 # Internal name of locale. e.g. "pt-BR"
14 # 14 #
15 # output 15 # additional_source_patterns [optional]
16 # Output file name. 16 # Extra source_patterns for repack_locales().
17 # 17 template("chrome_repack_locales") {
18 # visibility 18 repack_locales(target_name) {
19 # Normal meaning. 19 forward_variables_from(invoker, "*", [ "additional_source_patterns" ])
20 #
21 # additional_source_patterns
22 # The pattern of additional pak files which need repacked, the name of
23 # pak always ends with '_${locale}.pak' e.g. foo_zh-CN.pak, since the
24 # locale is argument of template, the sources in this list should be
25 # the file name without '_${locale}.pak', tempate expands sources to
26 # the full name, e.g
27 # ${root_gen_dir}/foo expands to ${root_gen_dir}/foo_zh-CN.pak
28 # when locale is zh-CN.
29 #
30 # additional_deps
31 # The corresponding deps of additonal_source_patterns.
32 #
33 template("_repack_one_locale") {
34 locale = invoker.locale
35 20
36 repack(target_name) { 21 # Each input pak file should also have a deps line.
37 visibility = invoker.visibility 22 source_patterns = [
38 23 "${root_gen_dir}/chrome/generated_resources_",
39 # Each input pak file should also have a deps line for completeness. 24 "${root_gen_dir}/chrome/locale_settings_",
40 sources = [ 25 "${root_gen_dir}/chrome/platform_locale_settings_",
41 "${root_gen_dir}/chrome/generated_resources_${locale}.pak", 26 "${root_gen_dir}/components/strings/components_locale_settings_",
42 "${root_gen_dir}/chrome/locale_settings_${locale}.pak", 27 "${root_gen_dir}/components/strings/components_strings_",
43 "${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
44 "${root_gen_dir}/components/strings/components_locale_settings_${locale}.p ak",
45 "${root_gen_dir}/components/strings/components_strings_${locale}.pak",
46 ] 28 ]
47 deps = [ 29 if (!defined(deps)) {
30 deps = []
31 }
32 deps += [
48 "//chrome/app:generated_resources", 33 "//chrome/app:generated_resources",
49 "//chrome/app/resources:locale_settings", 34 "//chrome/app/resources:locale_settings",
50 "//chrome/app/resources:platform_locale_settings", 35 "//chrome/app/resources:platform_locale_settings",
51 "//components/strings:components_locale_settings", 36 "//components/strings:components_locale_settings",
52 "//components/strings:components_strings", 37 "//components/strings:components_strings",
53 ] 38 ]
54 39
55 if (defined(invoker.additional_source_patterns)) {
56 sources += process_file_template(invoker.additional_source_patterns,
57 [ "{{source}}_${locale}.pak" ])
58 deps += invoker.additional_deps
59 }
60
61 if (use_ash) { 40 if (use_ash) {
62 sources += 41 source_patterns += [ "${root_gen_dir}/ash/common/strings/ash_strings_" ]
63 [ "${root_gen_dir}/ash/common/strings/ash_strings_${locale}.pak" ]
64 deps += [ "//ash/common/strings" ] 42 deps += [ "//ash/common/strings" ]
65 } 43 }
66 if (is_chromeos) { 44 if (is_chromeos) {
67 sources += [ 45 source_patterns += [
68 "${root_gen_dir}/remoting/resources/${locale}.pak", 46 "${root_gen_dir}/remoting/resources/",
69 "${root_gen_dir}/ui/chromeos/strings/ui_chromeos_strings_${locale}.pak", 47 "${root_gen_dir}/ui/chromeos/strings/ui_chromeos_strings_",
70 ] 48 ]
71 deps += [ 49 deps += [
72 "//remoting/resources", 50 "//remoting/resources",
73 "//ui/chromeos/strings", 51 "//ui/chromeos/strings",
74 ] 52 ]
75 } 53 }
76 if (!is_ios) { 54 if (!is_ios) {
77 sources += [ 55 source_patterns += [
78 "${root_gen_dir}/content/app/strings/content_strings_${locale}.pak", 56 "${root_gen_dir}/content/app/strings/content_strings_",
79 "${root_gen_dir}/device/bluetooth/strings/bluetooth_strings_${locale}.pa k", 57 "${root_gen_dir}/device/bluetooth/strings/bluetooth_strings_",
80 "${root_gen_dir}/third_party/libaddressinput/address_input_strings_${loc ale}.pak", 58 "${root_gen_dir}/third_party/libaddressinput/address_input_strings_",
81 "${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak", 59 "${root_gen_dir}/ui/strings/app_locale_settings_",
82 "${root_gen_dir}/ui/strings/ui_strings_${locale}.pak", 60 "${root_gen_dir}/ui/strings/ui_strings_",
83 ] 61 ]
84 deps += [ 62 deps += [
85 "//content/app/strings", 63 "//content/app/strings",
86 "//device/bluetooth/strings", 64 "//device/bluetooth/strings",
87 "//third_party/libaddressinput:strings", 65 "//third_party/libaddressinput:strings",
88 "//ui/strings:app_locale_settings", 66 "//ui/strings:app_locale_settings",
89 "//ui/strings:ui_strings", 67 "//ui/strings:ui_strings",
90 ] 68 ]
91 } 69 }
92 if (enable_extensions) { 70 if (enable_extensions) {
93 sources += [ 71 source_patterns += [
94 # TODO(jamescook): When Android stops building extensions code move 72 # TODO(jamescook): When Android stops building extensions code move
95 # this to the OS != 'ios' and OS != 'android' section. 73 # this to the OS != 'ios' and OS != 'android' section.
96 "${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak", 74 "${root_gen_dir}/extensions/strings/extensions_strings_",
97 ] 75 ]
98 deps += [ "//extensions/strings" ] 76 deps += [ "//extensions/strings" ]
99 } 77 }
100 78
101 if (is_chrome_branded) { 79 if (is_chrome_branded) {
102 sources += [ 80 source_patterns += [
103 "${root_gen_dir}/chrome/google_chrome_strings_${locale}.pak", 81 "${root_gen_dir}/chrome/google_chrome_strings_",
104 "${root_gen_dir}/components/strings/components_google_chrome_strings_${l ocale}.pak", 82 "${root_gen_dir}/components/strings/components_google_chrome_strings_",
105 ] 83 ]
106 deps += [ 84 deps += [
107 "//chrome/app:google_chrome_strings", 85 "//chrome/app:google_chrome_strings",
108 "//components/strings:components_google_chrome_strings", 86 "//components/strings:components_google_chrome_strings",
109 ] 87 ]
110 } else { 88 } else {
111 sources += [ 89 source_patterns += [
112 "${root_gen_dir}/chrome/chromium_strings_${locale}.pak", 90 "${root_gen_dir}/chrome/chromium_strings_",
113 "${root_gen_dir}/components/strings/components_chromium_strings_${locale }.pak", 91 "${root_gen_dir}/components/strings/components_chromium_strings_",
114 ] 92 ]
115 deps += [ 93 deps += [
116 "//chrome/app:chromium_strings", 94 "//chrome/app:chromium_strings",
117 "//components/strings:components_chromium_strings", 95 "//components/strings:components_chromium_strings",
118 ] 96 ]
119 } 97 }
120 98
121 if (enable_resource_whitelist_generation) { 99 if (defined(invoker.additional_source_patterns)) {
122 repack_whitelist = "$root_gen_dir/chrome/resource_whitelist.txt" 100 source_patterns += invoker.additional_source_patterns
123 deps += [ "//chrome:resource_whitelist" ]
124 } 101 }
125 output = invoker.output 102
103 if (!defined(output_dir)) {
104 if (is_mac || is_ios) {
105 output_dir = "${root_gen_dir}/repack/locales"
106 } else {
107 output_dir = "${root_out_dir}/locales"
108 }
109 }
126 } 110 }
127 } 111 }
128
129 # Creates an action to call the repack_locales script.
130 #
131 # The GYP version generates the locales in the "gen" directory and then copies
132 # it to the root build directory. This isn't easy to express in a GN copy
133 # rule since the files on Mac have a complex structure. So we generate the
134 # files into the final place and skip the "gen" directory.
135 #
136 # This template uses GN's looping constructs to avoid the complex call to
137 # chrome/tools/build/repack_locales.py which wraps the repack commands in the
138 # GYP build.
139 #
140 # Arguments
141 #
142 # input_locales
143 # List of locale names to use as inputs.
144 #
145 # output_locales
146 # A list containing the corresponding output names for each of the
147 # input names. Mac uses different names in some cases.
148 #
149 # visibility
150 #
151 # additional_source_patterns
152 # Pass to template("_repack_one_locale")
153 #
154 # additional_deps
155 # Pass to template("_repack_one_locale")
156 #
157 # output_dir
158 # this is used to override default output dir.
159 #
160 template("chrome_repack_locales") {
161 # This is the name of the group below that will collect all the invidual
162 # locale targets. External targets will depend on this.
163 group_target_name = target_name
164
165 # GN's subscript is too stupid to do invoker.output_locales[foo] so we need
166 # to make a copy and do output_locales[foo].
167 output_locales = invoker.output_locales
168
169 # Collects all targets the loop generates.
170 locale_targets = []
171
172 # This loop iterates over the input locales and also keeps a counter so it
173 # can simultaneously iterate over the output locales (using GN's very
174 # limited looping capabilities).
175 current_index = 0
176 foreach(input_locale, invoker.input_locales) {
177 output_locale = output_locales[current_index]
178
179 # Compute the name of the target for the current file. Save it for the deps.
180 current_name = "${target_name}_${input_locale}"
181 locale_targets += [ ":$current_name" ]
182
183 _repack_one_locale(current_name) {
184 visibility = [ ":$group_target_name" ]
185 locale = input_locale
186
187 # Compute the output name. Mac uses a different location.
188 if (defined(invoker.output_dir)) {
189 output = "${invoker.output_dir}/${output_locale}.pak"
190 } else if (is_mac || is_ios) {
191 output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
192 } else {
193 output = "${root_out_dir}/locales/${output_locale}.pak"
194 }
195
196 if (defined(invoker.additional_source_patterns)) {
197 additional_source_patterns = invoker.additional_source_patterns
198 additional_deps = invoker.additional_deps
199 }
200 }
201
202 current_index = current_index + 1
203 }
204
205 # The group that external targets depend on which collects all deps.
206 group(group_target_name) {
207 forward_variables_from(invoker, [ "visibility" ])
208 public_deps = locale_targets
209 }
210 }
OLDNEW
« no previous file with comments | « chrome/android/monochrome_repack_locales.gni ('k') | ios/chrome/app/resources/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698