Index: ios/chrome/app/resources/ios_chrome_repack.gni |
diff --git a/ios/chrome/app/resources/ios_chrome_repack.gni b/ios/chrome/app/resources/ios_chrome_repack.gni |
index 52da371b2b8c2f576aea71ff6a372c173fb5a48e..225a88ea6d11048dd737f63eeda89e9687b046e5 100644 |
--- a/ios/chrome/app/resources/ios_chrome_repack.gni |
+++ b/ios/chrome/app/resources/ios_chrome_repack.gni |
@@ -5,20 +5,93 @@ |
import("//tools/grit/repack.gni") |
import("//build/config/chrome_build.gni") |
-# Wraps repack_locales(), setting the source_patterns and deps required for |
-# Chrome. |
-# Generates a collection of bundle_data targets. |
-template("ios_chrome_repack_locales") { |
- repack_locales(target_name) { |
- forward_variables_from(invoker, "*") |
- source_patterns = [ |
- "${root_gen_dir}/components/strings/components_${branding_path_component}_strings_", |
- "${root_gen_dir}/components/strings/components_locale_settings_", |
- "${root_gen_dir}/components/strings/components_strings_", |
- "${root_gen_dir}/ios/chrome/ios_${branding_path_component}_strings_", |
- "${root_gen_dir}/ios/chrome/ios_strings_", |
- "${root_gen_dir}/ui/strings/app_locale_settings_", |
- "${root_gen_dir}/ui/strings/ui_strings_", |
+# Template to repack resources and copy them to the application bundles. |
+# |
+# Arguments |
+# |
+# deps |
+# list of strings corresponding to target labels. |
+# |
+# sources |
+# list of strings corresponding to path to resources pak to pack. |
+# |
+# output |
+# string, path of the packed resources. |
+# |
+# bundle_output |
+# string, path of the packed resources in the bundle. |
+# |
+# Generates a bundle_data target for convenience. |
+template("ios_repack") { |
+ assert(defined(invoker.deps), "deps must be defined for $target_name") |
+ assert(defined(invoker.sources), "sources must be defined for $target_name") |
+ assert(defined(invoker.output), "output must be defined for $target_name") |
+ assert(defined(invoker.bundle_output), |
+ "bundle_output must be defined for $target_name") |
+ |
+ _target_name = target_name |
+ |
+ repack("${_target_name}_pack") { |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ |
+ visibility = [ ":${_target_name}" ] |
+ sources = invoker.sources |
+ output = invoker.output |
+ deps = invoker.deps |
+ } |
+ |
+ bundle_data(_target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "testonly", |
+ "visibility", |
+ ]) |
+ public_deps = [ |
+ ":${_target_name}_pack", |
+ ] |
+ sources = [ |
+ invoker.output, |
+ ] |
+ outputs = [ |
+ invoker.bundle_output, |
+ ] |
+ } |
+} |
+ |
+# Template to repack all resources for a given locale. |
+# |
+# Arguments |
+# |
+# input_locale |
+# string, name of the locale to pack. |
+# |
+# output_locale |
+# string, name of the locale (may be different from input_locale |
+# as iOS and Chrome not use the same convention for naming locales |
+# with country variant). |
+# |
+# Generates a bundle_data target for convenience. |
+template("_ios_chrome_repack_one_locale") { |
+ assert(defined(invoker.input_locale), |
+ "input_locale must be defined for ${target_name}") |
+ assert(defined(invoker.output_locale), |
+ "output_locale must be defined for ${target_name}") |
+ |
+ ios_repack(target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "testonly", |
+ "visibility", |
+ ]) |
+ |
+ sources = [ |
+ "${root_gen_dir}/components/strings/components_${branding_path_component}_strings_${invoker.input_locale}.pak", |
+ "${root_gen_dir}/components/strings/components_locale_settings_${invoker.input_locale}.pak", |
+ "${root_gen_dir}/components/strings/components_strings_${invoker.input_locale}.pak", |
+ "${root_gen_dir}/ios/chrome/ios_${branding_path_component}_strings_${invoker.input_locale}.pak", |
+ "${root_gen_dir}/ios/chrome/ios_strings_${invoker.input_locale}.pak", |
+ "${root_gen_dir}/ui/strings/app_locale_settings_${invoker.input_locale}.pak", |
+ "${root_gen_dir}/ui/strings/ui_strings_${invoker.input_locale}.pak", |
] |
deps = [ |
@@ -31,7 +104,60 @@ |
"//ui/strings:ui_strings", |
] |
- copy_data_to_bundle = true |
+ output = "${target_gen_dir}/${invoker.output_locale}.lproj/locale.pak" |
+ bundle_output = "{{bundle_resources_dir}}/${invoker.output_locale}.lproj" + |
+ "/{{source_file_part}}" |
+ } |
+} |
+ |
+# Template to repack all resources for all locales. |
+# |
+# Arguments |
+# |
+# input_locales |
+# list of strings corresponding to all locales to pack. |
+# |
+# output_locales |
+# list of strings corresponding to all locales to pack (may be |
+# different from input_locales as iOS and Chrome do not use the |
+# same convention for naming locales with country variant). |
+# |
+# Must be the same length as input_locales. |
+# |
+# Generates a collection of bundle_data targets for convenience. |
+template("ios_chrome_repack_locales") { |
+ assert(defined(invoker.input_locales), |
+ "input_locales must be defined for ${target_name}") |
+ assert(defined(invoker.output_locales), |
+ "output_locales must be defined for ${target_name}") |
+ |
+ _target_name = target_name |
+ |
+ _locale_targets = [] |
+ _output_locales = invoker.output_locales |
+ |
+ _current_index = 0 |
+ foreach(_input_locale, invoker.input_locales) { |
+ _output_locale = _output_locales[_current_index] |
+ _locale_targets += [ ":${_target_name}_${_input_locale}" ] |
+ |
+ _ios_chrome_repack_one_locale("${_target_name}_${_input_locale}") { |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ visibility = [ ":${_target_name}" ] |
+ input_locale = _input_locale |
+ output_locale = _output_locale |
+ } |
+ |
+ _current_index = _current_index + 1 |
+ } |
+ |
+ group(_target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "testonly", |
+ "visibility", |
+ ]) |
+ public_deps = _locale_targets |
} |
} |
@@ -46,7 +172,7 @@ |
template("_ios_chrome_repack_one_scale") { |
assert(defined(invoker.scale), "scale must be defined for ${target_name}") |
- repack(target_name) { |
+ ios_repack(target_name) { |
forward_variables_from(invoker, |
[ |
"testonly", |
@@ -65,7 +191,7 @@ |
] |
output = "$target_gen_dir/chrome_${invoker.scale}_percent.pak" |
- copy_data_to_bundle = true |
+ bundle_output = "{{bundle_resources_dir}}/{{source_file_part}}" |
} |
} |