@@ -172,9 +172,22 @@ impl SpirvSource {
172
172
173
173
/// Get the shader crate's `spirv_std = ...` definition in its `Cargo.toml`
174
174
pub fn get_spirv_std_dep_definition ( shader_crate_path : & std:: path:: PathBuf ) -> Self {
175
- log:: debug!( "Running `cargo tree` on {}" , shader_crate_path. display( ) ) ;
175
+ let cwd = std:: env:: current_dir ( ) . expect ( "no cwd" ) ;
176
+ let exec_path = if shader_crate_path. is_absolute ( ) {
177
+ shader_crate_path. clone ( )
178
+ } else {
179
+ cwd. join ( shader_crate_path)
180
+ }
181
+ . canonicalize ( )
182
+ . expect ( "could not get absolute path to shader crate" ) ;
183
+ if !exec_path. is_dir ( ) {
184
+ log:: error!( "{exec_path:?} is not a directory, aborting" ) ;
185
+ panic ! ( "{exec_path:?} is not a directory" ) ;
186
+ }
187
+
188
+ log:: debug!( "Running `cargo tree` on {}" , exec_path. display( ) ) ;
176
189
let output_cargo_tree = std:: process:: Command :: new ( "cargo" )
177
- . current_dir ( shader_crate_path )
190
+ . current_dir ( & exec_path )
178
191
. args ( [ "tree" , "--workspace" , "--depth" , "1" , "--prefix" , "none" ] )
179
192
. output ( )
180
193
. unwrap ( ) ;
@@ -190,7 +203,7 @@ impl SpirvSource {
190
203
log:: trace!( " found {maybe_spirv_std_def:?}" ) ;
191
204
192
205
let Some ( spirv_std_def) = maybe_spirv_std_def else {
193
- panic ! ( "`spirv-std` not found in shader's `Cargo.toml` at {shader_crate_path :?}:\n {cargo_tree_string}" ) ;
206
+ panic ! ( "`spirv-std` not found in shader's `Cargo.toml` at {exec_path :?}:\n {cargo_tree_string}" ) ;
194
207
} ;
195
208
196
209
Self :: parse_spirv_std_source_and_version ( spirv_std_def)
@@ -344,4 +357,10 @@ mod test {
344
357
}
345
358
) ;
346
359
}
360
+
361
+ #[ test_log:: test]
362
+ fn path_sanity ( ) {
363
+ let path = std:: path:: PathBuf :: from ( "./" ) ;
364
+ assert ! ( path. is_relative( ) ) ;
365
+ }
347
366
}
0 commit comments