@@ -306,6 +306,7 @@ pub struct SpirvBuilder {
306
306
rustc_codegen_spirv_location : Option < std:: path:: PathBuf > ,
307
307
// Optional location of a known "target-spec" file
308
308
path_to_target_spec : Option < PathBuf > ,
309
+ target_dir_path : Option < String > ,
309
310
310
311
// `rustc_codegen_spirv::linker` codegen args
311
312
pub shader_panic_strategy : ShaderPanicStrategy ,
@@ -337,6 +338,7 @@ impl SpirvBuilder {
337
338
extra_args : Vec :: new ( ) ,
338
339
rustc_codegen_spirv_location : None ,
339
340
path_to_target_spec : None ,
341
+ target_dir_path : None ,
340
342
341
343
shader_panic_strategy : ShaderPanicStrategy :: SilentExit ,
342
344
@@ -514,6 +516,14 @@ impl SpirvBuilder {
514
516
self
515
517
}
516
518
519
+ /// Set the target dir path within `./target` to use for building shaders. Defaults to `spirv-builder`, resulting
520
+ /// in the path `./target/spirv-builder`.
521
+ #[ must_use]
522
+ pub fn target_dir_path ( mut self , name : impl Into < String > ) -> Self {
523
+ self . target_dir_path = Some ( name. into ( ) ) ;
524
+ self
525
+ }
526
+
517
527
/// Builds the module. If `print_metadata` is [`MetadataPrintout::Full`], you usually don't have to inspect the path
518
528
/// in the result, as the environment variable for the path to the module will already be set.
519
529
pub fn build ( mut self ) -> Result < CompileResult , SpirvBuilderError > {
@@ -790,7 +800,14 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
790
800
} ;
791
801
// FIXME(eddyb) use `crate metadata` to always be able to get the "outer"
792
802
// (or "default") `--target-dir`, to append `/spirv-builder` to it.
793
- let target_dir = outer_target_dir. map ( |outer| outer. join ( "spirv-builder" ) ) ;
803
+ let target_dir = outer_target_dir. map ( |outer| {
804
+ outer. join (
805
+ builder
806
+ . target_dir_path
807
+ . as_deref ( )
808
+ . unwrap_or ( "spirv-builder" ) ,
809
+ )
810
+ } ) ;
794
811
795
812
let profile = if builder. release { "release" } else { "dev" } ;
796
813
0 commit comments