freezing an .mpy with mpy-cross -s suffix = *.mpy results in frozen_mpy.c having a DOT prepended to "__lt_module_gt_"
- Create empty
main.py "../../mpy-cross/mpy-cross.exe" -o main.mpy -s main.**mpy** main.py
Note the-sparam suffix is .mpy, not the to-be-expected .pypython "../../tools/mpy-tool.py" -f -q build\genhdr\qstrdefs.preprocessed.h main.mpy > frozen_mpy.c
will result in a dot placed where it shouldn't be i.e. search for.__lt_module_gt_in the belowfrozen_mpy.c(it's in 4 places)
I understand you'd want to have -s with .py usually and I wasn't trying to break mpy-cross. If for some reason mpy-cross -s *.mpy isn't allowed because it unnecessarily increases difficulty in mpy-tool, then mpy-cross should err out and simply not produce an .mpy
But the idea place to fix this is in mpy-tool.py.
#include "py/mpconfig.h"
#include "py/objint.h"
#include "py/objstr.h"
#include "py/emitglue.h"
#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != 0
#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"
#endif
#if MICROPY_LONGINT_IMPL != 2
#error "incompatible MICROPY_LONGINT_IMPL"
#endif
#if MPZ_DIG_SIZE != 16
#error "incompatible MPZ_DIG_SIZE"
#endif
#if MICROPY_PY_BUILTINS_FLOAT
typedef struct _mp_obj_float_t {
mp_obj_base_t base;
mp_float_t value;
} mp_obj_float_t;
#endif
#if MICROPY_PY_BUILTINS_COMPLEX
typedef struct _mp_obj_complex_t {
mp_obj_base_t base;
mp_float_t real;
mp_float_t imag;
} mp_obj_complex_t;
#endif
enum {
MP_QSTR_main_dot_mpy = MP_QSTRnumber_of,
};
extern const qstr_pool_t mp_qstr_const_pool;
const qstr_pool_t mp_qstr_frozen_const_pool = {
(qstr_pool_t*)&mp_qstr_const_pool, // previous pool
MP_QSTRnumber_of, // previous pool size
1, // allocated entries
1, // used entries
{
(const byte*)"\xc4\x08" "main.mpy",
},
};
// frozen bytecode for file main.mpy, scope main._<module>
STATIC const byte bytecode_data_main.__lt_module_gt_[16] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
MP_QSTR__lt_module_gt_ & 0xff, MP_QSTR__lt_module_gt_ >> 8,
MP_QSTR_main_dot_mpy & 0xff, MP_QSTR_main_dot_mpy >> 8,
0x00, 0x00, 0xff,
0x11,
0x5b,
};
const mp_raw_code_t raw_code_main.__lt_module_gt_ = {
.kind = MP_CODE_BYTECODE,
.scope_flags = 0x00,
.n_pos_args = 0,
.data.u_byte = {
.bytecode = bytecode_data_main.__lt_module_gt_,
.const_table = NULL,
#if MICROPY_PERSISTENT_CODE_SAVE
.bc_len = 16,
.n_obj = 0,
.n_raw_code = 0,
#endif
},
};
const char mp_frozen_mpy_names[] = {
"main.mpy\0"
"\0"};
const mp_raw_code_t *const mp_frozen_mpy_content[] = {
&raw_code_main.__lt_module_gt_,
};
mpy-cross: Build process broken.
Since the update of mpy-cross with v1.18-155 I get compile errors in the generated frozen-content.c file. See the dump below. The file contains indeed syntax errors. The build target does not matter. mpy-cross is fresh built.
The file that cannot be frozen is pye.py https://github.com/robert-hh/Micropython-Editor/blob/master/pye.py
It contains some escape sequences. A short excerpt from this file which provokes an error:
oops = "\n\x1b["
build-TEENSY40/frozen_content.c:4341:1: error: stray '\33' in program
4341 | [
| ^
build-TEENSY40/frozen_content.c:4342:9: error: expected ']' before ',' token
4342 | 0x16,0x03, // STORE_NAME oops
| ^
| ]
build-TEENSY40/frozen_content.c:4345:1: error: expected expression before '}' token
4345 | };
| ^
build-TEENSY40/frozen_content.c:4394:12: error: 'raw_code_tipp_over__lt_module_gt_' undeclared here (not in a function); did you mean 'fun_data_tipp_over__lt_module_gt_'?
4394 | .rc = &raw_code_tipp_over__lt_module_gt_,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| fun_data_tipp_over__lt_module_gt_
build-TEENSY40/frozen_content.c:4336:19: error: 'fun_data_tipp_over__lt_module_gt_' defined but not used [-Werror=unused-const-variable=]
4336 | static const byte fun_data_tipp_over__lt_module_gt_[9] = {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [../../py/mkrules.mk:77: build-TEENSY40/build-TEENSY40/frozen_content.o] Fehler 1