Spec v19 §11 invariant 1 requires shell-native to compile on iOS / Android cargo check, with the `GlContextProvider` trait (invariant 2) importable on every non-wasm target. Previously the desktop GL stack (glutin / winit / skia-safe) was referenced unconditionally in src/, so mobile cargo check broke the moment the Cargo.toml target-gated those deps to macOS / Linux / Windows. This change cfg-gates the desktop-only modules and items so the mobile cargo check builds only the cross-platform surface: - src/lib.rs: gate `backend` + `canvas_view_stub` modules and their re-exports to desktop OS targets; add `EaglProvider` / `AndroidEglProvider` re-exports under `target_os = "ios"` / `"android"`. `GlContextProvider`, `ProviderError`, `ProviderResult` stay always-on (per §11 invariant 2). - src/context/mod.rs: split into a cross-platform trait surface + per-platform provider re-exports; gate `shared` (depends on `skia_safe` + `winit`) to desktop only. - src/context/provider.rs: cfg-gate `GlutinProvider` struct + impls + the `pick_display_api` helper to desktop OS only; localize `CString` / `NonZeroU32` imports inside fn bodies; gate `from_error` to desktop to silence dead_code on mobile (the only caller is `GlutinProvider`). - Cargo.toml: split deps into a cross-platform `cfg(not(wasm32))` block (jian-core + glow + raw-window-handle, all required by the trait signature on every non-wasm target) and a desktop-only block (skia-safe, glutin, glutin-winit, winit, scopeguard, jian-skia, jian-host-desktop). Merges the previously duplicate desktop `[target...]` table headers that cargo rejected. - ci: rust-multiplatform.yml mobile-check job now runs cargo check on shell-native too (per the comment update there). Verification: - cargo check -p openpencil-shell-native --target aarch64-apple-darwin: PASS - cargo check -p openpencil-shell-native --target aarch64-apple-ios: PASS - cargo check -p openpencil-shell-native --target aarch64-linux-android: PASS - cargo check -p openpencil-shell-native --target wasm32-unknown-unknown: FAILS with the spec §1.2 `compile_error!` (intended). - cargo test -p openpencil-shell-native: 14/14 PASS. - cargo clippy -p openpencil-shell-native --all-targets -- -D warnings: clean on macOS, iOS, Android targets. - cargo fmt --check: clean.
168 lines
5.7 KiB
YAML
168 lines
5.7 KiB
YAML
name: Rust multi-platform build
|
|
|
|
# Builds the OpenPencil Rust workspace across all supported targets.
|
|
# Runs on every push/PR to verify the matrix stays green; release artifacts
|
|
# are produced by `rust-release.yml` on tag pushes.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'Cargo.toml'
|
|
- 'Cargo.lock'
|
|
- 'crates/**'
|
|
- 'vendor/jian/**'
|
|
- 'rust-toolchain.toml'
|
|
- 'deny.toml'
|
|
- '.github/workflows/rust-multiplatform.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'Cargo.toml'
|
|
- 'Cargo.lock'
|
|
- 'crates/**'
|
|
- 'vendor/jian/**'
|
|
- '.github/workflows/rust-multiplatform.yml'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
desktop:
|
|
name: ${{ matrix.label }}
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- label: macos-aarch64
|
|
runner: macos-latest
|
|
target: aarch64-apple-darwin
|
|
cross: false
|
|
- label: macos-x86_64
|
|
runner: macos-13
|
|
target: x86_64-apple-darwin
|
|
cross: false
|
|
- label: linux-x86_64
|
|
runner: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
cross: false
|
|
- label: linux-aarch64
|
|
runner: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
cross: true
|
|
- label: windows-x86_64
|
|
runner: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
cross: false
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: '1.85'
|
|
targets: ${{ matrix.target }}
|
|
components: rustfmt, clippy
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ matrix.target }}
|
|
- name: Install Linux GL/EGL prereqs
|
|
if: runner.os == 'Linux' && matrix.cross == false
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libxkbcommon-dev libxkbcommon-x11-dev \
|
|
libwayland-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
|
|
libegl1-mesa-dev libgles2-mesa-dev libgbm-dev mesa-utils \
|
|
libfreetype-dev libfontconfig1-dev
|
|
- name: Install cross
|
|
if: matrix.cross == true
|
|
run: cargo install cross --locked --version 0.2.5
|
|
- name: Build (host)
|
|
if: matrix.cross == false
|
|
run: cargo build --workspace --target ${{ matrix.target }} --release
|
|
- name: Build (cross)
|
|
if: matrix.cross == true
|
|
run: cross build --workspace --target ${{ matrix.target }} --release
|
|
- name: Test (host, Linux strict-GPU)
|
|
if: matrix.cross == false && runner.os == 'Linux'
|
|
env:
|
|
STEP1A_REQUIRE_GPU: '1'
|
|
run: cargo test --workspace --target ${{ matrix.target }}
|
|
- name: Test (host, macOS / Windows)
|
|
if: matrix.cross == false && runner.os != 'Linux'
|
|
run: cargo test --workspace --target ${{ matrix.target }}
|
|
- name: Upload openpencil-app binary
|
|
if: matrix.cross == false
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: openpencil-app-${{ matrix.label }}
|
|
path: |
|
|
target/${{ matrix.target }}/release/openpencil-app
|
|
target/${{ matrix.target }}/release/openpencil-app.exe
|
|
if-no-files-found: ignore
|
|
retention-days: 14
|
|
|
|
wasm-web:
|
|
name: wasm32-unknown-unknown / openpencil-shell-web
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: '1.85'
|
|
targets: wasm32-unknown-unknown
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: wasm32
|
|
- run: cargo build -p openpencil-shell-web --target wasm32-unknown-unknown --release
|
|
- name: Upload wasm bundle
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: openpencil-shell-web-wasm
|
|
path: target/wasm32-unknown-unknown/release/openpencil_shell_web.wasm
|
|
if-no-files-found: warn
|
|
retention-days: 14
|
|
|
|
mobile-check:
|
|
name: ${{ matrix.label }} (cargo check only)
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# iOS targets need Xcode SDK — macOS runner only.
|
|
- label: ios-aarch64
|
|
runner: macos-latest
|
|
target: aarch64-apple-ios
|
|
- label: ios-aarch64-sim
|
|
runner: macos-latest
|
|
target: aarch64-apple-ios-sim
|
|
# Android targets via NDK — Linux runner.
|
|
- label: android-aarch64
|
|
runner: ubuntu-latest
|
|
target: aarch64-linux-android
|
|
- label: android-x86_64
|
|
runner: ubuntu-latest
|
|
target: x86_64-linux-android
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: '1.85'
|
|
targets: ${{ matrix.target }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: mobile-${{ matrix.target }}
|
|
# Step 1a spec §11 mobile invariants verify on iOS / Android cargo check:
|
|
# - shell-core wasm32/ios/android-clean (no platform deps).
|
|
# - shell-native compiles on mobile targets with EaglProvider /
|
|
# AndroidEglProvider stubs (`unimplemented!("Step 1f")`); desktop GL
|
|
# stack (glutin / winit) is target-gated to desktop in Cargo.toml +
|
|
# GlutinProvider source is cfg-gated to desktop OS only. Real SDK
|
|
# linking and iOS/Android runtime is Step 1f.
|
|
- run: cargo check -p openpencil-shell-core --target ${{ matrix.target }}
|
|
- run: cargo check -p openpencil-shell-native --target ${{ matrix.target }}
|