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 2
2
name = " rust-gpu-builder"
3
3
version = " 0.4.0"
4
4
edition = " 2021"
5
- build = false
6
5
7
6
[dependencies ]
8
7
rust-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 {
104
104
105
105
/// Builds a shader with the provided set of options.
106
106
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
+
107
112
let mut builder = SpirvBuilder :: new ( & self . path_to_crate , & self . target )
108
113
. deny_warnings ( self . deny_warnings )
109
114
. release ( self . release )
You can’t perform that action at this time.
0 commit comments