Skip to content

Commit 99b4719

Browse files
committed
tools/mpy-tool.py: Add checks for critical configuration vars.
When an mpy file is frozen it must know the values of certain configuration variables. This patch provides an explicit check in the generated C file that the configuration variables are what they are supposed to be.
1 parent 21ec1fd commit 99b4719

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tools/mpy-tool.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,23 @@ def freeze_mpy(qcfgs, base_qstrs, raw_codes):
450450
print('#include "py/emitglue.h"')
451451
print()
452452

453+
print('#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE')
454+
print('#error "MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE not supported with frozen mpy files"')
455+
print('#endif')
456+
print()
457+
458+
print('#if MICROPY_LONGINT_IMPL != %u' % config.MICROPY_LONGINT_IMPL)
459+
print('#error "incompatible MICROPY_LONGINT_IMPL"')
460+
print('#endif')
461+
print()
462+
463+
if config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_MPZ:
464+
print('#if MPZ_DIG_SIZE != %u' % config.MPZ_DIG_SIZE)
465+
print('#error "incompatible MPZ_DIG_SIZE"')
466+
print('#endif')
467+
print()
468+
469+
453470
print('#if MICROPY_PY_BUILTINS_FLOAT')
454471
print('typedef struct _mp_obj_float_t {')
455472
print(' mp_obj_base_t base;')

0 commit comments

Comments
 (0)