Chromium Code Reviews

Side by Side Diff: gclient.py

Issue 23875029: Handle conflicting os deps better in gclient. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: After review. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 484 matching lines...)
495 deps = local_scope.get('deps', {}) 495 deps = local_scope.get('deps', {})
496 if 'recursion' in local_scope: 496 if 'recursion' in local_scope:
497 self.recursion_override = local_scope.get('recursion') 497 self.recursion_override = local_scope.get('recursion')
498 logging.warning( 498 logging.warning(
499 'Setting %s recursion to %d.', self.name, self.recursion_limit) 499 'Setting %s recursion to %d.', self.name, self.recursion_limit)
500 # If present, save 'target_os' in the local_target_os property. 500 # If present, save 'target_os' in the local_target_os property.
501 if 'target_os' in local_scope: 501 if 'target_os' in local_scope:
502 self.local_target_os = local_scope['target_os'] 502 self.local_target_os = local_scope['target_os']
503 # load os specific dependencies if defined. these dependencies may 503 # load os specific dependencies if defined. these dependencies may
504 # override or extend the values defined by the 'deps' member. 504 # override or extend the values defined by the 'deps' member.
505 target_os_deps = {} 505 target_os_list = self.target_os
506 if 'deps_os' in local_scope: 506 if 'deps_os' in local_scope and target_os_list:
507 for deps_os_key in self.target_os: 507 if len(target_os_list) == 1:
508 os_deps = local_scope['deps_os'].get(deps_os_key, {}) 508 target_os_deps = local_scope['deps_os'].get(target_os_list[0], {})
509 if len(self.target_os) > 1: 509 else:
510 # Ignore any conflict when including deps for more than one 510 os_overrides = {}
511 # platform, so we collect the broadest set of dependencies 511 for the_target_os in target_os_list:
512 # available. We may end up with the wrong revision of something for 512 the_target_os_deps = local_scope['deps_os'].get(the_target_os, {})
513 # our platform, but this is the best we can do. 513 for os_dep_key, os_dep_value in the_target_os_deps.iteritems():
514 target_os_deps.update( 514 overrides = os_overrides.setdefault(os_dep_key, [])
515 [x for x in os_deps.items() if not x[0] in target_os_deps]) 515 overrides.append((the_target_os, os_dep_value))
516 else:
517 target_os_deps.update(os_deps)
518 516
519 # deps_os overrides paths from deps 517 for os_dep_key, os_dep_value in os_overrides.iteritems():
520 deps.update(target_os_deps) 518 if len(os_dep_value) != len(target_os_list):
Isaac (away) 2013/12/11 18:58:27 What does this loop do? Can you add a comment?
519 if os_dep_key in deps:
520 os_dep_value.append(('default', deps[os_dep_key]))
521
522 target_os_deps = {}
523 for os_dep_key, os_dep_value in os_overrides.iteritems():
524 # os_dep_value is a list of (os, value) pairs.
525 possible_values = set([x[1] for x in os_dep_value if x[1] is not None] )
Isaac (away) 2013/12/11 18:58:27 line length, but you can remove the unneeded brack
526 if len(possible_values) > 1:
527 logging.error('Conflicting dependencies for %s: %s' %
528 (os_dep_key, os_dep_value))
529 raise gclient_utils.Error('Inconsistent checkout instructions.')
Isaac (away) 2013/12/11 18:58:27 I gave conflicting suggestions here. in the first
530
531 if len(possible_values) == 1:
532 target_os_deps[os_dep_key] = possible_values.pop()
533 else:
534 target_os_deps[os_dep_key] = None
535
536 deps.update(target_os_deps)
521 537
522 # If a line is in custom_deps, but not in the solution, we want to append 538 # If a line is in custom_deps, but not in the solution, we want to append
523 # this line to the solution. 539 # this line to the solution.
524 for d in self.custom_deps: 540 for d in self.custom_deps:
525 if d not in deps: 541 if d not in deps:
526 deps[d] = self.custom_deps[d] 542 deps[d] = self.custom_deps[d]
527 543
528 # If use_relative_paths is set in the DEPS file, regenerate 544 # If use_relative_paths is set in the DEPS file, regenerate
529 # the dictionary using paths relative to the directory containing 545 # the dictionary using paths relative to the directory containing
530 # the DEPS file. 546 # the DEPS file.
(...skipping 1358 matching lines...)
1889 raise 1905 raise
1890 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1906 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1891 print >> sys.stderr, 'Error: %s' % str(e) 1907 print >> sys.stderr, 'Error: %s' % str(e)
1892 return 1 1908 return 1
1893 1909
1894 1910
1895 if '__main__' == __name__: 1911 if '__main__' == __name__:
1896 sys.exit(Main(sys.argv[1:])) 1912 sys.exit(Main(sys.argv[1:]))
1897 1913
1898 # vim: ts=2:sw=2:tw=80:et: 1914 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine