py: Remove calls to file reader functions when these are disabled.

If MICROPY_PERSISTENT_CODE_LOAD or MICROPY_ENABLE_COMPILER are enabled then
code gets enabled that calls file reading functions which may be disabled
if no readers have been implemented.

To fix this, introduce a MICROPY_HAS_FILE_READER variable, which is
automatically set if MICROPY_READER_POSIX or MICROPY_READER_VFS is set but
can also be manually set if a custom reader is being implemented.  Then
disable the file reading calls if this is not set.
This commit is contained in:
Sean Burton
2018-12-13 12:10:35 +00:00
committed by Damien George
parent 35687a87ec
commit e33bc59712
3 changed files with 12 additions and 4 deletions

View File

@@ -232,12 +232,16 @@ mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len) {
return mp_raw_code_load(&reader);
}
#if MICROPY_HAS_FILE_READER
mp_raw_code_t *mp_raw_code_load_file(const char *filename) {
mp_reader_t reader;
mp_reader_new_file(&reader, filename);
return mp_raw_code_load(&reader);
}
#endif // MICROPY_HAS_FILE_READER
#endif // MICROPY_PERSISTENT_CODE_LOAD
#if MICROPY_PERSISTENT_CODE_SAVE