From 621939b6803f7f23edde8f257b78a200accb2cbd Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 10 Aug 2010 20:12:00 +0000 Subject: [PATCH] Add Dependency.requirements which will solve the issues found in pagespeed and parallel checkout. Review URL: http://codereview.chromium.org/3159002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@55614 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gclient.py b/gclient.py index 70fad2d423..dfd17c3b07 100644 --- a/gclient.py +++ b/gclient.py @@ -54,6 +54,7 @@ __version__ = "0.5" import logging import optparse import os +import posixpath import pprint import re import subprocess @@ -165,6 +166,12 @@ class Dependency(GClientKeywords): self.processed = False # This dependency had its hook run self.hooks_ran = False + # Required dependencies to run before running this one: + self.requirements = [] + if self.parent and self.parent.name: + self.requirements.append(self.parent.name) + if isinstance(self.url, self.FromImpl): + self.requirements.append(self.url.module_name) # Sanity checks if not self.name and self.parent: @@ -362,6 +369,16 @@ class Dependency(GClientKeywords): if pm: pm._total = len(self.tree(False)) + 1 pm.update(0) + # Adjust the implicit dependency requirement; e.g. if a DEPS file contains + # both src/foo and src/foo/bar, src/foo/bar is implicitly dependent of + # src/foo. Yes, it's O(n^2)... + for s in self.dependencies: + for s2 in self.dependencies: + if s is s2: + continue + if s.name.startswith(posixpath.join(s2.name, '')): + s.requirements.append(s2.name) + # Parse the dependencies of this dependency. for s in self.dependencies: # TODO(maruel): All these can run concurrently! No need for threads, @@ -476,7 +493,7 @@ class Dependency(GClientKeywords): out = [] for i in ('name', 'url', 'parsed_url', 'safesync_url', 'custom_deps', 'custom_vars', 'deps_hooks', '_file_list', 'processed', - 'hooks_ran', 'deps_parsed'): + 'hooks_ran', 'deps_parsed', 'requirements'): # 'deps_file' if self.__dict__[i]: out.append('%s: %s' % (i, self.__dict__[i]))