OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Meta checkout manager supporting both Subversion and GIT.""" | 6 """Meta checkout manager supporting both Subversion and GIT.""" |
7 # Files | 7 # Files |
8 # .gclient : Current client configuration, written by 'config' command. | 8 # .gclient : Current client configuration, written by 'config' command. |
9 # Format is a Python script defining 'solutions', a list whose | 9 # Format is a Python script defining 'solutions', a list whose |
10 # entries each are maps binding the strings "name" and "url" | 10 # entries each are maps binding the strings "name" and "url" |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 (self.name, url, url)) | 459 (self.name, url, url)) |
460 return url | 460 return url |
461 | 461 |
462 if url is None: | 462 if url is None: |
463 logging.info( | 463 logging.info( |
464 'Dependency(%s).LateOverride(%s) -> %s' % (self.name, url, url)) | 464 'Dependency(%s).LateOverride(%s) -> %s' % (self.name, url, url)) |
465 return url | 465 return url |
466 | 466 |
467 raise gclient_utils.Error('Unknown url type') | 467 raise gclient_utils.Error('Unknown url type') |
468 | 468 |
469 @staticmethod | |
470 def UpdateWithOsDeps(deps, deps_os, target_os_list): | |
M-A Ruel
2013/12/16 13:18:18
The method doesn't make it obvious what is input o
| |
471 """Updates deps with information from deps_os (the deps_os section | |
472 of the DEPS file) that matches the list of target os.""" | |
473 os_overrides = {} | |
474 for the_target_os in target_os_list: | |
475 the_target_os_deps = deps_os.get(the_target_os, {}) | |
476 for os_dep_key, os_dep_value in the_target_os_deps.iteritems(): | |
477 overrides = os_overrides.setdefault(os_dep_key, []) | |
478 overrides.append((the_target_os, os_dep_value)) | |
479 | |
480 # If any os didn't specify a value (we have fewer value entries | |
481 # than in the os list), then it wants to use the default value. | |
482 for os_dep_key, os_dep_value in os_overrides.iteritems(): | |
483 if len(os_dep_value) != len(target_os_list): | |
484 # Record the default value too so that we don't accidently | |
485 # set it to None or miss a conflicting DEPS. | |
486 if os_dep_key in deps: | |
487 os_dep_value.append(('default', deps[os_dep_key])) | |
488 | |
489 target_os_deps = {} | |
490 for os_dep_key, os_dep_value in os_overrides.iteritems(): | |
491 # os_dep_value is a list of (os, value) pairs. | |
492 possible_values = set(x[1] for x in os_dep_value if x[1] is not None) | |
493 if not possible_values: | |
494 target_os_deps[os_dep_key] = None | |
495 else: | |
496 if len(possible_values) > 1: | |
497 # It would be possible to abort here but it would be | |
498 # unfortunate if we end up preventing any kind of checkout. | |
499 logging.error('Conflicting dependencies for %s: %s. (target_os=%s)', | |
500 os_dep_key, os_dep_value, target_os_list) | |
501 # Sorting to get the same result every time in case of conflicts. | |
502 target_os_deps[os_dep_key] = sorted(possible_values)[0] | |
503 | |
504 deps.update(target_os_deps) | |
505 | |
469 def ParseDepsFile(self): | 506 def ParseDepsFile(self): |
470 """Parses the DEPS file for this dependency.""" | 507 """Parses the DEPS file for this dependency.""" |
471 assert not self.deps_parsed | 508 assert not self.deps_parsed |
472 assert not self.dependencies | 509 assert not self.dependencies |
473 # One thing is unintuitive, vars = {} must happen before Var() use. | 510 # One thing is unintuitive, vars = {} must happen before Var() use. |
474 local_scope = {} | 511 local_scope = {} |
475 var = self.VarImpl(self.custom_vars, local_scope) | 512 var = self.VarImpl(self.custom_vars, local_scope) |
476 global_scope = { | 513 global_scope = { |
477 'File': self.FileImpl, | 514 'File': self.FileImpl, |
478 'From': self.FromImpl, | 515 'From': self.FromImpl, |
(...skipping 16 matching lines...) Expand all Loading... | |
495 deps = local_scope.get('deps', {}) | 532 deps = local_scope.get('deps', {}) |
496 if 'recursion' in local_scope: | 533 if 'recursion' in local_scope: |
497 self.recursion_override = local_scope.get('recursion') | 534 self.recursion_override = local_scope.get('recursion') |
498 logging.warning( | 535 logging.warning( |
499 'Setting %s recursion to %d.', self.name, self.recursion_limit) | 536 'Setting %s recursion to %d.', self.name, self.recursion_limit) |
500 # If present, save 'target_os' in the local_target_os property. | 537 # If present, save 'target_os' in the local_target_os property. |
501 if 'target_os' in local_scope: | 538 if 'target_os' in local_scope: |
502 self.local_target_os = local_scope['target_os'] | 539 self.local_target_os = local_scope['target_os'] |
503 # load os specific dependencies if defined. these dependencies may | 540 # load os specific dependencies if defined. these dependencies may |
504 # override or extend the values defined by the 'deps' member. | 541 # override or extend the values defined by the 'deps' member. |
505 target_os_deps = {} | 542 target_os_list = self.target_os |
506 if 'deps_os' in local_scope: | 543 if 'deps_os' in local_scope and target_os_list: |
507 for deps_os_key in self.target_os: | 544 Dependency.UpdateWithOsDeps(deps, local_scope['deps_os'], target_os_list) |
M-A Ruel
2013/12/16 13:18:18
self.UpdateWithOSDeps(...
| |
508 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | |
509 if len(self.target_os) > 1: | |
510 # Ignore any conflict when including deps for more than one | |
511 # platform, so we collect the broadest set of dependencies | |
512 # available. We may end up with the wrong revision of something for | |
513 # our platform, but this is the best we can do. | |
514 target_os_deps.update( | |
515 [x for x in os_deps.items() if not x[0] in target_os_deps]) | |
516 else: | |
517 target_os_deps.update(os_deps) | |
518 | |
519 # deps_os overrides paths from deps | |
520 deps.update(target_os_deps) | |
521 | 545 |
522 # If a line is in custom_deps, but not in the solution, we want to append | 546 # If a line is in custom_deps, but not in the solution, we want to append |
523 # this line to the solution. | 547 # this line to the solution. |
524 for d in self.custom_deps: | 548 for d in self.custom_deps: |
525 if d not in deps: | 549 if d not in deps: |
526 deps[d] = self.custom_deps[d] | 550 deps[d] = self.custom_deps[d] |
527 | 551 |
528 # If use_relative_paths is set in the DEPS file, regenerate | 552 # If use_relative_paths is set in the DEPS file, regenerate |
529 # the dictionary using paths relative to the directory containing | 553 # the dictionary using paths relative to the directory containing |
530 # the DEPS file. | 554 # the DEPS file. |
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 raise | 1913 raise |
1890 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1914 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1891 print >> sys.stderr, 'Error: %s' % str(e) | 1915 print >> sys.stderr, 'Error: %s' % str(e) |
1892 return 1 | 1916 return 1 |
1893 | 1917 |
1894 | 1918 |
1895 if '__main__' == __name__: | 1919 if '__main__' == __name__: |
1896 sys.exit(Main(sys.argv[1:])) | 1920 sys.exit(Main(sys.argv[1:])) |
1897 | 1921 |
1898 # vim: ts=2:sw=2:tw=80:et: | 1922 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |