8000 tools/mpy-tool.py: Fix build error when no qstrs present in frozen mpy. · msuszko/micropython@39eef27 · GitHub
[go: up one dir, main page]

Skip to content

Commit 39eef27

Browse files
dhylandsdpgeorge
authored andcommitted
tools/mpy-tool.py: Fix build error when no qstrs present in frozen mpy.
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.
1 parent 0d165fe commit 39eef27

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tools/mpy-tool.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,14 @@ def freeze_mpy(base_qstrs, raw_codes):
510510
print('#endif')
511511
print()
512512

513-
print('enum {')
514-
for i in range(len(new)):
515-
if i == 0:
516-
print(' MP_QSTR_%s = MP_QSTRnumber_of,' % new[i][1])
517-
else:
518-
print(' MP_QSTR_%s,' % new[i][1])
519-
print('};')
513+
if len(new) > 0:
514+
print('enum {')
515+
for i in range(len(new)):
516+
if i == 0:
517+
print(' MP_QSTR_%s = MP_QSTRnumber_of,' % new[i][1])
518+
else:
519+
print(' MP_QSTR_%s,' % new[i][1])
520+
print('};')
520521

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

0 commit comments

Comments
 (0)
0