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