mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
shared/runtime/pyexec: Provide support for compile-only mode.
When `MICROPY_PYEXEC_COMPILE_ONLY` is enabled and the global `mp_compile_only` is True, code is compiled but not executed. Also add comprehensive tests for compile-only functionality covering both successful compilation and syntax error detection. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This commit is contained in:
committed by
Damien George
parent
3b2b8dd538
commit
7b3a0fc6b7
@@ -130,7 +130,12 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
|
||||
#if MICROPY_REPL_INFO
|
||||
start = mp_hal_ticks_ms();
|
||||
#endif
|
||||
mp_call_function_0(module_fun);
|
||||
#if MICROPY_PYEXEC_COMPILE_ONLY
|
||||
if (!mp_compile_only)
|
||||
#endif
|
||||
{
|
||||
mp_call_function_0(module_fun);
|
||||
}
|
||||
mp_hal_set_interrupt_char(-1); // disable interrupt
|
||||
mp_handle_pending(true); // handle any pending exceptions (and any callbacks)
|
||||
nlr_pop();
|
||||
@@ -706,6 +711,7 @@ int pyexec_file(const char *filename) {
|
||||
return parse_compile_execute(filename, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_FILENAME);
|
||||
}
|
||||
|
||||
|
||||
int pyexec_file_if_exists(const char *filename) {
|
||||
#if MICROPY_MODULE_FROZEN
|
||||
if (mp_find_frozen_module(filename, NULL, NULL) == MP_IMPORT_STAT_FILE) {
|
||||
|
||||
Reference in New Issue
Block a user