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

Unified Diff: build/android/gyp/locale_pak_resources.py

Issue 1181953002: Load non-locale .pak files directly from the .apk on Android (rather than extracting on start-up). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@raw-paks
Patch Set: Fix content_browsertests Created 5 years, 6 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 | « base/android/java/src/org/chromium/base/ResourceExtractor.java ('k') | build/config/android/rules.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/locale_pak_resources.py
diff --git a/build/android/gyp/locale_pak_resources.py b/build/android/gyp/locale_pak_resources.py
index 8bf92185c1db8735205c18f1705667bede0b065c..a2bf09f8a437e4e2b14188496f576a823efc8734 100755
--- a/build/android/gyp/locale_pak_resources.py
+++ b/build/android/gyp/locale_pak_resources.py
@@ -6,7 +6,7 @@
"""Creates a resources.zip for locale .pak files.
Places the locale.pak files into appropriate resource configs
-(e.g. en-GB.pak -> res/raw-en/en_gb.pak). Also generates a locale_paks
+(e.g. en-GB.pak -> res/raw-en/en_gb.lpak). Also generates a locale_paks
TypedArray so that resource files can be enumerated at runtime.
"""
@@ -28,6 +28,14 @@ _CHROME_TO_ANDROID_LOCALE_MAP = {
}
+def ToResourceFileName(name):
+ """Returns the resource-compatible file name for the given file."""
+ # Resources file names must consist of [a-z0-9_.].
+ # Changes extension to .lpak so that compression can be toggled separately for
+ # locale pak files vs other pak files.
+ return name.replace('-', '_').replace('.pak', '.lpak').lower()
+
+
def CreateLocalePaksXml(names):
"""Creates the contents for the locale-paks.xml files."""
VALUES_FILE_TEMPLATE = '''<?xml version="1.0" encoding="utf-8"?>
@@ -61,13 +69,12 @@ def main():
build_utils.WriteDepfile(options.depfile, deps)
with zipfile.ZipFile(options.resources_zip, 'w', zipfile.ZIP_STORED) as out:
- # e.g. "en" -> ["en_gb.pak"]
+ # e.g. "en" -> ["en_gb.lpak"]
lang_to_locale_map = collections.defaultdict(list)
for src_path in sources:
basename = os.path.basename(src_path)
name = os.path.splitext(basename)[0]
- # Resources file names must consist of [a-z0-9_.].
- res_compatible_name = basename.replace('-', '_').lower()
+ res_name = ToResourceFileName(basename)
if name == 'en-US':
dest_dir = 'raw'
else:
@@ -76,16 +83,16 @@ def main():
android_locale = _CHROME_TO_ANDROID_LOCALE_MAP.get(name, name)
lang = android_locale[0:2]
dest_dir = 'raw-' + lang
- lang_to_locale_map[lang].append(res_compatible_name)
- out.write(src_path, os.path.join(dest_dir, res_compatible_name))
+ lang_to_locale_map[lang].append(res_name)
+ out.write(src_path, os.path.join(dest_dir, res_name))
# Create a String Arrays resource so ResourceExtractor can enumerate files.
def WriteValuesFile(lang, names):
dest_dir = 'values'
if lang:
dest_dir += '-' + lang
- # Always extract en-US.pak since it's the fallback.
- xml = CreateLocalePaksXml(names + ['en_us.pak'])
+ # Always extract en-US.lpak since it's the fallback.
+ xml = CreateLocalePaksXml(names + ['en_us.lpak'])
out.writestr(os.path.join(dest_dir, 'locale-paks.xml'), xml)
for lang, names in lang_to_locale_map.iteritems():
« no previous file with comments | « base/android/java/src/org/chromium/base/ResourceExtractor.java ('k') | build/config/android/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698