blob: eedf3ae9a511faabe05299904a4db058d413475c [file] [log] [blame]
Damien George9b908822020-09-23 15:55:55 +10001# Set location of base MicroPython directory.
2get_filename_component(MICROPY_DIR ${PROJECT_DIR}/../.. ABSOLUTE)
3
4# Include core source components.
5include(${MICROPY_DIR}/py/py.cmake)
6include(${MICROPY_DIR}/extmod/extmod.cmake)
7
8set(MICROPY_SOURCE_EXTMOD_EXTRA
9 ${MICROPY_DIR}/extmod/modonewire.c
10)
11
12set(MICROPY_SOURCE_LIB
13 ${MICROPY_DIR}/lib/littlefs/lfs1.c
14 ${MICROPY_DIR}/lib/littlefs/lfs1_util.c
15 ${MICROPY_DIR}/lib/littlefs/lfs2.c
16 ${MICROPY_DIR}/lib/littlefs/lfs2_util.c
17 ${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
18 ${MICROPY_DIR}/lib/mp-readline/readline.c
19 ${MICROPY_DIR}/lib/netutils/netutils.c
20 ${MICROPY_DIR}/lib/oofatfs/ff.c
21 ${MICROPY_DIR}/lib/oofatfs/ffunicode.c
22 ${MICROPY_DIR}/lib/timeutils/timeutils.c
23 ${MICROPY_DIR}/lib/utils/interrupt_char.c
24 ${MICROPY_DIR}/lib/utils/stdout_helpers.c
25 ${MICROPY_DIR}/lib/utils/sys_stdio_mphal.c
26 ${MICROPY_DIR}/lib/utils/pyexec.c
27)
28
29set(MICROPY_SOURCE_DRIVERS
30 ${MICROPY_DIR}/drivers/bus/softspi.c
31 ${MICROPY_DIR}/drivers/dht/dht.c
32)
33
34set(MICROPY_SOURCE_PORT
35 ${PROJECT_DIR}/main.c
36 ${PROJECT_DIR}/uart.c
37 ${PROJECT_DIR}/gccollect.c
38 ${PROJECT_DIR}/mphalport.c
39 ${PROJECT_DIR}/fatfs_port.c
40 ${PROJECT_DIR}/help.c
41 ${PROJECT_DIR}/modutime.c
42 ${PROJECT_DIR}/moduos.c
43 ${PROJECT_DIR}/machine_timer.c
44 ${PROJECT_DIR}/machine_pin.c
45 ${PROJECT_DIR}/machine_touchpad.c
46 ${PROJECT_DIR}/machine_adc.c
47 ${PROJECT_DIR}/machine_dac.c
48 ${PROJECT_DIR}/machine_i2c.c
49 ${PROJECT_DIR}/machine_pwm.c
50 ${PROJECT_DIR}/machine_uart.c
51 ${PROJECT_DIR}/modmachine.c
52 ${PROJECT_DIR}/modnetwork.c
53 ${PROJECT_DIR}/network_lan.c
54 ${PROJECT_DIR}/network_ppp.c
55 ${PROJECT_DIR}/mpnimbleport.c
56 ${PROJECT_DIR}/modsocket.c
57 ${PROJECT_DIR}/modesp.c
58 ${PROJECT_DIR}/esp32_partition.c
59 ${PROJECT_DIR}/esp32_rmt.c
60 ${PROJECT_DIR}/esp32_ulp.c
61 ${PROJECT_DIR}/modesp32.c
62 ${PROJECT_DIR}/espneopixel.c
63 ${PROJECT_DIR}/machine_hw_spi.c
64 ${PROJECT_DIR}/machine_wdt.c
65 ${PROJECT_DIR}/mpthreadport.c
66 ${PROJECT_DIR}/machine_rtc.c
67 ${PROJECT_DIR}/machine_sdcard.c
68)
69
70set(MICROPY_SOURCE_QSTR
71 ${MICROPY_SOURCE_PY}
72 ${MICROPY_SOURCE_EXTMOD}
73 ${MICROPY_SOURCE_EXTMOD_EXTRA}
74 ${MICROPY_SOURCE_LIB}
75 ${MICROPY_SOURCE_PORT}
76)
77
78set(IDF_COMPONENTS
79 app_update
80 bootloader_support
Damien Georgeda2b5fa2021-02-14 01:36:30 +110081 bt
Damien George9b908822020-09-23 15:55:55 +100082 driver
83 esp32
84 esp_common
85 esp_eth
86 esp_event
87 esp_ringbuf
88 esp_rom
89 esp_wifi
90 freertos
91 heap
92 log
93 lwip
94 mbedtls
95 mdns
96 newlib
97 nvs_flash
98 sdmmc
99 soc
100 spi_flash
101 tcpip_adapter
102 ulp
103 vfs
104 xtensa
105)
106
107# Register the main IDF component.
108idf_component_register(
109 SRCS
110 ${MICROPY_SOURCE_PY}
111 ${MICROPY_SOURCE_EXTMOD}
112 ${MICROPY_SOURCE_EXTMOD_EXTRA}
113 ${MICROPY_SOURCE_LIB}
114 ${MICROPY_SOURCE_DRIVERS}
115 ${MICROPY_SOURCE_PORT}
116 INCLUDE_DIRS
117 ${MICROPY_DIR}
118 ${MICROPY_PORT_DIR}
119 ${MICROPY_BOARD_DIR}
120 ${CMAKE_BINARY_DIR}
121 REQUIRES
122 ${IDF_COMPONENTS}
123)
124
125# Set the MicroPython target as the current (main) IDF component target.
126set(MICROPY_TARGET ${COMPONENT_TARGET})
127
128# Define mpy-cross flags, for use with frozen code.
129set(MICROPY_CROSS_FLAGS -march=xtensawin)
130
131# Set compile options for this port.
132target_compile_definitions(${MICROPY_TARGET} PUBLIC
133 MICROPY_ESP_IDF_4=1
134 MICROPY_VFS_FAT=1
135 MICROPY_VFS_LFS2=1
136 FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\"
137 LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT
138 LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT
139)
140
141# Disable some warnings to keep the build output clean.
142target_compile_options(${MICROPY_TARGET} PUBLIC
143 -Wno-clobbered
144 -Wno-deprecated-declarations
145 -Wno-missing-field-initializers
146)
147
148# Collect all of the include directories and compile definitions for the IDF components.
149foreach(comp ${IDF_COMPONENTS})
150 get_target_property(type __idf_${comp} TYPE)
151 set(_inc OFF)
152 set(_def OFF)
153 if(${type} STREQUAL STATIC_LIBRARY)
154 get_target_property(_inc __idf_${comp} INCLUDE_DIRECTORIES)
155 get_target_property(_def __idf_${comp} COMPILE_DEFINITIONS)
156 elseif(${type} STREQUAL INTERFACE_LIBRARY)
157 get_target_property(_inc __idf_${comp} INTERFACE_INCLUDE_DIRECTORIES)
158 get_target_property(_def __idf_${comp} INTERFACE_COMPILE_DEFINITIONS)
159 endif()
160 if(_inc)
161 list(APPEND MICROPY_CPP_INC_EXTRA ${_inc})
162 endif()
163 if(_def)
164 list(APPEND MICROPY_CPP_DEF_EXTRA ${_def})
165 endif()
166endforeach()
167
168# Include the main MicroPython cmake rules.
169include(${MICROPY_DIR}/py/mkrules.cmake)