Update teemsy/Makefile to use py.mk

I also fixed main.c to compile with the new str lexer
This commit is contained in:
Dave Hylands 2014-01-08 09:09:47 -08:00
parent ea9e441a75
commit ee0013d24e
2 changed files with 23 additions and 94 deletions

View File

@ -1,12 +1,19 @@
# define main target
all: all2
# include py core make definitions
include ../py/py.mk
# program for deletion
RM = /bin/rm
ifeq ($(ARDUINO),) ifeq ($(ARDUINO),)
$(error Please define ARDUINO (where TeensyDuino is installed)) $(error Please define ARDUINO (where TeensyDuino is installed))
endif endif
TOOLS_PATH = $(ARDUINO)/hardware/tools TOOLS_PATH = $(ARDUINO)/hardware/tools
COMPILER_PATH = $(TOOLS_PATH)/arm-none-eabi/bin COMPILER_PATH = $(TOOLS_PATH)/arm-none-eabi/bin
CORE_PATH = $(ARDUINO)/hardware/teensy/cores/teensy3 CORE_PATH = $(ARDUINO)/hardware/teensy/cores/teensy3
TARGET=TEENSY
PYSRC=../py
BUILD=build
AS = $(COMPILER_PATH)/arm-none-eabi-as AS = $(COMPILER_PATH)/arm-none-eabi-as
CC = $(COMPILER_PATH)/arm-none-eabi-gcc CC = $(COMPILER_PATH)/arm-none-eabi-gcc
@ -14,9 +21,9 @@ LD = $(COMPILER_PATH)/arm-none-eabi-ld
OBJCOPY = $(COMPILER_PATH)/arm-none-eabi-objcopy OBJCOPY = $(COMPILER_PATH)/arm-none-eabi-objcopy
SIZE = $(COMPILER_PATH)/arm-none-eabi-size SIZE = $(COMPILER_PATH)/arm-none-eabi-size
CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX256__ CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY) CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY)
CFLAGS = -I. -I$(PYSRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) CFLAGS = -I. -I$(PY_SRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) -D$(TARGET)
LDFLAGS = -nostdlib -T mk20dx256.ld LDFLAGS = -nostdlib -T mk20dx256.ld
LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc
@ -36,55 +43,6 @@ STM_SRC_C = \
STM_SRC_S = \ STM_SRC_S = \
gchelper.s \ gchelper.s \
PY_O = \
nlrthumb.o \
gc.o \
malloc.o \
qstr.o \
vstr.o \
unicode.o \
lexer.o \
lexerstr.o \
parse.o \
scope.o \
compile.o \
emitcommon.o \
emitpass1.o \
emitbc.o \
asmthumb.o \
emitnthumb.o \
emitinlinethumb.o \
runtime.o \
map.o \
obj.o \
objbool.o \
objboundmeth.o \
objcell.o \
objclass.o \
objclosure.o \
objcomplex.o \
objdict.o \
objexcept.o \
objfloat.o \
objfun.o \
objgenerator.o \
objinstance.o \
objint.o \
objlist.o \
objmodule.o \
objnone.o \
objrange.o \
objset.o \
objslice.o \
objstr.o \
objtuple.o \
objtype.o \
builtin.o \
builtinimport.o \
vm.o \
showbc.o \
repl.o \
SRC_TEENSY = \ SRC_TEENSY = \
mk20dx128.c \ mk20dx128.c \
pins_teensy.c \ pins_teensy.c \
@ -95,36 +53,29 @@ SRC_TEENSY = \
usb_serial.c \ usb_serial.c \
yield.c \ yield.c \
STM_SRC_C_OBJ = $(STM_SRC_C:.c=.o) OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C:.c=.o) $(STM_SRC_S:.s=.o) $(SRC_TEENSY:.c=.o)) $(PY_O)
STM_SRC_S_OBJ = $(STM_SRC_S:.s=.o)
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C_OBJ) $(STM_SRC_S_OBJ) $(PY_O) $(SRC_TEENSY:.c=.o))
#LIB = -lreadline #LIB = -lreadline
# the following is needed for BSD # the following is needed for BSD
#LIB += -ltermcap #LIB += -ltermcap
PROG = micropython
all: hex all2: $(BUILD) hex
hex: $(PROG).hex hex: $(BUILD)/flash.hex
post_compile: $(PROG).hex post_compile: $(BUILD)/flash.hex
$(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)" -path="$(CURDIR)" -tools="$(TOOLS_PATH)" $(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)" -path="$(BUILD)" -tools="$(TOOLS_PATH)"
reboot: reboot:
-$(TOOLS_PATH)/teensy_reboot -$(TOOLS_PATH)/teensy_reboot
upload: post_compile reboot upload: post_compile reboot
$(PROG).elf: $(BUILD) $(OBJ) $(BUILD)/flash.elf: $(OBJ)
$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(PROG).map $(OBJ) $(LIBS) $(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(@:.elf=.map) $(OBJ) $(LIBS)
$(SIZE) $@
%.hex: %.elf $(BUILD)/%.hex: $(BUILD)/%.elf
$(SIZE) "$<"
$(OBJCOPY) -O ihex -R .eeprom "$<" "$@" $(OBJCOPY) -O ihex -R .eeprom "$<" "$@"
$(BUILD):
mkdir -p $@
$(BUILD)/%.o: %.c $(BUILD)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<
@ -134,33 +85,12 @@ $(BUILD)/%.o: ../stm/%.s
$(BUILD)/%.o: ../stm/%.c $(BUILD)/%.o: ../stm/%.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(PYSRC)/%.S
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(PYSRC)/%.c mpconfigport.h
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(CORE_PATH)/%.c $(BUILD)/%.o: $(CORE_PATH)/%.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
# optimising gc for speed; 5ms down to 4ms
$(BUILD)/gc.o: $(PYSRC)/gc.c
$(CC) $(CFLAGS) -O3 -c -o $@ $<
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(BUILD)/vm.o: $(PYSRC)/vm.c
$(CC) $(CFLAGS) -O3 -c -o $@ $<
$(BUILD)/main.o: mpconfigport.h $(BUILD)/main.o: mpconfigport.h
$(BUILD)/parse.o: $(PYSRC)/grammar.h
$(BUILD)/compile.o: $(PYSRC)/grammar.h
$(BUILD)/emitbc.o: $(PYSRC)/emit.h
clean: clean:
/bin/rm -rf $(BUILD) /bin/rm -rf $(BUILD)
/bin/rm -f $(PROG).elf $(PROG).hex $(PROG).map
.PHONY: clean .PHONY: all all2 clean

View File

@ -347,8 +347,7 @@ void do_repl(void) {
} }
} }
mp_lexer_str_buf_t sb; mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", vstr_str(&line), vstr_len(&line), 0);
mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", vstr_str(&line), vstr_len(&line), false, &sb);
mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT); mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT);
mp_lexer_free(lex); mp_lexer_free(lex);