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 <michael.ocleirigh@rivulet.ca>
This commit is contained in:
Michael O'Cleirigh 2021-03-27 17:10:39 -04:00 committed by Damien George
parent ca3d51f122
commit 0ccd9e08aa
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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)