Skip to content
Snippets Groups Projects
Commit d3ebe482 authored by Damien George's avatar Damien George
Browse files

Factor and simplify Makefile's and mpconfig, part 2.

parent 136f6752
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <string.h>
#include "misc.h"
#include "asmx64.h"
#include "mpconfig.h"
// wrapper around everything in this file
#if MICROPY_EMIT_X64
#include <sys/types.h>
#include <sys/mman.h>
#include "asmx64.h"
#if defined(__OpenBSD__) || defined(__MACH__)
#define MAP_ANONYMOUS MAP_ANON
#endif
......
......@@ -6,6 +6,8 @@
#include "mpconfig.h"
#include "gc.h"
#if MICROPY_ENABLE_GC
// a machine word is big enough to hold a pointer
/*
#define BYTES_PER_WORD (8)
......@@ -380,3 +382,5 @@ int main(void) {
gc_dump_at();
}
*/
#endif // MICROPY_ENABLE_GC
......@@ -4,8 +4,11 @@
#include <fcntl.h>
#include "misc.h"
#include "mpconfig.h"
#include "lexer.h"
#if MICROPY_ENABLE_LEXER_UNIX
typedef struct _str_buf_t {
bool free; // free src_beg when done
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));
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)
#endif
// Whether to build code to show byte code
#ifndef MICROPY_SHOW_BC
#define MICROPY_SHOW_BC (0)
#endif
/*****************************************************************************/
/* 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
#ifndef MICROPY_ENABLE_REPL_HELPERS
#define MICROPY_ENABLE_REPL_HELPERS (0)
#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
#ifndef MICROPY_ENABLE_FLOAT
#define MICROPY_ENABLE_FLOAT (0)
......
......@@ -24,6 +24,7 @@ PY_O_BASENAME = \
nlrx64.o \
nlrthumb.o \
malloc.o \
gc.o \
qstr.o \
vstr.o \
unicode.o \
......@@ -88,6 +89,10 @@ $(PY_BUILD)%.o: $(PY_SRC)/%.S
$(PY_BUILD)%.o: $(PY_SRC)/%.c mpconfigport.h
$(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)
$(PY_BUILD)vm.o: $(PY_SRC)/vm.c
$(CC) $(CFLAGS) -O3 -c -o $@ $<
......
......@@ -8,6 +8,8 @@
#include "mpconfig.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_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)
......@@ -363,3 +365,5 @@ void mp_show_byte_code(const byte *ip, int len) {
printf("\n");
}
}
#endif // MICROPY_SHOW_BC
# define main target
all: all2
# include py core make definitions
include ../py/py.mk
# program for deletion
RM = /bin/rm
STMSRC=lib
#STMOTGSRC=lib-otg
FATFSSRC=fatfs
CC3KSRC=cc3k
PYSRC=../py
BUILD=build
DFU=../tools/dfu.py
TARGET=PYBOARD
......@@ -11,7 +18,7 @@ AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
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 = -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
LDFLAGS = --nostdlib -T stm32f405.ld
......@@ -43,53 +50,6 @@ SRC_S = \
startup_stm32f40xx.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 = \
ff.c \
diskio.c \
......@@ -146,10 +106,10 @@ SRC_CC3K = \
ccspi.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))
all: $(BUILD) $(BUILD)/flash.dfu
all2: $(BUILD) $(BUILD)/flash.dfu
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(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)
arm-none-eabi-size $@
$(BUILD):
mkdir -p $@
$(BUILD)/%.o: %.s
$(AS) -o $@ $<
......@@ -185,31 +142,7 @@ $(BUILD)/%.o: $(STMSRC)/%.c
$(BUILD)/%.o: $(CC3KSRC)/%.c
$(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:
/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_INLINE_THUMB (1)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_REPL_HELPERS (1)
#define MICROPY_ENABLE_FLOAT (1)
......
// options to control how Micro Python is built
#define MICROPY_ENABLE_FLOAT (1)
#define MICROPY_EMIT_CPYTHON (1)
#define MICROPY_ENABLE_LEXER_UNIX (1)
#define MICROPY_ENABLE_FLOAT (1)
// type definitions for the specific machine
......
......@@ -10,6 +10,7 @@
#define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (1)
#define MICROPY_ENABLE_REPL_HELPERS (1)
#define MICROPY_ENABLE_LEXER_UNIX (1)
#define MICROPY_ENABLE_FLOAT (1)
// type definitions for the specific machine
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment