esp32/esp32_common.cmake: Allow adding defines and compiler flags.

This commit introduces two extra CMake variables, MICROPY_DEF_COMPONENT
and MICROPY_COMPILE_COMPONENT, that make it easier to integrate
MicroPython as a custom ESP-IDF component.

Whilst there is no official MicroPython component available for ESP-IDF,
integration can be achieved with some minor CMake scripting outside the
MicroPython tree - except for customisation of compilation defines and
build flags, which is what this commit tries to provide.

Compilation defines customisation is especially important for
MicroPython configuration, as it is not possible to inject a value for
MP_CONFIGFILE otherwise.  This means that unless MicroPython itself is
forked first to edit ports/esp32/mpconfigport.h, it is not possible to
perform any meaningful configuration of the interpreter/runtime when
included as a component.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2025-03-25 21:53:45 +01:00
parent 1d4bf8ac40
commit 116d0d4945

View File

@@ -242,6 +242,7 @@ endif()
# Set compile options for this port.
target_compile_definitions(${MICROPY_TARGET} PUBLIC
${MICROPY_DEF_COMPONENT}
${MICROPY_DEF_CORE}
${MICROPY_DEF_BOARD}
${MICROPY_DEF_TINYUSB}
@@ -254,6 +255,7 @@ target_compile_definitions(${MICROPY_TARGET} PUBLIC
# Disable some warnings to keep the build output clean.
target_compile_options(${MICROPY_TARGET} PUBLIC
${MICROPY_COMPILE_COMPONENT}
-Wno-clobbered
-Wno-deprecated-declarations
-Wno-missing-field-initializers