[libcalamares] Also output size of locale-tables

This commit is contained in:
Adriaan de Groot 2019-05-10 12:41:35 +02:00
parent bf5ce44bd1
commit 07a9052fca

View File

@ -251,7 +251,6 @@ def make_identifier(classname):
else:
identifier.append(c)
identifier.append("_table")
return "".join(identifier)
@ -260,17 +259,27 @@ def export_class(cls, data):
Given a @p cls and a list of @p data objects from that class,
print (to stdout) a C++ file for that data.
"""
identifier = make_identifier(cls.cpp_classname)
with open("{!s}_p.cpp".format(cls.cpp_classname), "wt", encoding="UTF-8") as f:
f.write(cpp_header_comment)
f.write(cls.cpp_declaration)
f.write("\nstatic const {!s} {!s}[] = {!s}\n".format(
f.write("\nstatic constexpr int const {!s}_size = {!s};\n".format(
identifier,
len(data)))
f.write("\nstatic const {!s} {!s}_table[] = {!s}\n".format(
cls.cpp_classname,
make_identifier(cls.cpp_classname),
identifier,
"{"))
for d in data:
f.write(str(d))
f.write("\n")
f.write("};\n\n");
f.write("static_assert( (sizeof({!s}_table) / sizeof({!s})) == {!s}_size, \"Table size mismatch for {!s}\" );\n\n".format(
identifier,
cls.cpp_classname,
identifier,
cls.cpp_classname))
f.write(cpp_footer_comment)