Skip to content

Add multi-platform LVGL native builds and NuGet packaging via GitHub Actions#4

Merged
maikebing merged 5 commits intomasterfrom
copilot/add-lvgl-platform-support
Mar 15, 2026
Merged

Add multi-platform LVGL native builds and NuGet packaging via GitHub Actions#4
maikebing merged 5 commits intomasterfrom
copilot/add-lvgl-platform-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 15, 2026

LVGL supports a broad set of platforms but there was no CI pipeline to build the native shared library for each, nor any NuGet packaging for distribution.

CI: Native build matrix (build-native.yml)

Builds lvgl as a shared library (BUILD_SHARED_LIBS=ON) across 6 runtime identifiers using a matrix strategy, aligned with the LVGL official CI (ccpp.yml):

RID Runner Method
win-x64 / win-x86 / win-arm64 windows-latest MSVC -A flag
linux-x64 ubuntu-24.04 native GCC + Ninja
linux-arm / linux-arm64 ubuntu-24.04 cross-compile toolchain + Ninja

Per-RID artifacts (native-{rid}) are uploaded for consumption by the packaging job.

Linux builds use ubuntu-24.04 (matching the LVGL official CI), install cmake and ninja-build as base dependencies, and use -G Ninja for the CMake configure step.

CMake cross-compilation toolchain files

  • libs/cmake/toolchains/arm-linux-gnueabihf.cmake
  • libs/cmake/toolchains/aarch64-linux-gnu.cmake

Build fixes

  • lv_conf.h is copied into libs/lvgl/ before CMake configure so LVGL's own CMake can find it.
  • LV_USE_LINUX_FBDEV and LV_USE_EVDEV in lv_conf.h are now guarded with #if defined(__linux__) to prevent Windows builds from trying to compile Linux-only drivers that include <unistd.h>.
  • Cross-compilation toolchain paths use $GITHUB_WORKSPACE (shell variable, resolved at step run-time) instead of ${{ github.workspace }} (which expands to an empty string inside matrix include values).

NuGet packaging & publishing (nuget-publish.yml)

Triggered on GitHub release publication or workflow_dispatch. Pipeline:

  1. Calls build-native.yml as a reusable workflow
  2. Downloads all native artifacts and places them in runtimes/{rid}/native/ layout
  3. Registers the local nupkgs/ directory as a NuGet source before packing LVGLSharp.Interop, so the CI-activated LVGLSharp.Native package reference resolves correctly
  4. Packs LVGLSharp.Native, LVGLSharp.Interop, and LVGLSharp.Forms
  5. Pushes to NuGet.org (NUGET_API_KEY secret) and GitHub Packages (GITHUB_TOKEN)

New project: LVGLSharp.Native

A native-only NuGet package (netstandard2.0, IncludeBuildOutput=false) that bundles the platform shared libraries in the standard runtime graph layout:

runtimes/
  win-x64/native/lvgl.dll
  win-arm64/native/lvgl.dll
  linux-x64/native/liblvgl.so
  linux-arm/native/liblvgl.so
  linux-arm64/native/liblvgl.so
  ...

Shared metadata: Directory.Build.props

Centralises Authors, PackageLicenseExpression, RepositoryUrl, and default Version (9.3.0) for all projects.

Updated projects

  • LVGLSharp.InteropPackageId + LVGLSharp.Native dependency (CI-gated via '$(CI)' == 'true' to avoid breaking local builds before the package is first published)
  • LVGLSharp.FormsPackageId + Linux RID condition covers linux-x64, linux-arm, and linux-arm64

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

- CMake toolchain files for arm-linux-gnueabihf, aarch64-linux-gnu, loongarch64-linux-gnu
- GitHub Actions workflow build-native.yml: builds LVGL shared lib on 7 RIDs
- GitHub Actions workflow nuget-publish.yml: packs and publishes to NuGet.org and GitHub Packages
- New LVGLSharp.Native project: native-only NuGet package with runtimes layout
- Directory.Build.props: shared NuGet metadata for all projects
- LVGLSharp.Interop.csproj: added PackageId/description and CI-conditional LVGLSharp.Native dependency
- LVGLSharp.Forms.csproj: added PackageId/description and linux-loongarch64 RID

Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for multiple LVGL platforms with GitHub Actions Add multi-platform LVGL native builds and NuGet packaging via GitHub Actions Mar 15, 2026
Copilot AI requested a review from maikebing March 15, 2026 15:11
@maikebing
Copy link
Copy Markdown
Member

  • Using lv_conf.h from the top-level project directory
    CMake Error at env_support/cmake/os_desktop.cmake:126 (message):
    Configuration file:
    -- Configuring incomplete, errors occurred!
    D:/a/LVGLSharp.Forms/LVGLSharp.Forms/libs/lvgl/lv_conf.h - not found
    Call Stack (most recent call first):
    CMakeLists.txt:23 (include) @copilot

…onfigure

Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 15, 2026

  • Using lv_conf.h from the top-level project directory
    CMake Error at env_support/cmake/os_desktop.cmake:126 (message):
    Configuration file:
    ...

Fixed in 61b9c38. LVGL's CMake searches for lv_conf.h inside CMAKE_SOURCE_DIR (i.e. libs/lvgl/), but the file lives one level up at libs/lv_conf.h. Added a step in build-native.yml that copies libs/lv_conf.h into libs/lvgl/lv_conf.h right after checkout, before any CMake configure step runs. Also removed the now-redundant -DLVGL_ROOT_DIR flag from the Windows configure invocation.

@maikebing maikebing marked this pull request as ready for review March 15, 2026 15:29
Copilot AI review requested due to automatic review settings March 15, 2026 15:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds CI/CD infrastructure for building LVGL native shared libraries across multiple platforms and packaging them as NuGet packages. It introduces a reusable GitHub Actions workflow for cross-platform native builds, a NuGet publish pipeline, a new LVGLSharp.Native project for distributing platform-specific binaries, and shared build metadata.

Changes:

  • New build-native.yml workflow builds LVGL as a shared library for 7 RIDs (win-x64/x86/arm64, linux-x64/arm/arm64/loongarch64) with corresponding CMake cross-compilation toolchain files.
  • New nuget-publish.yml workflow assembles native artifacts and packs/publishes LVGLSharp.Native, LVGLSharp.Interop, and LVGLSharp.Forms to NuGet.org and GitHub Packages.
  • New LVGLSharp.Native project, Directory.Build.props for shared metadata, and updated .csproj files for Interop (CI-gated native dependency) and Forms (added linux-loongarch64 RID).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.github/workflows/build-native.yml Reusable workflow for multi-platform LVGL native library builds
.github/workflows/nuget-publish.yml NuGet packaging and publishing pipeline
src/LVGLSharp.Native/LVGLSharp.Native.csproj New native-only NuGet package project
src/LVGLSharp.Interop/LVGLSharp.Interop.csproj Added PackageId and CI-gated LVGLSharp.Native dependency
src/LVGLSharp.WinForms/LVGLSharp.Forms.csproj Added PackageId and loongarch64 RID to Linux condition
Directory.Build.props Shared NuGet metadata (authors, license, version)
libs/cmake/toolchains/*.cmake Cross-compilation toolchain files for ARM, ARM64, and LoongArch64

Comment on lines +116 to +121
- name: Pack LVGLSharp.Interop
run: |
dotnet pack src/LVGLSharp.Interop/LVGLSharp.Interop.csproj \
-c Release \
-p:Version=${{ steps.ver.outputs.version }} \
--output nupkgs
Comment on lines +22 to +23
# Derive version: prefer workflow_dispatch input, then release tag, then branch name.
# Strip any leading 'v' so we always get a semver string.
@maikebing
Copy link
Copy Markdown
Member

@copilot 有的成功了, 但大部分失败了, 你看下 https://github.com/IoTSharp/LVGLSharp.Forms/actions/runs/23113380409?pr=4

Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 15, 2026

@copilot 有的成功了, 但大部分失败了, 你看下 https://github.com/IoTSharp/LVGLSharp.Forms/actions/runs/23113380409?pr=4

Fixed in f5a716a. Three separate root causes, all addressed:

  1. Windows (win-x64/x86/arm64) — unistd.h not found (C1083): lv_conf.h had #define LV_USE_LINUX_FBDEV 1 and #define LV_USE_EVDEV 1 unconditionally, causing LVGL to compile Linux-specific drivers on Windows. Wrapped both with #if defined(__linux__) so they're enabled only on Linux.

  2. linux-arm / linux-arm64 — toolchain file not found: ${{ github.workspace }} in matrix include values is a known limitation — it expands to an empty string at matrix evaluation time, producing a path like /libs/cmake/toolchains/.... Changed to $GITHUB_WORKSPACE (a shell environment variable resolved at step run time), which correctly resolves to the full workspace path.

  3. linux-loongarch64 — gcc-loongarch64-linux-gnu package not found: Added sudo add-apt-repository universe -y before the apt-get update in the toolchain install step so the universe repository is guaranteed to be enabled and the package is locatable.

@maikebing
Copy link
Copy Markdown
Member

@copilot 去掉龙芯的编译, 然后参考 https://github.com/lvgl/lvgl/blob/master/.github/workflows/ccpp.yml 里面编译lvgl的参数 以及 编辑环境一来, 再一次做整理, 全程用中文, 这样方便我监督你。

Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 15, 2026

@copilot 去掉龙芯的编译, 然后参考 https://github.com/lvgl/lvgl/blob/master/.github/workflows/ccpp.yml 里面编译lvgl的参数 以及 编辑环境一来, 再一次做...

已在提交 9067315 中完成整理,具体改动如下:

移除龙芯编译支持:

  • 删除 build-native.yml 中的 linux-loongarch64 矩阵条目
  • 删除 nuget-publish.yml 中的 linux-loongarch64 RID 条目
  • 删除 libs/cmake/toolchains/loongarch64-linux-gnu.cmake 工具链文件
  • 更新两个 .csproj 的描述,移除龙芯相关文字

参考 LVGL 官方 CI(ccpp.yml)整理构建环境:

  • Linux 统一改用 ubuntu-24.04(与 LVGL 官方 CI 保持一致)
  • 显式安装 cmakeninja-build(LVGL 官方依赖)
  • Linux CMake 配置改用 -G Ninja 生成器(与 LVGL 官方 CI 一致)
  • 安装步骤合并:基础依赖与交叉编译工具链一次性安装

同步修复其他问题:

  • 打包 LVGLSharp.Interop 前自动注册本地 nupkgs/ 目录为 NuGet 源,避免 CI 环境中包引用解析失败
  • 工作流注释统一改为中文

@maikebing maikebing merged commit aaf3e26 into master Mar 15, 2026
6 checks passed
@maikebing
Copy link
Copy Markdown
Member

https://github.com/maikebing?tab=packages @copilot 暂时发布到这里。

@maikebing
Copy link
Copy Markdown
Member

@copilot 再开一个PR, 修正下面的问题 Package source with Name: github added successfully.
warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/IoTSharp'. To save an API Key for a source use the 'setApiKey' command.
Pushing LVGLSharp.Forms.0.0.1.nupkg to 'https://nuget.pkg.github.com/IoTSharp'...
PUT https://nuget.pkg.github.com/IoTSharp/
warn : Please use the --api-key option when publishing to GitHub Packages
OK https://nuget.pkg.github.com/IoTSharp/ 319ms
Your package was pushed.
warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/IoTSharp'. To save an API Key for a source use the 'setApiKey' command.
Pushing LVGLSharp.Interop.0.0.1.nupkg to 'https://nuget.pkg.github.com/IoTSharp'...
PUT https://nuget.pkg.github.com/IoTSharp/
warn : Please use the --api-key option when publishing to GitHub Packages
OK https://nuget.pkg.github.com/IoTSharp/ 302ms
Your package was pushed.
warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/IoTSharp'. To save an API Key for a source use the 'setApiKey' command.
Pushing LVGLSharp.Native.0.0.1.nupkg to 'https://nuget.pkg.github.com/IoTSharp'...
PUT https://nuget.pkg.github.com/IoTSharp/
error: The operation was canceled.
error: Error while copying content to a stream.
error: Unable to write data to the transport connection: Operation canceled.
error: Operation canceled
error: Pushing took too long. You can change the default timeout of 300 seconds by using the --timeout option with the push command.
Error: Process completed with exit code 1.

@maikebing maikebing deleted the copilot/add-lvgl-platform-support branch March 15, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants