summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-21 01:18:05 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-21 01:18:05 +0100
commit0ae21a81f70806afc6f96fe099083bc8273ab34c (patch)
treec8e4680b545c720ca28e6a142702ef2f5909f5d7
parent3771a097dac8baaf6dc8a9618dc8a1074a43c439 (diff)
parent521de04ce2dc7048afbdb2445979a203512b13e2 (diff)
downloadmicropython-0ae21a81f70806afc6f96fe099083bc8273ab34c.tar.gz
micropython-0ae21a81f70806afc6f96fe099083bc8273ab34c.zip
Merge branch 'master' of github.com:micropython/micropython
-rw-r--r--py/builtinimport.c4
-rw-r--r--py/nlrx86.S4
-rw-r--r--py/objfun.c4
-rw-r--r--unix/file.c1
-rw-r--r--unix/main.c6
-rw-r--r--windows/Makefile23
-rw-r--r--windows/README10
-rw-r--r--windows/mpconfigport.h4
-rw-r--r--windows/mpconfigport.mk13
9 files changed, 59 insertions, 10 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 262ee04a53..4a2f6510c3 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -3,6 +3,10 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#ifdef __MINGW32__
+// For alloca()
+#include <malloc.h>
+#endif
#include "nlr.h"
#include "misc.h"
diff --git a/py/nlrx86.S b/py/nlrx86.S
index 003de5095f..145bdb9da0 100644
--- a/py/nlrx86.S
+++ b/py/nlrx86.S
@@ -61,7 +61,11 @@ nlr_jump:
#endif
mov nlr_top, %edx # load nlr_top
test %edx, %edx # check for nlr_top being NULL
+#ifdef _WIN32
+ je _nlr_jump_fail # fail if nlr_top is NULL
+#else
je nlr_jump_fail # fail if nlr_top is NULL
+#endif
mov 4(%esp), %eax # load return value
mov %eax, 4(%edx) # store return value
mov (%edx), %eax # load prev nlr_top
diff --git a/py/objfun.c b/py/objfun.c
index c7144f3078..940b64a66e 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -2,6 +2,10 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#ifdef __MINGW32__
+// For alloca()
+#include <malloc.h>
+#endif
#include "nlr.h"
#include "misc.h"
diff --git a/unix/file.c b/unix/file.c
index a0a865a263..5bda34013f 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
diff --git a/unix/main.c b/unix/main.c
index 940fe48c14..4c86edeae5 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -250,7 +250,9 @@ int usage(char **argv) {
mp_obj_t mem_info(void) {
printf("mem: total=%d, current=%d, peak=%d\n", m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
+#if MICROPY_ENABLE_GC
gc_dump_info();
+#endif
return mp_const_none;
}
@@ -392,7 +394,11 @@ int main(int argc, char **argv) {
return usage(argv);
}
} else {
+#ifdef __MINGW32__
+ char *basedir = _fullpath(NULL, argv[a], _MAX_PATH);
+#else
char *basedir = realpath(argv[a], NULL);
+#endif
if (basedir == NULL) {
fprintf(stderr, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[1], errno);
perror("");
diff --git a/windows/Makefile b/windows/Makefile
index 651de7c7f1..2f5418886f 100644
--- a/windows/Makefile
+++ b/windows/Makefile
@@ -1,4 +1,5 @@
include ../py/mkenv.mk
+-include mpconfigport.mk
# define main target
PROG = micropython.exe
@@ -14,14 +15,15 @@ INC += -I$(PY_SRC)
INC += -I$(BUILD)
# compiler settings
-CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
-LDFLAGS = -lm
+CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
+LDFLAGS = $(LDFLAGS_MOD) -lm
# Debugging/Optimization
ifdef DEBUG
-CFLAGS += -O0 -g
+CFLAGS += -g
+COPT = -O0
else
-CFLAGS += -Os #-DNDEBUG
+COPT = -Os #-DNDEBUG
endif
# source files
@@ -30,11 +32,16 @@ SRC_C = \
unix/file.c \
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
-LIB = -lreadline
-LIB += -lws2_32
-LIB += -lmman
+
+ifeq ($(MICROPY_USE_READLINE),1)
+CFLAGS_MOD += -DMICROPY_USE_READLINE=1
+LDFLAGS_MOD += -lreadline
# the following is needed for BSD
-#LIB += -ltermcap
+#LDFLAGS_MOD += -ltermcap
+endif
+
+LIB += -lws2_32
+#LIB += -lmman
include ../py/mkrules.mk
diff --git a/windows/README b/windows/README
new file mode 100644
index 0000000000..615ada2012
--- /dev/null
+++ b/windows/README
@@ -0,0 +1,10 @@
+This is experimental, community-supported Windows port of MicroPython.
+It is based on Unix port, and expected to remain so.
+
+To cross-compile under Debian/Ubuntu Linux system:
+
+sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
+make CC=i586-mingw32msvc-gcc
+
+The port requires additional testing, debugging, and patches. Please
+consider to contribute.
diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h
index 74fe749e1e..993fef9d59 100644
--- a/windows/mpconfigport.h
+++ b/windows/mpconfigport.h
@@ -2,10 +2,10 @@
// Linking with GNU readline causes binary to be licensed under GPL
#ifndef MICROPY_USE_READLINE
-#define MICROPY_USE_READLINE (1)
+#define MICROPY_USE_READLINE (0)
#endif
-#define MICROPY_EMIT_X64 (1)
+#define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (1)
diff --git a/windows/mpconfigport.mk b/windows/mpconfigport.mk
new file mode 100644
index 0000000000..458f23dd1e
--- /dev/null
+++ b/windows/mpconfigport.mk
@@ -0,0 +1,13 @@
+# Enable/disable modules and 3rd-party libs to be included in interpreter
+
+# Build 32-bit binaries on a 64-bit host
+MICROPY_FORCE_32BIT = 0
+
+# Linking with GNU readline causes binary to be licensed under GPL
+MICROPY_USE_READLINE = 0
+
+# Subset of CPython time module
+MICROPY_MOD_TIME = 1
+
+# ffi module requires libffi (libffi-dev Debian package)
+MICROPY_MOD_FFI = 0