1+ #![ allow( clippy:: shadow_reuse, reason = "let's not be silly" ) ]
2+ #![ allow( clippy:: unwrap_used, reason = "this is basically a test" ) ]
13//! `cargo gpu build`, analogous to `cargo build`
24
35use anyhow:: Context as _;
@@ -20,6 +22,7 @@ pub struct Build {
2022
2123impl Build {
2224 /// Entrypoint
25+ #[ expect( clippy:: too_many_lines, reason = "these lines are fine" ) ]
2326 pub fn run ( & mut self ) -> anyhow:: Result < ( ) > {
2427 let spirv_builder_cli_path = self . install . run ( ) ?;
2528
@@ -100,11 +103,19 @@ impl Build {
100103 . file_name ( )
101104 . context ( "Couldn't parse file name from shader module path" ) ?,
102105 ) ;
106+ log:: debug!( "copying {} to {}" , filepath. display( ) , path. display( ) ) ;
103107 std:: fs:: copy ( & filepath, & path) ?;
104- let path_relative_to_shader_crate = path
105- . relative_to ( & self . install . spirv_install . shader_crate ) ?
106- . to_path ( "" ) ;
107- Ok ( Linkage :: new ( entry, path_relative_to_shader_crate) )
108+ log:: debug!(
109+ "linkage of {} relative to {}" ,
110+ path. display( ) ,
111+ self . install. spirv_install. shader_crate. display( )
112+ ) ;
113+ let spv_path = path
114+ . relative_to ( & self . install . spirv_install . shader_crate )
115+ . map_or ( path, |path_relative_to_shader_crate| {
116+ path_relative_to_shader_crate. to_path ( "" )
117+ } ) ;
118+ Ok ( Linkage :: new ( entry, spv_path) )
108119 } ,
109120 )
110121 . collect :: < anyhow:: Result < Vec < Linkage > > > ( ) ?;
@@ -173,7 +184,7 @@ mod test {
173184 // For some reason running a full build (`build.run()`) inside tests fails on Windows.
174185 // The error is in the `build.rs` step of compiling `spirv-tools-sys`. It is not clear
175186 // from the logged error what the problem is. For now we'll just run a full build
176- // outside the tests environment, see `justfile `'s `build-shader-template `.
187+ // outside the tests environment, see `xtask `'s `test-build `.
177188 } else {
178189 panic ! ( "was not a build command" ) ;
179190 }
0 commit comments