mpy-cross: Use binary file translation mode for creating mpy files on windows
This is a fix for https://github.com/micropython/micropython/issues/2209: by default a file created using open() uses text translation mode so writing \n to it will result in the file having \r\n. This is obviously problematic for binary .mpy files, so provide functions for setting the open mode and use binary mode in mpy-cross' main().
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/stackctrl.h"
|
||||
#ifdef _WIN32
|
||||
#include "windows/fmode.h"
|
||||
#endif
|
||||
|
||||
// Command line options, with their defaults
|
||||
STATIC uint emit_opt = MP_EMIT_OPT_NONE;
|
||||
@@ -185,6 +188,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
gc_init(heap, heap + heap_size);
|
||||
|
||||
mp_init();
|
||||
#ifdef _WIN32
|
||||
set_fmode_binary();
|
||||
#endif
|
||||
mp_obj_list_init(mp_sys_path, 0);
|
||||
mp_obj_list_init(mp_sys_argv, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user