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

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

Issue 1418243003: Add GN template for android_assets(). Use it in content_shell_apk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review1 Created 5 years, 2 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: build/android/gyp/apkbuilder.py
diff --git a/build/android/gyp/apkbuilder.py b/build/android/gyp/apkbuilder.py
index 1410d190540ffd51ed25b6b06cd7415fe76b9335..149f218f818c53a0e43cf38bedb56f886b058753 100755
--- a/build/android/gyp/apkbuilder.py
+++ b/build/android/gyp/apkbuilder.py
@@ -18,6 +18,8 @@ from util import build_utils
def _ParseArgs(args):
parser = argparse.ArgumentParser()
build_utils.AddDepfileOption(parser)
+ parser.add_argument('--assets-build-config',
+ help='Path to .build_config containing the asset list.')
parser.add_argument('--resource-apk',
help='An .ap_ file built using aapt',
required=True)
@@ -51,14 +53,22 @@ def main(args):
args = build_utils.ExpandFileArgs(args)
options = _ParseArgs(args)
+ assets_json = []
+ if options.assets_build_config:
+ assets_json = build_utils.ReadJson(options.assets_build_config)
+ assets_json = assets_json['merged_assets']
+
native_libs = []
if options.native_libs_dir:
native_libs = _ListSubPaths(options.native_libs_dir)
- input_paths = [options.resource_apk] + native_libs
+ input_paths = [options.resource_apk, __file__] + native_libs
if options.dex_file:
input_paths.append(options.dex_file)
+ for asset_entry in assets_json:
+ input_paths.extend(asset_entry['paths'])
+
def on_stale_md5():
tmp_apk = options.output_apk + '.tmp'
try:
@@ -69,6 +79,19 @@ def main(args):
# with finalize_apk(), which sometimes aligns and uncompresses the
# native libraries.
with zipfile.ZipFile(tmp_apk, 'a', zipfile.ZIP_DEFLATED) as apk:
+ for asset_entry in assets_json:
+ compress_type = zipfile.ZIP_STORED
+ if asset_entry['enable_compression']:
+ compress_type = zipfile.ZIP_DEFLATED
+ for path in asset_entry['paths']:
+ apk_path = 'assets/' + os.path.basename(path)
+ try:
+ apk.getinfo(apk_path)
+ # TODO(agrieve): Add support for asset clobbering if needed.
+ raise Exception('Multiple targets specified the asset path: %s' %
+ apk_path)
+ except KeyError:
+ apk.write(path, apk_path, compress_type)
for path in native_libs:
basename = os.path.basename(path)
apk.write(path, 'lib/%s/%s' % (options.android_abi, basename))
« base/BUILD.gn ('K') | « base/BUILD.gn ('k') | build/android/gyp/write_build_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698