Skip to content

Commit f40b3de

Browse files
authored
feat: 启用 host macOS SDL2 LVGL 适配包
启用 host macOS SDL2 LVGL 适配包。
1 parent 70e10b7 commit f40b3de

14 files changed

Lines changed: 1198 additions & 4 deletions

File tree

.github/workflows/host-macos-package.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
- name: Checkout
1212
uses: actions/checkout@v4
1313

14+
- name: Install SDL2
15+
run: brew install sdl2
16+
1417
- name: Build LVGL package
1518
run: ./scripts/build_host_macos.sh
1619

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build/
22
downloads/
33
src/lvgl/
4+
.worktrees/
45
*.tmp
56
.DS_Store

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,28 @@ if(NOT EXISTS "${LVGL_CONFIG_DIR}/lv_conf.h")
1313
message(FATAL_ERROR "lv_conf.h not found at ${LVGL_CONFIG_DIR}/lv_conf.h")
1414
endif()
1515

16+
find_program(SDL2_CONFIG_EXECUTABLE sdl2-config REQUIRED)
17+
18+
execute_process(COMMAND ${SDL2_CONFIG_EXECUTABLE} --cflags
19+
OUTPUT_VARIABLE SDL2_CFLAGS
20+
OUTPUT_STRIP_TRAILING_WHITESPACE
21+
)
22+
23+
execute_process(COMMAND ${SDL2_CONFIG_EXECUTABLE} --prefix
24+
OUTPUT_VARIABLE SDL2_PREFIX
25+
OUTPUT_STRIP_TRAILING_WHITESPACE
26+
)
27+
28+
separate_arguments(SDL2_CFLAGS_LIST NATIVE_COMMAND "${SDL2_CFLAGS}")
29+
set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include")
30+
1631
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
1732
set(LV_CONF_PATH "${LVGL_CONFIG_DIR}/lv_conf.h" CACHE STRING "" FORCE)
1833
set(LV_CONF_BUILD_DISABLE_EXAMPLES ON CACHE BOOL "" FORCE)
1934
set(LV_CONF_BUILD_DISABLE_DEMOS ON CACHE BOOL "" FORCE)
2035
set(LV_CONF_BUILD_DISABLE_THORVG_INTERNAL ON CACHE BOOL "" FORCE)
2136

2237
add_subdirectory("${LVGL_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/lvgl")
38+
39+
target_include_directories(lvgl PRIVATE "${SDL2_INCLUDE_DIR}")
40+
target_compile_options(lvgl PRIVATE ${SDL2_CFLAGS_LIST})

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# lvgl-prebuilt-host-macos
22

3-
这个仓库负责为 Mac host 产出 LVGL 9.1 预编译包。
3+
这个仓库负责为 Mac host 产出已适配 SDL2 的 LVGL 9.1 预编译包。
44

55
它的职责是:
66

77
- 固定 LVGL 官方版本。
88
- 使用 Mac 工具链编译 `liblvgl.a`
9+
- 启用 host macOS SDL2 display/input backend。
910
- 导出成 `embedded-platform-core` 可以消费的包结构。
1011

1112
它不负责:
1213

1314
- 编译匠芯创 Luban-Lite 的 LVGL。
1415
- 编译全志 Linux 的 LVGL。
1516
- 封装 LVGL 控件 API。
16-
- 提供显示窗口、输入设备或平台 port。
1717

1818
## 产物结构
1919

@@ -34,6 +34,12 @@ dist/lvgl/host_macos/
3434

3535
`include/``lv_conf.h``lib/liblvgl.a` 必须成套使用,不能和其他平台的 LVGL 包混用。
3636

37+
## 依赖
38+
39+
```bash
40+
brew install sdl2
41+
```
42+
3743
## 构建
3844

3945
```bash
@@ -46,8 +52,16 @@ dist/lvgl/host_macos/
4652
./scripts/verify_package.sh
4753
```
4854

55+
默认验证会编译 SDL2 demo,但不会强制打开窗口。需要本地看窗口效果时运行:
56+
57+
```bash
58+
LVGL_RUN_SDL2_DEMO=1 ./scripts/verify_package.sh
59+
```
60+
4961
## 版本
5062

5163
- LVGL tag: `v9.1.0`
5264
- LVGL commit: `e1c0b21b2723d391b885de4b2ee5cc997eccca91`
5365
- 平台: `host_macos`
66+
- 显示后端: `sdl2`
67+
- 输入后端: `sdl2`

config/host_macos/lv_conf.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
#define LV_USE_PXP 0
3535
#define LV_USE_ROTATE_PXP 0
3636
#define LV_USE_DRAW_DAVE2D 0
37+
#define LV_USE_DRAW_SDL 0
38+
39+
#define LV_USE_SDL 1
40+
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
41+
#define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
42+
#define LV_SDL_BUF_COUNT 1
43+
#define LV_SDL_ACCELERATED 0
44+
#define LV_SDL_FULLSCREEN 0
45+
#define LV_SDL_DIRECT_EXIT 0
46+
#define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER
3747

3848
#define LV_USE_LOG 0
3949
#define LV_USE_ASSERT_NULL 1

dist/lvgl/host_macos/include/lv_conf.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
#define LV_USE_PXP 0
3535
#define LV_USE_ROTATE_PXP 0
3636
#define LV_USE_DRAW_DAVE2D 0
37+
#define LV_USE_DRAW_SDL 0
38+
39+
#define LV_USE_SDL 1
40+
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
41+
#define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
42+
#define LV_SDL_BUF_COUNT 1
43+
#define LV_SDL_ACCELERATED 0
44+
#define LV_SDL_FULLSCREEN 0
45+
#define LV_SDL_DIRECT_EXIT 0
46+
#define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER
3747

3848
#define LV_USE_LOG 0
3949
#define LV_USE_ASSERT_NULL 1

dist/lvgl/host_macos/lib/liblvgl.a

13.2 KB
Binary file not shown.

dist/lvgl/host_macos/lvgl_package.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ lvgl.version=9.1.0
22
lvgl.tag=v9.1.0
33
lvgl.commit=e1c0b21b2723d391b885de4b2ee5cc997eccca91
44
platform=host_macos
5+
display_backend=sdl2
6+
input_backend=sdl2
57
toolchain=Apple clang version 21.0.0 (clang-2100.0.123.102)
68
arch=arm64
7-
lv_conf_hash=75672b9ddbb6f51a26c8bef62d269d156eaffca988574cf9a205076f5fda9985
8-
lib_hash=f60379df5c6da0cd7341776f7d69facfa2b1bbbab2bad4fb027509ffa07ab8e2
9+
sdl2.version=2.32.10
10+
sdl2.cflags=-I/opt/homebrew/include/SDL2 -D_THREAD_SAFE
11+
sdl2.libs=-L/opt/homebrew/lib -lSDL2
12+
lv_conf_hash=c719a317f5b7e78ef074fffc7ef0d1f399f1e8bab38d000b4f950a14a6273dfb
13+
lib_hash=3758c0a3749cb31fe7275b36acd87533c7d24fcac850d429d5394e6eec01c469

0 commit comments

Comments
 (0)