Chromium Code Reviews| 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 os_overrides = {} |
| 508 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 508 for the_target_os in target_os_list: |
| 509 if len(self.target_os) > 1: | 509 the_target_os_deps = local_scope['deps_os'].get(the_target_os, {}) |
| 510 # Ignore any conflict when including deps for more than one | 510 for os_dep_key, os_dep_value in the_target_os_deps.iteritems(): |
| 511 # platform, so we collect the broadest set of dependencies | 511 overrides = os_overrides.setdefault(os_dep_key, []) |
| 512 # available. We may end up with the wrong revision of something for | 512 overrides.append((the_target_os, os_dep_value)) |
| 513 # our platform, but this is the best we can do. | 513 |
| 514 target_os_deps.update( | 514 # If any os didn't specify a value (we have fewer value entries |
| 515 [x for x in os_deps.items() if not x[0] in target_os_deps]) | 515 # than in the os list), then it wants to use the default value. |
| 516 for os_dep_key, os_dep_value in os_overrides.iteritems(): | |
| 517 if len(os_dep_value) != len(target_os_list): | |
| 518 # Record the default value too so that we don't accidently | |
| 519 # set it to None or miss a conflicting DEPS. | |
| 520 if os_dep_key in deps: | |
| 521 os_dep_value.append(('default', deps[os_dep_key])) | |
| 522 | |
| 523 target_os_deps = {} | |
| 524 for os_dep_key, os_dep_value in os_overrides.iteritems(): | |
| 525 # os_dep_value is a list of (os, value) pairs. | |
| 526 possible_values = set([x[1] for x in os_dep_value if x[1] is not None]) | |
|
Isaac (away)
2013/12/12 09:41:01
remove brackets (it's best practice so python can
| |
| 527 if len(possible_values) == 0: | |
|
Isaac (away)
2013/12/12 09:41:01
Usually written as "if not possible_values". Howe
Daniel Bratell
2013/12/12 16:26:15
It's not an error (or even unusual) to have more t
| |
| 528 target_os_deps[os_dep_key] = None | |
| 516 else: | 529 else: |
| 517 target_os_deps.update(os_deps) | 530 if len(possible_values) > 1: |
| 531 # It would be possible to abort here but it would be | |
| 532 # unfortunate to prevent people from checking out the | |
| 533 # source at all. | |
| 534 logging.error('Conflicting dependencies for %s: %s.' % | |
|
Isaac (away)
2013/12/12 09:41:01
Nit, best practice here is to use logging implicit
Daniel Bratell
2013/12/12 16:26:15
gclient is super super slow but I don't think it's
| |
| 535 (os_dep_key, os_dep_value)) | |
| 536 # Sorting to get the same result every time in case of conflicts. | |
| 537 target_os_deps[os_dep_key] = sorted(possible_values)[0] | |
| 518 | 538 |
| 519 # deps_os overrides paths from deps | 539 deps.update(target_os_deps) |
| 520 deps.update(target_os_deps) | |
| 521 | 540 |
| 522 # If a line is in custom_deps, but not in the solution, we want to append | 541 # If a line is in custom_deps, but not in the solution, we want to append |
| 523 # this line to the solution. | 542 # this line to the solution. |
| 524 for d in self.custom_deps: | 543 for d in self.custom_deps: |
| 525 if d not in deps: | 544 if d not in deps: |
| 526 deps[d] = self.custom_deps[d] | 545 deps[d] = self.custom_deps[d] |
| 527 | 546 |
| 528 # If use_relative_paths is set in the DEPS file, regenerate | 547 # If use_relative_paths is set in the DEPS file, regenerate |
| 529 # the dictionary using paths relative to the directory containing | 548 # the dictionary using paths relative to the directory containing |
| 530 # the DEPS file. | 549 # the DEPS file. |
| (...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1889 raise | 1908 raise |
| 1890 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1909 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1891 print >> sys.stderr, 'Error: %s' % str(e) | 1910 print >> sys.stderr, 'Error: %s' % str(e) |
| 1892 return 1 | 1911 return 1 |
| 1893 | 1912 |
| 1894 | 1913 |
| 1895 if '__main__' == __name__: | 1914 if '__main__' == __name__: |
| 1896 sys.exit(Main(sys.argv[1:])) | 1915 sys.exit(Main(sys.argv[1:])) |
| 1897 | 1916 |
| 1898 # vim: ts=2:sw=2:tw=80:et: | 1917 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |