-
Notifications
You must be signed in to change notification settings - Fork 0
237 lines (208 loc) · 8.86 KB
/
build-native.yml
File metadata and controls
237 lines (208 loc) · 8.86 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: 构建 LVGL 原生库
on:
push:
branches: [main, develop, master]
pull_request:
branches: [main, master]
workflow_dispatch:
workflow_call:
jobs:
build:
name: 构建 ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
# Windows — 通过 MSVC -A 参数构建多架构
- rid: win-x64
os: windows-latest
cmake_generator: "Visual Studio 17 2022"
cmake_arch: x64
- rid: win-x86
os: windows-latest
cmake_generator: "Visual Studio 17 2022"
cmake_arch: Win32
- rid: win-arm64
os: windows-latest
cmake_generator: "Visual Studio 17 2022"
cmake_arch: ARM64
# Linux — 原生 x64(与 LVGL 官方 CI 一致,使用 ubuntu-24.04)
- rid: linux-x64
os: ubuntu-24.04
cmake_extra: ""
# Linux — ARM 交叉编译(硬浮点)
- rid: linux-arm
os: ubuntu-24.04
apt_packages: gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
cmake_extra: >-
-DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/libs/cmake/toolchains/arm-linux-gnueabihf.cmake
# Linux — ARM64 交叉编译
- rid: linux-arm64
os: ubuntu-24.04
apt_packages: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
cmake_extra: >-
-DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/libs/cmake/toolchains/aarch64-linux-gnu.cmake
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
submodules: recursive
# ─── 将 lv_conf.h 复制到 lvgl 源码目录 ────────────────────────────────
# LVGL 的 CMake 在 CMAKE_SOURCE_DIR(libs/lvgl/)中查找 lv_conf.h,
# 而该文件位于上一级 libs/lv_conf.h,因此需要复制到正确位置。
- name: 复制 lv_conf.h 到 lvgl 源码目录
shell: bash
run: cp libs/lv_conf.h libs/lvgl/lv_conf.h
# ─── Linux:安装构建依赖(参考 LVGL 官方 CI)──────────────────────────
# 参考:https://github.com/lvgl/lvgl/blob/master/.github/workflows/ccpp.yml
# 基础依赖:cmake、ninja-build;交叉编译时额外安装对应工具链
- name: 安装 Linux 构建依赖
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build ${{ matrix.apt_packages }}
# ─── Windows 构建 ────────────────────────────────────────────────────────
- name: CMake 配置(Windows)
if: runner.os == 'Windows'
shell: bash
run: |
cmake -S libs/lvgl -B libs/lvgl/build_shared \
-G "${{ matrix.cmake_generator }}" \
-A "${{ matrix.cmake_arch }}" \
-DCONFIG_LV_BUILD_EXAMPLES=OFF \
-DCONFIG_LV_BUILD_DEMOS=OFF \
-DCONFIG_LV_USE_THORVG_INTERNAL=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCONFIG_LV_USE_PRIVATE_API=ON
- name: 编译(Windows)
if: runner.os == 'Windows'
shell: bash
run: cmake --build libs/lvgl/build_shared --config Release
# ─── Linux 构建(使用 Ninja,参考 LVGL 官方 CI)─────────────────────────
- name: CMake 配置(Linux)
if: runner.os == 'Linux'
run: |
cmake -S libs/lvgl -B libs/lvgl/build_shared \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
${{ matrix.cmake_extra }} \
-DCONFIG_LV_BUILD_EXAMPLES=OFF \
-DCONFIG_LV_BUILD_DEMOS=OFF \
-DCONFIG_LV_USE_THORVG_INTERNAL=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCONFIG_LV_USE_PRIVATE_API=ON
- name: 编译(Linux)
if: runner.os == 'Linux'
run: cmake --build libs/lvgl/build_shared
# ─── 收集输出文件 ────────────────────────────────────────────────────────
- name: 收集原生库文件
shell: bash
run: |
mkdir -p native_output
# Windows:从 Release 子目录复制 DLL
find libs/lvgl/build_shared -name "lvgl.dll" | head -1 | xargs -I{} cp {} native_output/ 2>/dev/null || true
# Linux:复制 SO 文件(优先无版本号的符号链接)
so=$(find libs/lvgl/build_shared -name "liblvgl.so" | head -1)
if [ -n "$so" ]; then
cp "$so" native_output/liblvgl.so
fi
ls -la native_output/
- name: 校验导出符号(Linux)
if: runner.os == 'Linux'
shell: bash
run: |
lib="native_output/liblvgl.so"
if [ ! -f "$lib" ]; then
echo "错误:未找到 $lib"
exit 1
fi
expected_symbols=(
lv_init
lv_timer_handler
lv_linux_fbdev_create
lv_linux_fbdev_set_file
lv_evdev_create
)
missing=()
for symbol in "${expected_symbols[@]}"; do
if ! nm -D "$lib" | grep -w "$symbol" >/dev/null; then
missing+=("$symbol")
fi
done
if [ ${#missing[@]} -ne 0 ]; then
echo "错误:$lib 缺少以下导出符号:${missing[*]}"
echo "===== nm -D $lib ====="
nm -D "$lib" || true
exit 1
fi
echo "导出符号校验通过:${expected_symbols[*]}"
- name: 校验导出符号(Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$lib = Join-Path $PWD 'native_output\lvgl.dll'
if (-not (Test-Path $lib)) {
throw "未找到 $lib"
}
$dumpbin = (Get-Command dumpbin.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source -First 1)
if (-not $dumpbin) {
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
if (Test-Path $vswhere) {
$installationPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | Select-Object -First 1
if ($installationPath) {
$candidate = Get-ChildItem -Path (Join-Path $installationPath 'VC\Tools\MSVC') -Filter dumpbin.exe -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName -First 1
if ($candidate) {
$dumpbin = $candidate
}
}
}
}
if (-not $dumpbin) {
throw '未找到 dumpbin.exe,无法校验 Windows 导出符号。'
}
$exports = & $dumpbin /exports $lib 2>&1
$expectedSymbols = @(
'lv_init',
'lv_timer_handler',
'lv_display_create',
'lv_indev_create'
)
$missing = @()
foreach ($symbol in $expectedSymbols) {
if (-not ($exports | Select-String -SimpleMatch $symbol)) {
$missing += $symbol
}
}
if ($missing.Count -gt 0) {
Write-Host "错误:$lib 缺少以下导出符号:$($missing -join ', ')"
Write-Host "===== dumpbin /exports $lib ====="
$exports | ForEach-Object { Write-Host $_ }
throw 'Windows 导出符号校验失败。'
}
Write-Host "导出符号校验通过:$($expectedSymbols -join ', ')"
- name: 生成 sha256
shell: pwsh
run: |
$files = Get-ChildItem -Path native_output -File | Where-Object { $_.Extension -in '.dll', '.so' }
if (-not $files) {
throw 'native_output 中没有可生成校验值的原生库文件。'
}
foreach ($file in $files) {
$hash = (Get-FileHash -Path $file.FullName -Algorithm SHA256).Hash.ToLowerInvariant()
$shaFile = "$($file.FullName).sha256"
Set-Content -Path $shaFile -Value "$hash $($file.Name)" -NoNewline
Write-Host "已生成 $shaFile"
}
Get-ChildItem -Path native_output -Filter '*.sha256' | ForEach-Object {
Write-Host "===== $($_.Name) ====="
Get-Content $_.FullName | ForEach-Object { Write-Host $_ }
}
- name: 上传原生库制品
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.rid }}
path: native_output/
if-no-files-found: error