amd: Work around MSVC limit for string literals

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7791>
This commit is contained in:
James Park
2020-11-26 20:43:29 -08:00
parent 7404907870
commit 7c521e9968

View File

@@ -40,6 +40,10 @@ sys.path.append(AMD_REGISTERS)
from regdb import Object, RegisterDatabase
def string_to_chars(string):
return "'" + "', '".join(string) + "', '\\0',"
class StringTable:
"""
A class for collecting multiple strings in a single larger string that is
@@ -70,13 +74,14 @@ class StringTable:
to filp.
"""
fragments = [
'"%s\\0" /* %s */' % (
'%s /* %s (%s) */' % (
string_to_chars(te[0].encode('unicode_escape').decode()),
te[0].encode('unicode_escape').decode(),
', '.join(str(idx) for idx in sorted(te[2]))
)
for te in self.table
]
filp.write('%sconst char %s[] =\n%s;\n' % (
filp.write('%sconst char %s[] = {\n%s\n};\n' % (
'static ' if static else '',
name,
'\n'.join('\t' + fragment for fragment in fragments)