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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user