Skip to content

Commit

Permalink
tools/mpy-tool.py: Fix build error when no qstrs present in frozen mpy.
Browse files Browse the repository at this point in the history
If you happen to only have a really simple frozen file that doesn't contain
any new qstrs then the generated frozen_mpy.c file contains an empty
enumeration which causes a C compile time error.
  • Loading branch information
dhylands authored and dpgeorge committed Dec 15, 2018
1 parent 0d165fe commit 39eef27
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tools/mpy-tool.py
Expand Up @@ -510,13 +510,14 @@ def freeze_mpy(base_qstrs, raw_codes):
print('#endif')
print()

print('enum {')
for i in range(len(new)):
if i == 0:
print(' MP_QSTR_%s = MP_QSTRnumber_of,' % new[i][1])
else:
print(' MP_QSTR_%s,' % new[i][1])
print('};')
if len(new) > 0:
print('enum {')
for i in range(len(new)):
if i == 0:
print(' MP_QSTR_%s = MP_QSTRnumber_of,' % new[i][1])
else:
print(' MP_QSTR_%s,' % new[i][1])
print('};')

# As in qstr.c, set so that the first dynamically allocated pool is twice this size; must be <= the len
qstr_pool_alloc = min(len(new), 10)
Expand Down

0 comments on commit 39eef27

Please sign in to comment.