| Index: android_webview/tools/webview_repack_locales.py
|
| diff --git a/android_webview/tools/webview_locales_rename_paks.py b/android_webview/tools/webview_repack_locales.py
|
| similarity index 63%
|
| rename from android_webview/tools/webview_locales_rename_paks.py
|
| rename to android_webview/tools/webview_repack_locales.py
|
| index 4bc77e56806b93a80135f282f995fbf05cab8608..19c9286786ca7cf2be8709b26c4d8bb9b990017f 100755
|
| --- a/android_webview/tools/webview_locales_rename_paks.py
|
| +++ b/android_webview/tools/webview_repack_locales.py
|
| @@ -15,49 +15,58 @@ import os
|
| import shutil
|
| import sys
|
|
|
| +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
|
| + 'tools', 'grit'))
|
| +from grit.format import data_pack
|
| +
|
| 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 calc_inputs(locale):
|
| + """Determine the files that need processing for the given locale."""
|
| + inputs = []
|
| +
|
| + inputs.append(os.path.join(SHARE_INT_DIR, 'content', 'app', 'strings',
|
| + 'content_strings_%s.pak' % locale))
|
| + inputs.append(os.path.join(SHARE_INT_DIR, 'android_webview',
|
| + 'aw_strings_%s.pak' % locale))
|
| + return inputs
|
|
|
| def list_outputs(locales):
|
| - """Returns the names of the files that will be generated for the given
|
| - locales.
|
| + """Returns the names of 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)
|
| + outputs = []
|
| + for locale in locales:
|
| + outputs.append(calc_output(locale))
|
| + # Quote each element so filename spaces don't mess up gyp's attempt to parse
|
| + # it into a list.
|
| + return " ".join(['"%s"' % x for x in outputs])
|
|
|
| def list_inputs(locales):
|
| - """Returns the names of the files that will be processed for the given
|
| - locales.
|
| + """Returns the names of 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 = []
|
| + inputs = []
|
| for locale in locales:
|
| - files.append(filename_func(locale))
|
| - return " ".join(['"%s"' % x for x in files])
|
| + inputs += calc_inputs(locale)
|
| + # Quote each element so filename spaces don't mess up gyp's attempt to parse
|
| + # it into a list.
|
| + return " ".join(['"%s"' % x for x in inputs])
|
|
|
| -def rename_locales(locales):
|
| - """ Loop over and renames the given locales."""
|
| +def repack_locales(locales):
|
| + """ Loop over and repack the given locales."""
|
| for locale in locales:
|
| - shutil.copy(calc_input(locale), calc_output(locale))
|
| + inputs = []
|
| + inputs += calc_inputs(locale)
|
| + output = calc_output(locale)
|
| + data_pack.DataPack.RePack(output, inputs)
|
|
|
| def DoMain(argv):
|
| global SHARE_INT_DIR
|
| @@ -90,7 +99,7 @@ def DoMain(argv):
|
| if print_outputs:
|
| return list_outputs(locales)
|
|
|
| - return rename_locales(locales)
|
| + return repack_locales(locales)
|
|
|
| if __name__ == '__main__':
|
| results = DoMain(sys.argv[1:])
|
|
|