Skip to content

Commit 90db8e2

Browse files
committed
example-runner-ash: make sure spirv-builder uses a dedicated target dir.
1 parent 35df2de commit 90db8e2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

examples/runners/ash/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std::env;
2+
3+
fn main() {
4+
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
5+
// build.rs. So, export it to crate compilation as well.
6+
let profile = env::var("PROFILE").unwrap();
7+
println!("cargo:rustc-env=PROFILE={}", profile);
8+
}

examples/runners/ash/src/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ pub fn main() {
197197
}
198198

199199
pub fn compile_shaders() -> Vec<SpvFile> {
200+
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
201+
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
202+
// have different configurations when being built here vs. when building
203+
// rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to
204+
// not have to rebuild half the crate graph every time we run. So, pretend we're running
205+
// under cargo by setting these environment variables.
206+
std::env::set_var("OUT_DIR", env!("OUT_DIR"));
207+
std::env::set_var("PROFILE", env!("PROFILE"));
208+
200209
let sky_shader_path =
201210
SpirvBuilder::new("examples/shaders/sky-shader", "spirv-unknown-vulkan1.1")
202211
.print_metadata(MetadataPrintout::None)

0 commit comments

Comments
 (0)