Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
Merged
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
20 changes: 18 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
rust-gpu-version: [latest]
include:
# As well as testing on each OS, we also want to test to make sure we're still supporting
# older versions of `rust-gpu`. However, we can assume that these tests are already okay
# across platforms, so we only need to test on Linux, the chepeast in terms of minutes.
#
# `0.7.0` currently fails building `spirv-builder-cli` with:
# """
# package `is_terminal_polyfill v1.70.1` cannot be built because it requires rustc
# 1.70.0 or newer, while the currently active rustc version is 1.69.0-nightly
# """
# It's probably easily fixable. But also `0.7.0` was released in April 2023, so there's
# unlikely many users of it?
- os: ubuntu-latest
rust-gpu-version: 0.8.0
- os: ubuntu-latest
rust-gpu-version: 0.9.0
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -35,9 +52,8 @@ jobs:
rustup update
- run: cargo test
- name: Run a full build
run: cargo xtask test-build
run: cargo xtask test-build --rust-gpu-version ${{ matrix.rust-gpu-version }}


lints:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ flamegraph.svg

# Compiled shader assets from running tests
crates/shader-crate-template/shaders

# Build artefacts used by CI tests
tmp/*
crates/shader-crate-template/manifest.json
crates/shader-crate-template/rust_gpu_shader_crate_template.spv
31 changes: 19 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/cargo-gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ toml.workspace = true
chrono.workspace = true
http.workspace = true
crossterm.workspace = true
version_check = "0.9.5"

[dev-dependencies]
test-log.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions crates/cargo-gpu/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Build {

impl Build {
/// Entrypoint
#[expect(clippy::too_many_lines, reason = "these lines are fine")]
#[expect(clippy::too_many_lines, reason = "It's not too confusing")]
pub fn run(&mut self) -> anyhow::Result<()> {
let spirv_builder_cli_path = self.install.run()?;

Expand Down Expand Up @@ -150,7 +150,6 @@ impl Build {
);
std::fs::remove_file(spirv_manifest)?;
}

Ok(())
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/cargo-gpu/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ pub struct Install {

impl Install {
/// Returns a [`SpirvCLI`] instance, responsible for ensuring the right version of the `spirv-builder-cli` crate.
fn spirv_cli(&self, shader_crate_path: &std::path::PathBuf) -> anyhow::Result<SpirvCli> {
fn spirv_cli(&self, shader_crate_path: &std::path::Path) -> anyhow::Result<SpirvCli> {
SpirvCli::new(
shader_crate_path,
self.spirv_install.spirv_builder_source.clone(),
self.spirv_install.spirv_builder_version.clone(),
self.spirv_install.rust_toolchain.clone(),
self.spirv_install.auto_install_rust_toolchain,
self.spirv_install.force_overwrite_lockfiles_v4_to_v3,
)
}

Expand Down
38 changes: 19 additions & 19 deletions crates/cargo-gpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn run() -> anyhow::Result<()> {
"installing with final merged arguments: {:#?}",
command.install
);
let _: std::path::PathBuf = command.install.run()?;
command.install.run()?;
}
Command::Build(build) => {
let shader_crate_path = build.install.spirv_install.shader_crate;
Expand All @@ -150,7 +150,7 @@ fn run() -> anyhow::Result<()> {
command.run()?;
} else {
command.run()?;
}
};
}
Command::Show(show) => show.run()?,
Command::DumpUsage => dump_full_usage_for_readme()?,
Expand Down Expand Up @@ -274,6 +274,23 @@ mod test {
use crate::cache_dir;
use std::io::Write as _;

fn copy_dir_all(
src: impl AsRef<std::path::Path>,
dst: impl AsRef<std::path::Path>,
) -> anyhow::Result<()> {
std::fs::create_dir_all(&dst)?;
for maybe_entry in std::fs::read_dir(src)? {
let entry = maybe_entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}

pub fn shader_crate_template_path() -> std::path::PathBuf {
let project_base = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
project_base.join("../shader-crate-template")
Expand Down Expand Up @@ -304,21 +321,4 @@ mod test {
}
std::fs::remove_dir_all(cache_dir).unwrap();
}

pub fn copy_dir_all(
src: impl AsRef<std::path::Path>,
dst: impl AsRef<std::path::Path>,
) -> anyhow::Result<()> {
std::fs::create_dir_all(&dst)?;
for maybe_entry in std::fs::read_dir(src)? {
let entry = maybe_entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}
}
Loading