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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 self.recursion_override = local_scope.get('recursion') | 483 self.recursion_override = local_scope.get('recursion') |
484 logging.warning( | 484 logging.warning( |
485 'Setting %s recursion to %d.', self.name, self.recursion_limit) | 485 'Setting %s recursion to %d.', self.name, self.recursion_limit) |
486 # If present, save 'target_os' in the local_target_os property. | 486 # If present, save 'target_os' in the local_target_os property. |
487 if 'target_os' in local_scope: | 487 if 'target_os' in local_scope: |
488 self.local_target_os = local_scope['target_os'] | 488 self.local_target_os = local_scope['target_os'] |
489 # load os specific dependencies if defined. these dependencies may | 489 # load os specific dependencies if defined. these dependencies may |
490 # override or extend the values defined by the 'deps' member. | 490 # override or extend the values defined by the 'deps' member. |
491 target_os_deps = {} | 491 target_os_deps = {} |
492 if 'deps_os' in local_scope: | 492 if 'deps_os' in local_scope: |
493 for deps_os_key in self.target_os: | 493 if len(self.target_os) > 0: |
iannucci
2013/09/16 22:54:40
what values can target_os have? can it be None?
W
| |
494 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 494 the_first_os = self.target_os[0] |
495 if len(self.target_os) > 1: | 495 # |set_by_os| tracks what deps are overridden and by whom. |
496 # Ignore any conflict when including deps for more than one | 496 set_by_os = dict.fromkeys(deps.keys(), the_first_os) |
497 # platform, so we collect the broadest set of dependencies | 497 for os_dep_key in deps.keys(): |
498 # available. We may end up with the wrong revision of something for | 498 set_by_os[os_dep_key] = the_first_os |
iannucci
2013/09/16 22:54:40
Hm... Isn't this loop doing exactly the same thing
| |
499 # our platform, but this is the best we can do. | 499 |
500 target_os_deps.update( | 500 os_deps = local_scope['deps_os'].get(the_first_os, {}) |
501 [x for x in os_deps.items() if not x[0] in target_os_deps]) | 501 for os_dep_key, os_dep_value in os_deps.iteritems(): |
502 else: | 502 target_os_deps[os_dep_key] = os_dep_value |
503 target_os_deps.update(os_deps) | 503 set_by_os[os_dep_key] = the_first_os |
504 | |
505 for the_target_os in self.target_os[1:]: | |
506 # Ignore (but warn) for any conflict when including deps for | |
507 # more than one platform, so we collect the broadest set of | |
508 # dependencies available. We may end up with the wrong | |
509 # revision of something for our platform, but this is the | |
510 # best we can do. | |
511 os_deps = local_scope['deps_os'].get(the_target_os, {}) | |
512 for os_dep_key, os_dep_value in os_deps.iteritems(): | |
513 prev_value = target_os_deps.get(os_dep_key, deps.get(os_dep_key)) | |
514 if os_dep_key in set_by_os and prev_value is not None: | |
515 # Some platforms override with None just to create a | |
516 # smaller checkout. No reason to warn about that. | |
517 if os_dep_value is not None and os_dep_value != prev_value: | |
518 print('Conflicting dependencies for %s. %s wants %s ' | |
iannucci
2013/09/16 22:54:40
this should be logging.warning, probably
| |
519 'while %s wants %s. ' | |
520 '%s will be used since %s was listed before %s.' % | |
521 (os_dep_key, the_target_os, os_dep_value, | |
522 set_by_os[os_dep_key], prev_value, | |
523 prev_value, set_by_os[os_dep_key], the_target_os)) | |
524 else: | |
525 target_os_deps[os_dep_key] = os_dep_value | |
526 set_by_os[os_dep_key] = the_target_os | |
504 | 527 |
505 # deps_os overrides paths from deps | 528 # deps_os overrides paths from deps |
506 deps.update(target_os_deps) | 529 deps.update(target_os_deps) |
507 | 530 |
508 # If a line is in custom_deps, but not in the solution, we want to append | 531 # If a line is in custom_deps, but not in the solution, we want to append |
509 # this line to the solution. | 532 # this line to the solution. |
510 for d in self.custom_deps: | 533 for d in self.custom_deps: |
511 if d not in deps: | 534 if d not in deps: |
512 deps[d] = self.custom_deps[d] | 535 deps[d] = self.custom_deps[d] |
513 | 536 |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1797 raise | 1820 raise |
1798 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1821 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1799 print >> sys.stderr, 'Error: %s' % str(e) | 1822 print >> sys.stderr, 'Error: %s' % str(e) |
1800 return 1 | 1823 return 1 |
1801 | 1824 |
1802 | 1825 |
1803 if '__main__' == __name__: | 1826 if '__main__' == __name__: |
1804 sys.exit(Main(sys.argv[1:])) | 1827 sys.exit(Main(sys.argv[1:])) |
1805 | 1828 |
1806 # vim: ts=2:sw=2:tw=80:et: | 1829 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |