Commit 97960dc7 authored by Damien George's avatar Damien George

stm32: Support C++ code and user C modules written in C++.

Also build user C modules as part of the stm32 CI.
Signed-off-by: default avatarDamien George <damien@micropython.org>
parent df3b466d
......@@ -99,7 +99,7 @@ jobs:
- make ${MAKEOPTS} -C ports/stm32 submodules
- git submodule update --init lib/btstack
- make ${MAKEOPTS} -C ports/stm32 BOARD=NUCLEO_F091RC
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=5200 MICROPY_PY_CC3K=1
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=5200 MICROPY_PY_CC3K=1 USER_C_MODULES=../../examples/usercmodule CFLAGS_EXTRA="-DMODULE_CEXAMPLE_ENABLED=1 -DMODULE_CPPEXAMPLE_ENABLED=1"
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBD_SF2
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBD_SF6 NANBOX=1 MICROPY_BLUETOOTH_NIMBLE=0 MICROPY_BLUETOOTH_BTSTACK=1
- make ${MAKEOPTS} -C ports/stm32 BOARD=NUCLEO_H743ZI CFLAGS_EXTRA='-DMICROPY_PY_THREAD=1'
......
......@@ -138,6 +138,13 @@ else
COPT += -Os -DNDEBUG
endif
# Flags for optional C++ source code
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99,$(CFLAGS))
CXXFLAGS += $(CXXFLAGS_MOD)
ifneq ($(SRC_CXX)$(SRC_MOD_CXX),)
LDFLAGS += -L$(dir $(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a))
endif
# Options for mpy-cross
MPY_CROSS_FLAGS += -march=armv7m
......@@ -330,6 +337,9 @@ SRC_C += \
adc.c \
$(wildcard $(BOARD_DIR)/*.c)
SRC_CXX += \
$(SRC_MOD_CXX)
SRC_O += \
$(STARTUP_FILE) \
$(SYSTEM_FILE)
......@@ -511,6 +521,7 @@ OBJ += $(LIBM_O)
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_O))
OBJ += $(addprefix $(BUILD)/, $(SRC_HAL:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_USBDEV:.c=.o))
......@@ -644,7 +655,7 @@ GEN_CDCINF_FILE = $(HEADER_BUILD)/pybcdc.inf
GEN_CDCINF_HEADER = $(HEADER_BUILD)/pybcdc_inf.h
# List of sources for qstr extraction
SRC_QSTR += $(SRC_C) $(SRC_MOD) $(LIB_SRC_C) $(EXTMOD_SRC_C)
SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SRC_MOD) $(LIB_SRC_C) $(EXTMOD_SRC_C)
# Append any auto-generated sources that are needed by sources listed in
# SRC_QSTR
SRC_QSTR_AUTO_DEPS += $(GEN_CDCINF_HEADER)
......
/* This linker script fragment is intended to be included in SECTIONS. */
/* For C++ exception handling */
.ARM :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
/* Used by the start-up code to initialise data */
_sidata = LOADADDR(.data);
......
/* This linker script fragment is intended to be included in SECTIONS. */
/* For C++ exception handling */
.ARM :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH_APP
/* Used by the start-up code to initialise data */
_sidata = LOADADDR(.data);
......
/* This linker script fragment is intended to be included in SECTIONS. */
/* For C++ exception handling */
.ARM :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH_TEXT
/* Used by the start-up code to initialise data */
_sidata = LOADADDR(.data);
......
......@@ -133,6 +133,10 @@ void nlr_jump_fail(void *val) {
__fatal_error("");
}
void abort(void) {
__fatal_error("abort");
}
#ifndef NDEBUG
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
(void)func;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment