10000 lib/utils: Make pyexec_file_if_exists run frozen scripts if they exist. · micropython/micropython@859596c · GitHub
[go: up one dir, main page]

Skip to content

Commit 859596c

Browse files
pi-anldpgeorge
authored andcommitted
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.
1 parent 7b54001 commit 859596c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/utils/pyexec.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,12 @@ int pyexec_file(const char *filename) {
542542
}
543543

544544
int pyexec_file_if_exists(const char *filename) {
545-
mp_import_stat_t stat = mp_import_stat(filename);
546-
if (stat != MP_IMPORT_STAT_FILE) {
545+
#if MICROPY_MODULE_FROZEN
546+
if (mp_frozen_stat(filename) == MP_IMPORT_STAT_FILE) {
547+
return pyexec_frozen_module(filename);
548+
}
549+
#endif
550+
if (mp_import_stat(filename) != MP_IMPORT_STAT_FILE) {
547551
return 1; // success (no file is the same as an empty file executing without fail)
548552
}
549553
return pyexec_file(filename);

0 commit comments

Comments
 (0)
0