| 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("//tools/grit/repack.gni") | 5 import("//tools/grit/repack.gni") |
| 6 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
| 7 | 7 |
| 8 # Template to repack resources and copy them to the application bundles. | 8 # Wraps repack_locales(), setting the source_patterns and deps required for |
| 9 # | 9 # Chrome. |
| 10 # Arguments | 10 # Generates a collection of bundle_data targets. |
| 11 # | 11 template("ios_chrome_repack_locales") { |
| 12 # deps | 12 repack_locales(target_name) { |
| 13 # list of strings corresponding to target labels. | 13 forward_variables_from(invoker, "*") |
| 14 # | 14 source_patterns = [ |
| 15 # sources | 15 "${root_gen_dir}/components/strings/components_${branding_path_component}_
strings_", |
| 16 # list of strings corresponding to path to resources pak to pack. | 16 "${root_gen_dir}/components/strings/components_locale_settings_", |
| 17 # | 17 "${root_gen_dir}/components/strings/components_strings_", |
| 18 # output | 18 "${root_gen_dir}/ios/chrome/ios_${branding_path_component}_strings_", |
| 19 # string, path of the packed resources. | 19 "${root_gen_dir}/ios/chrome/ios_strings_", |
| 20 # | 20 "${root_gen_dir}/ui/strings/app_locale_settings_", |
| 21 # bundle_output | 21 "${root_gen_dir}/ui/strings/ui_strings_", |
| 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 ] | 22 ] |
| 96 | 23 |
| 97 deps = [ | 24 deps = [ |
| 98 "//components/strings:components_${branding_path_component}_strings", | 25 "//components/strings:components_${branding_path_component}_strings", |
| 99 "//components/strings:components_locale_settings", | 26 "//components/strings:components_locale_settings", |
| 100 "//components/strings:components_strings", | 27 "//components/strings:components_strings", |
| 101 "//ios/chrome/app/strings:ios_${branding_path_component}_strings", | 28 "//ios/chrome/app/strings:ios_${branding_path_component}_strings", |
| 102 "//ios/chrome/app/strings:ios_strings", | 29 "//ios/chrome/app/strings:ios_strings", |
| 103 "//ui/strings:app_locale_settings", | 30 "//ui/strings:app_locale_settings", |
| 104 "//ui/strings:ui_strings", | 31 "//ui/strings:ui_strings", |
| 105 ] | 32 ] |
| 106 | 33 |
| 107 output = "${target_gen_dir}/${invoker.output_locale}.lproj/locale.pak" | 34 copy_data_to_bundle = true |
| 108 bundle_output = "{{bundle_resources_dir}}/${invoker.output_locale}.lproj" + | |
| 109 "/{{source_file_part}}" | |
| 110 } | 35 } |
| 111 } | 36 } |
| 112 | 37 |
| 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. | 38 # Template to repack all scalable resources at a given scale. |
| 165 # | 39 # |
| 166 # Arguments | 40 # Arguments |
| 167 # | 41 # |
| 168 # scale | 42 # scale |
| 169 # string, scale as a percentage, e.g. "200" corresponds to @2x scale. | 43 # string, scale as a percentage, e.g. "200" corresponds to @2x scale. |
| 170 # | 44 # |
| 171 # Generates a bundle_data target for convenience. | 45 # Generates a bundle_data target for convenience. |
| 172 template("_ios_chrome_repack_one_scale") { | 46 template("_ios_chrome_repack_one_scale") { |
| 173 assert(defined(invoker.scale), "scale must be defined for ${target_name}") | 47 assert(defined(invoker.scale), "scale must be defined for ${target_name}") |
| 174 | 48 |
| 175 ios_repack(target_name) { | 49 repack(target_name) { |
| 176 forward_variables_from(invoker, | 50 forward_variables_from(invoker, |
| 177 [ | 51 [ |
| 178 "testonly", | 52 "testonly", |
| 179 "visibility", | 53 "visibility", |
| 180 ]) | 54 ]) |
| 181 | 55 |
| 182 sources = [ | 56 sources = [ |
| 183 "${root_gen_dir}/components/components_resources_${invoker.scale}_percent.
pak", | 57 "${root_gen_dir}/components/components_resources_${invoker.scale}_percent.
pak", |
| 184 "${root_gen_dir}/ios/chrome/ios_theme_resources_${invoker.scale}_percent.p
ak", | 58 "${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", | 59 "${root_gen_dir}/ui/resources/ui_resources_${invoker.scale}_percent.pak", |
| 186 ] | 60 ] |
| 187 deps = [ | 61 deps = [ |
| 188 "//components/resources", | 62 "//components/resources", |
| 189 "//ios/chrome/app/theme", | 63 "//ios/chrome/app/theme", |
| 190 "//ui/resources", | 64 "//ui/resources", |
| 191 ] | 65 ] |
| 192 | 66 |
| 193 output = "$target_gen_dir/chrome_${invoker.scale}_percent.pak" | 67 output = "$target_gen_dir/chrome_${invoker.scale}_percent.pak" |
| 194 bundle_output = "{{bundle_resources_dir}}/{{source_file_part}}" | 68 copy_data_to_bundle = true |
| 195 } | 69 } |
| 196 } | 70 } |
| 197 | 71 |
| 198 # Template to repack all scalable resources at all scales. | 72 # Template to repack all scalable resources at all scales. |
| 199 # | 73 # |
| 200 # Arguments | 74 # Arguments |
| 201 # | 75 # |
| 202 # scales | 76 # scales |
| 203 # list of strings corresponding to scales as percentage, e.g. "200" | 77 # list of strings corresponding to scales as percentage, e.g. "200" |
| 204 # corresponds to @2x scale. | 78 # corresponds to @2x scale. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 221 | 95 |
| 222 group(_target_name) { | 96 group(_target_name) { |
| 223 forward_variables_from(invoker, | 97 forward_variables_from(invoker, |
| 224 [ | 98 [ |
| 225 "testonly", | 99 "testonly", |
| 226 "visibility", | 100 "visibility", |
| 227 ]) | 101 ]) |
| 228 public_deps = _scale_targets | 102 public_deps = _scale_targets |
| 229 } | 103 } |
| 230 } | 104 } |
| OLD | NEW |