Angus Gratton | 043ba45 | 2024-10-22 16:01:01 +1100 | [diff] [blame] | 1 | # This is the common ESP-IDF "main component" CMakeLists.txt contents for MicroPython. |
| 2 | # |
| 3 | # This file is included directly from a main_${IDF_TARGET}/CMakeLists.txt file |
| 4 | # (or included from an out-of-tree main component CMakeLists.txt for out-of-tree |
| 5 | # builds.) |
| 6 | |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 7 | # Set location of base MicroPython directory. |
Damien George | 0009a7d | 2021-06-24 16:03:25 +1000 | [diff] [blame] | 8 | if(NOT MICROPY_DIR) |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 9 | get_filename_component(MICROPY_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE) |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 10 | endif() |
| 11 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 12 | # Set location of the ESP32 port directory. |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 13 | if(NOT MICROPY_PORT_DIR) |
| 14 | get_filename_component(MICROPY_PORT_DIR ${MICROPY_DIR}/ports/esp32 ABSOLUTE) |
Damien George | 0009a7d | 2021-06-24 16:03:25 +1000 | [diff] [blame] | 15 | endif() |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 16 | |
Angus Gratton | 4b1c666 | 2025-03-04 12:20:02 +1100 | [diff] [blame] | 17 | # RISC-V specific inclusions |
| 18 | if(CONFIG_IDF_TARGET_ARCH_RISCV) |
| 19 | list(APPEND MICROPY_SOURCE_LIB ${MICROPY_DIR}/shared/runtime/gchelper_generic.c) |
| 20 | list(APPEND IDF_COMPONENTS riscv) |
| 21 | endif() |
| 22 | |
| 23 | if(NOT DEFINED MICROPY_PY_TINYUSB) |
| 24 | if(CONFIG_IDF_TARGET_ESP32S2 OR CONFIG_IDF_TARGET_ESP32S3) |
| 25 | set(MICROPY_PY_TINYUSB ON) |
| 26 | endif() |
| 27 | endif() |
| 28 | |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 29 | # Include core source components. |
| 30 | include(${MICROPY_DIR}/py/py.cmake) |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 31 | |
Jim Mussared | ad123ed | 2023-07-31 17:24:38 +1000 | [diff] [blame] | 32 | # CMAKE_BUILD_EARLY_EXPANSION is set during the component-discovery phase of |
| 33 | # `idf.py build`, so none of the extmod/usermod (and in reality, most of the |
| 34 | # micropython) rules need to happen. Specifically, you cannot invoke add_library. |
Michael O'Cleirigh | 0ccd9e0 | 2021-03-27 17:10:39 -0400 | [diff] [blame] | 35 | if(NOT CMAKE_BUILD_EARLY_EXPANSION) |
Damien George | bd375df | 2022-06-08 12:21:51 +1000 | [diff] [blame] | 36 | # Enable extmod components that will be configured by extmod.cmake. |
| 37 | # A board may also have enabled additional components. |
| 38 | set(MICROPY_PY_BTREE ON) |
| 39 | |
Michael O'Cleirigh | 0ccd9e0 | 2021-03-27 17:10:39 -0400 | [diff] [blame] | 40 | include(${MICROPY_DIR}/py/usermod.cmake) |
Damien George | 212fe7f | 2021-04-08 23:45:28 +1000 | [diff] [blame] | 41 | include(${MICROPY_DIR}/extmod/extmod.cmake) |
Michael O'Cleirigh | 0ccd9e0 | 2021-03-27 17:10:39 -0400 | [diff] [blame] | 42 | endif() |
| 43 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 44 | list(APPEND MICROPY_QSTRDEFS_PORT |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 45 | ${MICROPY_PORT_DIR}/qstrdefsport.h |
Damien George | 75db0b9 | 2021-02-21 11:33:15 +1100 | [diff] [blame] | 46 | ) |
| 47 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 48 | list(APPEND MICROPY_SOURCE_SHARED |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 49 | ${MICROPY_DIR}/shared/readline/readline.c |
| 50 | ${MICROPY_DIR}/shared/netutils/netutils.c |
| 51 | ${MICROPY_DIR}/shared/timeutils/timeutils.c |
| 52 | ${MICROPY_DIR}/shared/runtime/interrupt_char.c |
robert-hh | a04a141 | 2024-03-10 15:14:20 +0100 | [diff] [blame] | 53 | ${MICROPY_DIR}/shared/runtime/mpirq.c |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 54 | ${MICROPY_DIR}/shared/runtime/stdout_helpers.c |
| 55 | ${MICROPY_DIR}/shared/runtime/sys_stdio_mphal.c |
| 56 | ${MICROPY_DIR}/shared/runtime/pyexec.c |
| 57 | ) |
| 58 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 59 | list(APPEND MICROPY_SOURCE_LIB |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 60 | ${MICROPY_DIR}/lib/littlefs/lfs1.c |
| 61 | ${MICROPY_DIR}/lib/littlefs/lfs1_util.c |
| 62 | ${MICROPY_DIR}/lib/littlefs/lfs2.c |
| 63 | ${MICROPY_DIR}/lib/littlefs/lfs2_util.c |
Damien George | c9eb6bc | 2023-12-12 16:05:03 +1100 | [diff] [blame] | 64 | ${MICROPY_DIR}/lib/mbedtls_errors/esp32_mbedtls_errors.c |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 65 | ${MICROPY_DIR}/lib/oofatfs/ff.c |
| 66 | ${MICROPY_DIR}/lib/oofatfs/ffunicode.c |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 67 | ) |
| 68 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 69 | list(APPEND MICROPY_SOURCE_DRIVERS |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 70 | ${MICROPY_DIR}/drivers/bus/softspi.c |
| 71 | ${MICROPY_DIR}/drivers/dht/dht.c |
| 72 | ) |
| 73 | |
Angus Gratton | cccac2c | 2025-03-11 17:17:39 +1100 | [diff] [blame^] | 74 | list(APPEND GIT_SUBMODULES lib/tinyusb) |
| 75 | if(MICROPY_PY_TINYUSB) |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 76 | set(TINYUSB_SRC "${MICROPY_DIR}/lib/tinyusb/src") |
| 77 | string(TOUPPER OPT_MCU_${IDF_TARGET} tusb_mcu) |
| 78 | |
| 79 | list(APPEND MICROPY_DEF_TINYUSB |
| 80 | CFG_TUSB_MCU=${tusb_mcu} |
| 81 | ) |
| 82 | |
| 83 | list(APPEND MICROPY_SOURCE_TINYUSB |
| 84 | ${TINYUSB_SRC}/tusb.c |
| 85 | ${TINYUSB_SRC}/common/tusb_fifo.c |
| 86 | ${TINYUSB_SRC}/device/usbd.c |
| 87 | ${TINYUSB_SRC}/device/usbd_control.c |
| 88 | ${TINYUSB_SRC}/class/cdc/cdc_device.c |
| 89 | ${TINYUSB_SRC}/portable/synopsys/dwc2/dcd_dwc2.c |
| 90 | ${MICROPY_DIR}/shared/tinyusb/mp_usbd.c |
| 91 | ${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c |
| 92 | ${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c |
Sebastian Romero | 5f2d05d | 2024-12-04 16:30:56 +0100 | [diff] [blame] | 93 | ${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 94 | ) |
| 95 | |
| 96 | list(APPEND MICROPY_INC_TINYUSB |
| 97 | ${TINYUSB_SRC} |
| 98 | ${MICROPY_DIR}/shared/tinyusb/ |
| 99 | ) |
| 100 | |
| 101 | list(APPEND MICROPY_LINK_TINYUSB |
| 102 | -Wl,--wrap=dcd_event_handler |
| 103 | ) |
| 104 | endif() |
| 105 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 106 | list(APPEND MICROPY_SOURCE_PORT |
Daniƫl van de Giessen | c10a74b | 2024-03-13 18:23:17 +0100 | [diff] [blame] | 107 | panichandler.c |
Damien George | 03eae48 | 2023-10-25 19:13:11 +1100 | [diff] [blame] | 108 | adc.c |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 109 | main.c |
Damien George | 1db40ed | 2023-06-21 15:09:26 +1000 | [diff] [blame] | 110 | ppp_set_auth.c |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 111 | uart.c |
| 112 | usb.c |
| 113 | usb_serial_jtag.c |
| 114 | gccollect.c |
| 115 | mphalport.c |
| 116 | fatfs_port.c |
| 117 | help.c |
| 118 | machine_bitstream.c |
| 119 | machine_timer.c |
| 120 | machine_pin.c |
| 121 | machine_touchpad.c |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 122 | machine_dac.c |
| 123 | machine_i2c.c |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 124 | network_common.c |
| 125 | network_lan.c |
| 126 | network_ppp.c |
| 127 | network_wlan.c |
| 128 | mpnimbleport.c |
| 129 | modsocket.c |
Angus Gratton | 82e69df | 2024-10-02 14:49:49 +1000 | [diff] [blame] | 130 | lwip_patch.c |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 131 | modesp.c |
| 132 | esp32_nvs.c |
| 133 | esp32_partition.c |
| 134 | esp32_rmt.c |
| 135 | esp32_ulp.c |
| 136 | modesp32.c |
| 137 | machine_hw_spi.c |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 138 | mpthreadport.c |
| 139 | machine_rtc.c |
| 140 | machine_sdcard.c |
| 141 | modespnow.c |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 142 | ) |
Brian 'redbeard' Harrington | 5fe2a3f | 2023-06-12 13:02:10 -0700 | [diff] [blame] | 143 | list(TRANSFORM MICROPY_SOURCE_PORT PREPEND ${MICROPY_PORT_DIR}/) |
Damien George | cb31c0a | 2023-07-15 00:03:59 +1000 | [diff] [blame] | 144 | list(APPEND MICROPY_SOURCE_PORT ${CMAKE_BINARY_DIR}/pins.c) |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 145 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 146 | list(APPEND MICROPY_SOURCE_QSTR |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 147 | ${MICROPY_SOURCE_PY} |
| 148 | ${MICROPY_SOURCE_EXTMOD} |
Michael O'Cleirigh | 0ccd9e0 | 2021-03-27 17:10:39 -0400 | [diff] [blame] | 149 | ${MICROPY_SOURCE_USERMOD} |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 150 | ${MICROPY_SOURCE_SHARED} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 151 | ${MICROPY_SOURCE_LIB} |
| 152 | ${MICROPY_SOURCE_PORT} |
Damien George | f046b50 | 2021-09-22 00:00:26 +1000 | [diff] [blame] | 153 | ${MICROPY_SOURCE_BOARD} |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 154 | ${MICROPY_SOURCE_TINYUSB} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 155 | ) |
| 156 | |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 157 | list(APPEND IDF_COMPONENTS |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 158 | app_update |
| 159 | bootloader_support |
Damien George | da2b5fa | 2021-02-14 01:36:30 +1100 | [diff] [blame] | 160 | bt |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 161 | driver |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 162 | esp_adc |
| 163 | esp_app_format |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 164 | esp_common |
| 165 | esp_eth |
| 166 | esp_event |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 167 | esp_hw_support |
| 168 | esp_netif |
| 169 | esp_partition |
| 170 | esp_pm |
| 171 | esp_psram |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 172 | esp_ringbuf |
| 173 | esp_rom |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 174 | esp_system |
| 175 | esp_timer |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 176 | esp_wifi |
| 177 | freertos |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 178 | hal |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 179 | heap |
| 180 | log |
| 181 | lwip |
| 182 | mbedtls |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 183 | newlib |
| 184 | nvs_flash |
| 185 | sdmmc |
| 186 | soc |
| 187 | spi_flash |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 188 | ulp |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 189 | usb |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 190 | vfs |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 191 | ) |
| 192 | |
Karl Palsson | cbd21b3 | 2025-01-27 16:05:07 +0000 | [diff] [blame] | 193 | # Provide the default LD fragment if not set |
| 194 | if (MICROPY_USER_LDFRAGMENTS) |
| 195 | set(MICROPY_LDFRAGMENTS ${MICROPY_USER_LDFRAGMENTS}) |
Karl Palsson | cbd21b3 | 2025-01-27 16:05:07 +0000 | [diff] [blame] | 196 | endif() |
| 197 | |
Angus Gratton | cccac2c | 2025-03-11 17:17:39 +1100 | [diff] [blame^] | 198 | if (UPDATE_SUBMODULES) |
| 199 | # ESP-IDF checks if some paths exist before CMake does. Some paths don't |
| 200 | # yet exist if this is an UPDATE_SUBMODULES pass on a brand new checkout, so remove |
| 201 | # any path which might not exist yet. A "real" build will not set UPDATE_SUBMODULES. |
| 202 | unset(MICROPY_SOURCE_TINYUSB) |
| 203 | unset(MICROPY_SOURCE_EXTMOD) |
| 204 | unset(MICROPY_SOURCE_LIB) |
| 205 | unset(MICROPY_INC_TINYUSB) |
| 206 | unset(MICROPY_INC_CORE) |
| 207 | endif() |
| 208 | |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 209 | # Register the main IDF component. |
| 210 | idf_component_register( |
| 211 | SRCS |
| 212 | ${MICROPY_SOURCE_PY} |
| 213 | ${MICROPY_SOURCE_EXTMOD} |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 214 | ${MICROPY_SOURCE_SHARED} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 215 | ${MICROPY_SOURCE_LIB} |
| 216 | ${MICROPY_SOURCE_DRIVERS} |
| 217 | ${MICROPY_SOURCE_PORT} |
Damien George | f046b50 | 2021-09-22 00:00:26 +1000 | [diff] [blame] | 218 | ${MICROPY_SOURCE_BOARD} |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 219 | ${MICROPY_SOURCE_TINYUSB} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 220 | INCLUDE_DIRS |
Damien George | 5dcc9b3 | 2021-04-09 00:59:16 +1000 | [diff] [blame] | 221 | ${MICROPY_INC_CORE} |
Michael O'Cleirigh | 0ccd9e0 | 2021-03-27 17:10:39 -0400 | [diff] [blame] | 222 | ${MICROPY_INC_USERMOD} |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 223 | ${MICROPY_INC_TINYUSB} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 224 | ${MICROPY_PORT_DIR} |
| 225 | ${MICROPY_BOARD_DIR} |
| 226 | ${CMAKE_BINARY_DIR} |
Jim Mussared | acbdbcd | 2024-03-21 15:46:41 +1100 | [diff] [blame] | 227 | LDFRAGMENTS |
Karl Palsson | cbd21b3 | 2025-01-27 16:05:07 +0000 | [diff] [blame] | 228 | ${MICROPY_LDFRAGMENTS} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 229 | REQUIRES |
| 230 | ${IDF_COMPONENTS} |
| 231 | ) |
| 232 | |
| 233 | # Set the MicroPython target as the current (main) IDF component target. |
| 234 | set(MICROPY_TARGET ${COMPONENT_TARGET}) |
| 235 | |
| 236 | # Define mpy-cross flags, for use with frozen code. |
Andrew Leech | 6d79937 | 2023-06-26 11:53:28 +1000 | [diff] [blame] | 237 | if(CONFIG_IDF_TARGET_ARCH STREQUAL "xtensa") |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 238 | set(MICROPY_CROSS_FLAGS -march=xtensawin) |
Alessandro Gatti | 95ce61d | 2023-10-31 13:28:25 +0100 | [diff] [blame] | 239 | endif() |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 240 | |
| 241 | # Set compile options for this port. |
| 242 | target_compile_definitions(${MICROPY_TARGET} PUBLIC |
Damien George | ab9d47e | 2021-04-08 23:56:28 +1000 | [diff] [blame] | 243 | ${MICROPY_DEF_CORE} |
Jim Mussared | 2fbf42d | 2023-07-25 15:03:30 +1000 | [diff] [blame] | 244 | ${MICROPY_DEF_BOARD} |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 245 | ${MICROPY_DEF_TINYUSB} |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 246 | MICROPY_ESP_IDF_4=1 |
| 247 | MICROPY_VFS_FAT=1 |
| 248 | MICROPY_VFS_LFS2=1 |
| 249 | FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\" |
| 250 | LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT |
| 251 | LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT |
| 252 | ) |
| 253 | |
| 254 | # Disable some warnings to keep the build output clean. |
| 255 | target_compile_options(${MICROPY_TARGET} PUBLIC |
| 256 | -Wno-clobbered |
| 257 | -Wno-deprecated-declarations |
| 258 | -Wno-missing-field-initializers |
| 259 | ) |
| 260 | |
Andrew Leech | 4247921 | 2024-05-23 17:23:41 +1000 | [diff] [blame] | 261 | target_link_options(${MICROPY_TARGET} PUBLIC |
| 262 | ${MICROPY_LINK_TINYUSB} |
| 263 | ) |
| 264 | |
Damien George | 5dbb822 | 2021-03-17 12:35:59 +1100 | [diff] [blame] | 265 | # Additional include directories needed for private NimBLE headers. |
| 266 | target_include_directories(${MICROPY_TARGET} PUBLIC |
| 267 | ${IDF_PATH}/components/bt/host/nimble/nimble |
| 268 | ) |
| 269 | |
Damien George | ab9d47e | 2021-04-08 23:56:28 +1000 | [diff] [blame] | 270 | # Add additional extmod and usermod components. |
| 271 | target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree) |
Michael O'Cleirigh | 0ccd9e0 | 2021-03-27 17:10:39 -0400 | [diff] [blame] | 272 | target_link_libraries(${MICROPY_TARGET} usermod) |
| 273 | |
Angus Gratton | b20687d | 2024-12-03 10:02:46 +1100 | [diff] [blame] | 274 | # Extra linker options |
| 275 | # (when wrap symbols are in standalone files, --undefined ensures |
| 276 | # the linker doesn't skip that file.) |
| 277 | target_link_options(${MICROPY_TARGET} PUBLIC |
| 278 | # Patch LWIP memory pool allocators (see lwip_patch.c) |
| 279 | -Wl,--undefined=memp_malloc |
| 280 | -Wl,--wrap=memp_malloc |
| 281 | -Wl,--wrap=memp_free |
Angus Gratton | ff70a91 | 2024-10-22 15:02:32 +1100 | [diff] [blame] | 282 | |
Angus Gratton | b20687d | 2024-12-03 10:02:46 +1100 | [diff] [blame] | 283 | # Enable the panic handler wrapper |
| 284 | -Wl,--undefined=esp_panic_handler |
| 285 | -Wl,--wrap=esp_panic_handler |
| 286 | ) |
Angus Gratton | ff70a91 | 2024-10-22 15:02:32 +1100 | [diff] [blame] | 287 | |
Luca Burelli | 31ef7c1 | 2023-07-05 18:03:11 +0200 | [diff] [blame] | 288 | # Collect all of the include directories and compile definitions for the IDF components, |
| 289 | # including those added by the IDF Component Manager via idf_components.yaml. |
| 290 | foreach(comp ${__COMPONENT_NAMES_RESOLVED}) |
Damien George | 0fabda3 | 2021-04-08 23:42:22 +1000 | [diff] [blame] | 291 | micropy_gather_target_properties(__idf_${comp}) |
Damien George | e465012 | 2023-05-09 09:52:54 +1000 | [diff] [blame] | 292 | micropy_gather_target_properties(${comp}) |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 293 | endforeach() |
| 294 | |
Damien George | 9b90882 | 2020-09-23 15:55:55 +1000 | [diff] [blame] | 295 | # Include the main MicroPython cmake rules. |
| 296 | include(${MICROPY_DIR}/py/mkrules.cmake) |
Damien George | cb31c0a | 2023-07-15 00:03:59 +1000 | [diff] [blame] | 297 | |
| 298 | # Generate source files for named pins (requires mkrules.cmake for MICROPY_GENHDR_DIR). |
| 299 | |
| 300 | set(GEN_PINS_PREFIX "${MICROPY_PORT_DIR}/boards/pins_prefix.c") |
| 301 | set(GEN_PINS_MKPINS "${MICROPY_PORT_DIR}/boards/make-pins.py") |
| 302 | set(GEN_PINS_SRC "${CMAKE_BINARY_DIR}/pins.c") |
| 303 | set(GEN_PINS_HDR "${MICROPY_GENHDR_DIR}/pins.h") |
| 304 | |
| 305 | if(EXISTS "${MICROPY_BOARD_DIR}/pins.csv") |
| 306 | set(GEN_PINS_BOARD_CSV "${MICROPY_BOARD_DIR}/pins.csv") |
| 307 | set(GEN_PINS_BOARD_CSV_ARG --board-csv "${GEN_PINS_BOARD_CSV}") |
| 308 | endif() |
| 309 | |
| 310 | target_sources(${MICROPY_TARGET} PRIVATE ${GEN_PINS_HDR}) |
| 311 | |
| 312 | add_custom_command( |
| 313 | OUTPUT ${GEN_PINS_SRC} ${GEN_PINS_HDR} |
| 314 | COMMAND ${Python3_EXECUTABLE} ${GEN_PINS_MKPINS} ${GEN_PINS_BOARD_CSV_ARG} |
| 315 | --prefix ${GEN_PINS_PREFIX} --output-source ${GEN_PINS_SRC} --output-header ${GEN_PINS_HDR} |
| 316 | DEPENDS |
| 317 | ${MICROPY_MPVERSION} |
| 318 | ${GEN_PINS_MKPINS} |
| 319 | ${GEN_PINS_BOARD_CSV} |
| 320 | ${GEN_PINS_PREFIX} |
| 321 | VERBATIM |
| 322 | COMMAND_EXPAND_LISTS |
| 323 | ) |