Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.

Commit a53784f

Browse files
committed
add Install.build_script to prevent stale shaders with local rust-gpu checkouts
1 parent 7f19958 commit a53784f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

crates/cargo-gpu-install/src/install.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,17 @@ pub struct Install {
102102

103103
/// Clear target dir of `rustc_codegen_spirv` build after a successful build, saves about
104104
/// 200MiB of disk space.
105-
#[cfg_attr(feature = "clap", clap(long = "no-clear-target", default_value = "true", action = clap::ArgAction::SetFalse))]
105+
#[cfg_attr(feature = "clap", clap(long = "no-clear-target", default_value = "true", action = clap::ArgAction::SetFalse
106+
))]
106107
pub clear_target: bool,
107108

109+
/// Enables printing `cargo:rerun-if-changed` to stdout for build scripts, defaults to `false`.
110+
///
111+
/// Currently only used with `path`-based `spirv-std` sources, so that any change in your local rust-gpu checkout
112+
/// reruns the build script to rebuild the codegen backend and your shaders.
113+
#[cfg_attr(feature = "clap", clap(skip))]
114+
pub build_script: bool,
115+
108116
/// There is a tricky situation where a shader crate that depends on workspace config can have
109117
/// a different `Cargo.lock` lockfile version from the the workspace's `Cargo.lock`. This can
110118
/// prevent builds when an old Rust toolchain doesn't recognise the newer lockfile version.
@@ -143,6 +151,7 @@ impl Install {
143151
rebuild_codegen: false,
144152
auto_install_rust_toolchain: true,
145153
clear_target: true,
154+
build_script: false,
146155
force_overwrite_lockfiles_v4_to_v3: false,
147156
}
148157
}
@@ -228,6 +237,15 @@ package = "rustc_codegen_spirv"
228237
std::env::consts::DLL_SUFFIX
229238
);
230239

240+
if self.build_script {
241+
if let SpirvSource::Path {
242+
rust_gpu_repo_root, ..
243+
} = &source
244+
{
245+
println!("cargo:rerun-if-changed={rust_gpu_repo_root}");
246+
}
247+
}
248+
231249
let (dest_dylib_path, skip_rebuild) = if source.is_path() {
232250
(
233251
install_dir

0 commit comments

Comments
 (0)