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