Skip to content

Commit 5926363

Browse files
committed
update spirv-builder
1 parent 816b3f6 commit 5926363

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude = [
1515
resolver = "2"
1616

1717
[workspace.dependencies]
18-
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "3df836eb9d7b01344f52737bf9a310d1fb5a0c26", default-features = false }
18+
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "e97524f6b4816056b3edaa70c3e0e0c656392c05", default-features = false }
1919
anyhow = "1.0.98"
2020
clap = { version = "4.5.41", features = ["derive"] }
2121
crossterm = "0.29.0"

crates/cargo-gpu/src/build.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::install::Install;
66
use crate::linkage::Linkage;
77
use crate::lockfile::LockfileMismatchHandler;
88
use anyhow::Context as _;
9-
use spirv_builder::{CompileResult, ModuleResult, SpirvBuilder};
9+
use spirv_builder::{CompileResult, ModuleResult, SpirvBuilder, SpirvBuilderError};
1010
use std::io::Write as _;
1111
use std::path::PathBuf;
1212

@@ -95,17 +95,22 @@ impl Build {
9595
);
9696

9797
if self.build.watch {
98-
let this = self.clone();
99-
self.build
100-
.spirv_builder
101-
.watch(move |result, accept| {
102-
let result1 = this.parse_compilation_result(&result);
103-
if let Some(accept) = accept {
104-
accept.submit(result1);
98+
let mut watcher = self.build.spirv_builder.clone().watch()?;
99+
loop {
100+
// if the build fails "regularly", eg. `cargo build` fails and nothing else, just retry
101+
crate::user_output!(
102+
"Compiling shaders at {}...\n",
103+
self.install.shader_crate.display()
104+
);
105+
match watcher.recv() {
106+
Ok(result) => {
107+
self.parse_compilation_result(&result)?;
108+
crate::user_output!("Build successful!\n");
105109
}
106-
})?
107-
.context("unreachable")??;
108-
std::thread::park();
110+
Err(SpirvBuilderError::BuildFailed) => crate::user_output!("Build failed!\n"),
111+
Err(err) => return Err(anyhow::Error::from(err)),
112+
}
113+
}
109114
} else {
110115
crate::user_output!(
111116
"Compiling shaders at {}...\n",

crates/cargo-gpu/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ package = "rustc_codegen_spirv"
299299
cargo.args(["-p", "rustc_codegen_spirv", "--lib"]);
300300
}
301301

302-
log::debug!("building artifacts with `{cargo}`");
302+
log::debug!("building artifacts with `{cargo:?}`");
303303
cargo
304304
.stdout(std::process::Stdio::inherit())
305305
.stderr(std::process::Stdio::inherit())

crates/cargo-gpu/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub use spirv_builder;
7474
/// Central function to write to the user.
7575
#[macro_export]
7676
macro_rules! user_output {
77-
($($args: tt)*) => {
77+
($($args: tt)*) => { {
7878
#[allow(
7979
clippy::allow_attributes,
8080
clippy::useless_attribute,
@@ -92,7 +92,7 @@ macro_rules! user_output {
9292
}
9393
print!($($args)*);
9494
std::io::stdout().flush().unwrap();
95-
}
95+
} }
9696
}
9797

9898
/// All of the available subcommands for `cargo gpu`

0 commit comments

Comments
 (0)