Skip to content

Commit d343eb9

Browse files
authored
RPi Pico port compilation (#174)
* use ESP_PLATFORM conditionals around ESP32-specific bits * use LIST(APPEND LV_SRC ...) * handle LV_PNG_PP_OPTIONS for non-ESP platform * Set LV_BINDINGS_DIR not relative to MICROPY_DIR (for out-of-tree builds) * add cmake file for use with USER_C_MODULE=bindings.cmake * interface lib for lvgl Related PRs: - lvgl/lv_micropython#42 - lvgl/lvgl#2532
1 parent f9b147c commit d343eb9

File tree

2 files changed

+61
-35
lines changed

2 files changed

+61
-35
lines changed

bindings.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file is to be given as "make USER_C_MODULES=..." when building Micropython port
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/mkrules.cmake)
4+
5+
# create targets for generated files
6+
all_lv_bindings()
7+
8+
# lvgl bindings target (the mpy module)
9+
add_library(usermod_lv_bindings INTERFACE)
10+
target_sources(usermod_lv_bindings INTERFACE ${LV_SRC})
11+
target_include_directories(usermod_lv_bindings INTERFACE ${LV_INCLUDE})
12+
13+
# lvgl bindings depend on lvgl itself, pull it in
14+
include(${LVGL_DIR}/CMakeLists.txt)
15+
target_link_libraries(usermod_lv_bindings INTERFACE lvgl_interface)
16+
17+
# make usermod (target declared by Micropython for all user compiled modules) link to bindings
18+
# this way the bindings (and transitively lvgl_interface) get proper compilation flags
19+
target_link_libraries(usermod INTERFACE usermod_lv_bindings)

mkrules.cmake

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
find_package(Python3 REQUIRED COMPONENTS Interpreter)
33
find_program(AWK awk mawk gawk)
44

5-
set(LV_BINDINGS_DIR ${MICROPY_DIR}/lib/lv_bindings)
5+
set(LV_BINDINGS_DIR ${CMAKE_CURRENT_LIST_DIR})
66

77
# Common function for creating LV bindings
88

@@ -81,7 +81,9 @@ set(LV_PNG_DIR ${LV_BINDINGS_DIR}/driver/png/lodepng)
8181
set(LV_MP ${CMAKE_BINARY_DIR}/lv_mp.c)
8282
set(LV_PNG ${CMAKE_BINARY_DIR}/lv_png.c)
8383
set(LV_PNG_C ${CMAKE_BINARY_DIR}/lv_png_c.c)
84-
set(LV_ESPIDF ${CMAKE_BINARY_DIR}/lv_espidf.c)
84+
if(ESP_PLATFORM)
85+
set(LV_ESPIDF ${CMAKE_BINARY_DIR}/lv_espidf.c)
86+
endif()
8587

8688
# Function for creating all specific bindings
8789

@@ -105,7 +107,11 @@ function(all_lv_bindings)
105107

106108
file(GLOB_RECURSE LV_PNG_HEADERS ${LV_PNG_DIR}/*.h)
107109
configure_file(${LV_PNG_DIR}/lodepng.cpp ${LV_PNG_C} COPYONLY)
108-
idf_build_set_property(COMPILE_DEFINITIONS "${LV_PNG_PP_OPTIONS}" APPEND)
110+
if(ESP_PLATFORM)
111+
idf_build_set_property(COMPILE_DEFINITIONS "${LV_PNG_PP_OPTIONS}" APPEND)
112+
else()
113+
add_definitions(${LV_PNG_PP_OPTIONS})
114+
endif()
109115
lv_bindings(
110116
OUTPUT
111117
${LV_PNG}
@@ -120,30 +126,31 @@ function(all_lv_bindings)
120126
)
121127

122128
# ESPIDF bindings
123-
124-
file(GLOB_RECURSE LV_ESPIDF_HEADERS ${IDF_PATH}/components/*.h ${LV_BINDINGS_DIR}/driver/esp32/*.h)
125-
lv_bindings(
126-
OUTPUT
127-
${LV_ESPIDF}
128-
INPUT
129-
${LV_BINDINGS_DIR}/driver/esp32/espidf.h
130-
DEPENDS
131-
${LV_ESPIDF_HEADERS}
132-
PP_OPTIONS
133-
-DPYCPARSER
134-
GEN_OPTIONS
135-
-M espidf
136-
FILTER
137-
i2s_ll.h
138-
i2s_hal.h
139-
esp_intr_alloc.h
140-
soc/spi_periph.h
141-
rom/ets_sys.h
142-
soc/sens_struct.h
143-
soc/rtc.h
144-
driver/periph_ctrl.h
145-
include/esp_private
146-
)
129+
if(ESP_PLATFORM)
130+
file(GLOB_RECURSE LV_ESPIDF_HEADERS ${IDF_PATH}/components/*.h ${LV_BINDINGS_DIR}/driver/esp32/*.h)
131+
lv_bindings(
132+
OUTPUT
133+
${LV_ESPIDF}
134+
INPUT
135+
${LV_BINDINGS_DIR}/driver/esp32/espidf.h
136+
DEPENDS
137+
${LV_ESPIDF_HEADERS}
138+
PP_OPTIONS
139+
-DPYCPARSER
140+
GEN_OPTIONS
141+
-M espidf
142+
FILTER
143+
i2s_ll.h
144+
i2s_hal.h
145+
esp_intr_alloc.h
146+
soc/spi_periph.h
147+
rom/ets_sys.h
148+
soc/sens_struct.h
149+
soc/rtc.h
150+
driver/periph_ctrl.h
151+
include/esp_private
152+
)
153+
endif(ESP_PLATFORM)
147154

148155
endfunction()
149156

@@ -158,16 +165,16 @@ set(LV_INCLUDE
158165

159166
set(LV_SRC
160167
${LV_MP}
161-
162-
${LV_BINDINGS_DIR}/driver/esp32/espidf.c
163-
${LV_BINDINGS_DIR}/driver/esp32/modrtch.c
164-
${LV_BINDINGS_DIR}/driver/esp32/sh2lib.c
165-
166168
${LV_PNG}
167169
${LV_PNG_C}
168170
${LV_BINDINGS_DIR}/driver/png/mp_lodepng.c
169-
170-
${LV_ESPIDF}
171171
)
172172

173-
173+
if(ESP_PLATFORM)
174+
LIST(APPEND LV_SRC
175+
${LV_BINDINGS_DIR}/driver/esp32/espidf.c
176+
${LV_BINDINGS_DIR}/driver/esp32/modrtch.c
177+
${LV_BINDINGS_DIR}/driver/esp32/sh2lib.c
178+
${LV_ESPIDF}
179+
)
180+
endif(ESP_PLATFORM)

0 commit comments

Comments
 (0)