aboutsummaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorPhil Howard2021-02-23 22:57:14 +0000
committerDamien George2021-03-31 00:26:01 +1100
commit0cf12dd59c9ddddbd602d4267410033cb5a9d265 (patch)
treeec069371e2773c95b498e712f2fe35d37cdc9c93 /ports
parentccc388f157eacfea6b5c44e1b6049a2bbeb44734 (diff)
rp2: Add support for USER_C_MODULES to CMake build system.
The parts that are generic are added to py/ so they can be used by other ports that use CMake. py/usermod.cmake: * Creates a usermod target to hang user C/CXX modules from. * Gathers sources from user C/CXX modules and libs for QSTR scan. ports/rp2/CMakeLists.txt: * Includes py/usermod.cmake. * Links the resulting usermod library to the MicroPython target. py/mkrules.cmake: Add cxxflags to qstr.i.last custom command for CXX modules: * MICROPY_CPP_FLAGS so CXX modules will find includes. * -DNO_QSTR to fix fatal error missing "genhdr/qstrdefs.generated.h". Usage: The rp2 port can be linked against user C modules by running: make USER_C_MODULES=/path/to/module/micropython.cmake CMake will print a list of included modules. Co-authored-by: Graham Sanderson <graham.sanderson@raspberrypi.org> Co-authored-by: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca> Signed-off-by: Phil Howard <phil@pimoroni.com>
Diffstat (limited to 'ports')
-rw-r--r--ports/rp2/CMakeLists.txt6
-rw-r--r--ports/rp2/Makefile8
2 files changed, 13 insertions, 1 deletions
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 3968194dc..3db0e6b62 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -27,6 +27,8 @@ project(${MICROPY_TARGET})
pico_sdk_init()
+include(${MICROPY_DIR}/py/usermod.cmake)
+
add_executable(${MICROPY_TARGET})
set(MICROPY_QSTRDEFS_PORT
@@ -80,6 +82,7 @@ set(MICROPY_SOURCE_PORT
set(MICROPY_SOURCE_QSTR
${MICROPY_SOURCE_PY}
${MICROPY_SOURCE_EXTMOD}
+ ${MICROPY_SOURCE_USERMOD}
${MICROPY_DIR}/lib/utils/mpirq.c
${MICROPY_DIR}/lib/utils/sys_stdio_mphal.c
${PROJECT_SOURCE_DIR}/machine_adc.c
@@ -142,7 +145,10 @@ target_sources(${MICROPY_TARGET} PRIVATE
${MICROPY_SOURCE_PORT}
)
+target_link_libraries(${MICROPY_TARGET} usermod)
+
target_include_directories(${MICROPY_TARGET} PRIVATE
+ ${MICROPY_INC_USERMOD}
"${PROJECT_SOURCE_DIR}"
"${MICROPY_DIR}"
"${CMAKE_BINARY_DIR}"
diff --git a/ports/rp2/Makefile b/ports/rp2/Makefile
index 08cd53dcc..3358c4cca 100644
--- a/ports/rp2/Makefile
+++ b/ports/rp2/Makefile
@@ -6,8 +6,14 @@ BUILD = build
$(VERBOSE)MAKESILENT = -s
+CMAKE_ARGS =
+
+ifdef USER_C_MODULES
+CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
+endif
+
all:
- [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0
+ [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0 ${CMAKE_ARGS}
$(MAKE) $(MAKESILENT) -C $(BUILD)
clean: