1
+ #![ allow( clippy:: shadow_reuse, reason = "let's not be silly" ) ]
2
+ #![ allow( clippy:: unwrap_used, reason = "this is basically a test" ) ]
1
3
//! `cargo gpu build`, analogous to `cargo build`
2
4
3
5
use anyhow:: Context as _;
@@ -20,6 +22,7 @@ pub struct Build {
20
22
21
23
impl Build {
22
24
/// Entrypoint
25
+ #[ expect( clippy:: too_many_lines, reason = "these lines are fine" ) ]
23
26
pub fn run ( & mut self ) -> anyhow:: Result < ( ) > {
24
27
let spirv_builder_cli_path = self . install . run ( ) ?;
25
28
@@ -100,11 +103,19 @@ impl Build {
100
103
. file_name ( )
101
104
. context ( "Couldn't parse file name from shader module path" ) ?,
102
105
) ;
106
+ log:: debug!( "copying {} to {}" , filepath. display( ) , path. display( ) ) ;
103
107
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) )
108
119
} ,
109
120
)
110
121
. collect :: < anyhow:: Result < Vec < Linkage > > > ( ) ?;
@@ -173,7 +184,7 @@ mod test {
173
184
// For some reason running a full build (`build.run()`) inside tests fails on Windows.
174
185
// The error is in the `build.rs` step of compiling `spirv-tools-sys`. It is not clear
175
186
// 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 `.
177
188
} else {
178
189
panic ! ( "was not a build command" ) ;
179
190
}
0 commit comments