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

Unified Diff: ios/chrome/tools/strings/generate_localizable_strings.gni

Issue 2001613002: [iOS/GN] Add template for generate_localizable_strings tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@{interlude}
Patch Set: Created 4 years, 7 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
Index: ios/chrome/tools/strings/generate_localizable_strings.gni
diff --git a/ios/chrome/tools/strings/generate_localizable_strings.gni b/ios/chrome/tools/strings/generate_localizable_strings.gni
new file mode 100644
index 0000000000000000000000000000000000000000..2606e58c131a9eb6daaad7cd4184dbac2610c7af
--- /dev/null
+++ b/ios/chrome/tools/strings/generate_localizable_strings.gni
@@ -0,0 +1,105 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Help template to define a data_bundle with localized strings for use by
+# the iOS system from packed locale.pak files.
+#
+# Arguments
+# config_file
+# string, path to the property list file containing the configuration
+# parameters for the invocation of generate_localizable_strings tool.
+#
+# datapack_dir
+# string, path to the directory containing the packed locale.pak files
+# in use for the generate_localizable_strings tool.
+#
+# locales
+# list of strings corresponding to all the locales that should be
+# generated and packed.
+#
+# output_filenames
+# list of strings corresponding to the basename of the files generated
+# by the generate_localizable_strings tool (i.e. if it contains ["a"]
+# then the tool will generate ["$locale.lproj/a"] for each locale set
+# in locales argument).
+#
+# deps
+# list of target labels.
+#
+template("generate_localizable_strings") {
+ assert(defined(invoker.config_file),
+ "config_file needs to be defined for ${target_name}")
+ assert(defined(invoker.datapack_dir),
+ "datapack_dir needs to be defined for ${target_name}")
+ assert(defined(invoker.output_filenames),
+ "output_filenames needs to be defined for ${target_name}")
+ assert(defined(invoker.packed_locales),
+ "packed_locales needs to be defined for ${target_name}")
+
+ _tool_target = "//ios/chrome/tools/strings" +
+ ":generate_localizable_strings(${host_toolchain})"
+ _tool_path = get_label_info(_tool_target, "root_out_dir") +
+ "/generate_localizable_strings"
+
+ _target_name = target_name
+
+ _bundle_targets = []
+ foreach(locale, invoker.packed_locales) {
+ _bundle_targets += [ ":${_target_name}_${locale}" ]
+
+ bundle_data("${_target_name}_${locale}") {
+ forward_variables_from(invoker, [ "testonly" ])
+
+ visibility = [ ":${_target_name}" ]
+ public_deps = [
+ ":${_target_name}_generate",
+ ]
+ sources = []
+ foreach(filename, invoker.output_filenames) {
+ sources += [ "${target_gen_dir}/${locale}.lproj/$filename" ]
+ }
+ outputs = [
+ "{{bundle_resources_dir}}/${locale}.lproj/{{source_file_part}}",
+ ]
+ }
+ }
+
+ action("${_target_name}_generate") {
+ forward_variables_from(invoker, [ "testonly" ])
+
+ visibility = _bundle_targets
+ script = "//ios/chrome/tools/strings/generate_localizable_strings.py"
+ deps = invoker.deps + [ _tool_target ]
+
+ outputs = []
+ sources = [
+ invoker.config_file,
+ ]
+
+ foreach(locale, invoker.packed_locales) {
+ sources += [ "${invoker.datapack_dir}/${locale}.lproj/locale.pak" ]
+ foreach(filename, invoker.output_filenames) {
+ outputs += [ "${target_gen_dir}/${locale}.lproj/$filename" ]
+ }
+ }
+
+ args = rebase_path([
+ _tool_path,
+ invoker.config_file,
+ root_gen_dir,
+ invoker.datapack_dir,
+ target_gen_dir,
+ ],
+ root_out_dir) + invoker.packed_locales
+ }
+
+ group(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
+ deps = _bundle_targets
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698