| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 # unavailable | 364 # unavailable |
| 365 self._got_revision = None | 365 self._got_revision = None |
| 366 | 366 |
| 367 # This is a mutable value that overrides the normal recursion limit for this | 367 # This is a mutable value that overrides the normal recursion limit for this |
| 368 # dependency. It is read from the actual DEPS file so cannot be set on | 368 # dependency. It is read from the actual DEPS file so cannot be set on |
| 369 # class instantiation. | 369 # class instantiation. |
| 370 self.recursion_override = None | 370 self.recursion_override = None |
| 371 # recursedeps is a mutable value that selectively overrides the default | 371 # recursedeps is a mutable value that selectively overrides the default |
| 372 # 'no recursion' setting on a dep-by-dep basis. It will replace | 372 # 'no recursion' setting on a dep-by-dep basis. It will replace |
| 373 # recursion_override. | 373 # recursion_override. |
| 374 # | |
| 375 # It will be a dictionary of {deps_name: {"deps_file": depfile_name}} or | |
| 376 # None. | |
| 377 self.recursedeps = None | 374 self.recursedeps = None |
| 378 | 375 |
| 379 if not self.name and self.parent: | 376 if not self.name and self.parent: |
| 380 raise gclient_utils.Error('Dependency without name') | 377 raise gclient_utils.Error('Dependency without name') |
| 381 | 378 |
| 382 @property | 379 @property |
| 383 def requirements(self): | 380 def requirements(self): |
| 384 """Calculate the list of requirements.""" | 381 """Calculate the list of requirements.""" |
| 385 requirements = set() | 382 requirements = set() |
| 386 # self.parent is implicitly a requirement. This will be recursive by | 383 # self.parent is implicitly a requirement. This will be recursive by |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 if not isinstance(val, (dict, list, tuple, str)): | 643 if not isinstance(val, (dict, list, tuple, str)): |
| 647 raise gclient_utils.Error( | 644 raise gclient_utils.Error( |
| 648 'ParseDepsFile(%s): Strict mode disallows %r -> %r' % | 645 'ParseDepsFile(%s): Strict mode disallows %r -> %r' % |
| 649 (self.name, key, val)) | 646 (self.name, key, val)) |
| 650 | 647 |
| 651 deps = local_scope.get('deps', {}) | 648 deps = local_scope.get('deps', {}) |
| 652 if 'recursion' in local_scope: | 649 if 'recursion' in local_scope: |
| 653 self.recursion_override = local_scope.get('recursion') | 650 self.recursion_override = local_scope.get('recursion') |
| 654 logging.warning( | 651 logging.warning( |
| 655 'Setting %s recursion to %d.', self.name, self.recursion_limit) | 652 'Setting %s recursion to %d.', self.name, self.recursion_limit) |
| 656 self.recursedeps = None | 653 self.recursedeps = local_scope.get('recursedeps', None) |
| 657 if 'recursedeps' in local_scope: | 654 if 'recursedeps' in local_scope: |
| 658 self.recursedeps = {} | 655 self.recursedeps = set(self.recursedeps) |
| 659 for ent in local_scope['recursedeps']: | |
| 660 if isinstance(ent, basestring): | |
| 661 self.recursedeps[ent] = {"deps_file": "DEPS"} | |
| 662 else: # (depname, depsfilename) | |
| 663 self.recursedeps[ent[0]] = {"deps_file": ent[1]} | |
| 664 logging.warning('Found recursedeps %r.', repr(self.recursedeps)) | 656 logging.warning('Found recursedeps %r.', repr(self.recursedeps)) |
| 665 # If present, save 'target_os' in the local_target_os property. | 657 # If present, save 'target_os' in the local_target_os property. |
| 666 if 'target_os' in local_scope: | 658 if 'target_os' in local_scope: |
| 667 self.local_target_os = local_scope['target_os'] | 659 self.local_target_os = local_scope['target_os'] |
| 668 # load os specific dependencies if defined. these dependencies may | 660 # load os specific dependencies if defined. these dependencies may |
| 669 # override or extend the values defined by the 'deps' member. | 661 # override or extend the values defined by the 'deps' member. |
| 670 target_os_list = self.target_os | 662 target_os_list = self.target_os |
| 671 if 'deps_os' in local_scope and target_os_list: | 663 if 'deps_os' in local_scope and target_os_list: |
| 672 deps = self.MergeWithOsDeps(deps, local_scope['deps_os'], target_os_list) | 664 deps = self.MergeWithOsDeps(deps, local_scope['deps_os'], target_os_list) |
| 673 | 665 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 688 for d, url in deps.items(): | 680 for d, url in deps.items(): |
| 689 # normpath is required to allow DEPS to use .. in their | 681 # normpath is required to allow DEPS to use .. in their |
| 690 # dependency local path. | 682 # dependency local path. |
| 691 rel_deps[os.path.normpath(os.path.join(self.name, d))] = url | 683 rel_deps[os.path.normpath(os.path.join(self.name, d))] = url |
| 692 logging.warning('Updating deps by prepending %s.', self.name) | 684 logging.warning('Updating deps by prepending %s.', self.name) |
| 693 deps = rel_deps | 685 deps = rel_deps |
| 694 | 686 |
| 695 # Update recursedeps if it's set. | 687 # Update recursedeps if it's set. |
| 696 if self.recursedeps is not None: | 688 if self.recursedeps is not None: |
| 697 logging.warning('Updating recursedeps by prepending %s.', self.name) | 689 logging.warning('Updating recursedeps by prepending %s.', self.name) |
| 698 rel_deps = {} | 690 rel_deps = set() |
| 699 for depname, options in self.recursedeps.iteritems(): | 691 for d in self.recursedeps: |
| 700 rel_deps[os.path.normpath(os.path.join(self.name, depname))] = options | 692 rel_deps.add(os.path.normpath(os.path.join(self.name, d))) |
| 701 self.recursedeps = rel_deps | 693 self.recursedeps = rel_deps |
| 702 | 694 |
| 703 if 'allowed_hosts' in local_scope: | 695 if 'allowed_hosts' in local_scope: |
| 704 try: | 696 try: |
| 705 self._allowed_hosts = frozenset(local_scope.get('allowed_hosts')) | 697 self._allowed_hosts = frozenset(local_scope.get('allowed_hosts')) |
| 706 except TypeError: # raised if non-iterable | 698 except TypeError: # raised if non-iterable |
| 707 pass | 699 pass |
| 708 if not self._allowed_hosts: | 700 if not self._allowed_hosts: |
| 709 logging.warning("allowed_hosts is specified but empty %s", | 701 logging.warning("allowed_hosts is specified but empty %s", |
| 710 self._allowed_hosts) | 702 self._allowed_hosts) |
| 711 raise gclient_utils.Error( | 703 raise gclient_utils.Error( |
| 712 'ParseDepsFile(%s): allowed_hosts must be absent ' | 704 'ParseDepsFile(%s): allowed_hosts must be absent ' |
| 713 'or a non-empty iterable' % self.name) | 705 'or a non-empty iterable' % self.name) |
| 714 | 706 |
| 715 # Convert the deps into real Dependency. | 707 # Convert the deps into real Dependency. |
| 716 deps_to_add = [] | 708 deps_to_add = [] |
| 717 for name, url in deps.iteritems(): | 709 for name, url in deps.iteritems(): |
| 718 should_process = self.recursion_limit and self.should_process | 710 should_process = self.recursion_limit and self.should_process |
| 719 deps_file = self.deps_file | |
| 720 if self.recursedeps is not None: | |
| 721 ent = self.recursedeps.get(name) | |
| 722 if ent is not None: | |
| 723 deps_file = ent['deps_file'] | |
| 724 deps_to_add.append(Dependency( | 711 deps_to_add.append(Dependency( |
| 725 self, name, url, None, None, None, self.custom_vars, None, | 712 self, name, url, None, None, None, self.custom_vars, None, |
| 726 deps_file, should_process)) | 713 self.deps_file, should_process)) |
| 727 deps_to_add.sort(key=lambda x: x.name) | 714 deps_to_add.sort(key=lambda x: x.name) |
| 728 | 715 |
| 729 # override named sets of hooks by the custom hooks | 716 # override named sets of hooks by the custom hooks |
| 730 hooks_to_run = [] | 717 hooks_to_run = [] |
| 731 hook_names_to_suppress = [c.get('name', '') for c in self.custom_hooks] | 718 hook_names_to_suppress = [c.get('name', '') for c in self.custom_hooks] |
| 732 for hook in local_scope.get('hooks', []): | 719 for hook in local_scope.get('hooks', []): |
| 733 if hook.get('name', '') not in hook_names_to_suppress: | 720 if hook.get('name', '') not in hook_names_to_suppress: |
| 734 hooks_to_run.append(hook) | 721 hooks_to_run.append(hook) |
| 735 | 722 |
| 736 # add the replacements and any additions | 723 # add the replacements and any additions |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 | 2329 |
| 2343 | 2330 |
| 2344 if '__main__' == __name__: | 2331 if '__main__' == __name__: |
| 2345 try: | 2332 try: |
| 2346 sys.exit(main(sys.argv[1:])) | 2333 sys.exit(main(sys.argv[1:])) |
| 2347 except KeyboardInterrupt: | 2334 except KeyboardInterrupt: |
| 2348 sys.stderr.write('interrupted\n') | 2335 sys.stderr.write('interrupted\n') |
| 2349 sys.exit(1) | 2336 sys.exit(1) |
| 2350 | 2337 |
| 2351 # vim: ts=2:sw=2:tw=80:et: | 2338 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |