@@ -303,6 +303,8 @@ pub struct SpirvBuilder {
303
303
extra_args : Vec < String > ,
304
304
// Optional location of a known `rustc_codegen_spirv` dylib
305
305
rustc_codegen_spirv_location : Option < std:: path:: PathBuf > ,
306
+ // Optional location of a known "target-spec" file
307
+ path_to_target_spec : Option < PathBuf > ,
306
308
307
309
// `rustc_codegen_spirv::linker` codegen args
308
310
pub shader_panic_strategy : ShaderPanicStrategy ,
@@ -333,6 +335,7 @@ impl SpirvBuilder {
333
335
extensions : Vec :: new ( ) ,
334
336
extra_args : Vec :: new ( ) ,
335
337
rustc_codegen_spirv_location : None ,
338
+ path_to_target_spec : None ,
336
339
337
340
shader_panic_strategy : ShaderPanicStrategy :: SilentExit ,
338
341
@@ -348,6 +351,16 @@ impl SpirvBuilder {
348
351
}
349
352
}
350
353
354
+ /// Sets the path of the "target specification" file.
355
+ ///
356
+ /// For more info on "target specification" see
357
+ /// [this RFC](https://rust-lang.github.io/rfcs/0131-target-specification.html).
358
+ #[ must_use]
359
+ pub fn target_spec ( mut self , p : impl AsRef < Path > ) -> Self {
360
+ self . path_to_target_spec = Some ( p. as_ref ( ) . to_path_buf ( ) ) ;
361
+ self
362
+ }
363
+
351
364
/// Whether to print build.rs cargo metadata (e.g. cargo:rustc-env=var=val). Defaults to [`MetadataPrintout::Full`].
352
365
#[ must_use]
353
366
pub fn print_metadata ( mut self , v : MetadataPrintout ) -> Self {
@@ -794,9 +807,11 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
794
807
// FIXME(eddyb) consider moving `target-specs` into `rustc_codegen_spirv_types`.
795
808
// FIXME(eddyb) consider the `RUST_TARGET_PATH` env var alternative.
796
809
cargo. arg ( "--target" ) . arg (
797
- Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) )
798
- . join ( "target-specs" )
799
- . join ( format ! ( "{}.json" , builder. target) ) ,
810
+ builder. path_to_target_spec . clone ( ) . unwrap_or_else ( || {
811
+ PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) )
812
+ . join ( "target-specs" )
813
+ . join ( format ! ( "{}.json" , builder. target) )
814
+ } ) ,
800
815
) ;
801
816
802
817
if let Some ( default_features) = builder. shader_crate_features . default_features {
0 commit comments