diff options
| author | stijn <stijn@ignitron.net> | 2016-07-22 11:54:26 +0200 |
|---|---|---|
| committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-07-22 21:21:54 +0300 |
| commit | 9bdb82ef6b3147662ffc6b6435c6bd376c60e19e (patch) | |
| tree | 71dae7119d4a6e0602b7b89f9c90781486d2e1f6 /mpy-cross/main.c | |
| parent | 43473372e6baa105e9facf13925f5eb750112e61 (diff) | |
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().
Diffstat (limited to 'mpy-cross/main.c')
| -rw-r--r-- | mpy-cross/main.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c index 4393d00ff..5e5bc7330 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -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); |
