Factor and simplify Makefile's and mpconfig, part 2.
This commit is contained in:
parent
136f67523b
commit
d3ebe4829d
|
@ -1,16 +1,18 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "asmx64.h"
|
|
||||||
#include "mpconfig.h"
|
#include "mpconfig.h"
|
||||||
|
|
||||||
// wrapper around everything in this file
|
// wrapper around everything in this file
|
||||||
#if MICROPY_EMIT_X64
|
#if MICROPY_EMIT_X64
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include "asmx64.h"
|
||||||
|
|
||||||
#if defined(__OpenBSD__) || defined(__MACH__)
|
#if defined(__OpenBSD__) || defined(__MACH__)
|
||||||
#define MAP_ANONYMOUS MAP_ANON
|
#define MAP_ANONYMOUS MAP_ANON
|
||||||
#endif
|
#endif
|
||||||
|
|
4
py/gc.c
4
py/gc.c
|
@ -6,6 +6,8 @@
|
||||||
#include "mpconfig.h"
|
#include "mpconfig.h"
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
|
|
||||||
|
#if MICROPY_ENABLE_GC
|
||||||
|
|
||||||
// a machine word is big enough to hold a pointer
|
// a machine word is big enough to hold a pointer
|
||||||
/*
|
/*
|
||||||
#define BYTES_PER_WORD (8)
|
#define BYTES_PER_WORD (8)
|
||||||
|
@ -380,3 +382,5 @@ int main(void) {
|
||||||
gc_dump_at();
|
gc_dump_at();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#endif // MICROPY_ENABLE_GC
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "mpconfig.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
|
#if MICROPY_ENABLE_LEXER_UNIX
|
||||||
|
|
||||||
typedef struct _str_buf_t {
|
typedef struct _str_buf_t {
|
||||||
bool free; // free src_beg when done
|
bool free; // free src_beg when done
|
||||||
const char *src_beg; // beginning of source
|
const char *src_beg; // beginning of source
|
||||||
|
@ -78,3 +81,5 @@ mp_lexer_t *mp_import_open_file(qstr mod_name) {
|
||||||
vstr_printf(vstr, "%s.py", qstr_str(mod_name));
|
vstr_printf(vstr, "%s.py", qstr_str(mod_name));
|
||||||
return mp_lexer_new_from_file(vstr_str(vstr)); // TODO does lexer need to copy the string? can we free it here?
|
return mp_lexer_new_from_file(vstr_str(vstr)); // TODO does lexer need to copy the string? can we free it here?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MICROPY_ENABLE_LEXER_UNIX
|
||||||
|
|
|
@ -39,14 +39,29 @@
|
||||||
#define MICROPY_MEM_STATS (0)
|
#define MICROPY_MEM_STATS (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Whether to build code to show byte code
|
||||||
|
#ifndef MICROPY_SHOW_BC
|
||||||
|
#define MICROPY_SHOW_BC (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Fine control over Python features */
|
/* Fine control over Python features */
|
||||||
|
|
||||||
|
// Whether to include the garbage collector
|
||||||
|
#ifndef MICROPY_ENABLE_GC
|
||||||
|
#define MICROPY_ENABLE_GC (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Whether to include REPL helper function
|
// Whether to include REPL helper function
|
||||||
#ifndef MICROPY_ENABLE_REPL_HELPERS
|
#ifndef MICROPY_ENABLE_REPL_HELPERS
|
||||||
#define MICROPY_ENABLE_REPL_HELPERS (0)
|
#define MICROPY_ENABLE_REPL_HELPERS (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Whether to include lexer helper function for unix
|
||||||
|
#ifndef MICROPY_ENABLE_LEXER_UNIX
|
||||||
|
#define MICROPY_ENABLE_LEXER_UNIX (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Whether to support float and complex types
|
// Whether to support float and complex types
|
||||||
#ifndef MICROPY_ENABLE_FLOAT
|
#ifndef MICROPY_ENABLE_FLOAT
|
||||||
#define MICROPY_ENABLE_FLOAT (0)
|
#define MICROPY_ENABLE_FLOAT (0)
|
||||||
|
|
5
py/py.mk
5
py/py.mk
|
@ -24,6 +24,7 @@ PY_O_BASENAME = \
|
||||||
nlrx64.o \
|
nlrx64.o \
|
||||||
nlrthumb.o \
|
nlrthumb.o \
|
||||||
malloc.o \
|
malloc.o \
|
||||||
|
gc.o \
|
||||||
qstr.o \
|
qstr.o \
|
||||||
vstr.o \
|
vstr.o \
|
||||||
unicode.o \
|
unicode.o \
|
||||||
|
@ -88,6 +89,10 @@ $(PY_BUILD)%.o: $(PY_SRC)/%.S
|
||||||
$(PY_BUILD)%.o: $(PY_SRC)/%.c mpconfigport.h
|
$(PY_BUILD)%.o: $(PY_SRC)/%.c mpconfigport.h
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
# optimising gc for speed; 5ms down to 4ms on pybv2
|
||||||
|
$(PY_BUILD)gc.o: $(PY_SRC)/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)
|
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
|
||||||
$(PY_BUILD)vm.o: $(PY_SRC)/vm.c
|
$(PY_BUILD)vm.o: $(PY_SRC)/vm.c
|
||||||
$(CC) $(CFLAGS) -O3 -c -o $@ $<
|
$(CC) $(CFLAGS) -O3 -c -o $@ $<
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "mpconfig.h"
|
#include "mpconfig.h"
|
||||||
#include "bc0.h"
|
#include "bc0.h"
|
||||||
|
|
||||||
|
#if MICROPY_SHOW_BC
|
||||||
|
|
||||||
#define DECODE_UINT do { unum = *ip++; if (unum > 127) { unum = ((unum & 0x3f) << 8) | (*ip++); } } while (0)
|
#define DECODE_UINT do { unum = *ip++; if (unum > 127) { unum = ((unum & 0x3f) << 8) | (*ip++); } } while (0)
|
||||||
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
|
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
|
||||||
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
|
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
|
||||||
|
@ -363,3 +365,5 @@ void mp_show_byte_code(const byte *ip, int len) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MICROPY_SHOW_BC
|
||||||
|
|
95
stm/Makefile
95
stm/Makefile
|
@ -1,9 +1,16 @@
|
||||||
|
# define main target
|
||||||
|
all: all2
|
||||||
|
|
||||||
|
# include py core make definitions
|
||||||
|
include ../py/py.mk
|
||||||
|
|
||||||
|
# program for deletion
|
||||||
|
RM = /bin/rm
|
||||||
|
|
||||||
STMSRC=lib
|
STMSRC=lib
|
||||||
#STMOTGSRC=lib-otg
|
#STMOTGSRC=lib-otg
|
||||||
FATFSSRC=fatfs
|
FATFSSRC=fatfs
|
||||||
CC3KSRC=cc3k
|
CC3KSRC=cc3k
|
||||||
PYSRC=../py
|
|
||||||
BUILD=build
|
|
||||||
DFU=../tools/dfu.py
|
DFU=../tools/dfu.py
|
||||||
TARGET=PYBOARD
|
TARGET=PYBOARD
|
||||||
|
|
||||||
|
@ -11,7 +18,7 @@ AS = arm-none-eabi-as
|
||||||
CC = arm-none-eabi-gcc
|
CC = arm-none-eabi-gcc
|
||||||
LD = arm-none-eabi-ld
|
LD = arm-none-eabi-ld
|
||||||
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion -DSTM32F40XX -DHSE_VALUE=8000000
|
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion -DSTM32F40XX -DHSE_VALUE=8000000
|
||||||
CFLAGS = -I. -I$(PYSRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) -D$(TARGET)
|
CFLAGS = -I. -I$(PY_SRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) -D$(TARGET)
|
||||||
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE
|
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE
|
||||||
LDFLAGS = --nostdlib -T stm32f405.ld
|
LDFLAGS = --nostdlib -T stm32f405.ld
|
||||||
|
|
||||||
|
@ -43,53 +50,6 @@ SRC_S = \
|
||||||
startup_stm32f40xx.s \
|
startup_stm32f40xx.s \
|
||||||
gchelper.s \
|
gchelper.s \
|
||||||
|
|
||||||
PY_O = \
|
|
||||||
nlrthumb.o \
|
|
||||||
gc.o \
|
|
||||||
malloc.o \
|
|
||||||
qstr.o \
|
|
||||||
vstr.o \
|
|
||||||
unicode.o \
|
|
||||||
lexer.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 \
|
|
||||||
repl.o \
|
|
||||||
|
|
||||||
SRC_FATFS = \
|
SRC_FATFS = \
|
||||||
ff.c \
|
ff.c \
|
||||||
diskio.c \
|
diskio.c \
|
||||||
|
@ -146,10 +106,10 @@ SRC_CC3K = \
|
||||||
ccspi.c \
|
ccspi.c \
|
||||||
pybcc3k.c \
|
pybcc3k.c \
|
||||||
|
|
||||||
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o))
|
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o)) $(PY_O)
|
||||||
#OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o))
|
#OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o))
|
||||||
|
|
||||||
all: $(BUILD) $(BUILD)/flash.dfu
|
all2: $(BUILD) $(BUILD)/flash.dfu
|
||||||
|
|
||||||
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
|
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
|
||||||
python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
|
python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
|
||||||
|
@ -164,9 +124,6 @@ $(BUILD)/flash.elf: $(OBJ)
|
||||||
$(LD) $(LDFLAGS) -o $@ $(OBJ)
|
$(LD) $(LDFLAGS) -o $@ $(OBJ)
|
||||||
arm-none-eabi-size $@
|
arm-none-eabi-size $@
|
||||||
|
|
||||||
$(BUILD):
|
|
||||||
mkdir -p $@
|
|
||||||
|
|
||||||
$(BUILD)/%.o: %.s
|
$(BUILD)/%.o: %.s
|
||||||
$(AS) -o $@ $<
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
|
@ -185,31 +142,7 @@ $(BUILD)/%.o: $(STMSRC)/%.c
|
||||||
$(BUILD)/%.o: $(CC3KSRC)/%.c
|
$(BUILD)/%.o: $(CC3KSRC)/%.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(BUILD)/%.o: $(PYSRC)/%.s
|
|
||||||
$(AS) -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD)/%.o: $(PYSRC)/%.S
|
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD)/%.o: $(PYSRC)/%.c mpconfigport.h
|
|
||||||
$(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)/parse.o: $(PYSRC)/grammar.h
|
|
||||||
$(BUILD)/compile.o: $(PYSRC)/grammar.h
|
|
||||||
$(BUILD)/emitbc.o: $(PYSRC)/emit.h
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
/bin/rm -rf $(BUILD)
|
$(RM) -rf $(BUILD)
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all all2 clean
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#define MICROPY_EMIT_THUMB (1)
|
#define MICROPY_EMIT_THUMB (1)
|
||||||
#define MICROPY_EMIT_INLINE_THUMB (1)
|
#define MICROPY_EMIT_INLINE_THUMB (1)
|
||||||
|
#define MICROPY_ENABLE_GC (1)
|
||||||
#define MICROPY_ENABLE_REPL_HELPERS (1)
|
#define MICROPY_ENABLE_REPL_HELPERS (1)
|
||||||
#define MICROPY_ENABLE_FLOAT (1)
|
#define MICROPY_ENABLE_FLOAT (1)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
// options to control how Micro Python is built
|
// options to control how Micro Python is built
|
||||||
|
|
||||||
#define MICROPY_ENABLE_FLOAT (1)
|
|
||||||
#define MICROPY_EMIT_CPYTHON (1)
|
#define MICROPY_EMIT_CPYTHON (1)
|
||||||
|
#define MICROPY_ENABLE_LEXER_UNIX (1)
|
||||||
|
#define MICROPY_ENABLE_FLOAT (1)
|
||||||
|
|
||||||
// type definitions for the specific machine
|
// type definitions for the specific machine
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define MICROPY_EMIT_INLINE_THUMB (0)
|
#define MICROPY_EMIT_INLINE_THUMB (0)
|
||||||
#define MICROPY_MEM_STATS (1)
|
#define MICROPY_MEM_STATS (1)
|
||||||
#define MICROPY_ENABLE_REPL_HELPERS (1)
|
#define MICROPY_ENABLE_REPL_HELPERS (1)
|
||||||
|
#define MICROPY_ENABLE_LEXER_UNIX (1)
|
||||||
#define MICROPY_ENABLE_FLOAT (1)
|
#define MICROPY_ENABLE_FLOAT (1)
|
||||||
|
|
||||||
// type definitions for the specific machine
|
// type definitions for the specific machine
|
||||||
|
|
Loading…
Reference in New Issue