8000 Modernize to Rust 2024 edition, add tests/, update CI by qatoqat · Pull Request #665 · not-fl3/miniquad · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 69 additions & 27 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
on: [push, pull_request]

name: Cross-compile
name: CI

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build
name: Build ${{ matrix.config.target }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
Expand All @@ -16,6 +19,7 @@ jobs:
- { os: ubuntu-latest, target: 'x86_64-pc-windows-gnu' }
- { os: ubuntu-latest, target: 'wasm32-unknown-unknown' }
- { os: macos-latest, target: 'x86_64-apple-darwin' }
- { os: macos-latest, target: 'aarch64-apple-darwin' }
- { os: macos-latest, target: 'aarch64-apple-ios' }
- { os: macos-latest, target: 'x86_64-apple-ios' }
- { os: windows-latest, target: 'x86_64-pc-windows-msvc' }
Expand All @@ -30,55 +34,93 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install ${{ matrix.packages }}
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.config.target }}
override: true
targets: ${{ matrix.config.target }}
- name: Workaround MinGW issue # https://github.com/rust-lang/rust/issues/47048
if: runner.os == 'Linux' && matrix.config.target == 'x86_64-pc-windows-gnu'
run: |
sudo cp /usr/x86_64-w64-mingw32/lib/dllcrt2.o ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/dllcrt2.o
sudo cp /usr/x86_64-w64-mingw32/lib/crt2.o ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o
echo "[target.x86_64-pc-windows-gnu]" >> ~/.cargo/config
echo "linker = \"/usr/bin/x86_64-w64-mingw32-gcc\"" >> ~/.cargo/config
echo "[target.x86_64-pc-windows-gnu]" >> ~/.cargo/config.toml
echo "linker = \"/usr/bin/x86_64-w64-mingw32-gcc\"" >> ~/.cargo/config.toml
- name: Setup aarch64
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt install gcc-aarch64-linux-gnu
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config
echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml
echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config.toml
- name: Setup armv7
if: matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt install gcc-arm-linux-gnueabihf
echo "[target.armv7-unknown-linux-gnueabihf]" >> ~/.cargo/config
echo "linker = \"arm-linux-gnueabihf-gcc\"" >> ~/.cargo/config
echo "[target.armv7-unknown-linux-gnueabihf]" >> ~/.cargo/config.toml
echo "linker = \"arm-linux-gnueabihf-gcc\"" >> ~/.cargo/config.toml

- name: Build
run: cargo build --all-targets --target=${{ matrix.config.target }}

- uses: actions-rs/cargo@v1
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install packages (Linux)
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install libx11-dev libxi-dev libgl1-mesa-dev
- uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test
- name: Run tests with log-impl
run: cargo test --features log-impl

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install packages (Linux)
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install libx11-dev libxi-dev libgl1-mesa-dev
- uses: dtolnay/rust-toolchain@stable
with:
command: build
args: --all-targets --target=${{ matrix.config.target }}
components: rustfmt, clippy
- name: rustfmt
run: cargo fmt --all -- --check
- name: clippy
run: cargo clippy --all-targets -- -D warnings

android:
name: Android
runs-on: ubuntu-latest
container: notfl3/cargo-apk
strategy:
fail-fast: false
matrix:
target:
- aarch64-linux-android
- armv7-linux-androideabi
- i686-linux-android
- x86_64-linux-android
steps:
- uses: actions/checkout@v2

- name: cargo quad-apk
run: |
cargo quad-apk build
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# `cargo check` needs no NDK/SDK (nothing is linked). The old
# `cargo quad-apk build` job is gone: cargo-quad-apk links a cargo
# library too old to parse edition-2024 manifests, and there is no
# newer release.
- name: Check
run: cargo check --target ${{ matrix.target }}

msrv:
name: MSRV Check
name: MSRV Check (1.85)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: '1.70.0'
override: true
- uses: dtolnay/rust-toolchain@1.85.0
- name: Verify MSRV
run: cargo build --all-targets
# Only the library: dev-dependencies (examples/tests) may require newer rustc.
run: cargo check
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "miniquad"
version = "0.4.11"
authors = ["not-fl3 <not.fl3@gmail.com>"]
edition = "2018"
rust-version = "1.70"
edition = "2024"
rust-version = "1.85"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/not-fl3/miniquad"
repository = "https://github.com/not-fl3/miniquad"
Expand Down Expand Up @@ -47,9 +47,9 @@ ndk-sys = "0.2"
objc = { package = "objc-rs", version = "0.2" }

[dev-dependencies]
glam = { version = "0.24", features = ["scalar-math"] }
quad-rand = "0.1"
fontdue = "0.8"
glam = { version = "0.33", features = ["scalar-math"] }
quad-rand = "0.2"
fontdue = "0.9"

[profile.release]
lto = true
Expand Down
2 changes: 1 addition & 1 deletion examples/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Stage {

let bindings = Bindings {
vertex_buffers: vec![vertex_buffer],
index_buffer: index_buffer,
index_buffer,
images: vec![],
};

Expand Down
Loading
Loading
0