Commit 0826b636 authored by igsolla's avatar igsolla Committed by Commit bot

[WebView] Pack the .pak files for all the locales.

This changes includes all the locale .pak files into the
WebView apk when building it from the chromium tree,
similarly to what we're doing when building it from the
Android tree, see android_webview/Android.mk.

BUG=405035

TESTED=Manual. Verified that the set of locales in the
downstream and upstream SystemWebViewGoogle.apk is the same.

Review URL: https://codereview.chromium.org/868673003

Cr-Commit-Position: refs/heads/master@{#315001}
parent 8fbff4fa
...@@ -31,12 +31,24 @@ ...@@ -31,12 +31,24 @@
'includes': [ '../build/repack_action.gypi' ], 'includes': [ '../build/repack_action.gypi' ],
}, },
{ {
'action_name': 'add_en_US_pak_locale', 'action_name': 'android_webview_locales_rename_paks',
'variables': { 'variables': {
'pak_inputs': ['<(SHARED_INTERMEDIATE_DIR)/content/app/strings/content_strings_en-US.pak'], 'rename_locales': 'tools/webview_locales_rename_paks.py',
'pak_output': '<(PRODUCT_DIR)/android_webview_assets/en-US.pak',
}, },
'includes': [ '../build/repack_action.gypi' ], 'inputs': [
'<(rename_locales)',
'<!@pymod_do_main(webview_locales_rename_paks -i -p <(PRODUCT_DIR) -s <(SHARED_INTERMEDIATE_DIR) <(locales))'
],
'outputs': [
'<!@pymod_do_main(webview_locales_rename_paks -o -p <(PRODUCT_DIR) -s <(SHARED_INTERMEDIATE_DIR) <(locales))'
],
'action': [
'python',
'<(rename_locales)',
'-p', '<(PRODUCT_DIR)',
'-s', '<(SHARED_INTERMEDIATE_DIR)',
'<@(locales)',
],
} }
], ],
}, },
...@@ -124,7 +136,6 @@ ...@@ -124,7 +136,6 @@
'../ui/shell_dialogs/shell_dialogs.gyp:shell_dialogs', '../ui/shell_dialogs/shell_dialogs.gyp:shell_dialogs',
'../v8/tools/gyp/v8.gyp:v8', '../v8/tools/gyp/v8.gyp:v8',
'../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu', '../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu',
'android_webview_pak',
'android_webview_version', 'android_webview_version',
], ],
'include_dirs': [ 'include_dirs': [
...@@ -265,6 +276,11 @@ ...@@ -265,6 +276,11 @@
'renderer/print_render_frame_observer.cc', 'renderer/print_render_frame_observer.cc',
'renderer/print_render_frame_observer.h', 'renderer/print_render_frame_observer.h',
], ],
'conditions': [
['android_webview_build==0', {
'dependencies': [ 'android_webview_pak', ],
}],
],
}, },
{ {
'target_name': 'libwebviewchromium', 'target_name': 'libwebviewchromium',
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
'destination': '<(PRODUCT_DIR)/android_webview_apk/assets', 'destination': '<(PRODUCT_DIR)/android_webview_apk/assets',
'files': [ 'files': [
'<(PRODUCT_DIR)/android_webview_assets/webviewchromium.pak', '<(PRODUCT_DIR)/android_webview_assets/webviewchromium.pak',
'<(PRODUCT_DIR)/android_webview_assets/en-US.pak', '<(PRODUCT_DIR)/android_webview_assets/locales/en-US.pak',
'<(java_in_dir)/assets/asset_file.html', '<(java_in_dir)/assets/asset_file.html',
'<(java_in_dir)/assets/asset_icon.png', '<(java_in_dir)/assets/asset_icon.png',
'<(java_in_dir)/assets/cookie_test.html', '<(java_in_dir)/assets/cookie_test.html',
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
'proguard_flags_paths': ['<(DEPTH)/android_webview/apk/java/proguard.flags'], 'proguard_flags_paths': ['<(DEPTH)/android_webview/apk/java/proguard.flags'],
# TODO: crbug.com/405035 Find a better solution for WebView .pak files. # TODO: crbug.com/405035 Find a better solution for WebView .pak files.
'additional_input_paths': [ 'additional_input_paths': [
'<@(webview_locales_output_paks)',
'<(asset_location)/webviewchromium.pak', '<(asset_location)/webviewchromium.pak',
'<(asset_location)/en-US.pak',
'<(asset_location)/webview_licenses.notice', '<(asset_location)/webview_licenses.notice',
], ],
'conditions': [ 'conditions': [
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
{ {
'destination': '<(asset_location)', 'destination': '<(asset_location)',
'files': [ 'files': [
'<@(webview_locales_input_paks)',
'<(PRODUCT_DIR)/android_webview_assets/webviewchromium.pak', '<(PRODUCT_DIR)/android_webview_assets/webviewchromium.pak',
'<(PRODUCT_DIR)/android_webview_assets/en-US.pak',
], ],
'conditions': [ 'conditions': [
['icu_use_data_file_flag==1', { ['icu_use_data_file_flag==1', {
...@@ -83,5 +83,8 @@ ...@@ -83,5 +83,8 @@
'message': 'Generating WebView license notice', 'message': 'Generating WebView license notice',
}, },
], ],
'includes': [ '../../build/java_apk.gypi' ], 'includes': [
'system_webview_locales_paks.gypi',
'../../build/java_apk.gypi',
],
} }
# 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.
#
# This file defines the set of locales that should be packed inside the
# System WebView apk.
# TODO: consider unifying this list with the one in chrome_android_paks.gypi
# once Chrome includes all the locales that the WebView needs.
{
'variables': {
'webview_locales_input_paks_folder': '<(PRODUCT_DIR)/android_webview_assets/locales/',
'webview_locales_output_paks_folder': '<(asset_location)',
'webview_locales_input_paks': [
'<(webview_locales_input_paks_folder)/am.pak',
'<(webview_locales_input_paks_folder)/ar.pak',
'<(webview_locales_input_paks_folder)/bg.pak',
'<(webview_locales_input_paks_folder)/bn.pak',
'<(webview_locales_input_paks_folder)/ca.pak',
'<(webview_locales_input_paks_folder)/cs.pak',
'<(webview_locales_input_paks_folder)/da.pak',
'<(webview_locales_input_paks_folder)/de.pak',
'<(webview_locales_input_paks_folder)/el.pak',
'<(webview_locales_input_paks_folder)/en-GB.pak',
'<(webview_locales_input_paks_folder)/en-US.pak',
'<(webview_locales_input_paks_folder)/es.pak',
'<(webview_locales_input_paks_folder)/es-419.pak',
'<(webview_locales_input_paks_folder)/et.pak',
'<(webview_locales_input_paks_folder)/fa.pak',
'<(webview_locales_input_paks_folder)/fi.pak',
'<(webview_locales_input_paks_folder)/fil.pak',
'<(webview_locales_input_paks_folder)/fr.pak',
'<(webview_locales_input_paks_folder)/gu.pak',
'<(webview_locales_input_paks_folder)/he.pak',
'<(webview_locales_input_paks_folder)/hi.pak',
'<(webview_locales_input_paks_folder)/hr.pak',
'<(webview_locales_input_paks_folder)/hu.pak',
'<(webview_locales_input_paks_folder)/id.pak',
'<(webview_locales_input_paks_folder)/it.pak',
'<(webview_locales_input_paks_folder)/ja.pak',
'<(webview_locales_input_paks_folder)/kn.pak',
'<(webview_locales_input_paks_folder)/ko.pak',
'<(webview_locales_input_paks_folder)/lt.pak',
'<(webview_locales_input_paks_folder)/lv.pak',
'<(webview_locales_input_paks_folder)/ml.pak',
'<(webview_locales_input_paks_folder)/mr.pak',
'<(webview_locales_input_paks_folder)/ms.pak',
'<(webview_locales_input_paks_folder)/nb.pak',
'<(webview_locales_input_paks_folder)/nl.pak',
'<(webview_locales_input_paks_folder)/pl.pak',
'<(webview_locales_input_paks_folder)/pt-BR.pak',
'<(webview_locales_input_paks_folder)/pt-PT.pak',
'<(webview_locales_input_paks_folder)/ro.pak',
'<(webview_locales_input_paks_folder)/ru.pak',
'<(webview_locales_input_paks_folder)/sk.pak',
'<(webview_locales_input_paks_folder)/sl.pak',
'<(webview_locales_input_paks_folder)/sr.pak',
'<(webview_locales_input_paks_folder)/sv.pak',
'<(webview_locales_input_paks_folder)/sw.pak',
'<(webview_locales_input_paks_folder)/ta.pak',
'<(webview_locales_input_paks_folder)/te.pak',
'<(webview_locales_input_paks_folder)/th.pak',
'<(webview_locales_input_paks_folder)/tr.pak',
'<(webview_locales_input_paks_folder)/uk.pak',
'<(webview_locales_input_paks_folder)/vi.pak',
'<(webview_locales_input_paks_folder)/zh-CN.pak',
'<(webview_locales_input_paks_folder)/zh-TW.pak',
],
'webview_locales_output_paks': [
'<(webview_locales_output_paks_folder)/am.pak',
'<(webview_locales_output_paks_folder)/ar.pak',
'<(webview_locales_output_paks_folder)/bg.pak',
'<(webview_locales_output_paks_folder)/bn.pak',
'<(webview_locales_output_paks_folder)/ca.pak',
'<(webview_locales_output_paks_folder)/cs.pak',
'<(webview_locales_output_paks_folder)/da.pak',
'<(webview_locales_output_paks_folder)/de.pak',
'<(webview_locales_output_paks_folder)/el.pak',
'<(webview_locales_output_paks_folder)/en-GB.pak',
'<(webview_locales_output_paks_folder)/en-US.pak',
'<(webview_locales_output_paks_folder)/es.pak',
'<(webview_locales_output_paks_folder)/es-419.pak',
'<(webview_locales_output_paks_folder)/et.pak',
'<(webview_locales_output_paks_folder)/fa.pak',
'<(webview_locales_output_paks_folder)/fi.pak',
'<(webview_locales_output_paks_folder)/fil.pak',
'<(webview_locales_output_paks_folder)/fr.pak',
'<(webview_locales_output_paks_folder)/gu.pak',
'<(webview_locales_output_paks_folder)/he.pak',
'<(webview_locales_output_paks_folder)/hi.pak',
'<(webview_locales_output_paks_folder)/hr.pak',
'<(webview_locales_output_paks_folder)/hu.pak',
'<(webview_locales_output_paks_folder)/id.pak',
'<(webview_locales_output_paks_folder)/it.pak',
'<(webview_locales_output_paks_folder)/ja.pak',
'<(webview_locales_output_paks_folder)/kn.pak',
'<(webview_locales_output_paks_folder)/ko.pak',
'<(webview_locales_output_paks_folder)/lt.pak',
'<(webview_locales_output_paks_folder)/lv.pak',
'<(webview_locales_output_paks_folder)/ml.pak',
'<(webview_locales_output_paks_folder)/mr.pak',
'<(webview_locales_output_paks_folder)/ms.pak',
'<(webview_locales_output_paks_folder)/nb.pak',
'<(webview_locales_output_paks_folder)/nl.pak',
'<(webview_locales_output_paks_folder)/pl.pak',
'<(webview_locales_output_paks_folder)/pt-BR.pak',
'<(webview_locales_output_paks_folder)/pt-PT.pak',
'<(webview_locales_output_paks_folder)/ro.pak',
'<(webview_locales_output_paks_folder)/ru.pak',
'<(webview_locales_output_paks_folder)/sk.pak',
'<(webview_locales_output_paks_folder)/sl.pak',
'<(webview_locales_output_paks_folder)/sr.pak',
'<(webview_locales_output_paks_folder)/sv.pak',
'<(webview_locales_output_paks_folder)/sw.pak',
'<(webview_locales_output_paks_folder)/ta.pak',
'<(webview_locales_output_paks_folder)/te.pak',
'<(webview_locales_output_paks_folder)/th.pak',
'<(webview_locales_output_paks_folder)/tr.pak',
'<(webview_locales_output_paks_folder)/uk.pak',
'<(webview_locales_output_paks_folder)/vi.pak',
'<(webview_locales_output_paks_folder)/zh-CN.pak',
'<(webview_locales_output_paks_folder)/zh-TW.pak',
],
},
}
#!/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
...@@ -28,6 +28,7 @@ import gyp ...@@ -28,6 +28,7 @@ import gyp
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Add paths so that pymod_do_main(...) can import files. # Add paths so that pymod_do_main(...) can import files.
sys.path.insert(1, os.path.join(chrome_src, 'android_webview', 'tools'))
sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp')) sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp'))
sys.path.insert(1, os.path.join(chrome_src, 'tools')) sys.path.insert(1, os.path.join(chrome_src, 'tools'))
sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment