Add project annotation handling to repo
Allow the optional addition of "annotation" nodes nested under
projects. Each annotation node must have "name" and "value"
attributes. These name/value pairs will be exported into the
environment during any forall command, prefixed with "REPO__"
In addition, an optional "keep" attribute with case insensitive "true"
or "false" values can be included to determine whether the annotation
will be exported with 'repo manifest'
Change-Id: Icd7540afaae02c958f769ce3d25661aa721a9de8
Signed-off-by: James W. Mills <jameswmills@gmail.com>
diff --git a/manifest_xml.py b/manifest_xml.py
index a250382..9b804da 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -203,6 +203,13 @@
if p.groups:
e.setAttribute('groups', ','.join(p.groups))
+ for a in p.annotations:
+ if a.keep == "true":
+ ae = doc.createElement('annotation')
+ ae.setAttribute('name', a.name)
+ ae.setAttribute('value', a.value)
+ e.appendChild(ae)
+
if self._repo_hooks_project:
root.appendChild(doc.createTextNode(''))
e = doc.createElement('repo-hooks')
@@ -545,6 +552,8 @@
for n in node.childNodes:
if n.nodeName == 'copyfile':
self._ParseCopyFile(project, n)
+ if n.nodeName == 'annotation':
+ self._ParseAnnotation(project, n)
return project
@@ -556,6 +565,17 @@
# dest is relative to the top of the tree
project.AddCopyFile(src, dest, os.path.join(self.topdir, dest))
+ def _ParseAnnotation(self, project, node):
+ name = self._reqatt(node, 'name')
+ value = self._reqatt(node, 'value')
+ try:
+ keep = self._reqatt(node, 'keep').lower()
+ except ManifestParseError:
+ keep = "true"
+ if keep != "true" and keep != "false":
+ raise ManifestParseError, "optional \"keep\" attribute must be \"true\" or \"false\""
+ project.AddAnnotation(name, value, keep)
+
def _get_remote(self, node):
name = node.getAttribute('remote')
if not name: