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.
pull/1/head
Andrew Leech 2019-04-29 12:00:13 +10:00 committed by Damien George
parent 7b5400134b
commit 859596ce25
1 changed files with 6 additions and 2 deletions

View File

@ -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);