summaryrefslogtreecommitdiff
path: root/mpy-cross
diff options
context:
space:
mode:
Diffstat (limited to 'mpy-cross')
-rw-r--r--mpy-cross/Makefile23
-rw-r--r--mpy-cross/main.c8
-rw-r--r--mpy-cross/mpconfigport.h3
3 files changed, 21 insertions, 13 deletions
diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile
index 3f9956620..f5b643c6c 100644
--- a/mpy-cross/Makefile
+++ b/mpy-cross/Makefile
@@ -1,3 +1,16 @@
+# The following is a temporary hack to forefully undefine vars that might have
+# be defined by a calling Makefile (from recursive make).
+# TODO: Find a better way to be able to call this Makefile recursively.
+ifneq ($(findstring undefine,$(.FEATURES)),)
+override undefine COPT
+override undefine CFLAGS_EXTRA
+override undefine LDFLAGS_EXTRA
+override undefine FROZEN_DIR
+override undefine FROZEN_MPY_DIR
+override undefine BUILD
+override undefine PROG
+endif
+
include ../py/mkenv.mk
# define main target
@@ -19,7 +32,7 @@ INC += -I$(BUILD)
# compiler settings
CWARN = -Wall -Werror
CWARN += -Wpointer-arith -Wuninitialized
-CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
+CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables
# Debugging/Optimization
@@ -49,10 +62,10 @@ SRC_C = \
main.c \
gccollect.c \
-ifeq ($(OS),Windows_NT)
- ifeq (,$(findstring MSYS,$(UNAME_S)))
- SRC_C += windows/fmode.c
- endif
+# Add fmode when compiling with mingw gcc
+COMPILER_TARGET := $(shell $(CC) -dumpmachine)
+ifneq (,$(findstring mingw,$(COMPILER_TARGET)))
+ SRC_C += windows/fmode.c
endif
OBJ = $(PY_O)
diff --git a/mpy-cross/main.c b/mpy-cross/main.c
index 378c013c8..4c88c7222 100644
--- a/mpy-cross/main.c
+++ b/mpy-cross/main.c
@@ -57,14 +57,10 @@ STATIC void stderr_print_strn(void *env, const char *str, mp_uint_t len) {
STATIC const mp_print_t mp_stderr_print = {NULL, stderr_print_strn};
STATIC int compile_and_save(const char *file, const char *output_file, const char *source_file) {
- mp_lexer_t *lex = mp_lexer_new_from_file(file);
- if (lex == NULL) {
- printf("could not open file '%s' for reading\n", file);
- return 1;
- }
-
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
+ mp_lexer_t *lex = mp_lexer_new_from_file(file);
+
qstr source_name;
if (source_file == NULL) {
source_name = lex->source_name;
diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h
index 0f7651098..e227d1be5 100644
--- a/mpy-cross/mpconfigport.h
+++ b/mpy-cross/mpconfigport.h
@@ -44,6 +44,7 @@
#define MICROPY_COMP_CONST (1)
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1)
+#define MICROPY_COMP_RETURN_IF_EXPR (1)
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
@@ -100,8 +101,6 @@ typedef int mp_int_t; // must be pointer size
typedef unsigned int mp_uint_t; // must be pointer size
#endif
-#define BYTES_PER_WORD sizeof(mp_int_t)
-
// Cannot include <sys/types.h>, as it may lead to symbol name clashes
#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
typedef long long mp_off_t;