Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: ios/chrome/extension_repack.gni

Issue 2340673002: Revert of 🍵 Refactor the various locale_paks() templates to be more shared (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/app/resources/ios_chrome_repack.gni ('k') | ios/chrome/share_extension/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/extension_repack.gni
diff --git a/ios/chrome/extension_repack.gni b/ios/chrome/extension_repack.gni
index 50b118ba97d43fe733cf5def72f109b3ac6d71e1..f029d1aaf353950d1531448a0fdf734a19f08825 100644
--- a/ios/chrome/extension_repack.gni
+++ b/ios/chrome/extension_repack.gni
@@ -4,24 +4,122 @@
import("//tools/grit/repack.gni")
-# Pack all resources for an application extension for all locales.
+# Pack all resources for an application extension for a given locale.
#
-# Arguments (in addition to those from repack_locales):
+# Arguments:
#
# extension [required]
# name of the application extension.
#
-template("extension_repack_all_locales") {
- # Wraps repack_locales(), setting the source_patterns and deps required for
- # Chrome.
- # Generates a collection of bundle_data targets.
- repack_locales(target_name) {
- forward_variables_from(invoker, "*", [ "extension" ])
+# input_locale [required]
+# name of the locale to pack.
+#
+# output_locale [required]
+# name of the locale (may be different from input_locale as iOS
+# and Chrome does not use the same convention for naming locales
+# with country variants).
+#
+# copy_data_to_bundle [required]
+# controls whether bundle_data targets are defined to copy the repacked
+# data into the final bundle.
+#
+# visibility [optional]
+# usual meaning.
+#
+template("_extension_repack_one_locale") {
+ assert(defined(invoker.extension), "Need extension for $target_name")
+ assert(defined(invoker.input_locale), "Need input_locale for $target_name")
+ assert(defined(invoker.output_locale), "Need output_locale for $target_name")
- source_patterns = [ "$root_gen_dir/ios/${invoker.extension}/ios_${invoker.extension}_strings_" ]
+ if (invoker.copy_data_to_bundle) {
+ _target_type = "repack_and_bundle"
+ } else {
+ _target_type = "repack"
+ }
+
+ target(_target_type, target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
deps = [
"//ios/chrome/${invoker.extension}/strings",
]
+
+ sources = [
+ "$root_gen_dir/ios/${invoker.extension}/" +
+ "ios_${invoker.extension}_strings_${invoker.input_locale}.pak",
+ ]
+
+ output = "$target_gen_dir/${invoker.output_locale}.lproj/locale.pak"
+ if (invoker.copy_data_to_bundle) {
+ bundle_output = "{{bundle_resources_dir}}/" +
+ "${invoker.output_locale}.lproj/locale.pak"
+ }
}
}
+
+# Pack all resources for an application extension for all locales.
+#
+# Arguments:
+#
+# extension [required]
+# name of the application extension.
+#
+# input_locales [required]
+# list of all locales to pack.
+#
+# output_locales [required]
+# list of all locales in application bundle (may differ from input
+# locales as iOS and Chrome does not use the same convention for
+# naming locales with country variants).
+#
+# Must be the same length as input_locales.
+#
+# copy_data_to_bundle [optional]
+# controls whether bundle_data targets are defined to copy the repacked
+# data into the final bundle (defaults to true if not defined).
+#
+# visibility [optional]
+# usual meaning.
+#
+template("extension_repack_all_locales") {
+ assert(defined(invoker.extension), "Need extension for $target_name")
+ assert(defined(invoker.input_locales), "Need input_locales for $target_name")
+ assert(defined(invoker.output_locales),
+ "Need output_locales for $target_name")
+
+ _target_name = target_name
+
+ _copy_data_to_bundle = true
+ if (defined(invoker.copy_data_to_bundle)) {
+ _copy_data_to_bundle = invoker.copy_data_to_bundle
+ }
+
+ # TODO(614747): GN parser does not grok invoker.output_locales[foo]. Use a
+ # local variables to workaround this issue until the issue is fixed.
+ _current_locale = 0
+ _output_locales = invoker.output_locales
+
+ # Collect all locale targets to avoid looping twice over the locales.
+ _locale_targets = []
+
+ foreach(_input_locale, invoker.input_locales) {
+ _output_locale = _output_locales[_current_locale]
+
+ _locale_target = _target_name + "_$_input_locale"
+ _extension_repack_one_locale(_locale_target) {
+ visibility = [ ":$_target_name" ]
+ input_locale = _input_locale
+ output_locale = _output_locale
+ extension = invoker.extension
+ copy_data_to_bundle = _copy_data_to_bundle
+ }
+
+ _locale_targets += [ ":$_locale_target" ]
+ _current_locale = _current_locale + 1
+ }
+
+ group(_target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ public_deps = _locale_targets
+ }
+}
« no previous file with comments | « ios/chrome/app/resources/ios_chrome_repack.gni ('k') | ios/chrome/share_extension/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698