Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

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: Addressed review issues. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 deps = local_scope.get('deps', {}) 481 deps = local_scope.get('deps', {})
482 if 'recursion' in local_scope: 482 if 'recursion' in local_scope:
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 if 'deps_os' in local_scope and self.target_os:
Isaac (away) 2013/12/09 10:33:13 self.target_os is a recursive function, let's save
Daniel Bratell 2013/12/11 18:09:49 To make the code faster?
Isaac (away) 2013/12/11 18:58:27 yes, also because in theory the order could change
492 if 'deps_os' in local_scope: 492 target_os_deps = {}
493 for deps_os_key in self.target_os: 493 the_first_os = self.target_os[0]
Isaac (away) 2013/12/09 10:33:13 It seems like we're going to have two decision pat
494 os_deps = local_scope['deps_os'].get(deps_os_key, {}) 494 # |set_by_os| tracks what deps are overridden and by whom.
495 if len(self.target_os) > 1: 495 set_by_os = dict.fromkeys(deps.keys(), the_first_os)
496 # Ignore any conflict when including deps for more than one
497 # platform, so we collect the broadest set of dependencies
498 # available. We may end up with the wrong revision of something for
499 # our platform, but this is the best we can do.
500 target_os_deps.update(
501 [x for x in os_deps.items() if not x[0] in target_os_deps])
502 else:
503 target_os_deps.update(os_deps)
504 496
505 # deps_os overrides paths from deps 497 os_deps = local_scope['deps_os'].get(the_first_os, {})
506 deps.update(target_os_deps) 498 for os_dep_key, os_dep_value in os_deps.iteritems():
499 target_os_deps[os_dep_key] = os_dep_value
500 set_by_os[os_dep_key] = the_first_os
501
502 for the_target_os in self.target_os[1:]:
503 # Ignore (but warn) for any conflict when including deps for
504 # more than one platform, so we collect the broadest set of
505 # dependencies available. We may end up with the wrong
506 # revision of something for our platform, but this is the
507 # best we can do.
508 os_deps = local_scope['deps_os'].get(the_target_os, {})
509 for os_dep_key, os_dep_value in os_deps.iteritems():
510 prev_value = target_os_deps.get(os_dep_key, deps.get(os_dep_key))
511 if os_dep_key in set_by_os and prev_value is not None:
512 # Some platforms override with None just to create a
513 # smaller checkout. No reason to warn about that.
514 if os_dep_value is not None and os_dep_value != prev_value:
515 print('Conflicting dependencies for %s. %s wants %s '
Isaac (away) 2013/12/09 10:33:13 Use logging calls instead of print
516 'while %s wants %s. '
517 '%s will be used since %s was listed before %s.' %
Isaac (away) 2013/12/09 10:33:13 Order is completely arbitrary in this list since t
Daniel Bratell 2013/12/11 18:09:49 The problem with that is that it won't be the pers
518 (os_dep_key, the_target_os, os_dep_value,
519 set_by_os[os_dep_key], prev_value,
520 prev_value, set_by_os[os_dep_key], the_target_os))
521 else:
522 target_os_deps[os_dep_key] = os_dep_value
523 set_by_os[os_dep_key] = the_target_os
524
525 # deps_os overrides paths from deps
526 deps.update(target_os_deps)
507 527
508 # If a line is in custom_deps, but not in the solution, we want to append 528 # If a line is in custom_deps, but not in the solution, we want to append
509 # this line to the solution. 529 # this line to the solution.
510 for d in self.custom_deps: 530 for d in self.custom_deps:
511 if d not in deps: 531 if d not in deps:
512 deps[d] = self.custom_deps[d] 532 deps[d] = self.custom_deps[d]
513 533
514 # If use_relative_paths is set in the DEPS file, regenerate 534 # If use_relative_paths is set in the DEPS file, regenerate
515 # the dictionary using paths relative to the directory containing 535 # the dictionary using paths relative to the directory containing
516 # the DEPS file. 536 # the DEPS file.
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 raise 1817 raise
1798 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1818 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1799 print >> sys.stderr, 'Error: %s' % str(e) 1819 print >> sys.stderr, 'Error: %s' % str(e)
1800 return 1 1820 return 1
1801 1821
1802 1822
1803 if '__main__' == __name__: 1823 if '__main__' == __name__:
1804 sys.exit(Main(sys.argv[1:])) 1824 sys.exit(Main(sys.argv[1:]))
1805 1825
1806 # vim: ts=2:sw=2:tw=80:et: 1826 # 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
This is Rietveld 408576698