OLD | NEW |
---|---|
(Empty) | |
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 | |
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. | |
Dirk Pranke
2015/10/30 01:48:43
it is unfortunate that we have to duplicate all of
michaelbai
2015/10/30 04:21:52
I were thinking about this, but didn't come up wit
| |
7 | |
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") | |
12 | |
13 # Arguments: | |
14 # | |
15 # locale | |
16 # Internal name of locale. e.g. "pt-BR" | |
17 # | |
18 # output | |
19 # Output file name. | |
20 # | |
21 # visibility | |
22 # Normal meaning. | |
23 template("_repack_one_locale") { | |
24 locale = invoker.locale | |
25 | |
26 repack(target_name) { | |
27 visibility = invoker.visibility | |
28 | |
29 # Each input pak file should also have a deps line for completeness. | |
30 sources = [ | |
31 "${root_gen_dir}/android_webview/aw_strings_${locale}.pak", | |
32 "${root_gen_dir}/android_webview/components_strings_${locale}.pak", | |
33 "${root_gen_dir}/content/app/strings/content_strings_${locale}.pak", | |
34 ] | |
35 deps = [ | |
36 "//android_webview:generate_aw_strings", | |
37 "//android_webview:generate_components_strings", | |
38 "//content/app/strings", | |
39 ] | |
40 output = invoker.output | |
41 } | |
42 } | |
43 | |
44 # Creates an action to call the repack_locales script. | |
45 # | |
46 # The GYP version generates the locales in the "gen" directory and then copies | |
47 # it to the root build directory. This isn't easy to express in a GN copy | |
48 # rule since the files on Mac have a complex structure. So we generate the | |
49 # files into the final place and skip the "gen" directory. | |
50 # | |
51 # This template uses GN's looping constructs to avoid the complex call to | |
52 # chrome/tools/build/repack_locales.py which wraps the repack commands in the | |
53 # GYP build. | |
54 # | |
55 # Arguments | |
56 # | |
57 # input_locales | |
58 # List of locale names to use as inputs. | |
59 # | |
60 # output_locales | |
61 # A list containing the corresponding output names for each of the | |
62 # input names. | |
63 # | |
64 # visibility | |
65 template("webview_repack_locales") { | |
66 # This is the name of the group below that will collect all the invidual | |
67 # locale targets. External targets will depend on this. | |
68 group_target_name = target_name | |
69 | |
70 # GN's subscript is too stupid to do invoker.output_locales[foo] so we need | |
71 # to make a copy and do output_locales[foo]. | |
72 output_locales = invoker.output_locales | |
73 | |
74 # Collects all targets the loop generates. | |
75 locale_targets = [] | |
76 | |
77 # This loop iterates over the input locales and also keeps a counter so it | |
78 # can simultaneously iterate over the output locales (using GN's very | |
79 # limited looping capabilities). | |
80 current_index = 0 | |
81 foreach(input_locale, invoker.input_locales) { | |
82 output_locale = output_locales[current_index] | |
83 | |
84 # Compute the name of the target for the current file. Save it for the deps. | |
85 current_name = "${target_name}_${input_locale}" | |
86 locale_targets += [ ":$current_name" ] | |
87 | |
88 _repack_one_locale(current_name) { | |
89 visibility = [ ":$group_target_name" ] | |
90 locale = input_locale | |
91 output = "${root_out_dir}/android_webview/locales/${output_locale}.pak" | |
92 } | |
93 | |
94 current_index = current_index + 1 | |
95 } | |
96 | |
97 # The group that external targets depend on which collects all deps. | |
98 group(group_target_name) { | |
99 forward_variables_from(invoker, [ "visibility" ]) | |
100 public_deps = locale_targets | |
101 } | |
102 } | |
OLD | NEW |