From 46d42eb7f183ac37c2f1209c3c733fc3bc348e1a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 19 Feb 2013 15:59:20 +0000 Subject: Replace builder order graph with just a single artifact The artifact's build dependencies replace the build order graph from previously. --- morphlib/artifact.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'morphlib/artifact.py') diff --git a/morphlib/artifact.py b/morphlib/artifact.py index ccde11d4..3bb2a520 100644 --- a/morphlib/artifact.py +++ b/morphlib/artifact.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012, 2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -63,3 +63,24 @@ class Artifact(object): def __str__(self): # pragma: no cover return '%s|%s' % (self.source, self.name) + + def walk(self): # pragma: no cover + '''Return list of an artifact and its build dependencies. + + The artifacts are returned in depth-first order: an artifact + is returned only after all of its dependencies. + + ''' + + done = set() + + def depth_first(a): + for dep in a.dependencies: + for ret in depth_first(dep): + yield ret + if a not in done: + done.add(a) + yield a + + return list(depth_first(self)) + -- cgit v1.2.1