Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009 Google Inc. All rights reserved. | 3 # Copyright (c) 2009 Google Inc. 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 import errno | 7 import errno |
| 8 import filecmp | 8 import filecmp |
| 9 import os.path | 9 import os.path |
| 10 import re | 10 import re |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 | 212 |
| 213 Returns EncodePOSIXShellArgument for each item in list, and joins them | 213 Returns EncodePOSIXShellArgument for each item in list, and joins them |
| 214 together using the space character as an argument separator. | 214 together using the space character as an argument separator. |
| 215 """ | 215 """ |
| 216 | 216 |
| 217 encoded_arguments = [] | 217 encoded_arguments = [] |
| 218 for argument in list: | 218 for argument in list: |
| 219 encoded_arguments.append(EncodePOSIXShellArgument(argument)) | 219 encoded_arguments.append(EncodePOSIXShellArgument(argument)) |
| 220 return ' '.join(encoded_arguments) | 220 return ' '.join(encoded_arguments) |
| 221 | 221 |
| 222 | 222 def DeepDependencyTargets(target_dicts, roots, dependencies=None): |
|
Mark Mentovai
2010/07/07 17:45:28
Could you explain what’s going on in this function
| |
| 223 def DeepDependencyTargets(target_dicts, roots): | |
| 224 """Returns the recursive list of target dependencies. | 223 """Returns the recursive list of target dependencies. |
| 225 """ | 224 """ |
| 226 dependencies = set() | 225 dependencies = dependencies or set() |
| 226 unseen_deps = [] | |
| 227 for r in roots: | 227 for r in roots: |
| 228 spec = target_dicts[r] | 228 spec = target_dicts[r] |
| 229 r_deps = list(set((spec.get('dependencies', []) + | 229 r_deps = list(set((spec.get('dependencies', []) + |
| 230 spec.get('dependencies_original', [])))) | 230 spec.get('dependencies_original', [])))) |
| 231 for d in r_deps: | 231 for d in r_deps: |
| 232 if d not in roots: | 232 if d not in dependencies and d not in roots: |
| 233 dependencies.add(d) | 233 dependencies.add(d) |
| 234 for d in DeepDependencyTargets(target_dicts, r_deps): | 234 unseen_deps.append(d) |
| 235 if d not in roots: | 235 if unseen_deps: |
| 236 dependencies.add(d) | 236 DeepDependencyTargets(target_dicts, unseen_deps, dependencies) |
| 237 return list(dependencies) | 237 return list(dependencies) |
| 238 | 238 |
| 239 | 239 |
| 240 def BuildFileTargets(target_list, build_file): | 240 def BuildFileTargets(target_list, build_file): |
| 241 """From a target_list, returns the subset from the specified build_file. | 241 """From a target_list, returns the subset from the specified build_file. |
| 242 """ | 242 """ |
| 243 return [p for p in target_list if BuildFile(p) == build_file] | 243 return [p for p in target_list if BuildFile(p) == build_file] |
| 244 | 244 |
| 245 | 245 |
| 246 def AllTargets(target_list, target_dicts, build_file): | 246 def AllTargets(target_list, target_dicts, build_file): |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 if idfun is None: | 334 if idfun is None: |
| 335 def idfun(x): return x | 335 def idfun(x): return x |
| 336 seen = {} | 336 seen = {} |
| 337 result = [] | 337 result = [] |
| 338 for item in seq: | 338 for item in seq: |
| 339 marker = idfun(item) | 339 marker = idfun(item) |
| 340 if marker in seen: continue | 340 if marker in seen: continue |
| 341 seen[marker] = 1 | 341 seen[marker] = 1 |
| 342 result.append(item) | 342 result.append(item) |
| 343 return result | 343 return result |
| OLD | NEW |