Cleanup: Pass std::string as const reference from pdf/
[chromium-blink-merge.git] / chrome / chrome_repack_locales.gni
blob81cd09277deb1d9a593d5451a56ee55a7a6226b5
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
3 # found in the LICENSE file.
5 import("//build/config/chrome_build.gni")
6 import("//build/config/features.gni")
7 import("//build/config/ui.gni")
8 import("//tools/grit/repack.gni")
10 # Arguments:
12 #   locale
13 #       Internal name of locale. e.g. "pt-BR"
15 #   output
16 #       Output file name.
18 #   visibility
19 #       Normal meaning.
20 template("_repack_one_locale") {
21   locale = invoker.locale
23   repack(target_name) {
24     visibility = invoker.visibility
26     # Each input pak file should also have a deps line for completeness.
27     sources = [
28       "${root_gen_dir}/chrome/generated_resources_${locale}.pak",
29       "${root_gen_dir}/chrome/locale_settings_${locale}.pak",
30       "${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
31       "${root_gen_dir}/components/strings/components_strings_${locale}.pak",
32     ]
33     deps = [
34       "//chrome/app/resources:platform_locale_settings",
35       "//chrome/app:generated_resources",
36       "//chrome/app/resources:locale_settings",
37       "//components/strings:components_strings",
38     ]
40     if (use_ash) {
41       sources += [ "${root_gen_dir}/ash/strings/ash_strings_${locale}.pak" ]
42       deps += [ "//ash/strings" ]
43     }
44     if (is_chromeos) {
45       sources += [
46         "${root_gen_dir}/remoting/resources/${locale}.pak",
47         "${root_gen_dir}/ui/chromeos/strings/ui_chromeos_strings_${locale}.pak",
48       ]
49       deps += [
50         "//remoting/resources",
51         "//ui/chromeos/strings",
52       ]
53     }
54     if (!is_ios) {
55       sources += [
56         "${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
57         "${root_gen_dir}/device/bluetooth/strings/bluetooth_strings_${locale}.pak",
58         "${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
59         "${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
60       ]
61       deps += [
62         "//content/app/strings",
63         "//device/bluetooth/strings",
64         "//ui/strings:ui_strings",
65         "//ui/strings:app_locale_settings",
66       ]
67     }
68     if (enable_autofill_dialog) {
69       sources += [ "${root_gen_dir}/third_party/libaddressinput/address_input_strings_${locale}.pak" ]
70       deps += [ "//third_party/libaddressinput:strings" ]
71     }
72     if (enable_extensions) {
73       sources += [
74         # TODO(jamescook): When Android stops building extensions code move
75         # this to the OS != 'ios' and OS != 'android' section.
76         "${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
77       ]
78       deps += [ "//extensions/strings" ]
79     }
81     if (is_chrome_branded) {
82       sources += [
83         "${root_gen_dir}/chrome/google_chrome_strings_${locale}.pak",
84         "${root_gen_dir}/components/strings/components_google_chrome_strings_${locale}.pak",
85       ]
86       deps += [
87         "//chrome/app:google_chrome_strings",
88         "//components/strings:components_google_chrome_strings",
89       ]
90     } else {
91       sources += [
92         "${root_gen_dir}/chrome/chromium_strings_${locale}.pak",
93         "${root_gen_dir}/components/strings/components_chromium_strings_${locale}.pak",
94       ]
95       deps += [
96         "//chrome/app:chromium_strings",
97         "//components/strings:components_chromium_strings",
98       ]
99     }
101     output = invoker.output
102   }
105 # Creates an action to call the repack_locales script.
107 # The GYP version generates the locales in the "gen" directory and then copies
108 # it to the root build directory. This isn't easy to express in a GN copy
109 # rule since the files on Mac have a complex structure. So we generate the
110 # files into the final place and skip the "gen" directory.
112 # This template uses GN's looping constructs to avoid the complex call to
113 # chrome/tools/build/repack_locales.py which wraps the repack commands in the
114 # GYP build.
116 # Arguments
118 #   input_locales
119 #       List of locale names to use as inputs.
121 #   output_locales
122 #       A list containing the corresponding output names for each of the
123 #       input names. Mac uses different names in some cases.
125 #   visibility
126 template("chrome_repack_locales") {
127   # This is the name of the group below that will collect all the invidual
128   # locale targets. External targets will depend on this.
129   group_target_name = target_name
131   # GN's subscript is too stupid to do invoker.output_locales[foo] so we need
132   # to make a copy and do output_locales[foo].
133   output_locales = invoker.output_locales
135   # Collects all targets the loop generates.
136   locale_targets = []
138   # This loop iterates over the input locales and also keeps a counter so it
139   # can simultaneously iterate over the output locales (using GN's very
140   # limited looping capabilities).
141   current_index = 0
142   foreach(input_locale, invoker.input_locales) {
143     output_locale = output_locales[current_index]
145     # Compute the name of the target for the current file. Save it for the deps.
146     current_name = "${target_name}_${input_locale}"
147     locale_targets += [ ":$current_name" ]
149     _repack_one_locale(current_name) {
150       visibility = [ ":$group_target_name" ]
151       locale = input_locale
153       # Compute the output name. Mac uses a different location.
154       if (is_mac || is_ios) {
155         output = "${root_gen_dir}/repack/${output_locale}.lproj/locale.pak"
156       } else {
157         output = "${root_out_dir}/locales/${output_locale}.pak"
158       }
159     }
161     current_index = current_index + 1
162   }
164   # The group that external targets depend on which collects all deps.
165   group(group_target_name) {
166     forward_variables_from(invoker, [ "visibility" ])
167     public_deps = locale_targets
168   }