diff options
| author | Dave Hylands | 2018-12-11 14:55:26 -0800 |
|---|---|---|
| committer | Damien George | 2018-12-15 14:36:08 +1100 |
| commit | 39eef270831323b77445e0458c9357d38e23658a (patch) | |
| tree | 4c9db7b72274321154aa80305c9085c19c7ab359 | |
| parent | 0d165fec9c61f009cea589eeca7febb1c3b1cbfe (diff) | |
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.
| -rwxr-xr-x | tools/mpy-tool.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 5b63e33c4..6fbb10a39 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -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) |
