example-runner-ash: make sure spirv-builder uses a dedicated target dir.

This commit is contained in:
Eduard-Mihai Burtescu 2022-10-04 13:21:33 +03:00 committed by Eduard-Mihai Burtescu
parent 35df2de639
commit 90db8e22d5
2 changed files with 17 additions and 0 deletions

View File

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

View File

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