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 import("//build/config/chrome_build.gni") |
| 7 |
| 8 # Template to repack resources and copy them to the application bundles. |
| 9 # |
| 10 # Arguments |
| 11 # |
| 12 # deps |
| 13 # list of strings corresponding to target labels. |
| 14 # |
| 15 # sources |
| 16 # list of strings corresponding to path to resources pak to pack. |
| 17 # |
| 18 # output |
| 19 # string, path of the packed resources. |
| 20 # |
| 21 # bundle_output |
| 22 # string, path of the packed resources in the bundle. |
| 23 # |
| 24 # Generates a bundle_data target for convenience. |
| 25 template("ios_repack") { |
| 26 assert(defined(invoker.deps), "deps must be defined for $target_name") |
| 27 assert(defined(invoker.sources), "sources must be defined for $target_name") |
| 28 assert(defined(invoker.output), "output must be defined for $target_name") |
| 29 assert(defined(invoker.bundle_output), |
| 30 "bundle_output must be defined for $target_name") |
| 31 |
| 32 _target_name = target_name |
| 33 |
| 34 repack("${_target_name}_pack") { |
| 35 forward_variables_from(invoker, [ "testonly" ]) |
| 36 |
| 37 visibility = [ ":${_target_name}" ] |
| 38 sources = invoker.sources |
| 39 output = invoker.output |
| 40 deps = invoker.deps |
| 41 } |
| 42 |
| 43 bundle_data(_target_name) { |
| 44 forward_variables_from(invoker, |
| 45 [ |
| 46 "testonly", |
| 47 "visibility", |
| 48 ]) |
| 49 public_deps = [ |
| 50 ":${_target_name}_pack", |
| 51 ] |
| 52 sources = [ |
| 53 invoker.output, |
| 54 ] |
| 55 outputs = [ |
| 56 invoker.bundle_output, |
| 57 ] |
| 58 } |
| 59 } |
| 60 |
| 61 # Template to repack all resources for a given locale. |
| 62 # |
| 63 # Arguments |
| 64 # |
| 65 # input_locale |
| 66 # string, name of the locale to pack. |
| 67 # |
| 68 # output_locale |
| 69 # string, name of the locale (may be different from input_locale |
| 70 # as iOS and Chrome not use the same convention for naming locales |
| 71 # with country variant). |
| 72 # |
| 73 # Generates a bundle_data target for convenience. |
| 74 template("_ios_chrome_repack_one_locale") { |
| 75 assert(defined(invoker.input_locale), |
| 76 "input_locale must be defined for ${target_name}") |
| 77 assert(defined(invoker.output_locale), |
| 78 "output_locale must be defined for ${target_name}") |
| 79 |
| 80 ios_repack(target_name) { |
| 81 forward_variables_from(invoker, |
| 82 [ |
| 83 "testonly", |
| 84 "visibility", |
| 85 ]) |
| 86 |
| 87 sources = [ |
| 88 "${root_gen_dir}/components/strings/components_${branding_path_component}_
strings_${invoker.input_locale}.pak", |
| 89 "${root_gen_dir}/components/strings/components_locale_settings_${invoker.i
nput_locale}.pak", |
| 90 "${root_gen_dir}/components/strings/components_strings_${invoker.input_loc
ale}.pak", |
| 91 "${root_gen_dir}/ios/chrome/ios_${branding_path_component}_strings_${invok
er.input_locale}.pak", |
| 92 "${root_gen_dir}/ios/chrome/ios_strings_${invoker.input_locale}.pak", |
| 93 "${root_gen_dir}/ui/strings/app_locale_settings_${invoker.input_locale}.pa
k", |
| 94 "${root_gen_dir}/ui/strings/ui_strings_${invoker.input_locale}.pak", |
| 95 ] |
| 96 |
| 97 deps = [ |
| 98 "//components/strings:components_${branding_path_component}_strings", |
| 99 "//components/strings:components_locale_settings", |
| 100 "//components/strings:components_strings", |
| 101 "//ios/chrome/app/strings:ios_${branding_path_component}_strings", |
| 102 "//ios/chrome/app/strings:ios_strings", |
| 103 "//ui/strings:app_locale_settings", |
| 104 "//ui/strings:ui_strings", |
| 105 ] |
| 106 |
| 107 output = "${target_gen_dir}/${invoker.output_locale}.lproj/locale.pak" |
| 108 bundle_output = "{{bundle_resources_dir}}/${invoker.output_locale}.lproj" + |
| 109 "/{{source_file_part}}" |
| 110 } |
| 111 } |
| 112 |
| 113 # Template to repack all resources for all locales. |
| 114 # |
| 115 # Arguments |
| 116 # |
| 117 # input_locales |
| 118 # list of strings corresponding to all locales to pack. |
| 119 # |
| 120 # output_locales |
| 121 # list of strings corresponding to all locales to pack (may be |
| 122 # different from input_locales as iOS and Chrome do not use the |
| 123 # same convention for naming locales with country variant). |
| 124 # |
| 125 # Must be the same length as input_locales. |
| 126 # |
| 127 # Generates a collection of bundle_data targets for convenience. |
| 128 template("ios_chrome_repack_locales") { |
| 129 assert(defined(invoker.input_locales), |
| 130 "input_locales must be defined for ${target_name}") |
| 131 assert(defined(invoker.output_locales), |
| 132 "output_locales must be defined for ${target_name}") |
| 133 |
| 134 _target_name = target_name |
| 135 |
| 136 _locale_targets = [] |
| 137 _output_locales = invoker.output_locales |
| 138 |
| 139 _current_index = 0 |
| 140 foreach(_input_locale, invoker.input_locales) { |
| 141 _output_locale = _output_locales[_current_index] |
| 142 _locale_targets += [ ":${_target_name}_${_input_locale}" ] |
| 143 |
| 144 _ios_chrome_repack_one_locale("${_target_name}_${_input_locale}") { |
| 145 forward_variables_from(invoker, [ "testonly" ]) |
| 146 visibility = [ ":${_target_name}" ] |
| 147 input_locale = _input_locale |
| 148 output_locale = _output_locale |
| 149 } |
| 150 |
| 151 _current_index = _current_index + 1 |
| 152 } |
| 153 |
| 154 group(_target_name) { |
| 155 forward_variables_from(invoker, |
| 156 [ |
| 157 "testonly", |
| 158 "visibility", |
| 159 ]) |
| 160 public_deps = _locale_targets |
| 161 } |
| 162 } |
| 163 |
| 164 # Template to repack all scalable resources at a given scale. |
| 165 # |
| 166 # Arguments |
| 167 # |
| 168 # scale |
| 169 # string, scale as a percentage, e.g. "200" corresponds to @2x scale. |
| 170 # |
| 171 # Generates a bundle_data target for convenience. |
| 172 template("_ios_chrome_repack_one_scale") { |
| 173 assert(defined(invoker.scale), "scale must be defined for ${target_name}") |
| 174 |
| 175 ios_repack(target_name) { |
| 176 forward_variables_from(invoker, |
| 177 [ |
| 178 "testonly", |
| 179 "visibility", |
| 180 ]) |
| 181 |
| 182 sources = [ |
| 183 "${root_gen_dir}/components/components_resources_${invoker.scale}_percent.
pak", |
| 184 "${root_gen_dir}/ios/chrome/ios_theme_resources_${invoker.scale}_percent.p
ak", |
| 185 "${root_gen_dir}/ui/resources/ui_resources_${invoker.scale}_percent.pak", |
| 186 ] |
| 187 deps = [ |
| 188 "//components/resources", |
| 189 "//ios/chrome/app/theme", |
| 190 "//ui/resources", |
| 191 ] |
| 192 |
| 193 output = "$target_gen_dir/chrome_${invoker.scale}_percent.pak" |
| 194 bundle_output = "{{bundle_resources_dir}}/{{source_file_part}}" |
| 195 } |
| 196 } |
| 197 |
| 198 # Template to repack all scalable resources at all scales. |
| 199 # |
| 200 # Arguments |
| 201 # |
| 202 # scales |
| 203 # list of strings corresponding to scales as percentage, e.g. "200" |
| 204 # corresponds to @2x scale. |
| 205 # |
| 206 # Generates a collection of bundle_data targets for convenience. |
| 207 template("ios_chrome_repack_all_scales") { |
| 208 assert(defined(invoker.scales), "scales must be defined for ${target_name}") |
| 209 |
| 210 _scale_targets = [] |
| 211 _target_name = target_name |
| 212 |
| 213 foreach(_scale, invoker.scales) { |
| 214 _scale_targets += [ ":${_target_name}_${_scale}_percent" ] |
| 215 _ios_chrome_repack_one_scale("${_target_name}_${_scale}_percent") { |
| 216 forward_variables_from(invoker, [ "testonly" ]) |
| 217 visibility = [ ":${_target_name}" ] |
| 218 scale = _scale |
| 219 } |
| 220 } |
| 221 |
| 222 group(_target_name) { |
| 223 forward_variables_from(invoker, |
| 224 [ |
| 225 "testonly", |
| 226 "visibility", |
| 227 ]) |
| 228 public_deps = _scale_targets |
| 229 } |
| 230 } |
OLD | NEW |