@@ -4,6 +4,7 @@ use crate::spirv_source::{
44 get_channel_from_rustc_codegen_spirv_build_script, query_metadata, FindPackage as _,
55} ;
66use crate :: target_specs:: update_target_specs_files;
7+ use crate :: MetadataCache ;
78use crate :: { cache_dir, spirv_source:: SpirvSource } ;
89use anyhow:: Context as _;
910use spirv_builder:: SpirvBuilder ;
@@ -150,6 +151,24 @@ impl Install {
150151 }
151152 }
152153
154+ /// Resolves a possible workspace package passed with `-p {package}` to its shader crate path,
155+ /// as if it had been passed with `--shader-crate {package-parent-path}`.
156+ ///
157+ /// If no such package was passed, this resolves to the shader crate passed, or the default.
158+ ///
159+ /// ## Errors
160+ /// Errs if the metadata cache cannot resolve the shader crate.
161+ /// See [`MetadataCache::resolve_package_to_shader_crate`] for more info.
162+ pub fn get_resolved_shader_crate (
163+ & self ,
164+ metadata : & mut MetadataCache ,
165+ ) -> anyhow:: Result < std:: path:: PathBuf > {
166+ self . package . as_ref ( ) . map_or_else (
167+ || Ok ( self . shader_crate . clone ( ) ) ,
168+ |package| metadata. resolve_package_to_shader_crate ( package) ,
169+ )
170+ }
171+
153172 /// Create the `rustc_codegen_spirv_dummy` crate that depends on `rustc_codegen_spirv`
154173 fn write_source_files ( source : & SpirvSource , checkout : & Path ) -> anyhow:: Result < ( ) > {
155174 // skip writing a dummy project if we use a local rust-gpu checkout
0 commit comments