移除不必要的嵌入资源和第三方通知文件,简化项目文件 #132
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: Build Native Assets | |
| '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: Optional note for this manual run | |
| required: false | |
| default: "" | |
| workflow_call: | |
| jobs: | |
| build: | |
| name: Build native (${{ matrix.rid }}) | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - 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 | |
| - rid: linux-x64 | |
| os: ubuntu-24.04 | |
| apt_packages: "" | |
| cmake_extra: "" | |
| - 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 | |
| - 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 | |
| - rid: osx-arm64 | |
| os: macos-15 | |
| cmake_osx_architectures: arm64 | |
| cmake_extra: "" | |
| - rid: osx-x64 | |
| os: macos-15-intel | |
| cmake_osx_architectures: x86_64 | |
| cmake_extra: "" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Copy lv_conf.h into the LVGL tree | |
| shell: bash | |
| run: cp libs/lv_conf.h libs/lvgl/lv_conf.h | |
| - name: Install Linux build dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y cmake ninja-build ${{ matrix.apt_packages }} | |
| - name: Install macOS build dependencies | |
| if: runner.os == 'macOS' | |
| run: brew install cmake ninja | |
| - name: Configure with CMake on 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: Build on Windows | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: cmake --build libs/lvgl/build_shared --config Release | |
| - name: Configure with CMake on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| 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: Configure with CMake on macOS | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| cmake -S libs/lvgl -B libs/lvgl/build_shared \ | |
| -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_osx_architectures }} \ | |
| -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: Build on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: cmake --build libs/lvgl/build_shared | |
| - name: Build on macOS | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: cmake --build libs/lvgl/build_shared | |
| - name: Collect native binaries | |
| 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 | |
| dylib=$(find libs/lvgl/build_shared -name "liblvgl.dylib" | head -1) | |
| if [ -n "$dylib" ]; then | |
| cp "$dylib" native_output/liblvgl.dylib | |
| fi | |
| ls -la native_output/ | |
| - name: Validate exported symbols on Linux | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| lib="native_output/liblvgl.so" | |
| if [ ! -f "$lib" ]; then | |
| echo "Error: missing $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 "Error: missing exports: ${missing[*]}" | |
| echo "===== nm -D $lib =====" | |
| nm -D "$lib" || true | |
| exit 1 | |
| fi | |
| echo "Validated exports: ${expected_symbols[*]}" | |
| - name: Validate exported symbols on macOS | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| lib="native_output/liblvgl.dylib" | |
| if [ ! -f "$lib" ]; then | |
| echo "Error: missing $lib" | |
| exit 1 | |
| fi | |
| expected_symbols=( | |
| _lv_init | |
| _lv_timer_handler | |
| _lv_display_create | |
| _lv_indev_create | |
| ) | |
| missing=() | |
| for symbol in "${expected_symbols[@]}"; do | |
| if ! nm -gU "$lib" | grep -w "$symbol" >/dev/null; then | |
| missing+=("$symbol") | |
| fi | |
| done | |
| if [ ${#missing[@]} -ne 0 ]; then | |
| echo "Error: missing exports: ${missing[*]}" | |
| echo "===== nm -gU $lib =====" | |
| nm -gU "$lib" || true | |
| exit 1 | |
| fi | |
| echo "Validated exports: ${expected_symbols[*]}" | |
| - name: Validate exported symbols on Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $lib = Join-Path $PWD 'native_output\lvgl.dll' | |
| if (-not (Test-Path $lib)) { | |
| throw "Missing $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 'Missing dumpbin.exe; cannot validate Windows exports.' | |
| } | |
| $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 "Error: missing exports: $($missing -join ', ')" | |
| Write-Host "===== dumpbin /exports $lib =====" | |
| $exports | ForEach-Object { Write-Host $_ } | |
| throw 'Windows export validation failed.' | |
| } | |
| Write-Host "Validated exports: $($expectedSymbols -join ', ')" | |
| - name: Generate sha256 files | |
| shell: pwsh | |
| run: | | |
| $files = Get-ChildItem -Path native_output -File | Where-Object { $_.Extension -in '.dll', '.so', '.dylib' } | |
| if (-not $files) { | |
| throw 'No native binaries were found in 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 "Generated $shaFile" | |
| } | |
| Get-ChildItem -Path native_output -Filter '*.sha256' | ForEach-Object { | |
| Write-Host "===== $($_.Name) =====" | |
| Get-Content $_.FullName | ForEach-Object { Write-Host $_ } | |
| } | |
| - name: Upload native artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-${{ matrix.rid }} | |
| path: native_output/ | |
| if-no-files-found: error |