OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 # | |
5 # This is a copy of src/chrome/chrome_repack_locales.gni with the necessary | |
6 # modifications to meet WebView's requirement. | |
7 | 4 |
8 import("//build/config/chrome_build.gni") | |
9 import("//build/config/features.gni") | |
10 import("//build/config/ui.gni") | |
11 import("//tools/grit/repack.gni") | 5 import("//tools/grit/repack.gni") |
12 import("webview_repack_locales_list.gni") | 6 import("webview_repack_locales_list.gni") |
13 | 7 |
14 # Arguments: | 8 # Wraps repack_locales(), setting the source_patterns and deps required for |
15 # | 9 # Chrome. |
16 # locale | 10 template("webview_repack_locales") { |
17 # Internal name of locale. e.g. "pt-BR" | 11 repack_locales(target_name) { |
18 # | 12 forward_variables_from(invoker, "*") |
19 # output | |
20 # Output file name. | |
21 # | |
22 # visibility | |
23 # Normal meaning. | |
24 template("_repack_one_locale") { | |
25 locale = invoker.locale | |
26 | |
27 repack(target_name) { | |
28 visibility = invoker.visibility | |
29 | 13 |
30 # Adding webview specific pak file? You should add it to | 14 # Adding webview specific pak file? You should add it to |
31 # webview_repack_locales_source_patterns, so it is also included in | 15 # webview_repack_locales_source_patterns, so it is also included in |
32 # Monochrome. | 16 # Monochrome. |
33 | 17 |
34 # Each input pak file should also have a deps line for completeness. | 18 source_patterns = [ |
35 sources = [ | 19 "${root_gen_dir}/android_webview/components_strings_", |
36 "${root_gen_dir}/android_webview/components_strings_${locale}.pak", | 20 "${root_gen_dir}/content/app/strings/content_strings_", |
37 "${root_gen_dir}/content/app/strings/content_strings_${locale}.pak", | 21 "${root_gen_dir}/ui/strings/app_locale_settings_", |
38 "${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak", | |
39 ] | 22 ] |
40 deps = [ | 23 deps = [ |
41 "//android_webview:generate_components_strings", | 24 "//android_webview:generate_components_strings", |
42 "//content/app/strings", | 25 "//content/app/strings", |
43 "//ui/strings:app_locale_settings", | 26 "//ui/strings:app_locale_settings", |
44 ] | 27 ] |
45 sources += process_file_template(webview_repack_locales_source_patterns, | 28 source_patterns += webview_repack_locales_source_patterns |
46 [ "{{source}}_${locale}.pak" ]) | |
47 deps += webview_repack_locales_deps | 29 deps += webview_repack_locales_deps |
48 output = invoker.output | 30 output_dir = "$root_out_dir/android_webview/locales" |
49 } | 31 } |
50 } | 32 } |
51 | |
52 # Creates an action to call the repack_locales script. | |
53 # | |
54 # The GYP version generates the locales in the "gen" directory and then copies | |
55 # it to the root build directory. This isn't easy to express in a GN copy | |
56 # rule since the files on Mac have a complex structure. So we generate the | |
57 # files into the final place and skip the "gen" directory. | |
58 # | |
59 # This template uses GN's looping constructs to avoid the complex call to | |
60 # chrome/tools/build/repack_locales.py which wraps the repack commands in the | |
61 # GYP build. | |
62 # | |
63 # Arguments | |
64 # | |
65 # input_locales | |
66 # List of locale names to use as inputs. | |
67 # | |
68 # output_locales | |
69 # A list containing the corresponding output names for each of the | |
70 # input names. | |
71 # | |
72 # visibility | |
73 template("webview_repack_locales") { | |
74 # This is the name of the group below that will collect all the invidual | |
75 # locale targets. External targets will depend on this. | |
76 group_target_name = target_name | |
77 | |
78 # GN's subscript is too stupid to do invoker.output_locales[foo] so we need | |
79 # to make a copy and do output_locales[foo]. | |
80 output_locales = invoker.output_locales | |
81 | |
82 # Collects all targets the loop generates. | |
83 locale_targets = [] | |
84 | |
85 # This loop iterates over the input locales and also keeps a counter so it | |
86 # can simultaneously iterate over the output locales (using GN's very | |
87 # limited looping capabilities). | |
88 current_index = 0 | |
89 foreach(input_locale, invoker.input_locales) { | |
90 output_locale = output_locales[current_index] | |
91 | |
92 # Compute the name of the target for the current file. Save it for the deps. | |
93 current_name = "${target_name}_${input_locale}" | |
94 locale_targets += [ ":$current_name" ] | |
95 | |
96 _repack_one_locale(current_name) { | |
97 visibility = [ ":$group_target_name" ] | |
98 locale = input_locale | |
99 output = "${root_out_dir}/android_webview/locales/${output_locale}.pak" | |
100 } | |
101 | |
102 current_index = current_index + 1 | |
103 } | |
104 | |
105 # The group that external targets depend on which collects all deps. | |
106 group(group_target_name) { | |
107 forward_variables_from(invoker, [ "visibility" ]) | |
108 public_deps = locale_targets | |
109 } | |
110 } | |
OLD | NEW |