SDK: sync lv_conf demo flags, expose demos/ include, add NO_KBD_STUBS opt-out

sdk/include/lv_conf.h mirrors the emulator's (music + keypad_encoder
demos enabled) so apps using the SDK see the same LVGL feature set
the host provides.

sdk/cmake/CZApp.cmake gains:
- demos/ header search path so apps can #include
  "widgets/lv_demo_widgets.h" etc.
- NO_KBD_STUBS option for apps that want to resolve the host's real
  lv_sdl_keyboard_create at dlopen time (instead of the weak inert
  stub). Default weak stub stays for the 90% of apps that don't care
  about keyboard input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
LiHaohua
2026-05-06 14:30:34 +08:00
committed by eggfly
co-authored by Claude Opus 4.7
parent dd46c57179
commit f12cf51e16
2 changed files with 18 additions and 7 deletions
+16 -5
View File
@@ -36,7 +36,13 @@ if(NOT EXISTS "${CZ_LVGL_DIR}/lvgl.h")
endif()
function(cz_add_lvgl_app TARGET)
cmake_parse_arguments(CZA "" "" "SOURCES" ${ARGN})
# Options:
# NO_KBD_STUBS — skip the default weak lv_sdl_keyboard_create/handler
# shim. Apps that want real keyboard input (using the
# emulator's real SDL keyboard driver) should set this so
# that the symbols stay unresolved in the .dylib/.so and
# get bound to the host at dlopen time.
cmake_parse_arguments(CZA "NO_KBD_STUBS" "" "SOURCES" ${ARGN})
if(NOT CZA_SOURCES)
message(FATAL_ERROR "cz_add_lvgl_app(${TARGET}): no SOURCES given")
endif()
@@ -51,8 +57,9 @@ function(cz_add_lvgl_app TARGET)
)
target_include_directories(${TARGET} PRIVATE
"${CZ_SDK_DIR}/include" # cz_app.h + lv_conf.h
"${CZ_LVGL_DIR}" # lvgl.h
"${CZ_SDK_DIR}/include" # cz_app.h + lv_conf.h
"${CZ_LVGL_DIR}" # lvgl.h
"${CZ_LVGL_DIR}/demos" # demos/widgets/lv_demo_widgets.h etc.
)
# Pinned LVGL config — must byte-match the host's.
@@ -95,13 +102,17 @@ function(cz_add_lvgl_app TARGET)
)
target_sources(${TARGET} PRIVATE "${_weak}")
if(CZA_NO_KBD_STUBS)
return()
endif()
# Default weak keyboard stubs. The emulator always dlsyms
# lv_sdl_keyboard_create / lv_sdl_keyboard_handler; when the app provides
# neither, the emulator falls back to a bare keypad indev with no read_cb
# and LVGL floods the log with "indev_read_cb is not registered". These
# stubs give the emulator a real (but inert) indev so the log stays clean.
# Apps that want real keyboard input define their own strong versions and
# override the weak ones at link time.
# Apps that want real keyboard input pass NO_KBD_STUBS and let the
# emulator's real lv_sdl_keyboard_* resolve via dlopen.
set(_kbd "${CMAKE_CURRENT_BINARY_DIR}/cz_${TARGET}_kbd_default.c")
file(WRITE "${_kbd}"
"/* Auto-generated by CZApp.cmake — default no-op SDL keyboard stubs. */\n"
+2 -2
View File
@@ -495,12 +495,12 @@
#if LV_BUILD_DEMOS
#define LV_USE_DEMO_WIDGETS 1
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1
#define LV_USE_DEMO_BENCHMARK 0
#define LV_USE_DEMO_RENDER 0
#define LV_USE_DEMO_STRESS 0
#define LV_USE_DEMO_MUSIC 0
#define LV_USE_DEMO_MUSIC 1
#define LV_USE_DEMO_VECTOR_GRAPHIC 0
#define LV_USE_DEMO_GLTF 0
#define LV_USE_DEMO_FLEX_LAYOUT 0