Skip to content
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
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exclude = [
resolver = "2"

[workspace.dependencies]
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "3df836eb9d7b01344f52737bf9a310d1fb5a0c26", default-features = false }
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "e97524f6b4816056b3edaa70c3e0e0c656392c05", default-features = false }
anyhow = "1.0.98"
clap = { version = "4.5.41", features = ["derive"] }
crossterm = "0.29.0"
Expand Down
27 changes: 16 additions & 11 deletions crates/cargo-gpu/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::install::Install;
use crate::linkage::Linkage;
use crate::lockfile::LockfileMismatchHandler;
use anyhow::Context as _;
use spirv_builder::{CompileResult, ModuleResult, SpirvBuilder};
use spirv_builder::{CompileResult, ModuleResult, SpirvBuilder, SpirvBuilderError};
use std::io::Write as _;
use std::path::PathBuf;

Expand Down Expand Up @@ -95,17 +95,22 @@ impl Build {
);

if self.build.watch {
let this = self.clone();
self.build
.spirv_builder
.watch(move |result, accept| {
let result1 = this.parse_compilation_result(&result);
if let Some(accept) = accept {
accept.submit(result1);
let mut watcher = self.build.spirv_builder.clone().watch()?;
loop {
// if the build fails "regularly", eg. `cargo build` fails and nothing else, just retry
crate::user_output!(
"Compiling shaders at {}...\n",
self.install.shader_crate.display()
);
match watcher.recv() {
Ok(result) => {
self.parse_compilation_result(&result)?;
crate::user_output!("Build successful!\n");
}
})?
.context("unreachable")??;
std::thread::park();
Err(SpirvBuilderError::BuildFailed) => crate::user_output!("Build failed!\n"),
Err(err) => return Err(anyhow::Error::from(err)),
}
}
} else {
crate::user_output!(
"Compiling shaders at {}...\n",
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-gpu/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ package = "rustc_codegen_spirv"
cargo.args(["-p", "rustc_codegen_spirv", "--lib"]);
}

log::debug!("building artifacts with `{cargo}`");
log::debug!("building artifacts with `{cargo:?}`");
cargo
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit())
Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-gpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub use spirv_builder;
/// Central function to write to the user.
#[macro_export]
macro_rules! user_output {
($($args: tt)*) => {
($($args: tt)*) => { {
#[allow(
clippy::allow_attributes,
clippy::useless_attribute,
Expand All @@ -92,7 +92,7 @@ macro_rules! user_output {
}
print!($($args)*);
std::io::stdout().flush().unwrap();
}
} }
}

/// All of the available subcommands for `cargo gpu`
Expand Down
4 changes: 0 additions & 4 deletions crates/cargo-gpu/src/spirv_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ pub enum SpirvSource {
}

impl core::fmt::Display for SpirvSource {
#[expect(
clippy::min_ident_chars,
reason = "It's a core library trait implementation"
)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::CratesIO(version) => version.fmt(f),
Expand Down
Loading