@@ -19,12 +19,11 @@ use std::{
19
19
process:: Stdio ,
20
20
} ;
21
21
22
- use spirv_builder:: { cargo_cmd:: CargoCmd , SpirvBuilder , SpirvBuilderError } ;
23
-
24
22
use crate :: {
25
23
cache:: { cache_dir, CacheDirError } ,
26
24
command:: { execute_command, CommandExecError } ,
27
25
metadata:: { query_metadata, MetadataExt as _, MissingPackageError , QueryMetadataError } ,
26
+ spirv_builder:: { cargo_cmd:: CargoCmd , SpirvBuilder , SpirvBuilderError } ,
28
27
spirv_source:: {
29
28
rust_gpu_toolchain_channel, RustGpuToolchainChannelError , SpirvSource , SpirvSourceError ,
30
29
} ,
@@ -201,28 +200,7 @@ impl Install {
201
200
fs:: File :: create ( src. join ( "lib.rs" ) ) . map_err ( InstallError :: CreateDummyLibRs ) ?;
202
201
203
202
log:: trace!( "writing dummy Cargo.toml" ) ;
204
-
205
- /// Contents of the `Cargo.toml` file for the local `rustc_codegen_spirv_dummy` crate.
206
- #[ expect( clippy:: items_after_statements, reason = "local constant" ) ]
207
- const DUMMY_CARGO_TOML : & str = include_str ! ( "dummy/Cargo.toml" ) ;
208
-
209
- let version_spec = match & source {
210
- SpirvSource :: CratesIO ( version) => format ! ( "version = \" {version}\" " ) ,
211
- SpirvSource :: Git { url, rev } => format ! ( "git = \" {url}\" \n rev = \" {rev}\" " ) ,
212
- SpirvSource :: Path {
213
- rust_gpu_repo_root,
214
- version,
215
- } => {
216
- // this branch is currently unreachable, as we just build `rustc_codegen_spirv` directly,
217
- // since we don't need the `dummy` crate to make cargo download it for us
218
- let mut new_path = rust_gpu_repo_root. to_owned ( ) ;
219
- new_path. push ( "crates/spirv-builder" ) ;
220
- format ! ( "path = \" {new_path}\" \n version = \" {version}\" " )
221
- }
222
- } ;
223
-
224
- let cargo_toml = format ! ( "{DUMMY_CARGO_TOML}{version_spec}\n " ) ;
225
- fs:: write ( checkout. join ( "Cargo.toml" ) , cargo_toml)
203
+ fs:: write ( checkout. join ( "Cargo.toml" ) , dummy_cargo_toml ( source) )
226
204
. map_err ( InstallError :: WriteDummyCargoToml ) ?;
227
205
228
206
Ok ( ( ) )
@@ -411,7 +389,7 @@ impl<W, T, C, O, E> InstallRunParams<W, T, C, O, E> {
411
389
}
412
390
413
391
/// [`Default`] parameters for [`Install::run()`].
414
- type DefaultInstallRunParams = InstallRunParams <
392
+ pub type DefaultInstallRunParams = InstallRunParams <
415
393
io:: Empty ,
416
394
NoopOnToolchainInstall ,
417
395
NoopOnComponentsInstall ,
@@ -439,6 +417,28 @@ fn dylib_filename(name: impl AsRef<str>) -> String {
439
417
format ! ( "{DLL_PREFIX}{str_name}{DLL_SUFFIX}" )
440
418
}
441
419
420
+ /// Contents of the `Cargo.toml` file for the local `rustc_codegen_spirv_dummy` crate
421
+ /// without the version specification of the `rustc_codegen_spirv` dependency.
422
+ const DUMMY_CARGO_TOML_NO_VERSION_SPEC : & str = include_str ! ( "dummy/Cargo.toml" ) ;
423
+
424
+ /// Returns the contents of the `Cargo.toml` file for the local `rustc_codegen_spirv_dummy` crate.
425
+ fn dummy_cargo_toml ( source : & SpirvSource ) -> String {
426
+ let version_spec = match source {
427
+ SpirvSource :: CratesIO ( version) => format ! ( "version = \" {version}\" " ) ,
428
+ SpirvSource :: Git { url, rev } => format ! ( "git = \" {url}\" \n rev = \" {rev}\" " ) ,
429
+ SpirvSource :: Path {
430
+ rust_gpu_repo_root,
431
+ version,
432
+ } => {
433
+ // this branch is currently unreachable, as we just build `rustc_codegen_spirv` directly,
434
+ // since we don't need the `dummy` crate to make cargo download it for us
435
+ let new_path = rust_gpu_repo_root. join ( "crates" ) . join ( "spirv-builder" ) ;
436
+ format ! ( "path = \" {new_path}\" \n version = \" {version}\" " )
437
+ }
438
+ } ;
439
+ format ! ( "{DUMMY_CARGO_TOML_NO_VERSION_SPEC}{version_spec}\n " )
440
+ }
441
+
442
442
/// An error indicating codegen `rustc_codegen_spirv` installation failure.
443
443
#[ derive( Debug , thiserror:: Error ) ]
444
444
#[ non_exhaustive]
0 commit comments