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

Commit ee7eb44

Browse files
committed
build_script: forward to spirv_builder
1 parent 28e4bc9 commit ee7eb44

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub struct InstalledBackend {
1616
pub rustc_codegen_spirv_location: PathBuf,
1717
/// toolchain channel name
1818
pub toolchain_channel: String,
19+
/// Whether this runs in a build script
20+
pub build_script: bool,
1921
}
2022

2123
impl InstalledBackend {
@@ -45,6 +47,7 @@ impl InstalledBackend {
4547
pub fn configure_spirv_builder(&self, builder: &mut SpirvBuilder) -> anyhow::Result<()> {
4648
builder.rustc_codegen_spirv_location = Some(self.rustc_codegen_spirv_location.clone());
4749
builder.toolchain_overwrite = Some(self.toolchain_channel.clone());
50+
builder.build_script.defaults = self.build_script;
4851
Ok(())
4952
}
5053
}
@@ -108,8 +111,9 @@ pub struct Install {
108111

109112
/// Enables printing `cargo:rerun-if-changed` to stdout for build scripts, defaults to `false`.
110113
///
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.
114+
/// Will be forwarded to `spirv_builder.build_script.defaults`. On the cargo-gpu side, only used with `path`-based
115+
/// `spirv-std` sources, so that any change in your local rust-gpu checkout reruns the build script to rebuild the
116+
/// codegen backend and your shaders.
113117
#[cfg_attr(feature = "clap", clap(skip))]
114118
pub build_script: bool,
115119

@@ -156,6 +160,15 @@ impl Install {
156160
}
157161
}
158162

163+
/// Set `build_script = true`
164+
#[inline]
165+
pub fn within_build_script(self) -> Self {
166+
Self {
167+
build_script: true,
168+
..self
169+
}
170+
}
171+
159172
/// Create the `rustc_codegen_spirv_dummy` crate that depends on `rustc_codegen_spirv`
160173
fn write_source_files(source: &SpirvSource, checkout: &Path) -> anyhow::Result<()> {
161174
// skip writing a dummy project if we use a local rust-gpu checkout
@@ -352,6 +365,7 @@ package = "rustc_codegen_spirv"
352365
Ok(InstalledBackend {
353366
rustc_codegen_spirv_location: dest_dylib_path,
354367
toolchain_channel,
368+
build_script: self.build_script,
355369
})
356370
}
357371
}

0 commit comments

Comments
 (0)