diff --git a/examples/runners/ash/build.rs b/examples/runners/ash/build.rs new file mode 100644 index 0000000000..7bf0734bed --- /dev/null +++ b/examples/runners/ash/build.rs @@ -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); +} diff --git a/examples/runners/ash/src/main.rs b/examples/runners/ash/src/main.rs index 841fa8fc67..055b57eac6 100644 --- a/examples/runners/ash/src/main.rs +++ b/examples/runners/ash/src/main.rs @@ -197,6 +197,15 @@ pub fn main() { } pub fn compile_shaders() -> Vec { + // 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)