From 859596ce25bcaa9b6104f16b8b55d0832c55e3f8 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Mon, 29 Apr 2019 12:00:13 +1000 Subject: [PATCH] lib/utils: Make pyexec_file_if_exists run frozen scripts if they exist. So that boot.py and/or main.py can be frozen (either as STR or MPY) in the same way that other scripts are frozen. Frozen scripts have preference to scripts in the VFS. --- lib/utils/pyexec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 946a97a00..adb16937d 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -542,8 +542,12 @@ int pyexec_file(const char *filename) { } int pyexec_file_if_exists(const char *filename) { - mp_import_stat_t stat = mp_import_stat(filename); - if (stat != MP_IMPORT_STAT_FILE) { + #if MICROPY_MODULE_FROZEN + if (mp_frozen_stat(filename) == MP_IMPORT_STAT_FILE) { + return pyexec_frozen_module(filename); + } + #endif + if (mp_import_stat(filename) != MP_IMPORT_STAT_FILE) { return 1; // success (no file is the same as an empty file executing without fail) } return pyexec_file(filename);