File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 22name = " rust-gpu-builder"
33version = " 0.4.0"
44edition = " 2021"
5- build = false
65
76[dependencies ]
87rust-gpu-builder-shared = { git = " https://github.com/bevy-rust-gpu/rust-gpu-builder-shared" }
Original file line number Diff line number Diff line change 1+ use std:: { env, error:: Error } ;
2+
3+ fn main ( ) -> Result < ( ) , Box < dyn Error > > {
4+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
5+ println ! ( "cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS" ) ;
6+ println ! ( "cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH" ) ;
7+ // While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
8+ // build.rs. So, export it to crate compilation as well.
9+ let profile = env:: var ( "PROFILE" ) . unwrap ( ) ;
10+ println ! ( "cargo:rustc-env=PROFILE={profile}" ) ;
11+ Ok ( ( ) )
12+ }
Original file line number Diff line number Diff line change @@ -104,6 +104,11 @@ impl ShaderBuilder {
104104
105105 /// Builds a shader with the provided set of options.
106106 pub fn build_shader ( & self ) -> Result < CompileResult , SpirvBuilderError > {
107+ // As per `spirv-builder`, apply env vars set in build.rs
108+ // to work around potentially suboptimal cargo behaviour
109+ std:: env:: set_var ( "OUT_DIR" , env ! ( "OUT_DIR" ) ) ;
110+ std:: env:: set_var ( "PROFILE" , env ! ( "PROFILE" ) ) ;
111+
107112 let mut builder = SpirvBuilder :: new ( & self . path_to_crate , & self . target )
108113 . deny_warnings ( self . deny_warnings )
109114 . release ( self . release )
You can’t perform that action at this time.
0 commit comments