Also place payload lengths in the header... not known at compile time

This commit is contained in:
2020-01-12 17:14:21 -05:00
parent 37c11da469
commit c94c776a61
4 changed files with 20 additions and 5 deletions

View File

@@ -21,13 +21,21 @@ if __name__ == '__main__':
'#define CHECKM8_TOOL_LIBPAYLOAD_H\n',
'\n']
name_lines = []
size_lines = []
for n in lib_names:
with open(n, 'r') as f:
line = f.readline() # looks like "const unsigned char PAYLOAD_NAME[PAYLOAD_SIZE] = "
name = line.split(' ')[3].split('[')[0]
size = line.split(' ')[3].split('[')[1][:-1]
header_lines.append('extern const unsigned char %s[%s];\n' % (name, size))
name_lines.append('extern const unsigned char %s[%s_SZ];\n' % (name, name.upper()))
size_lines.append('#define %s_SZ %s\n' % (name.upper(), size))
header_lines.extend(size_lines)
header_lines.append('\n')
header_lines.extend(name_lines)
header_lines.append('\n')
header_lines.append('#endif //CHECKM8_TOOL_LIBPAYLOAD_H\n')