Treat spir-v.xml as utf-8 (#5306)

* Treat spir-v.xml as utf-8

Treat the input file as utf-8, and configure the XML parser to use
the utf-8 encoding.

The Chromium build was breaking when trying to parse the XML
file as ASCII.

* Use Python io.open

Try to fix the android-ndk-build flow.  It seems to be using
an old Python. For example, Python 2.6 builtin function open()
did not support the 'encoding' keyword argument.  But its io.open
method did support it.
This commit is contained in:
David Neto 2023-07-07 12:25:26 -04:00 committed by GitHub
parent 0f3bea06ef
commit e751c7e7db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,8 +15,9 @@
"""Generates the vendor tool table from the SPIR-V XML registry."""
import errno
import io
import os.path
import xml.etree.ElementTree
from xml.etree.ElementTree import XML, XMLParser, TreeBuilder
def mkdir_p(directory):
@ -78,8 +79,9 @@ def main():
help='output file for SPIR-V generators table')
args = parser.parse_args()
with open(args.xml) as xml_in:
registry = xml.etree.ElementTree.fromstring(xml_in.read())
with io.open(args.xml, encoding='utf-8') as xml_in:
parser = XMLParser(target=TreeBuilder(), encoding='utf-8')
registry = XML(xml_in.read(), parser=parser)
mkdir_p(os.path.dirname(args.generator_output))
with open(args.generator_output, 'w') as f: