Skip to content

Commit 0ae21a8

Browse files
committed
Merge branch 'master' of github.com:micropython/micropython
2 parents 3771a09 + 521de04 commit 0ae21a8

9 files changed

Lines changed: 59 additions & 10 deletions

File tree

py/builtinimport.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#include <stdio.h>
44
#include <string.h>
55
#include <assert.h>
6+
#ifdef __MINGW32__
7+
// For alloca()
8+
#include <malloc.h>
9+
#endif
610

711
#include "nlr.h"
812
#include "misc.h"

py/nlrx86.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ nlr_jump:
6161
#endif
6262
mov nlr_top, %edx # load nlr_top
6363
test %edx, %edx # check for nlr_top being NULL
64+
#ifdef _WIN32
65+
je _nlr_jump_fail # fail if nlr_top is NULL
66+
#else
6467
je nlr_jump_fail # fail if nlr_top is NULL
68+
#endif
6569
mov 4(%esp), %eax # load return value
6670
mov %eax, 4(%edx) # store return value
6771
mov (%edx), %eax # load prev nlr_top

py/objfun.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include <stdlib.h>
33
#include <string.h>
44
#include <assert.h>
5+
#ifdef __MINGW32__
6+
// For alloca()
7+
#include <malloc.h>
8+
#endif
59

610
#include "nlr.h"
711
#include "misc.h"

unix/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <stdio.h>
12
#include <unistd.h>
23
#include <fcntl.h>
34
#include <errno.h>

unix/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ int usage(char **argv) {
250250

251251
mp_obj_t mem_info(void) {
252252
printf("mem: total=%d, current=%d, peak=%d\n", m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
253+
#if MICROPY_ENABLE_GC
253254
gc_dump_info();
255+
#endif
254256
return mp_const_none;
255257
}
256258

@@ -392,7 +394,11 @@ int main(int argc, char **argv) {
392394
return usage(argv);
393395
}
394396
} else {
397+
#ifdef __MINGW32__
398+
char *basedir = _fullpath(NULL, argv[a], _MAX_PATH);
399+
#else
395400
char *basedir = realpath(argv[a], NULL);
401+
#endif
396402
if (basedir == NULL) {
397403
fprintf(stderr, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[1], errno);
398404
perror("");

windows/Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include ../py/mkenv.mk
2+
-include mpconfigport.mk
23

34
# define main target
45
PROG = micropython.exe
@@ -14,14 +15,15 @@ INC += -I$(PY_SRC)
1415
INC += -I$(BUILD)
1516

1617
# compiler settings
17-
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
18-
LDFLAGS = -lm
18+
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
19+
LDFLAGS = $(LDFLAGS_MOD) -lm
1920

2021
# Debugging/Optimization
2122
ifdef DEBUG
22-
CFLAGS += -O0 -g
23+
CFLAGS += -g
24+
COPT = -O0
2325
else
24-
CFLAGS += -Os #-DNDEBUG
26+
COPT = -Os #-DNDEBUG
2527
endif
2628

2729
# source files
@@ -30,11 +32,16 @@ SRC_C = \
3032
unix/file.c \
3133

3234
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
33-
LIB = -lreadline
34-
LIB += -lws2_32
35-
LIB += -lmman
35+
36+
ifeq ($(MICROPY_USE_READLINE),1)
37+
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
38+
LDFLAGS_MOD += -lreadline
3639
# the following is needed for BSD
37-
#LIB += -ltermcap
40+
#LDFLAGS_MOD += -ltermcap
41+
endif
42+
43+
LIB += -lws2_32
44+
#LIB += -lmman
3845

3946
include ../py/mkrules.mk
4047

windows/README

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This is experimental, community-supported Windows port of MicroPython.
2+
It is based on Unix port, and expected to remain so.
3+
4+
To cross-compile under Debian/Ubuntu Linux system:
5+
6+
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
7+
make CC=i586-mingw32msvc-gcc
8+
9+
The port requires additional testing, debugging, and patches. Please
10+
consider to contribute.

windows/mpconfigport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// Linking with GNU readline causes binary to be licensed under GPL
44
#ifndef MICROPY_USE_READLINE
5-
#define MICROPY_USE_READLINE (1)
5+
#define MICROPY_USE_READLINE (0)
66
#endif
77

8-
#define MICROPY_EMIT_X64 (1)
8+
#define MICROPY_EMIT_X64 (0)
99
#define MICROPY_EMIT_THUMB (0)
1010
#define MICROPY_EMIT_INLINE_THUMB (0)
1111
#define MICROPY_MEM_STATS (1)

windows/mpconfigport.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Enable/disable modules and 3rd-party libs to be included in interpreter
2+
3+
# Build 32-bit binaries on a 64-bit host
4+
MICROPY_FORCE_32BIT = 0
5+
6+
# Linking with GNU readline causes binary to be licensed under GPL
7+
MICROPY_USE_READLINE = 0
8+
9+
# Subset of CPython time module
10+
MICROPY_MOD_TIME = 1
11+
12+
# ffi module requires libffi (libffi-dev Debian package)
13+
MICROPY_MOD_FFI = 0

0 commit comments

Comments
 (0)