diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2019-04-29 12:00:13 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-05-01 11:27:51 +1000 |
commit | 859596ce25bcaa9b6104f16b8b55d0832c55e3f8 (patch) | |
tree | 0103d2f646ad9b42c7b32bac75f531cdb42cb863 /lib | |
parent | 7b5400134b6d121741234cc99313145c0edf28c2 (diff) | |
download | micropython-859596ce25bcaa9b6104f16b8b55d0832c55e3f8.tar.gz micropython-859596ce25bcaa9b6104f16b8b55d0832c55e3f8.zip |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/pyexec.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 946a97a00a..adb16937d0 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); |