Skip to content

Commit

Permalink
Add CI for all targets and features (#152)
Browse files Browse the repository at this point in the history
- Make sure the repo will run against minimum compatible rust version (1.73) 
- Add rust-toolchain.toml file
- lock cargo make and the CI to compatible nightly versions 
- Improved tools installations in Makefile.toml
  • Loading branch information
alloncm authored Dec 21, 2024
1 parent 2bcf0d5 commit 56e8dde
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 19 deletions.
51 changes: 44 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,50 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-and-test:
build-and-test-all-targets:
strategy:
fail-fast: false # Allow the other job to continue running
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
# Stable toolchains are installed with rust-toolchain.toml and the rest toolchains and targets are installed by Makefile.toml
with:
rustflags: ""
cache-directories: "/home/runner/.cargo/bin
C:\\Users\\runneradmin\\.cargo\\bin"

- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25 # This is the minimum version rust supports
add-to-path: true

- name: install cargo make
run: cargo install --no-default-features --locked --version 0.37.23 cargo-make

steps:
- uses: actions/checkout@v2
- name: Build sdl
run: cargo build --verbose --package magenboy_sdl
- name: Run tests
run: cargo test --verbose --package magenboy_core
run: cargo make test

# For some reason the other installation causing this to fail (some error about not finding glibc) so this should come first
- name: Build rpi os
if: ${{ matrix.os == 'ubuntu-latest' }} # This fails on windows since it does not have docker installed
run: cargo make rpios

- name: Build rpi baremetal
run: cargo make -e RPI=4 rpibm

- name: Build sdl
run: cargo make sdl

- name: Build sdl with debugger
run: cargo make sdl_dbg

- name: Build libretro desktop
run: cargo make libretro_desktop

- name: Build libretro android
run: cargo make libretro_android
36 changes: 28 additions & 8 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[config]
default_to_workspace = false

[tasks.all]
dependencies = ["test", "sdl", "rpios", "rpibm", "libretro"]
[env]
nightly_version = "nightly-2023-10-05" # 1.73.0 toolchain nightly version

[tasks.test]
command = "cargo"
Expand All @@ -12,10 +12,18 @@ args = ["test", "--package", "magenboy_core"]
command = "cargo"
args = ["build", "--release", "--package", "magenboy_sdl"]

[tasks.sdl_dbg]
command = "cargo"
args = ["build", "--release", "--package", "magenboy_sdl", "--features", "dbg"]

[tasks.sdl.linux]
args = ["build", "--release", "--package", "magenboy_sdl", "--no-default-features"]
dependencies = ["install_sdl2_linux"]

[tasks.sdl_dbg.linux]
args = ["build", "--release", "--package", "magenboy_sdl", "--no-default-features", "--features", "dbg"]
dependencies = ["install_sdl2_linux"]

[tasks.install_sdl2_linux]
script = [
"""
Expand All @@ -33,28 +41,34 @@ try_install libsdl2-dev

[tasks.rpios]
install_crate = {crate_name = "cross", binary = "cross", test_arg = "-h"}
install_crate_args=["--locked", "--version", "0.2.5"]
command = "cross"
args = ["build", "--release", "--target", "armv7-unknown-linux-gnueabihf", "--bin", "rpios","--no-default-features", "--features", "os"]

[tasks.pre-rpibm]
command = "rustup"
args = ["toolchain", "install", "--profile", "minimal", "--no-self-update", "${nightly_version}"]

[tasks.rpibm]
toolchain = "nightly"
toolchain = "${nightly_version}"
install_crate = "cargo-binutils"
install_crate_args=["--locked", "--version", "0.3.6"]
command = "rust-objcopy"
args = ["target/armv7a-none-eabihf/release/baremetal", "-O", "binary", "kernel7.img"]
dependencies = ["build_rpi_baremetal","install_llvm_tools"]
dependencies = ["pre-rpibm", "build_rpi_baremetal","install_llvm_tools"]

[tasks.build_rpi_baremetal]
toolchain = "nightly"
toolchain = "${nightly_version}"
command = "cargo"
args = ["build", "--release", "--target", "armv7a-none-eabihf","--package", "magenboy_rpi", "--bin", "baremetal", "-Z", "build-std=core"]
dependencies = ["install_rust_src"]

[tasks.install_llvm_tools]
toolchain = "nightly"
toolchain = "${nightly_version}"
install_crate = {rustup_component_name = "llvm-tools-preview"}

[tasks.install_rust_src]
toolchain = "nightly"
toolchain = "${nightly_version}"
command = "rustup"
args = ["component", "add", "rust-src"]

Expand All @@ -64,5 +78,11 @@ args = ["build", "--release", "--package", "magenboy_libretro"]

[tasks.libretro_android]
install_crate = {crate_name = "cargo-ndk", binary = "cargo", test_arg = "ndk"}
install_crate_args=["--locked", "--version", "3.5.4"]
command = "cargo"
args = ["ndk", "--target=aarch64-linux-android", "build", "--release", "--package", "magenboy_libretro"]
args = ["ndk", "--target=aarch64-linux-android", "build", "--release", "--package", "magenboy_libretro"]
dependencies = ["add_android_target"]

[tasks.add_android_target]
command = "rustup"
args = ["target", "add", "aarch64-linux-android"]
10 changes: 6 additions & 4 deletions rpi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ fn main(){
let rpi_version = std::env::var(config::RPI_ENV_VAR_NAME)
.expect(std::format!("{} env must be set", config::RPI_ENV_VAR_NAME).as_str());
println!("cargo:rustc-cfg=rpi=\"{}\"", rpi_version);

// Silent warnings for this cfg
println!("cargo::rustc-check-cfg=cfg(rpi, values(\"4\", \"2\"))");
println!("cargo::rustc-check-cfg=cfg(rpi)");

// Silent warnings for this cfg
println!("cargo:rustc-check-cfg=cfg(rpi, values(\"4\", \"2\"))");
}

// Silent warnings for this cfg
println!("cargo:rustc-check-cfg=cfg(rpi)");
}
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "1.73.0"
components = [ "rust-src" ]
profile = "minimal"

0 comments on commit 56e8dde

Please sign in to comment.