aboutsummaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2017-08-15 16:34:20 -0700
committerChad Versace <[email protected]>2017-09-18 14:26:54 -0700
commit7f57e58e2777c0e2c82cdf8de49d9cfa1ac9e6b1 (patch)
treef3b1afc88803894ddf0e63c5d7c844c1494cf6d8 /src/vulkan
parent7554fa266a87d84d914683a649ad50a654c19ab0 (diff)
vulkan/util: Teach gen_enum_to_str.py to parse mutliple XML files
To give the script multiple XML files, call it like so: gen_enum_to_str.py --xml a.xml --xml b.xml --xml c.xml ... The script parses the XML files in the given order. This will allow us to feed the script XML files for extensions that are missing from the official vk.xml, such as VK_ANDROID_native_buffer. Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/util/gen_enum_to_str.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index ef37972c20d..bc72c189943 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -121,13 +121,12 @@ class VkEnum(object):
self.values = values or []
-def xml_parser(filename):
- """Parse the XML file and return parsed data.
+def parse_xml(efactory, filename):
+ """Parse the XML file. Accumulate results into the efactory.
This parser is a memory efficient iterative XML parser that returns a list
of VkEnum objects.
"""
- efactory = EnumFactory(VkEnum)
with open(filename, 'rb') as f:
context = iter(et.iterparse(f, events=('start', 'end')))
@@ -153,25 +152,29 @@ def xml_parser(filename):
root.clear()
- return efactory.registry.values()
-
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('--xml', help='Vulkan API XML file.', required=True)
+ parser.add_argument('--xml', required=True,
+ help='Vulkan API XML files',
+ action='append',
+ dest='xml_files')
parser.add_argument('--outdir',
help='Directory to put the generated files in',
required=True)
args = parser.parse_args()
- enums = xml_parser(args.xml)
+ efactory = EnumFactory(VkEnum)
+ for filename in args.xml_files:
+ parse_xml(efactory, filename)
+
for template, file_ in [(C_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.c')),
(H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h'))]:
with open(file_, 'wb') as f:
f.write(template.render(
file=os.path.basename(__file__),
- enums=enums,
+ enums=efactory.registry.values(),
copyright=COPYRIGHT))