fix: use release configuration in demo restore and skip non-doc workf… #69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 构建原生库资产 | |
| on: | |
| push: | |
| branches: [main, develop, master] | |
| paths-ignore: | |
| - 'docs/**' | |
| - 'README.md' | |
| - 'README_en.md' | |
| - 'ROADMAP.md' | |
| - 'CHANGELOG.md' | |
| - '.github/workflows/docs-pages.yml' | |
| pull_request: | |
| branches: [main, develop, master] | |
| paths-ignore: | |
| - 'docs/**' | |
| - 'README.md' | |
| - 'README_en.md' | |
| - 'ROADMAP.md' | |
| - 'CHANGELOG.md' | |
| - '.github/workflows/docs-pages.yml' | |
| workflow_dispatch: | |
| inputs: | |
| note: | |
| description: "可选备注:用于说明本次手动触发的目的" | |
| required: false | |
| default: "" | |
| workflow_call: | |
| # inputs: 当前工作流无需调用方额外传参,按矩阵直接构建多平台原生库。 | |
| # outputs: 当前工作流仅产出 artifact,不向调用方返回结构化 outputs。 | |
| 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 | |
| # 1. 准备 LVGL 构建输入 | |
| - name: 复制 lv_conf.h 到 lvgl 源码目录 | |
| shell: bash | |
| run: cp libs/lv_conf.h libs/lvgl/lv_conf.h | |
| # 2. 安装 Linux 构建依赖 | |
| - name: 安装 Linux 构建依赖 | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y cmake ninja-build ${{ matrix.apt_packages }} | |
| # 3. 配置并编译 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 | |
| # 4. 配置并编译 Linux 原生库 | |
| - 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 | |
| # 5. 收集并校验原生库产物 | |
| - name: 收集原生库文件 | |
| shell: bash | |
| run: | | |
| mkdir -p native_output | |
| find libs/lvgl/build_shared -name "lvgl.dll" | head -1 | xargs -I{} cp {} native_output/ 2>/dev/null || true | |
| 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 |