diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-02-19 15:59:20 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-02-19 17:17:19 +0000 |
commit | 46d42eb7f183ac37c2f1209c3c733fc3bc348e1a (patch) | |
tree | e2f72f54731288b545a28dc7f3e363b38287a92d /morphlib/artifact.py | |
parent | 24866984ce4c1e2e444ea4aaf2d4860c60ac617f (diff) | |
download | morph-46d42eb7f183ac37c2f1209c3c733fc3bc348e1a.tar.gz |
Replace builder order graph with just a single artifact
The artifact's build dependencies replace the build order graph
from previously.
Diffstat (limited to 'morphlib/artifact.py')
-rw-r--r-- | morphlib/artifact.py | 23 |
1 files changed, 22 insertions, 1 deletions
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)) + |