summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCurtis Dunham <Curtis.Dunham@arm.com>2017-02-14 15:09:18 -0600
committerCurtis Dunham <Curtis.Dunham@arm.com>2017-02-14 15:09:18 -0600
commit5638a074b9e493c0b4b2acc627072da5f3e41079 (patch)
tree96aeef2b3d281ca458d611d5a84add6b3441afc0
parent72e74aed0af72dbfd503e235938a5cfabe820696 (diff)
downloadgem5-5638a074b9e493c0b4b2acc627072da5f3e41079.tar.xz
sim: allow forward dependencies in checkpoint upgraders
The notion of forward dependencies is just expressing the same dependency but at the other end of the dependency edge, i.e. at the dependee rather than the depender. As there is no more 'power' here, it's strictly a convenience feature for handling dependencies with tags that are not in the upstream repository. Change-Id: Ic7c68de6aff4094aaa12de62cdf690a5dc65ccb5 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
-rwxr-xr-xutil/cpt_upgrader.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/util/cpt_upgrader.py b/util/cpt_upgrader.py
index b4e4beab2..59a468989 100755
--- a/util/cpt_upgrader.py
+++ b/util/cpt_upgrader.py
@@ -64,6 +64,14 @@
# its upgrader (or downgrader) can run. It is still the case that a tag
# can only be used once.
+# Dependencies between tags are expressed by two variables at the top-level
+# of the upgrader script: "depends" can be either a string naming another
+# tag that it depends upon or a list of such strings; and "fwd_depends"
+# accepts the same datatypes but it reverses the sense of the dependency
+# arrow(s) -- it expresses that that tag depends upon the tag of the current
+# upgrader. This can be especially valuable when maintaining private
+# upgraders in private branches.
+
import ConfigParser
import glob, types, sys, os
@@ -94,6 +102,20 @@ class Upgrader:
elif isinstance(self.depends, str):
self.depends = [self.depends]
+ if not isinstance(self.depends, list):
+ print "Error: 'depends' for %s is the wrong type" % self.tag
+ sys.exit(1)
+
+ if hasattr(self, 'fwd_depends'):
+ if isinstance(self.fwd_depends, str):
+ self.fwd_depends = [self.fwd_depends]
+ else:
+ self.fwd_depends = []
+
+ if not isinstance(self.fwd_depends, list):
+ print "Error: 'fwd_depends' for %s is the wrong type" % self.tag
+ sys.exit(1)
+
if hasattr(self, 'upgrader'):
if not isinstance(self.upgrader, types.FunctionType):
print "Error: 'upgrader' for %s is %s, not function" \
@@ -148,6 +170,20 @@ class Upgrader:
Upgrader.legacy[i].depends = [Upgrader.legacy[i-1].tag]
i = i + 1
+ # resolve forward dependencies and audit normal dependencies
+ for tag, upg in Upgrader.by_tag.items():
+ for fd in upg.fwd_depends:
+ if fd not in Upgrader.by_tag:
+ print "Error: '%s' cannot (forward) depend on "\
+ "nonexistent tag '%s'" % (fd, tag)
+ sys.exit(1)
+ Upgrader.by_tag[fd].depends.append(tag)
+ for dep in upg.depends:
+ if dep not in Upgrader.by_tag:
+ print "Error: '%s' cannot depend on "\
+ "nonexistent tag '%s'" % (tag, dep)
+ sys.exit(1)
+
def process_file(path, **kwargs):
if not osp.isfile(path):
import errno