OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 | 4 |
| 5 import("//build/compiled_action.gni") |
| 6 |
5 # Help template to define a data_bundle with localized strings for use by | 7 # Help template to define a data_bundle with localized strings for use by |
6 # the iOS system from packed locale.pak files. | 8 # the iOS system from packed locale.pak files. |
7 # | 9 # |
8 # Arguments | 10 # Arguments |
9 # config_file | 11 # config_file |
10 # string, path to the property list file containing the configuration | 12 # string, path to the property list file containing the configuration |
11 # parameters for the invocation of generate_localizable_strings tool. | 13 # parameters for the invocation of generate_localizable_strings tool. |
12 # | 14 # |
13 # datapack_dir | 15 # datapack_dir |
14 # string, path to the directory containing the packed locale.pak files | 16 # string, path to the directory containing the packed locale.pak files |
(...skipping 15 matching lines...) Expand all Loading... |
30 template("generate_localizable_strings") { | 32 template("generate_localizable_strings") { |
31 assert(defined(invoker.config_file), | 33 assert(defined(invoker.config_file), |
32 "config_file needs to be defined for ${target_name}") | 34 "config_file needs to be defined for ${target_name}") |
33 assert(defined(invoker.datapack_dir), | 35 assert(defined(invoker.datapack_dir), |
34 "datapack_dir needs to be defined for ${target_name}") | 36 "datapack_dir needs to be defined for ${target_name}") |
35 assert(defined(invoker.output_filenames), | 37 assert(defined(invoker.output_filenames), |
36 "output_filenames needs to be defined for ${target_name}") | 38 "output_filenames needs to be defined for ${target_name}") |
37 assert(defined(invoker.packed_locales), | 39 assert(defined(invoker.packed_locales), |
38 "packed_locales needs to be defined for ${target_name}") | 40 "packed_locales needs to be defined for ${target_name}") |
39 | 41 |
40 _tool_target = "//ios/chrome/tools/strings" + | |
41 ":generate_localizable_strings(${host_toolchain})" | |
42 _tool_path = get_label_info(_tool_target, "root_out_dir") + | |
43 "/generate_localizable_strings" | |
44 | |
45 _target_name = target_name | 42 _target_name = target_name |
46 | 43 |
47 _bundle_targets = [] | 44 _bundle_targets = [] |
48 foreach(locale, invoker.packed_locales) { | 45 foreach(locale, invoker.packed_locales) { |
49 _bundle_targets += [ ":${_target_name}_${locale}" ] | 46 _bundle_targets += [ ":${_target_name}_${locale}" ] |
50 | 47 |
51 bundle_data("${_target_name}_${locale}") { | 48 bundle_data("${_target_name}_${locale}") { |
52 forward_variables_from(invoker, [ "testonly" ]) | 49 forward_variables_from(invoker, [ "testonly" ]) |
53 | 50 |
54 visibility = [ ":${_target_name}" ] | 51 visibility = [ ":${_target_name}" ] |
55 public_deps = [ | 52 public_deps = [ |
56 ":${_target_name}_generate", | 53 ":${_target_name}_generate", |
57 ] | 54 ] |
58 sources = [] | 55 sources = [] |
59 foreach(filename, invoker.output_filenames) { | 56 foreach(filename, invoker.output_filenames) { |
60 sources += [ "${target_gen_dir}/${locale}.lproj/$filename" ] | 57 sources += [ "${target_gen_dir}/${locale}.lproj/$filename" ] |
61 } | 58 } |
62 outputs = [ | 59 outputs = [ |
63 "{{bundle_resources_dir}}/${locale}.lproj/{{source_file_part}}", | 60 "{{bundle_resources_dir}}/${locale}.lproj/{{source_file_part}}", |
64 ] | 61 ] |
65 } | 62 } |
66 } | 63 } |
67 | 64 |
68 action("${_target_name}_generate") { | 65 compiled_action("${_target_name}_generate") { |
69 forward_variables_from(invoker, [ "testonly" ]) | 66 forward_variables_from(invoker, [ "testonly" ]) |
70 | 67 |
71 visibility = _bundle_targets | 68 visibility = _bundle_targets |
72 script = "//ios/chrome/tools/strings/generate_localizable_strings.py" | 69 deps = invoker.deps |
73 deps = invoker.deps + [ _tool_target ] | 70 tool = "//ios/chrome/tools/strings:generate_localizable_strings" |
74 | 71 |
75 outputs = [] | 72 outputs = [] |
76 sources = [ | 73 inputs = [ |
77 invoker.config_file, | 74 invoker.config_file, |
78 ] | 75 ] |
79 | 76 |
80 foreach(locale, invoker.packed_locales) { | 77 foreach(locale, invoker.packed_locales) { |
81 sources += [ "${invoker.datapack_dir}/${locale}.lproj/locale.pak" ] | 78 inputs += [ "${invoker.datapack_dir}/${locale}.lproj/locale.pak" ] |
82 foreach(filename, invoker.output_filenames) { | 79 foreach(filename, invoker.output_filenames) { |
83 outputs += [ "${target_gen_dir}/${locale}.lproj/$filename" ] | 80 outputs += [ "${target_gen_dir}/${locale}.lproj/$filename" ] |
84 } | 81 } |
85 } | 82 } |
86 | 83 |
87 args = rebase_path([ | 84 args = [ |
88 _tool_path, | 85 "-c", |
89 invoker.config_file, | 86 rebase_path(invoker.config_file, root_build_dir), |
90 root_gen_dir, | 87 "-I", |
91 invoker.datapack_dir, | 88 rebase_path(root_gen_dir, root_build_dir), |
92 target_gen_dir, | 89 "-p", |
93 ], | 90 rebase_path(invoker.datapack_dir, root_build_dir), |
94 root_out_dir) + invoker.packed_locales | 91 "-o", |
| 92 rebase_path(target_gen_dir, root_build_dir), |
| 93 ] + invoker.packed_locales |
95 } | 94 } |
96 | 95 |
97 group(_target_name) { | 96 group(_target_name) { |
98 forward_variables_from(invoker, | 97 forward_variables_from(invoker, |
99 [ | 98 [ |
100 "testonly", | 99 "testonly", |
101 "visibility", | 100 "visibility", |
102 ]) | 101 ]) |
103 deps = _bundle_targets | 102 deps = _bundle_targets |
104 } | 103 } |
105 } | 104 } |
OLD | NEW |