OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Writes a build_config file. | 7 """Writes a build_config file. |
8 | 8 |
9 The build_config file for a target is a json file containing information about | 9 The build_config file for a target is a json file containing information about |
10 how to build that target based on the target's dependencies. This includes | 10 how to build that target based on the target's dependencies. This includes |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 def DepsOfType(wanted_type, configs): | 86 def DepsOfType(wanted_type, configs): |
87 return [c for c in configs if c['type'] == wanted_type] | 87 return [c for c in configs if c['type'] == wanted_type] |
88 | 88 |
89 | 89 |
90 def GetAllDepsConfigsInOrder(deps_config_paths): | 90 def GetAllDepsConfigsInOrder(deps_config_paths): |
91 def GetDeps(path): | 91 def GetDeps(path): |
92 return set(GetDepConfig(path)['deps_configs']) | 92 return set(GetDepConfig(path)['deps_configs']) |
93 return build_utils.GetSortedTransitiveDependencies(deps_config_paths, GetDeps) | 93 return build_utils.GetSortedTransitiveDependencies(deps_config_paths, GetDeps) |
94 | 94 |
95 | 95 |
| 96 def ResolveGroups(configs): |
| 97 while True: |
| 98 groups = DepsOfType('group', configs) |
| 99 if not groups: |
| 100 return configs |
| 101 for config in groups: |
| 102 index = configs.index(config) |
| 103 expanded_configs = [GetDepConfig(p) for p in config['deps_configs']] |
| 104 configs[index:index + 1] = expanded_configs |
| 105 |
| 106 |
96 class Deps(object): | 107 class Deps(object): |
97 def __init__(self, direct_deps_config_paths): | 108 def __init__(self, direct_deps_config_paths): |
98 self.all_deps_config_paths = GetAllDepsConfigsInOrder( | 109 self.all_deps_config_paths = GetAllDepsConfigsInOrder( |
99 direct_deps_config_paths) | 110 direct_deps_config_paths) |
100 self.direct_deps_configs = [ | 111 self.direct_deps_configs = ResolveGroups( |
101 GetDepConfig(p) for p in direct_deps_config_paths] | 112 [GetDepConfig(p) for p in direct_deps_config_paths]) |
102 self.all_deps_configs = [ | 113 self.all_deps_configs = [ |
103 GetDepConfig(p) for p in self.all_deps_config_paths] | 114 GetDepConfig(p) for p in self.all_deps_config_paths] |
104 self.direct_deps_config_paths = direct_deps_config_paths | 115 self.direct_deps_config_paths = direct_deps_config_paths |
105 | 116 |
106 def All(self, wanted_type=None): | 117 def All(self, wanted_type=None): |
107 if type is None: | 118 if type is None: |
108 return self.all_deps_configs | 119 return self.all_deps_configs |
109 return DepsOfType(wanted_type, self.all_deps_configs) | 120 return DepsOfType(wanted_type, self.all_deps_configs) |
110 | 121 |
111 def Direct(self, wanted_type=None): | 122 def Direct(self, wanted_type=None): |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 if args: | 248 if args: |
238 parser.error('No positional arguments should be given.') | 249 parser.error('No positional arguments should be given.') |
239 | 250 |
240 required_options_map = { | 251 required_options_map = { |
241 'java_binary': ['build_config', 'jar_path'], | 252 'java_binary': ['build_config', 'jar_path'], |
242 'java_library': ['build_config', 'jar_path'], | 253 'java_library': ['build_config', 'jar_path'], |
243 'android_assets': ['build_config'], | 254 'android_assets': ['build_config'], |
244 'android_resources': ['build_config', 'resources_zip'], | 255 'android_resources': ['build_config', 'resources_zip'], |
245 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'], | 256 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'], |
246 'deps_dex': ['build_config', 'dex_path'], | 257 'deps_dex': ['build_config', 'dex_path'], |
247 'resource_rewriter': ['build_config'] | 258 'resource_rewriter': ['build_config'], |
| 259 'group': ['build_config'], |
248 } | 260 } |
249 required_options = required_options_map.get(options.type) | 261 required_options = required_options_map.get(options.type) |
250 if not required_options: | 262 if not required_options: |
251 raise Exception('Unknown type: <%s>' % options.type) | 263 raise Exception('Unknown type: <%s>' % options.type) |
252 | 264 |
253 if options.native_libs: | 265 if options.native_libs: |
254 required_options.append('readelf_path') | 266 required_options.append('readelf_path') |
255 | 267 |
256 build_utils.CheckOptions(options, parser, required_options) | 268 build_utils.CheckOptions(options, parser, required_options) |
257 | 269 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 523 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
512 | 524 |
513 if options.depfile: | 525 if options.depfile: |
514 build_utils.WriteDepfile( | 526 build_utils.WriteDepfile( |
515 options.depfile, | 527 options.depfile, |
516 deps.AllConfigPaths() + build_utils.GetPythonDependencies()) | 528 deps.AllConfigPaths() + build_utils.GetPythonDependencies()) |
517 | 529 |
518 | 530 |
519 if __name__ == '__main__': | 531 if __name__ == '__main__': |
520 sys.exit(main(sys.argv[1:])) | 532 sys.exit(main(sys.argv[1:])) |
OLD | NEW |