| Index: build/android/gyp/write_build_config.py
|
| diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py
|
| index 340d23f15f8cdc5873baf3f22d8c6210fa515e29..dda6c9f5cf3efccc21634b80418bbc9426b498a1 100755
|
| --- a/build/android/gyp/write_build_config.py
|
| +++ b/build/android/gyp/write_build_config.py
|
| @@ -26,6 +26,7 @@ Note: If paths to input files are passed in this way, it is important that:
|
| b. the files are added to the action's depfile
|
| """
|
|
|
| +import itertools
|
| import optparse
|
| import os
|
| import sys
|
| @@ -108,6 +109,43 @@ class Deps(object):
|
| return self.all_deps_config_paths
|
|
|
|
|
| +def _MergeAssets(all_assets):
|
| + """Merges all assets from the given deps.
|
| +
|
| + Returns:
|
| + A tuple of lists: (compressed, uncompressed)
|
| + Each tuple entry is a list of "srcPath:zipPath", where ":zipPath" is
|
| + optional.
|
| + """
|
| + compressed = {}
|
| + uncompressed = {}
|
| + for asset_dep in all_assets:
|
| + entry = asset_dep['assets']
|
| + disable_compression = entry.get('disable_compression', False)
|
| + dest_map = uncompressed if disable_compression else compressed
|
| + other_map = compressed if disable_compression else uncompressed
|
| + outputs = entry.get('outputs', [])
|
| + for src, dest in itertools.izip_longest(entry['paths'], outputs):
|
| + if not dest:
|
| + dest = os.path.basename(src)
|
| + # Merge so that each path shows up in only one of the lists, and that
|
| + # deps of the same target override previous ones.
|
| + other_map.pop(dest, 0)
|
| + dest_map[dest] = src
|
| +
|
| + def create_list(asset_map):
|
| + ret = []
|
| + for dest, src in asset_map.iteritems():
|
| + ret.append(src)
|
| + if dest != os.path.basename(src):
|
| + ret[-1] += ':%s' % dest
|
| + # Sort to ensure deterministic ordering.
|
| + ret.sort()
|
| + return ret
|
| +
|
| + return create_list(compressed), create_list(uncompressed)
|
| +
|
| +
|
| def main(argv):
|
| parser = optparse.OptionParser()
|
| build_utils.AddDepfileOption(parser)
|
| @@ -129,6 +167,12 @@ def main(argv):
|
| help='Java package name for these resources.')
|
| parser.add_option('--android-manifest', help='Path to android manifest.')
|
|
|
| + # android_assets options
|
| + parser.add_option('--assets', help='List of asset\'s sources.')
|
| + parser.add_option('--asset-outputs', help='List of asset outputs.')
|
| + parser.add_option('--disable-asset-compression', action='store_true',
|
| + help='Whether to disable asset compression.')
|
| +
|
| # java library options
|
| parser.add_option('--jar-path', help='Path to target\'s jar output.')
|
| parser.add_option('--supports-android', action='store_true',
|
| @@ -154,18 +198,17 @@ def main(argv):
|
| if args:
|
| parser.error('No positional arguments should be given.')
|
|
|
| -
|
| - if not options.type in [
|
| - 'java_library', 'android_resources', 'android_apk', 'deps_dex']:
|
| + required_options_map = {
|
| + 'java_library': ['build_config', 'jar_path'],
|
| + 'android_assets': ['build_config', 'assets'],
|
| + 'android_resources': ['build_config', 'resources_zip'],
|
| + 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'],
|
| + 'deps_dex': ['build_config', 'dex_path']
|
| + }
|
| + required_options = required_options_map.get(options.type)
|
| + if not required_options:
|
| raise Exception('Unknown type: <%s>' % options.type)
|
|
|
| - required_options = ['build_config'] + {
|
| - 'java_library': ['jar_path'],
|
| - 'android_resources': ['resources_zip'],
|
| - 'android_apk': ['jar_path', 'dex_path', 'resources_zip'],
|
| - 'deps_dex': ['dex_path']
|
| - }[options.type]
|
| -
|
| if options.native_libs:
|
| required_options.append('readelf_path')
|
|
|
| @@ -182,8 +225,8 @@ def main(argv):
|
| possible_deps_config_paths = build_utils.ParseGypList(
|
| options.possible_deps_configs)
|
|
|
| - allow_unknown_deps = (options.type == 'android_apk' or
|
| - options.type == 'android_resources')
|
| + allow_unknown_deps = (options.type in
|
| + ('android_apk', 'android_assets', 'android_resources'))
|
| unknown_deps = [
|
| c for c in possible_deps_config_paths if not os.path.exists(c)]
|
| if unknown_deps and not allow_unknown_deps:
|
| @@ -262,6 +305,16 @@ def main(argv):
|
| # Apks will get their resources srcjar explicitly passed to the java step.
|
| config['javac']['srcjars'] = []
|
|
|
| + if options.type == 'android_assets':
|
| + deps_info['assets'] = {
|
| + 'paths': build_utils.ParseGypList(options.assets),
|
| + }
|
| + if options.disable_asset_compression:
|
| + deps_info['assets']['disable_compression'] = True
|
| + if options.asset_outputs:
|
| + deps_info['assets']['outputs'] = (
|
| + build_utils.ParseGypList(options.asset_outputs))
|
| +
|
| if options.type == 'android_resources':
|
| deps_info['resources_zip'] = options.resources_zip
|
| if options.srcjar:
|
| @@ -358,6 +411,8 @@ def main(argv):
|
| 'libraries': library_paths,
|
| 'java_libraries_list': java_libraries_list_holder[0],
|
| }
|
| + config['assets'], config['uncompressed_assets'] = (
|
| + _MergeAssets(deps.All('android_assets')))
|
|
|
| build_utils.WriteJson(config, options.build_config, only_if_changed=True)
|
|
|
|
|