-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicropython.cmake
More file actions
71 lines (64 loc) · 2.93 KB
/
Copy pathmicropython.cmake
File metadata and controls
71 lines (64 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# MicroPython CMake glue for usbif (ESP32-S2/S3/P4; see the guard below).
# For Make-based ports (unix, windows), see micropython.mk in this dir.
#
# Point USER_C_MODULES at this repo (or this file) directly, e.g.:
# idf.py build -DUSER_C_MODULES=<path to usbif>/micropython.cmake
# Or let the workspace aggregator's own micropython.cmake discover it
# alongside other usermods.
set(USBIF_MOD_DIR ${CMAKE_CURRENT_LIST_DIR})
set(USBIF_SRC_DIR ${USBIF_MOD_DIR}/src)
# usbif is TinyUSB all the way down -- every source below needs it -- and
# TinyUSB is present on parts with a USB OTG controller: ESP32-S2, S3, and P4.
# That is the same line MicroPython draws with MICROPY_PY_TINYUSB
# (ports/esp32/esp32_common.cmake).
#
# Other ESP32 parts (C6, C3, C61, H2, classic) have USB Serial/JTAG at most, so
# the TinyUSB component is absent from their build. rp2 fails differently and
# more quietly: it HAS TinyUSB, but a usermod there does not get its include
# path, so every source fails on `tusb.h: No such file or directory`. Wiring
# that up is plausible work nobody has done, so rp2 is skipped too rather than
# half-supported.
#
# Without this guard the whole firmware fails to configure on those targets:
# idf_component_get_property() below is a hard CMake error for a component that
# does not exist, so the `if(usbif_tusb_lib)` test never gets to run. Skipping
# the module leaves the rest of the firmware buildable.
if(NOT (ESP_PLATFORM AND (CONFIG_IDF_TARGET_ESP32S2 OR CONFIG_IDF_TARGET_ESP32S3 OR CONFIG_IDF_TARGET_ESP32P4)))
message(STATUS
"usbif: skipped -- builds only on the ESP32-S2, S3, and P4. The firmware "
"builds without the _usbif module.")
return()
endif()
add_library(usermod_usbif INTERFACE)
target_sources(usermod_usbif INTERFACE
${USBIF_SRC_DIR}/mod_usbif.c
${USBIF_SRC_DIR}/usbif_uac.c
${USBIF_SRC_DIR}/usbif_i2s.c
${USBIF_SRC_DIR}/usbif_host.c
${USBIF_SRC_DIR}/usbif_host_cdc.c
${USBIF_SRC_DIR}/usbif_host_hid.c
${USBIF_SRC_DIR}/usbif_host_msc.c
${USBIF_SRC_DIR}/usbif_host_midi.c
${USBIF_SRC_DIR}/usbif_host_uac.c
${USBIF_SRC_DIR}/usbif_host_uvc.c
${USBIF_SRC_DIR}/usbif_desc.c
${USBIF_SRC_DIR}/usbif_hid_dev.c
${USBIF_SRC_DIR}/usbif_msc_dev.c
${USBIF_SRC_DIR}/usbif_uvc_dev.c
${USBIF_SRC_DIR}/shared/usbif_ringbuf.c
${USBIF_SRC_DIR}/shared/usbif_midi_packet.c
)
target_include_directories(usermod_usbif INTERFACE
${USBIF_SRC_DIR}
)
# MicroPython compiles the TinyUSB component against its own tusb_config.h,
# whose extension hook includes a header from this repo. The component's
# include path must therefore reach src/ -- the same arrangement the esp32
# port already makes for shared/tinyusb.
if(ESP_PLATFORM)
idf_component_get_property(usbif_tusb_lib espressif__tinyusb COMPONENT_LIB)
if(usbif_tusb_lib)
target_include_directories(${usbif_tusb_lib} PRIVATE ${USBIF_SRC_DIR})
endif()
endif()
target_link_libraries(usermod INTERFACE usermod_usbif)