From 0ccd9e08aad95f955ded0006cff67e2a50778c84 Mon Sep 17 00:00:00 2001 From: Michael O'Cleirigh Date: Sat, 27 Mar 2021 17:10:39 -0400 Subject: [PATCH] esp32: Restore USER_C_MODULE support with new CMake build system. Support for User C and C++ modules was lost due to upgrading the esp32 to the latest CMake based IDF from the GNUMakefile build process. Restore the support for the esp32 port by integrating with the approach recently added for the rp2 port. Signed-off-by: Michael O'Cleirigh --- ports/esp32/Makefile | 8 +++++++- ports/esp32/main/CMakeLists.txt | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile index 9a3a15d6ee..39b740ffae 100644 --- a/ports/esp32/Makefile +++ b/ports/esp32/Makefile @@ -18,7 +18,13 @@ GIT_SUBMODULES = lib/berkeley-db-1.xx .PHONY: all clean deploy erase submodules FORCE -IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -B $(BUILD) +CMAKE_ARGS = + +ifdef USER_C_MODULES + CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES} +endif + +IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -B $(BUILD) $(CMAKE_ARGS) all: idf.py $(IDFPY_FLAGS) build diff --git a/ports/esp32/main/CMakeLists.txt b/ports/esp32/main/CMakeLists.txt index b6bccdde3c..082410f4c0 100644 --- a/ports/esp32/main/CMakeLists.txt +++ b/ports/esp32/main/CMakeLists.txt @@ -5,6 +5,10 @@ get_filename_component(MICROPY_DIR ${PROJECT_DIR}/../.. ABSOLUTE) include(${MICROPY_DIR}/py/py.cmake) include(${MICROPY_DIR}/extmod/extmod.cmake) +if(NOT CMAKE_BUILD_EARLY_EXPANSION) + include(${MICROPY_DIR}/py/usermod.cmake) +endif() + set(MICROPY_QSTRDEFS_PORT ${PROJECT_DIR}/qstrdefsport.h ) @@ -71,6 +75,7 @@ set(MICROPY_SOURCE_PORT set(MICROPY_SOURCE_QSTR ${MICROPY_SOURCE_PY} ${MICROPY_SOURCE_EXTMOD} + ${MICROPY_SOURCE_USERMOD} ${MICROPY_SOURCE_LIB} ${MICROPY_SOURCE_PORT} ) @@ -129,6 +134,7 @@ idf_component_register( ${MICROPY_SOURCE_PORT} INCLUDE_DIRS ${MICROPY_DIR} + ${MICROPY_INC_USERMOD} ${MICROPY_PORT_DIR} ${MICROPY_BOARD_DIR} ${CMAKE_BINARY_DIR} @@ -159,6 +165,10 @@ target_compile_options(${MICROPY_TARGET} PUBLIC -Wno-missing-field-initializers ) +# add usermod +target_link_libraries(${MICROPY_TARGET} usermod) + + # Collect all of the include directories and compile definitions for the IDF components. foreach(comp ${IDF_COMPONENTS}) get_target_property(type __idf_${comp} TYPE)