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

Unified Diff: android_webview/tools/webview_locales_rename_paks.py

Issue 868673003: [WebView] Repack the .pak files for all the locales. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Inline android_webview_locales_rename_paks.gypi Created 5 years, 10 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 | « android_webview/apk/system_webview_locales_paks.gypi ('k') | build/gyp_chromium » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/tools/webview_locales_rename_paks.py
diff --git a/android_webview/tools/webview_locales_rename_paks.py b/android_webview/tools/webview_locales_rename_paks.py
new file mode 100755
index 0000000000000000000000000000000000000000..4bc77e56806b93a80135f282f995fbf05cab8608
--- /dev/null
+++ b/android_webview/tools/webview_locales_rename_paks.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 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.
+
+"""Helper script to rename paks for a list of locales for the Android WebView.
+
+Gyp doesn't have any built-in looping capability, so this just provides a way to
+loop over a list of locales when renaming pak files. Based on
+chrome/tools/build/repack_locales.py
+"""
+
+import optparse
+import os
+import shutil
+import sys
+
+def calc_output(locale):
+ """Determine the file that will be generated for the given locale."""
+ return os.path.join(PRODUCT_DIR, 'android_webview_assets',
+ 'locales', locale + '.pak')
+
+def calc_input(locale):
+ """Determine the file that needs processing for the given locale."""
+ return os.path.join(SHARE_INT_DIR, 'content', 'app', 'strings',
+ 'content_strings_%s.pak' % locale)
+
+def list_outputs(locales):
+ """Returns the names of the files that will be generated for the given
+ locales.
+
+ This is to provide gyp the list of output files, so build targets can
+ properly track what needs to be built.
+ """
+ return list_files(locales, calc_output)
+
+def list_inputs(locales):
+ """Returns the names of the files that will be processed for the given
+ locales.
+
+ This is to provide gyp the list of input files, so build targets can properly
+ track their prerequisites.
+ """
+ return list_files(locales, calc_input)
+
+def list_files(locales, filename_func):
+ """Returns the names of the files generated by filename_func for a list of
+ locales.
+
+ :param filename_func: function that generates a filename for a given locale
+ """
+ files = []
+ for locale in locales:
+ files.append(filename_func(locale))
+ return " ".join(['"%s"' % x for x in files])
+
+def rename_locales(locales):
+ """ Loop over and renames the given locales."""
+ for locale in locales:
+ shutil.copy(calc_input(locale), calc_output(locale))
+
+def DoMain(argv):
+ global SHARE_INT_DIR
+ global PRODUCT_DIR
+
+ parser = optparse.OptionParser("usage: %prog [options] locales")
+ parser.add_option("-i", action="store_true", dest="inputs", default=False,
+ help="Print the expected input file list, then exit.")
+ parser.add_option("-o", action="store_true", dest="outputs", default=False,
+ help="Print the expected output file list, then exit.")
+ parser.add_option("-p", action="store", dest="product_dir",
+ help="Product build files output directory.")
+ parser.add_option("-s", action="store", dest="share_int_dir",
+ help="Shared intermediate build files output directory.")
+ options, locales = parser.parse_args(argv)
+ if not locales:
+ parser.error('Please specify at least one locale to process.\n')
+
+ print_inputs = options.inputs
+ print_outputs = options.outputs
+ SHARE_INT_DIR = options.share_int_dir
+ PRODUCT_DIR = options.product_dir
+
+ if print_inputs and print_outputs:
+ parser.error('Please specify only one of "-i" or "-o".\n')
+
+ if print_inputs:
+ return list_inputs(locales)
+
+ if print_outputs:
+ return list_outputs(locales)
+
+ return rename_locales(locales)
+
+if __name__ == '__main__':
+ results = DoMain(sys.argv[1:])
+ if results:
+ print results
« no previous file with comments | « android_webview/apk/system_webview_locales_paks.gypi ('k') | build/gyp_chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698