OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2016 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 import("//tools/grit/repack.gni") | |
6 | |
7 # Pack all resources for an application extension for a given locale. | |
8 # | |
9 # Arguments: | |
10 # | |
11 # extension [required] | |
12 # name of the application extension. | |
13 # | |
14 # input_locale [required] | |
15 # name of the locale to pack. | |
16 # | |
17 # output_locale [required] | |
18 # name of the locale (may be different from input_locale as iOS | |
19 # and Chrome does not use the same convention for naming locales | |
20 # with country variants). | |
21 # | |
22 # visibility [optional] | |
23 # usual meaning. | |
24 # | |
25 template("_extension_repack_one_locale") { | |
26 assert(defined(invoker.extension), "Need extension for $target_name") | |
27 assert(defined(invoker.input_locale), "Need input_locale for $target_name") | |
28 assert(defined(invoker.output_locale), "Need output_locale for $target_name") | |
29 | |
30 repack_and_bundle(target_name) { | |
31 forward_variables_from(invoker, [ "visibility" ]) | |
32 | |
33 deps = [ | |
34 "//ios/chrome/${invoker.extension}/strings", | |
35 ] | |
36 | |
37 sources = [ | |
38 "$root_gen_dir/ios/${invoker.extension}/" + | |
39 "ios_${invoker.extension}_strings_${invoker.input_locale}.pak", | |
40 ] | |
41 | |
42 output = "$target_gen_dir/${invoker.output_locale}.lproj/locale.pak" | |
43 bundle_output = "{{bundle_resources_dir}}/" + | |
44 "${invoker.output_locale}.lproj/locale.pak" | |
45 } | |
46 } | |
47 | |
48 # Pack all resoruces for an application extension for all locales. | |
49 # | |
50 # Arguments: | |
51 # | |
52 # extension [required] | |
53 # name of the application extension. | |
54 # | |
55 # input_locales [required] | |
56 # list of all locales to pack. | |
57 # | |
58 # output_locales [required] | |
59 # list of all locales in application bundle (may differ from input | |
60 # locales as iOS and Chrome does not use the same convention for | |
61 # naming locales with country variants). | |
62 # | |
63 # Must be the same length as input_locales. | |
64 # | |
65 # visibility [optional] | |
66 # usual meaning. | |
67 # | |
68 template("extension_repack_all_locales") { | |
69 assert(defined(invoker.extension), "Need extension for $target_name") | |
70 assert(defined(invoker.input_locales), "Need input_locales for $target_name") | |
71 assert(defined(invoker.output_locales), | |
72 "Need output_locales for $target_name") | |
73 | |
74 _target_name = target_name | |
75 | |
76 # GN parser does not understand invoker.output_locales[_current_locale]. | |
77 # Use a locale variables to workaround this issue. | |
justincohen
2016/05/25 14:23:56
Is this a bug? crbug link?
sdefresne
2016/05/25 15:00:09
I think this is just a design decision AFAICT.
Dirk Pranke
2016/05/25 16:02:04
The GN grammar doesn't allow array access on scope
| |
78 _current_locale = 0 | |
79 _output_locales = invoker.output_locales | |
80 | |
81 # Collect all locale targets to avoid looping twice over the locales. | |
82 _locale_targets = [] | |
83 | |
84 foreach(_input_locale, invoker.input_locales) { | |
85 _output_locale = _output_locales[_current_locale] | |
86 | |
87 _locale_target = _target_name + "_$_input_locale" | |
88 _extension_repack_one_locale(_locale_target) { | |
89 visibility = [ ":$_target_name" ] | |
90 input_locale = _input_locale | |
91 output_locale = _output_locale | |
92 extension = invoker.extension | |
93 } | |
94 | |
95 _locale_targets += [ ":$_locale_target" ] | |
96 _current_locale = _current_locale + 1 | |
97 } | |
98 | |
99 group(_target_name) { | |
100 forward_variables_from(invoker, [ "visibility" ]) | |
101 public_deps = _locale_targets | |
102 } | |
103 } | |
OLD | NEW |