Chromium Code Reviews| 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 ff12a1ed7ca4641141787987ec4611fcb4b9d9f9..e746e9feb3afd7c0f1f6c8931f04ac02fa709464 100755 |
| --- a/build/android/gyp/write_build_config.py |
| +++ b/build/android/gyp/write_build_config.py |
| @@ -35,6 +35,23 @@ import sys |
| from util import build_utils |
| +dep_config_cache = {} |
| +def GetDepConfig(path): |
| + if not path in dep_config_cache: |
| + dep_config_cache[path] = build_utils.ReadJson(path)['deps_info'] |
| + return dep_config_cache[path] |
| + |
| + |
| +def DepsOfType(wanted_type, configs): |
| + return [c for c in configs if c['type'] == wanted_type] |
| + |
| + |
| +def GetAllDepsConfigsInOrder(deps_config_paths): |
| + def Deps(path): |
| + return set(GetDepConfig(path)['deps_configs']) |
| + return build_utils.GetSortedTransitiveDependencies(deps_config_paths, Deps) |
| + |
| + |
| def main(argv): |
| parser = optparse.OptionParser() |
| build_utils.AddDepfileOption(parser) |
| @@ -46,6 +63,10 @@ def main(argv): |
| 'dependencies may not write build_config files. Missing build_config ' |
| 'files are handled differently based on the type of this target.') |
| + # android_resources options |
| + parser.add_option('--srcjar', help='Path to target\'s resources srcjar.') |
| + parser.add_option('--resources-zip', help='Path to target\'s resources zip.') |
| + |
| # android_library options |
| parser.add_option('--jar-path', help='Path to target\'s jar output.') |
| @@ -57,37 +78,62 @@ def main(argv): |
| required_options = ('build_config', 'type') |
| build_utils.CheckOptions(options, parser, required_options) |
| + if not options.type in [ |
| + 'android_library', 'android_resources']: |
| + raise Exception('Unknown type: <%s>' % options.type) |
| + |
| if options.type == 'android_library': |
| required_options = ('jar_path',) |
| build_utils.CheckOptions(options, parser, required_options) |
| - deps_configs = build_utils.ParseGypList(options.possible_deps_configs) |
| - for c in deps_configs: |
| + possible_deps_configs = build_utils.ParseGypList( |
| + options.possible_deps_configs) |
| + for c in possible_deps_configs: |
| if not os.path.exists(c): |
| # Currently we only allow deps to things that write build_config files. |
| raise Exception('Unknown dep type: ' + c) |
| - deps_configs = [build_utils.ReadJson(c) for c in deps_configs] |
| + direct_deps_config_paths = possible_deps_configs |
| + all_deps_config_paths = GetAllDepsConfigsInOrder(direct_deps_config_paths) |
| + |
| + direct_deps_configs = [GetDepConfig(p) for p in direct_deps_config_paths] |
| + all_deps_configs = [GetDepConfig(p) for p in all_deps_config_paths] |
| + |
| + direct_library_deps = DepsOfType('android_library', direct_deps_configs) |
| + all_resources_deps = DepsOfType('android_resources', all_deps_configs) |
|
newt (away)
2014/07/07 21:47:12
all_resources_deps contains only android_resources
cjhopman
2014/07/08 00:16:27
It is. I added a comment below about it.
|
| + |
| + # Initialize some common config. |
| + config = { |
| + 'deps_info': { |
| + 'path': options.build_config, |
| + 'type': options.type, |
| + 'deps_configs': direct_deps_config_paths, |
| + } |
| + } |
| + deps_info = config['deps_info'] |
| if options.type == 'android_library': |
| - javac_classpath = [c['outputs']['jar_path'] for c in deps_configs] |
| - config = { |
| - 'outputs': { |
| - 'jar_path': options.jar_path |
| - }, |
| - 'javac': { |
| - 'classpath': javac_classpath |
| - } |
| + javac_classpath = [c['jar_path'] for c in direct_library_deps] |
| + deps_info['jar_path'] = options.jar_path |
| + config['javac'] = { |
| + 'classpath': javac_classpath, |
| + 'srcjars': [c['srcjar'] for c in all_resources_deps if 'srcjar' in c], |
| } |
| - else: |
| - raise Exception('Unknown type: ' + options.type) |
| - build_utils.WriteJson(config, options.build_config) |
| + if options.type == 'android_resources': |
| + deps_info['resources_zip'] = options.resources_zip |
| + if options.srcjar: |
| + deps_info['srcjar'] = options.srcjar |
| + config['resources'] = {} |
| + config['resources']['dependency_zips'] = [ |
| + c['resources_zip'] for c in all_resources_deps] |
| + |
| + build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
| if options.depfile: |
| build_utils.WriteDepfile( |
| options.depfile, |
| - build_utils.GetPythonDependencies()) |
| + all_deps_config_paths + build_utils.GetPythonDependencies()) |
| if __name__ == '__main__': |