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