@@ -19,12 +19,11 @@ use std::{
1919 process:: Stdio ,
2020} ;
2121
22- use spirv_builder:: { cargo_cmd:: CargoCmd , SpirvBuilder , SpirvBuilderError } ;
23-
2422use crate :: {
2523 cache:: { cache_dir, CacheDirError } ,
2624 command:: { execute_command, CommandExecError } ,
2725 metadata:: { query_metadata, MetadataExt as _, MissingPackageError , QueryMetadataError } ,
26+ spirv_builder:: { cargo_cmd:: CargoCmd , SpirvBuilder , SpirvBuilderError } ,
2827 spirv_source:: {
2928 rust_gpu_toolchain_channel, RustGpuToolchainChannelError , SpirvSource , SpirvSourceError ,
3029 } ,
@@ -201,28 +200,7 @@ impl Install {
201200 fs:: File :: create ( src. join ( "lib.rs" ) ) . map_err ( InstallError :: CreateDummyLibRs ) ?;
202201
203202 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) )
226204 . map_err ( InstallError :: WriteDummyCargoToml ) ?;
227205
228206 Ok ( ( ) )
@@ -411,7 +389,7 @@ impl<W, T, C, O, E> InstallRunParams<W, T, C, O, E> {
411389}
412390
413391/// [`Default`] parameters for [`Install::run()`].
414- type DefaultInstallRunParams = InstallRunParams <
392+ pub type DefaultInstallRunParams = InstallRunParams <
415393 io:: Empty ,
416394 NoopOnToolchainInstall ,
417395 NoopOnComponentsInstall ,
@@ -439,6 +417,28 @@ fn dylib_filename(name: impl AsRef<str>) -> String {
439417 format ! ( "{DLL_PREFIX}{str_name}{DLL_SUFFIX}" )
440418}
441419
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+
442442/// An error indicating codegen `rustc_codegen_spirv` installation failure.
443443#[ derive( Debug , thiserror:: Error ) ]
444444#[ non_exhaustive]
0 commit comments