intel/genxml: Add support for excluding items when importing

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20593>
This commit is contained in:
Jordan Justen
2022-12-26 02:52:53 -08:00
parent 6cc21dc8b5
commit b076b4f99b
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -486,7 +486,7 @@ class Parser(object):
self.prefix = None
elif name == "value":
self.values.append(Value(attrs))
elif name == "import":
elif name in ("import", "exclude"):
pass
else:
assert False
@@ -514,7 +514,7 @@ class Parser(object):
elif name == "enum":
self.emit_enum()
self.enum = None
elif name in ("import", "value"):
elif name in ("import", "exclude", "value"):
pass
else:
assert False
+7
View File
@@ -86,6 +86,7 @@ class Struct(object):
GENXML_DESC = {
'genxml' : [ 'name', 'gen', ],
'import' : [ 'name', ],
'exclude' : [ 'name', ],
'enum' : [ 'name', 'value', 'prefix', ],
'struct' : [ 'name', 'length', ],
'field' : [ 'name', 'start', 'end', 'type', 'default', 'prefix', 'nonzero' ],
@@ -224,6 +225,10 @@ class GenXml(object):
if item.tag == 'import':
assert 'name' in item.attrib
filename = os.path.split(item.attrib['name'])
exceptions = set()
for e in item:
assert e.tag == 'exclude'
exceptions.add(e.attrib['name'])
# We should be careful to restrict loaded files to
# those under the source or build trees. For now, only
# allow siblings of the current xml file.
@@ -250,6 +255,8 @@ class GenXml(object):
for i in imported_elements:
if i.tag not in orig_by_tag:
continue
if i.attrib['name'] in exceptions:
continue
if i.attrib['name'] in orig_by_tag[i.tag]:
# An item with this same name was defined in
# the genxml directly. There we should ignore