comparison mxtool/mx.py @ 17245:86d9e456ef98

mx: added cyclic dependency checking
author Doug Simon <doug.simon@oracle.com>
date Mon, 29 Sep 2014 13:57:52 +0200
parents 9d728eb7fdec
children 03826360967b
comparison
equal deleted inserted replaced
17244:aef31f60e970 17245:86d9e456ef98
282 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False): 282 def all_deps(self, deps, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
283 """ 283 """
284 Add the transitive set of dependencies for this project, including 284 Add the transitive set of dependencies for this project, including
285 libraries if 'includeLibs' is true, to the 'deps' list. 285 libraries if 'includeLibs' is true, to the 'deps' list.
286 """ 286 """
287 return self._all_deps_helper(deps, [], includeLibs, includeSelf, includeJreLibs, includeAnnotationProcessors)
288
289 def _all_deps_helper(self, deps, dependants, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
290 if self in dependants:
291 abort(str(self) + 'Project dependency cycle found:\n ' +
292 '\n |\n V\n '.join(map(str, dependants[dependants.index(self):])) +
293 '\n |\n V\n ' + self.name)
287 childDeps = list(self.deps) 294 childDeps = list(self.deps)
288 if includeAnnotationProcessors and len(self.annotation_processors()) > 0: 295 if includeAnnotationProcessors and len(self.annotation_processors()) > 0:
289 childDeps = self.annotation_processors() + childDeps 296 childDeps = self.annotation_processors() + childDeps
290 if self in deps: 297 if self in deps:
291 return deps 298 return deps
292 for name in childDeps: 299 for name in childDeps:
293 assert name != self.name 300 assert name != self.name
294 dep = dependency(name) 301 dep = dependency(name)
295 if not dep in deps and (dep.isProject or (dep.isLibrary() and includeLibs) or (dep.isJreLibrary() and includeJreLibs)): 302 if not dep in deps:
296 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors) 303 if dep.isProject():
304 dep._all_deps_helper(deps, dependants + [self], includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
305 elif (dep.isProject or (dep.isLibrary() and includeLibs) or (dep.isJreLibrary() and includeJreLibs)):
306 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
297 if not self in deps and includeSelf: 307 if not self in deps and includeSelf:
298 deps.append(self) 308 deps.append(self)
299 return deps 309 return deps
300 310
301 def _compute_max_dep_distances(self, name, distances, dist): 311 def _compute_max_dep_distances(self, name, distances, dist):