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